From bfdc4b54dd5c4422bc55ca5549d7e5c6b4a0150d Mon Sep 17 00:00:00 2001 From: azure-sdk Date: Sun, 10 May 2026 19:01:11 +0000 Subject: [PATCH] Configurations: 'specification/sql/resource-manager/Microsoft.Sql/SQL/tspconfig.yaml', API Version: 2025-02-01-preview, SDK Release Type: beta, and CommitSHA: '41784cfad64229e05cb37b1532a686a0cc3a60a9' in SpecRepo: 'https://github.com/Azure/azure-rest-api-specs' Pipeline run: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=6276220 Refer to https://eng.ms/docs/products/azure-developer-experience/develop/sdk-release/sdk-release-prerequisites to prepare for SDK release. --- sdk/sql/azure-mgmt-sql/CHANGELOG.md | 655 + sdk/sql/azure-mgmt-sql/README.md | 4 +- sdk/sql/azure-mgmt-sql/_metadata.json | 15 +- .../azure-mgmt-sql/apiview-properties.json | 3387 +- .../azure-mgmt-sql/azure/mgmt/sql/__init__.py | 4 +- .../{_sql_management_client.py => _client.py} | 924 +- .../azure/mgmt/sql/_configuration.py | 17 +- .../azure-mgmt-sql/azure/mgmt/sql/_patch.py | 39 +- .../azure/mgmt/sql/_utils/__init__.py | 2 +- .../azure/mgmt/sql/_utils/model_base.py | 1459 + .../azure/mgmt/sql/_utils/serialization.py | 21 +- .../azure/mgmt/sql/_validation.py | 66 + .../azure-mgmt-sql/azure/mgmt/sql/_version.py | 4 +- .../azure/mgmt/sql/aio/__init__.py | 4 +- .../{_sql_management_client.py => _client.py} | 937 +- .../azure/mgmt/sql/aio/_configuration.py | 17 +- .../azure/mgmt/sql/aio/_patch.py | 39 +- .../azure/mgmt/sql/aio/operations/__init__.py | 497 +- ...hort_term_retention_policies_operations.py | 648 - .../operations/_capabilities_operations.py | 112 - .../_data_masking_policies_operations.py | 258 - .../_data_masking_rules_operations.py | 287 - ...ta_warehouse_user_activities_operations.py | 202 - ...d_threat_protection_settings_operations.py | 363 - .../_database_advisors_operations.py | 339 - .../_database_automatic_tuning_operations.py | 254 - ...abase_blob_auditing_policies_operations.py | 341 - .../_database_columns_operations.py | 327 - ...tabase_encryption_protectors_operations.py | 309 - .../_database_extensions_operations.py | 419 - .../_database_operations_operations.py | 191 - ...database_recommended_actions_operations.py | 353 - .../_database_schemas_operations.py | 202 - ...base_security_alert_policies_operations.py | 360 - ...ability_assessment_baselines_operations.py | 390 - ...lity_assessment_execute_scan_operations.py | 181 - ...ty_assessment_rule_baselines_operations.py | 481 - ...ility_assessment_scan_result_operations.py | 229 - ...lnerability_assessment_scans_operations.py | 217 - ...ability_assessments_settings_operations.py | 205 - .../operations/_database_tables_operations.py | 215 - .../operations/_database_usages_operations.py | 129 - ...ty_assessment_rule_baselines_operations.py | 397 - ...lnerability_assessment_scans_operations.py | 426 - ...se_vulnerability_assessments_operations.py | 431 - .../aio/operations/_databases_operations.py | 2056 - .../operations/_deleted_servers_operations.py | 356 - ...tributed_availability_groups_operations.py | 1156 - .../_elastic_pool_activities_operations.py | 130 - ...tic_pool_database_activities_operations.py | 131 - .../_elastic_pool_operations_operations.py | 190 - .../operations/_elastic_pools_operations.py | 991 - .../_encryption_protectors_operations.py | 527 - .../_endpoint_certificates_operations.py | 188 - ...abase_blob_auditing_policies_operations.py | 341 - ...erver_blob_auditing_policies_operations.py | 396 - .../operations/_failover_groups_operations.py | 1069 - .../operations/_firewall_rules_operations.py | 519 - .../_geo_backup_policies_operations.py | 355 - .../_instance_failover_groups_operations.py | 742 - .../operations/_instance_pools_operations.py | 741 - .../_ipv6_firewall_rules_operations.py | 389 - .../aio/operations/_job_agents_operations.py | 715 - .../operations/_job_credentials_operations.py | 408 - .../operations/_job_executions_operations.py | 687 - .../_job_private_endpoints_operations.py | 536 - .../_job_step_executions_operations.py | 252 - .../aio/operations/_job_steps_operations.py | 604 - .../_job_target_executions_operations.py | 384 - .../_job_target_groups_operations.py | 408 - .../operations/_job_versions_operations.py | 205 - .../sql/aio/operations/_jobs_operations.py | 407 - .../_ledger_digest_uploads_operations.py | 555 - ..._long_term_retention_backups_operations.py | 3466 - ...ion_managed_instance_backups_operations.py | 976 - ...long_term_retention_policies_operations.py | 431 - .../_maintenance_window_options_operations.py | 122 - .../_maintenance_windows_operations.py | 267 - ...hort_term_retention_policies_operations.py | 648 - ...d_threat_protection_settings_operations.py | 363 - .../_managed_database_columns_operations.py | 327 - ...ged_database_move_operations_operations.py | 202 - .../_managed_database_queries_operations.py | 214 - ...commended_sensitivity_labels_operations.py | 190 - ...ged_database_restore_details_operations.py | 121 - .../_managed_database_schemas_operations.py | 202 - ...base_security_alert_policies_operations.py | 360 - ...ged_database_security_events_operations.py | 152 - ..._database_sensitivity_labels_operations.py | 861 - .../_managed_database_tables_operations.py | 215 - ..._transparent_data_encryption_operations.py | 360 - ...ty_assessment_rule_baselines_operations.py | 397 - ...lnerability_assessment_scans_operations.py | 426 - ...se_vulnerability_assessments_operations.py | 431 - .../_managed_databases_operations.py | 1583 - ...aged_instance_administrators_operations.py | 524 - ...d_threat_protection_settings_operations.py | 417 - ...zure_ad_only_authentications_operations.py | 540 - .../_managed_instance_dtcs_operations.py | 400 - ...stance_encryption_protectors_operations.py | 532 - .../_managed_instance_keys_operations.py | 517 - ...long_term_retention_policies_operations.py | 428 - ..._managed_instance_operations_operations.py | 249 - ...private_endpoint_connections_operations.py | 517 - ...tance_private_link_resources_operations.py | 192 - ...ed_instance_tde_certificates_operations.py | 243 - ...ce_vulnerability_assessments_operations.py | 416 - .../_managed_instances_operations.py | 1477 - ...anaged_ledger_digest_uploads_operations.py | 561 - ...hort_term_retention_policies_operations.py | 648 - .../_managed_server_dns_aliases_operations.py | 716 - ...rver_security_alert_policies_operations.py | 409 - .../mgmt/sql/aio/operations/_operations.py | 76154 ++++++++++++- .../_outbound_firewall_rules_operations.py | 510 - .../azure/mgmt/sql/aio/operations/_patch.py | 13 +- ...private_endpoint_connections_operations.py | 511 - .../_private_link_resources_operations.py | 187 - ...commended_sensitivity_labels_operations.py | 190 - .../_recoverable_databases_operations.py | 200 - ...ecoverable_managed_databases_operations.py | 189 - .../_replication_links_operations.py | 1061 - ...restorable_dropped_databases_operations.py | 202 - ...le_dropped_managed_databases_operations.py | 192 - .../operations/_restore_points_operations.py | 466 - .../_sensitivity_labels_operations.py | 861 - ...d_threat_protection_settings_operations.py | 417 - .../operations/_server_advisors_operations.py | 318 - .../_server_automatic_tuning_operations.py | 239 - ...rver_azure_ad_administrators_operations.py | 529 - ...zure_ad_only_authentications_operations.py | 538 - ...erver_blob_auditing_policies_operations.py | 391 - .../_server_communication_links_operations.py | 458 - ...server_configuration_options_operations.py | 414 - .../_server_connection_policies_operations.py | 405 - ...erver_dev_ops_audit_settings_operations.py | 409 - .../_server_dns_aliases_operations.py | 624 - .../aio/operations/_server_keys_operations.py | 517 - .../_server_operations_operations.py | 126 - ...rver_security_alert_policies_operations.py | 406 - .../_server_trust_certificates_operations.py | 512 - .../_server_trust_groups_operations.py | 583 - .../operations/_server_usages_operations.py | 126 - ...er_vulnerability_assessments_operations.py | 415 - .../sql/aio/operations/_servers_operations.py | 1179 - .../_service_objectives_operations.py | 187 - .../aio/operations/_sql_agent_operations.py | 240 - ...rability_assessment_baseline_operations.py | 221 - ...ability_assessment_baselines_operations.py | 215 - ...lity_assessment_execute_scan_operations.py | 183 - ...ity_assessment_rule_baseline_operations.py | 401 - ...ty_assessment_rule_baselines_operations.py | 126 - ...ility_assessment_scan_result_operations.py | 229 - ...lnerability_assessment_scans_operations.py | 217 - ...ql_vulnerability_assessments_operations.py | 114 - ...ability_assessments_settings_operations.py | 343 - ...p_managed_instance_schedules_operations.py | 404 - .../_subscription_usages_operations.py | 175 - .../_synapse_link_workspaces_operations.py | 130 - .../aio/operations/_sync_agents_operations.py | 648 - .../aio/operations/_sync_groups_operations.py | 1239 - .../operations/_sync_members_operations.py | 1032 - .../_tde_certificates_operations.py | 243 - .../aio/operations/_time_zones_operations.py | 175 - ...transparent_data_encryptions_operations.py | 438 - .../sql/aio/operations/_usages_operations.py | 130 - .../_virtual_clusters_operations.py | 663 - .../_virtual_network_rules_operations.py | 510 - .../_workload_classifiers_operations.py | 581 - .../operations/_workload_groups_operations.py | 532 - .../azure/mgmt/sql/models/__init__.py | 612 +- ...l_management_client_enums.py => _enums.py} | 884 +- .../azure/mgmt/sql/models/_models.py | 25285 +++++ .../azure/mgmt/sql/models/_models_py3.py | 23141 ---- .../azure/mgmt/sql/models/_patch.py | 13 +- .../azure/mgmt/sql/operations/__init__.py | 497 +- ...hort_term_retention_policies_operations.py | 790 - .../operations/_capabilities_operations.py | 149 - .../_data_masking_policies_operations.py | 332 - .../_data_masking_rules_operations.py | 366 - ...ta_warehouse_user_activities_operations.py | 275 - ...d_threat_protection_settings_operations.py | 475 - .../_database_advisors_operations.py | 457 - .../_database_automatic_tuning_operations.py | 324 - ...abase_blob_auditing_policies_operations.py | 441 - .../_database_columns_operations.py | 463 - ...tabase_encryption_protectors_operations.py | 376 - .../_database_extensions_operations.py | 522 - .../_database_operations_operations.py | 279 - ...database_recommended_actions_operations.py | 473 - .../_database_schemas_operations.py | 282 - ...base_security_alert_policies_operations.py | 468 - ...ability_assessment_baselines_operations.py | 515 - ...lity_assessment_execute_scan_operations.py | 218 - ...ty_assessment_rule_baselines_operations.py | 649 - ...ility_assessment_scan_result_operations.py | 314 - ...lnerability_assessment_scans_operations.py | 298 - ...ability_assessments_settings_operations.py | 275 - .../operations/_database_tables_operations.py | 299 - .../operations/_database_usages_operations.py | 164 - ...ty_assessment_rule_baselines_operations.py | 525 - ...lnerability_assessment_scans_operations.py | 582 - ...se_vulnerability_assessments_operations.py | 576 - .../sql/operations/_databases_operations.py | 2557 - .../operations/_deleted_servers_operations.py | 463 - ...tributed_availability_groups_operations.py | 1431 - .../_elastic_pool_activities_operations.py | 165 - ...tic_pool_database_activities_operations.py | 165 - .../_elastic_pool_operations_operations.py | 256 - .../operations/_elastic_pools_operations.py | 1241 - .../_encryption_protectors_operations.py | 660 - .../_endpoint_certificates_operations.py | 253 - ...abase_blob_auditing_policies_operations.py | 441 - ...erver_blob_auditing_policies_operations.py | 488 - .../operations/_failover_groups_operations.py | 1316 - .../operations/_firewall_rules_operations.py | 675 - .../_geo_backup_policies_operations.py | 464 - .../_instance_failover_groups_operations.py | 925 - .../operations/_instance_pools_operations.py | 908 - .../_ipv6_firewall_rules_operations.py | 512 - .../sql/operations/_job_agents_operations.py | 862 - .../operations/_job_credentials_operations.py | 548 - .../operations/_job_executions_operations.py | 947 - .../_job_private_endpoints_operations.py | 676 - .../_job_step_executions_operations.py | 358 - .../sql/operations/_job_steps_operations.py | 831 - .../_job_target_executions_operations.py | 552 - .../_job_target_groups_operations.py | 548 - .../operations/_job_versions_operations.py | 280 - .../mgmt/sql/operations/_jobs_operations.py | 532 - .../_ledger_digest_uploads_operations.py | 701 - ..._long_term_retention_backups_operations.py | 4510 - ...ion_managed_instance_backups_operations.py | 1375 - ...long_term_retention_policies_operations.py | 540 - .../_maintenance_window_options_operations.py | 166 - .../_maintenance_windows_operations.py | 348 - ...hort_term_retention_policies_operations.py | 797 - ...d_threat_protection_settings_operations.py | 476 - .../_managed_database_columns_operations.py | 463 - ...ged_database_move_operations_operations.py | 278 - .../_managed_database_queries_operations.py | 302 - ...commended_sensitivity_labels_operations.py | 225 - ...ged_database_restore_details_operations.py | 162 - .../_managed_database_schemas_operations.py | 282 - ...base_security_alert_policies_operations.py | 468 - ...ged_database_security_events_operations.py | 204 - ..._database_sensitivity_labels_operations.py | 1185 - .../_managed_database_tables_operations.py | 299 - ..._transparent_data_encryption_operations.py | 468 - ...ty_assessment_rule_baselines_operations.py | 525 - ...lnerability_assessment_scans_operations.py | 582 - ...se_vulnerability_assessments_operations.py | 576 - .../_managed_databases_operations.py | 1891 - ...aged_instance_administrators_operations.py | 656 - ...d_threat_protection_settings_operations.py | 525 - ...zure_ad_only_authentications_operations.py | 673 - .../_managed_instance_dtcs_operations.py | 504 - ...stance_encryption_protectors_operations.py | 664 - .../_managed_instance_keys_operations.py | 645 - ...long_term_retention_policies_operations.py | 537 - ..._managed_instance_operations_operations.py | 335 - ...private_endpoint_connections_operations.py | 656 - ...tance_private_link_resources_operations.py | 253 - ...ed_instance_tde_certificates_operations.py | 277 - ...ce_vulnerability_assessments_operations.py | 555 - .../_managed_instances_operations.py | 1894 - ...anaged_ledger_digest_uploads_operations.py | 706 - ...hort_term_retention_policies_operations.py | 809 - .../_managed_server_dns_aliases_operations.py | 871 - ...rver_security_alert_policies_operations.py | 509 - .../azure/mgmt/sql/operations/_operations.py | 93606 +++++++++++++++- .../_outbound_firewall_rules_operations.py | 631 - .../azure/mgmt/sql/operations/_patch.py | 13 +- ...private_endpoint_connections_operations.py | 649 - .../_private_link_resources_operations.py | 252 - ...commended_sensitivity_labels_operations.py | 225 - .../_recoverable_databases_operations.py | 276 - ...ecoverable_managed_databases_operations.py | 257 - .../_replication_links_operations.py | 1314 - ...restorable_dropped_databases_operations.py | 279 - ...le_dropped_managed_databases_operations.py | 259 - .../operations/_restore_points_operations.py | 600 - .../_sensitivity_labels_operations.py | 1185 - ...d_threat_protection_settings_operations.py | 521 - .../operations/_server_advisors_operations.py | 415 - .../_server_automatic_tuning_operations.py | 305 - ...rver_azure_ad_administrators_operations.py | 661 - ...zure_ad_only_authentications_operations.py | 667 - ...erver_blob_auditing_policies_operations.py | 486 - .../_server_communication_links_operations.py | 579 - ...server_configuration_options_operations.py | 521 - .../_server_connection_policies_operations.py | 509 - ...erver_dev_ops_audit_settings_operations.py | 515 - .../_server_dns_aliases_operations.py | 776 - .../sql/operations/_server_keys_operations.py | 633 - .../_server_operations_operations.py | 160 - ...rver_security_alert_policies_operations.py | 509 - .../_server_trust_certificates_operations.py | 633 - .../_server_trust_groups_operations.py | 734 - .../operations/_server_usages_operations.py | 160 - ...er_vulnerability_assessments_operations.py | 553 - .../sql/operations/_servers_operations.py | 1444 - .../_service_objectives_operations.py | 252 - .../sql/operations/_sql_agent_operations.py | 306 - ...rability_assessment_baseline_operations.py | 306 - ...ability_assessment_baselines_operations.py | 265 - ...lity_assessment_execute_scan_operations.py | 222 - ...ity_assessment_rule_baseline_operations.py | 538 - ...ty_assessment_rule_baselines_operations.py | 169 - ...ility_assessment_scan_result_operations.py | 318 - ...lnerability_assessment_scans_operations.py | 302 - ...ql_vulnerability_assessments_operations.py | 149 - ...ability_assessments_settings_operations.py | 450 - ...p_managed_instance_schedules_operations.py | 536 - .../_subscription_usages_operations.py | 232 - .../_synapse_link_workspaces_operations.py | 165 - .../sql/operations/_sync_agents_operations.py | 826 - .../sql/operations/_sync_groups_operations.py | 1616 - .../operations/_sync_members_operations.py | 1290 - .../_tde_certificates_operations.py | 277 - .../sql/operations/_time_zones_operations.py | 232 - ...transparent_data_encryptions_operations.py | 546 - .../mgmt/sql/operations/_usages_operations.py | 171 - .../_virtual_clusters_operations.py | 825 - .../_virtual_network_rules_operations.py | 631 - .../_workload_classifiers_operations.py | 733 - .../operations/_workload_groups_operations.py | 672 - .../administrator_create_or_update.py | 7 +- .../generated_samples/administrator_delete.py | 7 +- .../generated_samples/administrator_get.py | 7 +- .../generated_samples/administrator_list.py | 7 +- .../azure_ad_only_auth_create_or_update.py | 7 +- .../azure_ad_only_auth_delete.py | 7 +- .../azure_ad_only_auth_get.py | 7 +- .../azure_ad_only_auth_list.py | 7 +- .../cancel_database_operation.py | 7 +- .../cancel_elastic_pool_operation.py | 7 +- .../generated_samples/cancel_job_execution.py | 7 +- .../cancel_managed_instance_operation.py | 7 +- ..._long_term_retention_backup_access_tier.py | 7 +- ...name_availability_server_already_exists.py | 7 +- ...heck_name_availability_server_available.py | 7 +- .../check_name_availability_server_invalid.py | 7 +- .../column_sensitivity_label_create_max.py | 8 +- .../column_sensitivity_label_delete.py | 7 +- .../column_sensitivity_label_get.py | 7 +- .../columns_list_by_database_max.py | 7 +- .../columns_list_by_database_min.py | 7 +- ...se_configured_backup_storage_redundancy.py | 7 +- .../create_database_copy_mode.py | 6 +- .../create_database_default_enclave.py | 7 +- .../create_database_default_mode.py | 7 +- ...mode_with_keys_and_encryption_protector.py | 6 +- ...ys_and_versionless_encryption_protector.py | 64 + .../create_database_ledger.py | 7 +- ...eate_database_maintenance_configuration.py | 6 +- .../generated_samples/create_database_min.py | 7 +- .../create_database_named_replica.py | 6 +- .../create_database_pitr_mode.py | 6 +- .../create_database_secondary_mode.py | 6 +- .../create_database_standby_mode.py | 6 +- .../create_database_vbs_enclave.py | 7 +- .../create_database_with_availability_zone.py | 7 +- ...with_encryption_protector_auto_rotation.py | 61 + ...ate_dw_database_cross_subscription_pitr.py | 6 +- ...dw_database_cross_subscription_recovery.py | 6 +- ..._dw_database_cross_subscription_restore.py | 6 +- ...ate_elastic_pool_with_availability_zone.py | 7 +- .../generated_samples/create_job_execution.py | 7 +- .../create_managed_database_ledger.py | 7 +- ...ate_managed_short_term_retention_policy.py | 45 + ...rm_retention_policy_restorable_dropped.py} | 24 +- .../create_or_update_database_extensions.py | 6 +- .../create_or_update_instance_pool_max.py | 6 +- .../create_or_update_instance_pool_min.py | 6 +- .../create_or_update_job_agent.py | 6 +- ...reate_or_update_job_agent_with_identity.py | 56 + .../create_or_update_job_agent_with_sku.py | 51 + .../create_or_update_job_credential.py | 7 +- .../create_or_update_job_execution.py | 7 +- .../create_or_update_job_max.py | 7 +- .../create_or_update_job_min.py | 68 + .../create_or_update_job_private_endpoint.py | 6 +- .../create_or_update_job_step_max.py | 6 +- .../create_or_update_job_step_min.py | 7 +- .../create_or_update_job_target_group_max.py | 6 +- .../create_or_update_job_target_group_min.py | 7 +- .../create_or_update_maintenance_windows.py | 9 +- ...reate_or_update_workload_classifier_max.py | 7 +- ...reate_or_update_workload_classifier_min.py | 7 +- .../create_or_update_workload_group_max.py | 7 +- .../create_or_update_workload_group_min.py | 7 +- .../create_short_term_retention_policy.py | 45 + ...ate_vcore_database_by_service_objective.py | 7 +- ...ate_vcore_database_by_sku_name_capacity.py | 7 +- ...ata_masking_policy_create_or_update_max.py | 8 +- ...ata_masking_policy_create_or_update_min.py | 8 +- .../data_masking_policy_get.py | 8 +- ...sking_rule_create_or_update_default_max.py | 8 +- ...sking_rule_create_or_update_default_min.py | 8 +- ...ta_masking_rule_create_or_update_number.py | 8 +- ...data_masking_rule_create_or_update_text.py | 8 +- ... => data_masking_rule_list_by_database.py} | 10 +- .../data_warehouse_restore_points_get.py | 7 +- ...rehouse_restore_points_list_by_database.py | 7 +- ...d_threat_protection_settings_create_max.py | 7 +- ...d_threat_protection_settings_create_min.py | 7 +- ...advanced_threat_protection_settings_get.py | 7 +- ...at_protection_settings_list_by_database.py | 7 +- .../generated_samples/database_advisor_get.py | 7 +- .../database_advisor_list.py | 7 +- .../database_advisor_update.py | 7 +- .../database_auditing_settings_list.py | 7 +- .../database_automatic_tuning_get.py | 7 +- .../database_automatic_tuning_update_max.py | 7 +- .../database_automatic_tuning_update_min.py | 7 +- ...abase_azure_monitor_auditing_create_min.py | 7 +- .../database_blob_auditing_create_max.py | 6 +- .../database_blob_auditing_create_min.py | 6 +- .../database_blob_auditing_get.py | 7 +- .../generated_samples/database_column_get.py | 7 +- .../database_column_list_by_table.py | 7 +- ...atabase_encryption_protector_revalidate.py | 7 +- .../database_encryption_protector_revert.py | 7 +- ...atabase_extended_auditing_settings_list.py | 7 +- .../database_metrics_definitions_list.py | 45 - .../database_metrics_list_with_filter.py | 46 - .../database_recommended_action_get.py | 7 +- .../database_recommended_action_list.py | 7 +- ...database_recommended_action_list_expand.py | 7 +- .../database_recommended_action_update.py | 7 +- .../database_restore_points_delete.py | 7 +- .../database_restore_points_get.py | 7 +- ...atabase_restore_points_list_by_database.py | 7 +- .../database_restore_points_post.py | 7 +- .../generated_samples/database_schema_get.py | 7 +- .../database_schema_list_by_database.py | 7 +- .../database_security_alert_create_max.py | 6 +- .../database_security_alert_create_min.py | 7 +- .../database_security_alert_get.py | 7 +- ...atabase_security_alert_list_by_database.py | 7 +- ...l_vulnerability_assessment_baseline_add.py | 7 +- ...rability_assessment_baseline_add_latest.py | 7 +- ...l_vulnerability_assessment_baseline_get.py | 7 +- ...ne_list_by_sql_vulnerability_assessment.py | 7 +- ...tabase_sql_vulnerability_assessment_get.py | 7 +- ...lnerability_assessment_list_by_database.py | 7 +- ...erability_assessment_list_scans_results.py | 7 +- ...ability_assessment_rule_baseline_create.py | 7 +- ...ability_assessment_rule_baseline_delete.py | 7 +- ...nerability_assessment_rule_baseline_get.py | 7 +- ...sessment_rule_baseline_list_by_baseline.py | 7 +- ...abase_sql_vulnerability_assessment_scan.py | 7 +- ...ssessment_scan_records_list_by_database.py | 7 +- ..._vulnerability_assessment_scans_execute.py | 7 +- ..._vulnerability_assessment_scans_results.py | 7 +- .../generated_samples/database_table_get.py | 7 +- .../database_table_list_by_schema.py | 7 +- ...assessment_create_container_sas_key_min.py | 7 +- ...ase_vulnerability_assessment_create_max.py | 7 +- ...ssessment_create_storage_access_key_min.py | 7 +- ...atabase_vulnerability_assessment_delete.py | 7 +- .../database_vulnerability_assessment_get.py | 7 +- ...lnerability_assessment_list_by_database.py | 7 +- ...ability_assessment_rule_baseline_create.py | 7 +- ...ability_assessment_rule_baseline_delete.py | 7 +- ...nerability_assessment_rule_baseline_get.py | 7 +- ...se_vulnerability_assessment_scan_export.py | 7 +- ...lnerability_assessment_scan_records_get.py | 7 +- ...ssessment_scan_records_list_by_database.py | 7 +- ..._vulnerability_assessment_scans_execute.py | 7 +- .../generated_samples/delete_database.py | 7 +- .../generated_samples/delete_instance_pool.py | 7 +- .../generated_samples/delete_job.py | 7 +- .../generated_samples/delete_job_agent.py | 7 +- .../delete_job_credential.py | 7 +- .../delete_job_private_endpoint.py | 7 +- .../generated_samples/delete_job_step.py | 7 +- .../delete_job_target_group.py | 7 +- .../delete_workload_classifier.py | 7 +- .../delete_workload_group.py | 7 +- .../generated_samples/deleted_server_get.py | 7 +- .../generated_samples/deleted_server_list.py | 7 +- .../deleted_server_list_by_subscription.py | 7 +- .../deleted_server_recover.py | 7 +- ...tributed_availability_groups_create_max.py | 7 +- ...tributed_availability_groups_create_min.py | 7 +- .../distributed_availability_groups_delete.py | 7 +- ...istributed_availability_groups_failover.py | 7 +- .../distributed_availability_groups_get.py | 7 +- ...ed_availability_groups_list_by_instance.py | 7 +- ...istributed_availability_groups_set_role.py | 7 +- .../distributed_availability_groups_update.py | 7 +- .../elastic_pool_create_or_update_max.py | 7 +- .../elastic_pool_create_or_update_min.py | 7 +- ..._create_or_update_serverless_properties.py | 52 + ...or_update_set_maintenance_configuration.py | 6 +- ...ate_with_default_preferred_enclave_type.py | 7 +- ..._create_with_vbs_preferred_enclave_type.py | 7 +- .../elastic_pool_database_activity_list.py | 45 - .../generated_samples/elastic_pool_delete.py | 7 +- .../generated_samples/elastic_pool_get.py | 7 +- ...ic_pool_get_with_preferred_enclave_type.py | 7 +- .../elastic_pool_list_by_server.py | 7 +- .../elastic_pool_metrics_definitions_list.py | 45 - .../elastic_pool_metrics_list_with_filter.py | 46 - ...update_assign_maintenance_configuration.py | 6 +- .../elastic_pool_update_max.py | 7 +- .../elastic_pool_update_min.py | 60 + ..._update_reset_maintenance_configuration.py | 6 +- ...astic_pool_update_serverless_properties.py | 51 + ...ate_with_default_preferred_enclave_type.py | 7 +- ..._update_with_vbs_preferred_enclave_type.py | 7 +- ...on_protector_create_or_update_key_vault.py | 7 +- ...r_update_key_vault_with_versionless_key.py | 50 + ...tector_create_or_update_service_managed.py | 7 +- .../encryption_protector_get.py | 7 +- ...ion_protector_get_with_versionless_key.py} | 13 +- .../encryption_protector_list.py | 7 +- .../encryption_protector_revalidate.py | 7 +- .../endpoint_certificates_get.py | 7 +- .../endpoint_certificates_list_by_instance.py | 7 +- .../generated_samples/export_database.py | 7 +- ...port_database_using_database_extensions.py | 56 + ...tabase_extensions_with_managed_identity.py | 55 + .../export_database_with_managed_identity.py | 51 + .../export_database_with_network_isolation.py | 6 +- ...abase_azure_monitor_auditing_create_min.py | 7 +- ...ended_database_blob_auditing_create_max.py | 6 +- ...ended_database_blob_auditing_create_min.py | 6 +- .../extended_database_blob_auditing_get.py | 7 +- ...xtended_server_blob_auditing_create_max.py | 6 +- ...xtended_server_blob_auditing_create_min.py | 6 +- .../extended_server_blob_auditing_get.py | 7 +- .../generated_samples/failover_database.py | 7 +- .../failover_elastic_pool.py | 7 +- .../failover_group_create_or_update.py | 6 +- ...roup_create_or_update_standby_secondary.py | 6 +- .../failover_group_delete.py | 7 +- .../failover_group_failover.py | 7 +- ...er_group_force_failover_allow_data_loss.py | 7 +- .../generated_samples/failover_group_get.py | 7 +- .../generated_samples/failover_group_list.py | 7 +- ...roup_try_planned_before_forced_failover.py | 7 +- .../failover_group_update.py | 6 +- ...failover_group_update_standby_secondary.py | 6 +- .../failover_managed_instance.py | 7 +- .../generated_samples/firewall_rule_create.py | 7 +- .../generated_samples/firewall_rule_delete.py | 7 +- .../generated_samples/firewall_rule_get.py | 7 +- .../generated_samples/firewall_rule_list.py | 7 +- .../firewall_rule_replace.py | 7 +- .../generated_samples/firewall_rule_update.py | 7 +- .../geo_backup_policies_create_or_update.py | 7 +- .../geo_backup_policies_get.py | 7 +- .../geo_backup_policies_list.py | 9 +- .../get_data_warehouse_user_activities.py | 7 +- .../get_database_extensions.py | 7 +- .../generated_samples/get_database_usages.py | 7 +- .../get_database_with_availability_zone.py | 7 +- ...get_elastic_pool_with_availability_zone.py | 7 +- ...elastic_pool_with_serverless_properties.py | 43 + .../generated_samples/get_instance_pool.py | 7 +- .../get_instance_pool_operation.py | 43 + .../generated_samples/get_job.py | 6 +- .../generated_samples/get_job_agent.py | 7 +- .../generated_samples/get_job_credential.py | 7 +- .../generated_samples/get_job_execution.py | 7 +- .../get_job_execution_step.py | 7 +- .../get_job_execution_target.py | 7 +- .../get_job_private_endpoint.py | 7 +- .../generated_samples/get_job_step_by_job.py | 7 +- .../get_job_step_by_version.py | 7 +- .../generated_samples/get_job_target_group.py | 7 +- .../generated_samples/get_job_version.py | 7 +- ...ist_managed_short_term_retention_policy.py | 7 +- ...erm_retention_policy_restorable_dropped.py | 6 +- .../get_maintenance_window_options.py | 7 +- .../get_maintenance_windows.py | 7 +- .../get_managed_instance_operation.py | 7 +- ...get_managed_short_term_retention_policy.py | 7 +- ...erm_retention_policy_restorable_dropped.py | 7 +- .../get_recoverable_managed_database.py | 7 +- .../get_restorable_dropped_database.py | 7 +- ...ropped_database_with_expand_equals_keys.py | 7 +- ...get_restorable_dropped_managed_database.py | 7 +- .../get_short_term_retention_policy.py | 7 +- .../generated_samples/get_vcore_database.py | 7 +- .../get_vcore_database_default_enclave.py | 7 +- .../get_vcore_database_vbs_enclave.py | 7 +- ..._vcore_database_with_expand_equals_keys.py | 7 +- ...xpand_equals_keys_with_versionless_keys.py | 43 + .../get_workload_classifier.py | 7 +- .../get_workload_classifier_list.py | 7 +- .../generated_samples/get_workload_group.py | 7 +- .../get_workload_group_list.py | 7 +- ...ate_set_high_availability_replica_count.py | 7 +- .../hyperscale_elastic_pool_get.py | 7 +- ...ate_set_high_availability_replica_count.py | 7 +- .../generated_samples/import_database.py | 7 +- ...port_database_using_database_extensions.py | 56 + .../import_database_with_managed_identity.py | 51 + .../import_database_with_network_isolation.py | 6 +- .../generated_samples/import_new_database.py | 7 +- ...port_new_database_with_managed_identity.py | 6 +- ...ort_new_database_with_network_isolation.py | 6 +- ...naged_database_list_by_managed_instance.py | 7 +- ...nstance_failover_group_create_or_update.py | 6 +- .../instance_failover_group_delete.py | 7 +- .../instance_failover_group_failover.py | 7 +- ...er_group_force_failover_allow_data_loss.py | 7 +- .../instance_failover_group_get.py | 7 +- .../instance_failover_group_list.py | 7 +- .../ipv6_firewall_rule_create.py | 7 +- .../ipv6_firewall_rule_delete.py | 7 +- .../ipv6_firewall_rule_get.py | 7 +- .../ipv6_firewall_rule_list.py | 7 +- .../ipv6_firewall_rule_update.py | 7 +- .../ledger_digest_uploads_disable.py | 7 +- .../ledger_digest_uploads_enable.py | 7 +- .../ledger_digest_uploads_get.py | 7 +- .../ledger_digest_uploads_list.py | 7 +- .../list_data_warehouse_user_activities.py | 7 +- .../list_database_extensions.py | 7 +- .../list_database_operations.py | 7 +- .../list_databases_by_elastic_pool.py | 7 +- .../list_elastic_pool_operations.py | 7 +- ...st.py => list_instance_pool_operations.py} | 15 +- .../list_instance_pool_operations_empty.py | 43 + .../list_instance_pool_usage.py | 7 +- .../list_instance_pool_usage_expanded.py | 7 +- .../list_instance_pools_by_resource_group.py | 7 +- .../list_instance_pools_by_subscription_id.py | 7 +- .../list_job_agents_by_server.py | 7 +- .../list_job_credentials_by_agent.py | 7 +- .../list_job_execution_steps.py | 7 +- ...list_job_execution_targets_by_execution.py | 7 +- .../list_job_execution_targets_by_step.py | 7 +- .../list_job_executions_by_agent.py | 7 +- ...ist_job_executions_by_agent_with_filter.py | 7 +- .../list_job_executions_by_job.py | 7 +- .../list_job_private_endpoints_by_agent.py | 7 +- .../list_job_steps_by_job.py | 7 +- .../list_job_steps_by_version.py | 7 +- .../list_job_target_groups.py | 7 +- .../generated_samples/list_job_versions.py | 7 +- .../generated_samples/list_jobs_by_agent.py | 7 +- .../list_managed_instance_operations.py | 7 +- .../generated_samples/list_operations.py | 40 + ...etwork_dependencies_by_managed_instance.py | 7 +- ...recoverable_managed_databases_by_server.py | 7 +- ..._restorable_dropped_databases_by_server.py | 7 +- .../list_server_operations.py | 7 +- ...ort_term_retention_policies_by_database.py | 7 +- .../list_vcore_databases_by_server.py | 7 +- ...st_vcore_databases_by_server_with_odata.py | 43 + ..._vcore_databases_enclave_type_by_server.py | 7 +- ..._vcore_inaccessible_databases_by_server.py | 7 +- .../location_capability_list_by_location.py | 7 +- ...immutability_long_term_retention_backup.py | 7 +- .../long_term_retention_backup_copy.py | 6 +- .../long_term_retention_backup_delete.py | 7 +- .../long_term_retention_backup_get.py | 7 +- ..._term_retention_backup_list_by_database.py | 7 +- ..._term_retention_backup_list_by_location.py | 7 +- ...ng_term_retention_backup_list_by_server.py | 7 +- .../long_term_retention_backup_update.py | 7 +- ..._term_retention_policy_create_or_update.py | 7 +- .../long_term_retention_policy_get.py | 7 +- ..._term_retention_policy_list_by_database.py | 7 +- .../managed_columns_list_by_database_max.py | 7 +- .../managed_columns_list_by_database_min.py | 7 +- ...d_threat_protection_settings_create_max.py | 7 +- ...d_threat_protection_settings_create_min.py | 7 +- ...advanced_threat_protection_settings_get.py | 7 +- ...at_protection_settings_list_by_database.py | 7 +- .../managed_database_cancel_move.py | 6 +- .../managed_database_column_get.py | 7 +- .../managed_database_column_list_by_table.py | 7 +- ...atabase_column_sensitivity_label_create.py | 8 +- ...atabase_column_sensitivity_label_delete.py | 7 +- ...d_database_column_sensitivity_label_get.py | 7 +- ...aged_database_complete_external_restore.py | 7 +- .../managed_database_complete_move.py | 6 +- ...ross_subscription_point_in_time_restore.py | 6 +- .../managed_database_create_max.py | 7 +- .../managed_database_create_min.py | 7 +- ...d_database_create_point_in_time_restore.py | 6 +- .../managed_database_create_recovery.py | 6 +- ...database_create_restore_external_backup.py | 7 +- ...estore_external_backup_managed_identity.py | 7 +- ...aged_database_create_restore_ltr_backup.py | 7 +- .../managed_database_delete.py | 7 +- .../generated_samples/managed_database_get.py | 7 +- ...naged_database_list_by_managed_instance.py | 7 +- ...aged_database_move_operation_result_get.py | 7 +- ...ged_database_move_operation_result_list.py | 7 +- ...e_operation_result_list_last_operations.py | 7 +- ...database_move_operation_result_list_max.py | 7 +- ...mended_column_sensitivity_label_disable.py | 7 +- ...mmended_column_sensitivity_label_enable.py | 7 +- ..._reevaluate_inaccessible_database_state.py | 43 + .../managed_database_restore_details.py | 7 +- .../managed_database_schema_get.py | 7 +- ...anaged_database_schema_list_by_database.py | 7 +- ...aged_database_security_alert_create_max.py | 6 +- ...aged_database_security_alert_create_min.py | 7 +- .../managed_database_security_alert_get.py | 7 +- ...atabase_security_alert_list_by_database.py | 7 +- ...anaged_database_security_events_get_max.py | 7 +- ...anaged_database_security_events_get_min.py | 7 +- ...abase_sensitivity_labels_current_update.py | 7 +- ...ase_sensitivity_labels_list_by_database.py | 44 + ...itivity_labels_list_by_database_current.py | 7 +- ...ity_labels_list_by_database_recommended.py | 7 +- ...e_sensitivity_labels_recommended_update.py | 7 +- .../managed_database_start_move_max.py | 6 +- .../managed_database_start_move_min.py | 6 +- .../managed_database_table_get.py | 7 +- .../managed_database_table_list_by_schema.py | 7 +- .../managed_database_update_max.py | 7 +- .../managed_database_update_min.py | 7 +- ...ase_vulnerability_assessment_create_max.py | 7 +- ...ase_vulnerability_assessment_create_min.py | 7 +- ...atabase_vulnerability_assessment_delete.py | 7 +- ...d_database_vulnerability_assessment_get.py | 7 +- ...lnerability_assessment_list_by_database.py | 7 +- ...ability_assessment_rule_baseline_create.py | 7 +- ...ability_assessment_rule_baseline_delete.py | 7 +- ...nerability_assessment_rule_baseline_get.py | 7 +- ...se_vulnerability_assessment_scan_export.py | 7 +- ...lnerability_assessment_scan_records_get.py | 7 +- ...ssessment_scan_records_list_by_database.py | 7 +- ..._vulnerability_assessment_scans_execute.py | 7 +- ...validate_azure_key_vault_encryption_key.py | 42 + .../managed_instance_administrator_create.py | 7 +- .../managed_instance_administrator_delete.py | 7 +- .../managed_instance_administrator_get.py | 7 +- ...instance_administrator_list_by_instance.py | 7 +- .../managed_instance_administrator_update.py | 7 +- ...d_threat_protection_settings_create_max.py | 7 +- ...d_threat_protection_settings_create_min.py | 7 +- ...advanced_threat_protection_settings_get.py | 7 +- ...at_protection_settings_list_by_instance.py | 7 +- ...nce_azure_ad_only_auth_create_or_update.py | 7 +- ...aged_instance_azure_ad_only_auth_delete.py | 7 +- ...managed_instance_azure_ad_only_auth_get.py | 7 +- ...nce_azure_ad_only_auth_list_by_instance.py | 7 +- .../managed_instance_create_max.py | 8 +- .../managed_instance_create_min.py | 6 +- .../managed_instance_delete.py | 7 +- .../managed_instance_dtc_get.py | 7 +- .../managed_instance_dtc_list.py | 7 +- .../managed_instance_dtc_update_enable_dtc.py | 7 +- .../managed_instance_dtc_update_max.py | 7 +- ...on_protector_create_or_update_key_vault.py | 7 +- ...tector_create_or_update_service_managed.py | 7 +- ...naged_instance_encryption_protector_get.py | 7 +- ...aged_instance_encryption_protector_list.py | 7 +- ...nstance_encryption_protector_revalidate.py | 7 +- .../generated_samples/managed_instance_get.py | 7 +- .../managed_instance_get_while_updating.py | 7 +- ...e_get_with_expand_equals_administrators.py | 7 +- .../managed_instance_key_create_or_update.py | 7 +- .../managed_instance_key_delete.py | 7 +- .../managed_instance_key_get.py | 7 +- .../managed_instance_key_list.py | 7 +- .../managed_instance_list.py | 7 +- .../managed_instance_list_by_instance_pool.py | 7 +- ..._pool_with_expand_equals_administrators.py | 7 +- ...managed_instance_list_by_resource_group.py | 7 +- ...group_with_expand_equals_administrators.py | 7 +- ..._list_with_expand_equals_administrators.py | 7 +- ...tance_long_term_retention_backup_delete.py | 9 +- ...instance_long_term_retention_backup_get.py | 9 +- ..._term_retention_backup_list_by_database.py | 7 +- ..._term_retention_backup_list_by_instance.py | 7 +- ..._term_retention_backup_list_by_location.py | 7 +- ...m_retention_backup_list_by_location_max.py | 42 + ..._term_retention_policy_create_or_update.py | 8 +- ...tance_long_term_retention_policy_delete.py | 44 + ...instance_long_term_retention_policy_get.py | 7 +- ..._term_retention_policy_list_by_database.py | 7 +- ...ance_private_endpoint_connection_delete.py | 7 +- ...nstance_private_endpoint_connection_get.py | 7 +- ...stance_private_endpoint_connection_list.py | 7 +- ...ance_private_endpoint_connection_update.py | 9 +- ...ged_instance_private_link_resources_get.py | 7 +- ...ed_instance_private_link_resources_list.py | 7 +- .../managed_instance_query_get.py | 7 +- .../managed_instance_query_statistics_list.py | 7 +- ...aged_instance_query_statistics_list_max.py | 7 +- ...aged_instance_query_statistics_list_min.py | 7 +- ..._reevaluate_inaccessible_database_state.py | 41 + ...ance_refresh_external_governance_status.py | 7 +- ...stance_remove_maintenance_configuration.py | 6 +- .../managed_instance_tde_certificate.py | 7 +- .../managed_instance_time_zone_get.py | 7 +- ...ged_instance_time_zone_list_by_location.py | 7 +- .../managed_instance_top_queries_list.py | 7 +- .../managed_instance_top_queries_list_max.py | 7 +- .../managed_instance_top_queries_list_min.py | 7 +- .../managed_instance_update_max.py | 7 +- .../managed_instance_update_min.py | 7 +- ...assessment_create_container_sas_key_min.py | 7 +- ...nce_vulnerability_assessment_create_max.py | 7 +- ...ssessment_create_storage_access_key_min.py | 7 +- ...nstance_vulnerability_assessment_delete.py | 7 +- ...d_instance_vulnerability_assessment_get.py | 7 +- ...lnerability_assessment_list_by_instance.py | 7 +- .../managed_ledger_digest_uploads_disable.py | 7 +- .../managed_ledger_digest_uploads_enable.py | 7 +- .../managed_ledger_digest_uploads_get.py | 7 +- .../managed_ledger_digest_uploads_list.py | 7 +- .../managed_server_dns_alias_acquire.py | 6 +- ...naged_server_dns_alias_create_or_update.py | 44 + .../managed_server_dns_alias_delete.py | 7 +- .../managed_server_dns_alias_get.py | 7 +- .../managed_server_dns_alias_list.py | 7 +- ...anaged_server_security_alert_create_max.py | 6 +- ...anaged_server_security_alert_create_min.py | 7 +- .../managed_server_security_alert_get.py | 7 +- ..._server_security_alert_list_by_instance.py | 7 +- ...managed_transparent_data_encryption_get.py | 7 +- ...anaged_transparent_data_encryption_list.py | 7 +- ...aged_transparent_data_encryption_update.py | 7 +- ...k_security_perimeter_configurations_get.py | 43 + ...erimeter_configurations_list_by_server.py} | 13 +- ...rity_perimeter_configurations_reconcile.py | 43 + ...te.py => outbound_firewall_rule_create.py} | 14 +- .../outbound_firewall_rule_delete.py | 7 +- .../outbound_firewall_rule_get.py | 7 +- .../outbound_firewall_rule_list.py | 7 +- .../patch_database_default_enclave.py | 7 +- .../patch_database_vbs_enclave.py | 7 +- .../generated_samples/patch_instance_pool.py | 7 +- .../generated_samples/patch_vcore_database.py | 7 +- ...tabase_assign_maintenance_configuration.py | 6 +- ...atabase_reset_maintenance_configuration.py | 6 +- ...base_with_keys_and_encryption_protector.py | 6 +- .../generated_samples/pause_database.py | 7 +- .../private_endpoint_connection_delete.py | 7 +- .../private_endpoint_connection_get.py | 7 +- .../private_endpoint_connection_list.py | 7 +- .../private_endpoint_connection_update.py | 9 +- .../private_link_resources_get.py | 7 +- .../private_link_resources_list.py | 7 +- ...mended_column_sensitivity_label_disable.py | 7 +- ...mmended_column_sensitivity_label_enable.py | 7 +- .../recoverable_database_get.py | 7 +- ...le_database_get_with_expand_equals_keys.py | 7 +- .../recoverable_database_list.py | 7 +- .../refresh_external_governance_status.py | 7 +- ...immutability_long_term_retention_backup.py | 7 +- ...immutability_long_term_retention_backup.py | 7 +- .../generated_samples/rename_database.py | 6 +- .../replication_link_create_or_update.py | 7 +- .../replication_link_delete.py | 7 +- .../replication_link_failover.py | 7 +- ...plication_link_failover_allow_data_loss.py | 7 +- .../generated_samples/replication_link_get.py | 7 +- .../replication_link_list_by_database.py | 7 +- .../replication_link_list_by_server.py | 7 +- .../replication_link_update.py | 7 +- ..._long_term_retention_backup_access_tier.py | 7 +- ...immutability_long_term_retention_backup.py | 7 +- ...p_based_long_term_retention_backup_copy.py | 6 +- ...based_long_term_retention_backup_delete.py | 7 +- ...up_based_long_term_retention_backup_get.py | 7 +- ..._term_retention_backup_list_by_database.py | 7 +- ..._term_retention_backup_list_by_location.py | 7 +- ...ng_term_retention_backup_list_by_server.py | 7 +- ...based_long_term_retention_backup_update.py | 7 +- ...tance_long_term_retention_backup_delete.py | 9 +- ...instance_long_term_retention_backup_get.py | 9 +- ..._term_retention_backup_list_by_database.py | 7 +- ..._term_retention_backup_list_by_instance.py | 7 +- ..._term_retention_backup_list_by_location.py | 7 +- ...m_retention_backup_list_by_location_max.py | 43 + ...immutability_long_term_retention_backup.py | 7 +- ...immutability_long_term_retention_backup.py | 7 +- ...immutability_long_term_retention_backup.py | 7 +- ...naged_database_list_by_managed_instance.py | 7 +- .../generated_samples/resume_database.py | 7 +- ...sume_transparent_data_encryption_update.py | 44 + .../sensitivity_labels_current_update.py | 7 +- .../sensitivity_labels_list_by_database.py | 44 + ...ls_list_by_database_with_source_current.py | 7 +- ...ist_by_database_with_source_recommended.py | 7 +- .../sensitivity_labels_recommended_update.py | 7 +- ...d_threat_protection_settings_create_max.py | 7 +- ...d_threat_protection_settings_create_min.py | 7 +- ...advanced_threat_protection_settings_get.py | 7 +- ...reat_protection_settings_list_by_server.py | 7 +- .../generated_samples/server_advisor_get.py | 7 +- .../generated_samples/server_advisor_list.py | 7 +- .../server_advisor_update.py | 7 +- .../server_auditing_settings_list.py | 7 +- .../server_automatic_tuning_get.py | 7 +- .../server_automatic_tuning_update_max.py | 7 +- .../server_automatic_tuning_update_min.py | 7 +- .../server_blob_auditing_create_max.py | 6 +- .../server_blob_auditing_create_min.py | 6 +- .../server_blob_auditing_get.py | 7 +- .../server_configuration_option_get.py | 7 +- .../server_configuration_option_list.py | 7 +- .../server_configuration_option_update.py | 7 +- .../server_connection_policies_get.py | 7 +- .../server_connection_policies_list.py | 7 +- .../server_connection_policies_update.py | 7 +- .../generated_samples/server_create.py | 7 +- .../generated_samples/server_delete.py | 7 +- .../server_dev_ops_audit_create_max.py | 7 +- .../server_dev_ops_audit_create_min.py | 7 +- .../server_dev_ops_audit_get.py | 7 +- .../server_dev_ops_audit_list.py | 7 +- .../server_dns_alias_acquire.py | 6 +- .../server_dns_alias_create_or_update.py | 7 +- .../server_dns_alias_delete.py | 7 +- .../generated_samples/server_dns_alias_get.py | 7 +- .../server_dns_alias_list.py | 7 +- .../server_extended_auditing_settings_list.py | 7 +- .../generated_samples/server_get.py | 7 +- ...r_get_with_expand_equals_administrators.py | 7 +- .../server_key_create_or_update.py | 7 +- ...y_create_or_update_with_versionless_key.py | 46 + .../generated_samples/server_key_delete.py | 7 +- .../generated_samples/server_key_get.py | 7 +- ...=> server_key_get_with_versionless_key.py} | 14 +- .../generated_samples/server_key_list.py | 7 +- .../generated_samples/server_list.py | 7 +- .../server_list_by_resource_group.py | 7 +- ...group_with_expand_equals_administrators.py | 7 +- ..._list_with_expand_equals_administrators.py | 7 +- .../server_recommended_action_list_expand.py | 7 +- .../server_security_alerts_create_max.py | 6 +- .../server_security_alerts_create_min.py | 7 +- .../server_security_alerts_get.py | 7 +- .../server_security_alerts_list_by_server.py | 7 +- .../server_trust_certificates_create.py | 7 +- .../server_trust_certificates_delete.py | 7 +- .../server_trust_certificates_get.py | 7 +- ...ver_trust_certificates_list_by_instance.py | 7 +- .../server_trust_group_create.py | 6 +- .../server_trust_group_delete.py | 7 +- .../server_trust_group_get.py | 7 +- .../server_trust_group_list.py | 7 +- ...er_trust_group_list_by_managed_instance.py | 7 +- .../generated_samples/server_update.py | 7 +- ...e_metrics_list.py => server_usage_list.py} | 9 +- ...assessment_create_container_sas_key_min.py | 7 +- ...ver_vulnerability_assessment_create_max.py | 7 +- ...ssessment_create_storage_access_key_min.py | 7 +- .../server_vulnerability_assessment_delete.py | 7 +- .../server_vulnerability_assessment_get.py | 7 +- ...vulnerability_assessment_list_by_server.py | 7 +- ...immutability_long_term_retention_backup.py | 7 +- .../sql_agent_configuration_get.py | 7 +- .../sql_agent_configuration_put.py | 7 +- .../sql_tde_certificate_create.py | 7 +- ...l_vulnerability_assessment_baseline_add.py | 8 +- ...rability_assessment_baseline_add_latest.py | 8 +- ...l_vulnerability_assessment_baseline_get.py | 8 +- ...ne_list_by_sql_vulnerability_assessment.py | 8 +- .../sql_vulnerability_assessment_create.py | 7 +- .../sql_vulnerability_assessment_delete.py | 7 +- .../sql_vulnerability_assessment_get.py | 7 +- ...vulnerability_assessment_list_by_server.py | 7 +- ...erability_assessment_list_scans_results.py | 8 +- ...ability_assessment_rule_baseline_create.py | 8 +- ...ability_assessment_rule_baseline_delete.py | 8 +- ...nerability_assessment_rule_baseline_get.py | 8 +- ...sessment_rule_baseline_list_by_baseline.py | 8 +- .../sql_vulnerability_assessment_scan.py | 8 +- ...ssessment_scan_records_list_by_database.py | 8 +- ..._vulnerability_assessment_scans_execute.py | 8 +- ..._vulnerability_assessment_scans_results.py | 8 +- .../start_managed_instance.py | 7 +- ..._instance_schedule_create_or_update_max.py | 7 +- ..._instance_schedule_create_or_update_min.py | 7 +- ...t_stop_managed_instance_schedule_delete.py | 7 +- ...tart_stop_managed_instance_schedule_get.py | 7 +- ...art_stop_managed_instance_schedule_list.py | 7 +- .../stop_managed_instance.py | 7 +- .../subscription_usage_get.py | 7 +- .../subscription_usage_list_by_location.py | 7 +- ...pend_transparent_data_encryption_update.py | 44 + ...synapse_link_workspace_list_by_database.py | 7 +- .../generated_samples/sync_agent_create.py | 6 +- .../generated_samples/sync_agent_delete.py | 7 +- .../sync_agent_generate_key.py | 7 +- .../generated_samples/sync_agent_get.py | 7 +- .../sync_agent_get_linked_databases.py | 7 +- .../sync_agent_list_by_server.py | 7 +- .../generated_samples/sync_agent_update.py | 6 +- .../sync_group_cancel_sync.py | 7 +- .../generated_samples/sync_group_create.py | 6 +- .../sync_group_create_with_identity.py | 59 + .../generated_samples/sync_group_delete.py | 7 +- .../generated_samples/sync_group_get.py | 7 +- .../sync_group_get_hub_schema.py | 7 +- .../generated_samples/sync_group_get_log.py | 7 +- .../sync_group_get_sync_database_id.py | 7 +- .../sync_group_get_with_identity.py | 44 + .../sync_group_list_by_database.py | 7 +- .../generated_samples/sync_group_patch.py | 6 +- ...ync_group_patch_add_and_remove_identity.py | 60 + .../sync_group_patch_with_identity.py | 59 + .../sync_group_refresh_hub_schema.py | 7 +- .../sync_group_trigger_sync.py | 7 +- .../generated_samples/sync_group_update.py | 6 +- .../generated_samples/sync_member_create.py | 6 +- .../sync_member_create_with_identity.py | 62 + .../generated_samples/sync_member_delete.py | 7 +- .../generated_samples/sync_member_get.py | 7 +- .../sync_member_get_schema.py | 7 +- .../sync_member_get_with_identity.py | 45 + .../sync_member_list_by_sync_group.py | 7 +- .../generated_samples/sync_member_patch.py | 6 +- ...nc_member_patch_add_and_remove_identity.py | 63 + .../sync_member_patch_with_identity.py | 62 + .../sync_member_refresh_schema.py | 7 +- .../generated_samples/sync_member_update.py | 6 +- .../transparent_data_encryption_get.py | 7 +- .../transparent_data_encryption_list.py | 7 +- .../transparent_data_encryption_update.py | 9 +- ...se_hyperscale_migration_perform_cutover.py | 6 +- ...yperscale_migration_with_manual_cutover.py | 6 +- .../generated_samples/update_job_agent.py | 7 +- .../update_job_agent_with_identity.py | 52 + ...ve_get.py => update_job_agent_with_sku.py} | 18 +- ...ate_managed_short_term_retention_policy.py | 9 +- ...erm_retention_policy_restorable_dropped.py | 9 +- .../update_short_term_retention_policy.py | 9 +- .../update_virtual_cluster_dns_servers.py | 7 +- .../upgrade_data_warehouse.py | 7 +- .../virtual_cluster_create.py | 43 + .../virtual_cluster_delete.py | 7 +- .../generated_samples/virtual_cluster_get.py | 7 +- .../generated_samples/virtual_cluster_list.py | 7 +- .../virtual_cluster_list_by_resource_group.py | 7 +- .../virtual_cluster_update.py | 7 +- .../virtual_network_rules_create_or_update.py | 6 +- .../virtual_network_rules_delete.py | 7 +- .../virtual_network_rules_get.py | 7 +- .../virtual_network_rules_list.py | 7 +- .../generated_tests/conftest.py | 2 +- ...hort_term_retention_policies_operations.py | 36 +- ...erm_retention_policies_operations_async.py | 28 +- ..._sql_management_capabilities_operations.py | 3 +- ...anagement_capabilities_operations_async.py | 3 +- ...gement_data_masking_policies_operations.py | 48 +- ..._data_masking_policies_operations_async.py | 48 +- ...anagement_data_masking_rules_operations.py | 65 +- ...ent_data_masking_rules_operations_async.py | 65 +- ...ta_warehouse_user_activities_operations.py | 4 +- ...ehouse_user_activities_operations_async.py | 4 +- ...d_threat_protection_settings_operations.py | 32 +- ...at_protection_settings_operations_async.py | 32 +- ...management_database_advisors_operations.py | 179 +- ...ment_database_advisors_operations_async.py | 179 +- ...nt_database_automatic_tuning_operations.py | 22 +- ...abase_automatic_tuning_operations_async.py | 22 +- ...abase_blob_auditing_policies_operations.py | 59 +- ...blob_auditing_policies_operations_async.py | 59 +- ..._management_database_columns_operations.py | 23 +- ...ement_database_columns_operations_async.py | 23 +- ...tabase_encryption_protectors_operations.py | 4 +- ..._encryption_protectors_operations_async.py | 4 +- ...nagement_database_extensions_operations.py | 30 +- ...nt_database_extensions_operations_async.py | 30 +- ...nagement_database_operations_operations.py | 4 +- ...nt_database_operations_operations_async.py | 4 +- ...database_recommended_actions_operations.py | 135 +- ...se_recommended_actions_operations_async.py | 135 +- ..._management_database_schemas_operations.py | 18 +- ...ement_database_schemas_operations_async.py | 18 +- ...base_security_alert_policies_operations.py | 23 +- ...ecurity_alert_policies_operations_async.py | 23 +- ...ability_assessment_baselines_operations.py | 34 +- ...y_assessment_baselines_operations_async.py | 38 +- ...lity_assessment_execute_scan_operations.py | 3 +- ...ssessment_execute_scan_operations_async.py | 3 +- ...ty_assessment_rule_baselines_operations.py | 37 +- ...essment_rule_baselines_operations_async.py | 37 +- ...ility_assessment_scan_result_operations.py | 18 +- ...assessment_scan_result_operations_async.py | 18 +- ...lnerability_assessment_scans_operations.py | 18 +- ...ility_assessment_scans_operations_async.py | 22 +- ...ability_assessments_settings_operations.py | 18 +- ...y_assessments_settings_operations_async.py | 18 +- ...l_management_database_tables_operations.py | 18 +- ...gement_database_tables_operations_async.py | 18 +- ...l_management_database_usages_operations.py | 3 +- ...gement_database_usages_operations_async.py | 3 +- ...ty_assessment_rule_baselines_operations.py | 20 +- ...essment_rule_baselines_operations_async.py | 20 +- ...lnerability_assessment_scans_operations.py | 22 +- ...ility_assessment_scans_operations_async.py | 46 +- ...se_vulnerability_assessments_operations.py | 24 +- ...nerability_assessments_operations_async.py | 24 +- ...est_sql_management_databases_operations.py | 333 +- ...l_management_databases_operations_async.py | 337 +- ...l_management_deleted_servers_operations.py | 23 +- ...gement_deleted_servers_operations_async.py | 23 +- ...tributed_availability_groups_operations.py | 205 +- ...ed_availability_groups_operations_async.py | 215 +- ...ment_elastic_pool_activities_operations.py | 32 - ...lastic_pool_activities_operations_async.py | 33 - ...tic_pool_database_activities_operations.py | 32 - ...ol_database_activities_operations_async.py | 33 - ...ment_elastic_pool_operations_operations.py | 18 +- ...lastic_pool_operations_operations_async.py | 18 +- ...sql_management_elastic_pools_operations.py | 129 +- ...nagement_elastic_pools_operations_async.py | 129 +- ...gement_encryption_protectors_operations.py | 51 +- ..._encryption_protectors_operations_async.py | 51 +- ...gement_endpoint_certificates_operations.py | 18 +- ..._endpoint_certificates_operations_async.py | 18 +- ...abase_blob_auditing_policies_operations.py | 61 +- ...blob_auditing_policies_operations_async.py | 61 +- ...erver_blob_auditing_policies_operations.py | 61 +- ...blob_auditing_policies_operations_async.py | 61 +- ...l_management_failover_groups_operations.py | 82 +- ...gement_failover_groups_operations_async.py | 82 +- ...ql_management_firewall_rules_operations.py | 23 +- ...agement_firewall_rules_operations_async.py | 23 +- ...nagement_geo_backup_policies_operations.py | 42 +- ...nt_geo_backup_policies_operations_async.py | 42 +- ...ent_instance_failover_groups_operations.py | 54 +- ...stance_failover_groups_operations_async.py | 56 +- ...ent_instance_pool_operations_operations.py | 18 +- ...stance_pool_operations_operations_async.py | 18 +- ...ql_management_instance_pools_operations.py | 93 +- ...agement_instance_pools_operations_async.py | 93 +- ...nagement_ipv6_firewall_rules_operations.py | 35 +- ...nt_ipv6_firewall_rules_operations_async.py | 35 +- ...st_sql_management_job_agents_operations.py | 63 +- ..._management_job_agents_operations_async.py | 63 +- ...l_management_job_credentials_operations.py | 43 +- ...gement_job_credentials_operations_async.py | 43 +- ...ql_management_job_executions_operations.py | 42 +- ...agement_job_executions_operations_async.py | 56 +- ...gement_job_private_endpoints_operations.py | 41 +- ..._job_private_endpoints_operations_async.py | 41 +- ...nagement_job_step_executions_operations.py | 18 +- ...nt_job_step_executions_operations_async.py | 18 +- ...est_sql_management_job_steps_operations.py | 110 +- ...l_management_job_steps_operations_async.py | 110 +- ...gement_job_target_executions_operations.py | 21 +- ..._job_target_executions_operations_async.py | 21 +- ...management_job_target_groups_operations.py | 62 +- ...ment_job_target_groups_operations_async.py | 62 +- ..._sql_management_job_versions_operations.py | 18 +- ...anagement_job_versions_operations_async.py | 18 +- .../test_sql_management_jobs_operations.py | 56 +- ...st_sql_management_jobs_operations_async.py | 56 +- ...gement_ledger_digest_uploads_operations.py | 21 +- ..._ledger_digest_uploads_operations_async.py | 21 +- ..._long_term_retention_backups_operations.py | 190 +- ...term_retention_backups_operations_async.py | 196 +- ...ion_managed_instance_backups_operations.py | 82 +- ...naged_instance_backups_operations_async.py | 90 +- ...long_term_retention_policies_operations.py | 51 +- ...erm_retention_policies_operations_async.py | 51 +- ...t_maintenance_window_options_operations.py | 3 +- ...tenance_window_options_operations_async.py | 3 +- ...nagement_maintenance_windows_operations.py | 16 +- ...nt_maintenance_windows_operations_async.py | 16 +- ...hort_term_retention_policies_operations.py | 36 +- ...erm_retention_policies_operations_async.py | 36 +- ...d_threat_protection_settings_operations.py | 32 +- ...at_protection_settings_operations_async.py | 32 +- ...ent_managed_database_columns_operations.py | 23 +- ...naged_database_columns_operations_async.py | 23 +- ...ged_database_move_operations_operations.py | 18 +- ...tabase_move_operations_operations_async.py | 18 +- ...ent_managed_database_queries_operations.py | 4 +- ...naged_database_queries_operations_async.py | 4 +- ...commended_sensitivity_labels_operations.py | 16 +- ...ded_sensitivity_labels_operations_async.py | 16 +- ...ged_database_restore_details_operations.py | 3 +- ...tabase_restore_details_operations_async.py | 3 +- ...ent_managed_database_schemas_operations.py | 18 +- ...naged_database_schemas_operations_async.py | 18 +- ...base_security_alert_policies_operations.py | 31 +- ...ecurity_alert_policies_operations_async.py | 31 +- ...ged_database_security_events_operations.py | 3 +- ...tabase_security_events_operations_async.py | 3 +- ..._database_sensitivity_labels_operations.py | 108 +- ...ase_sensitivity_labels_operations_async.py | 108 +- ...ment_managed_database_tables_operations.py | 18 +- ...anaged_database_tables_operations_async.py | 18 +- ..._transparent_data_encryption_operations.py | 20 +- ...parent_data_encryption_operations_async.py | 20 +- ...ty_assessment_rule_baselines_operations.py | 20 +- ...essment_rule_baselines_operations_async.py | 20 +- ...lnerability_assessment_scans_operations.py | 32 +- ...ility_assessment_scans_operations_async.py | 46 +- ...se_vulnerability_assessments_operations.py | 24 +- ...nerability_assessments_operations_async.py | 24 +- ...management_managed_databases_operations.py | 172 +- ...ment_managed_databases_operations_async.py | 174 +- ...aged_instance_administrators_operations.py | 41 +- ...nstance_administrators_operations_async.py | 41 +- ...d_threat_protection_settings_operations.py | 30 +- ...at_protection_settings_operations_async.py | 30 +- ...zure_ad_only_authentications_operations.py | 21 +- ...d_only_authentications_operations_async.py | 21 +- ...gement_managed_instance_dtcs_operations.py | 64 +- ..._managed_instance_dtcs_operations_async.py | 64 +- ...stance_encryption_protectors_operations.py | 64 +- ..._encryption_protectors_operations_async.py | 70 +- ...gement_managed_instance_keys_operations.py | 48 +- ..._managed_instance_keys_operations_async.py | 48 +- ...long_term_retention_policies_operations.py | 37 +- ...erm_retention_policies_operations_async.py | 39 +- ..._managed_instance_operations_operations.py | 19 +- ...ed_instance_operations_operations_async.py | 19 +- ...private_endpoint_connections_operations.py | 26 +- ...e_endpoint_connections_operations_async.py | 28 +- ...tance_private_link_resources_operations.py | 18 +- ...private_link_resources_operations_async.py | 18 +- ...ed_instance_tde_certificates_operations.py | 18 +- ...tance_tde_certificates_operations_async.py | 18 +- ...ce_vulnerability_assessments_operations.py | 24 +- ...nerability_assessments_operations_async.py | 24 +- ...management_managed_instances_operations.py | 371 +- ...ment_managed_instances_operations_async.py | 379 +- ...anaged_ledger_digest_uploads_operations.py | 43 +- ..._ledger_digest_uploads_operations_async.py | 45 +- ...hort_term_retention_policies_operations.py | 36 +- ...erm_retention_policies_operations_async.py | 36 +- ...t_managed_server_dns_aliases_operations.py | 31 +- ...ged_server_dns_aliases_operations_async.py | 31 +- ...rver_security_alert_policies_operations.py | 23 +- ...ecurity_alert_policies_operations_async.py | 23 +- ...ity_perimeter_configurations_operations.py | 19 +- ...rimeter_configurations_operations_async.py | 19 +- .../test_sql_management_operations.py | 6 +- .../test_sql_management_operations_async.py | 6 +- ...ment_outbound_firewall_rules_operations.py | 7 +- ...utbound_firewall_rules_operations_async.py | 7 +- ...private_endpoint_connections_operations.py | 50 +- ...e_endpoint_connections_operations_async.py | 52 +- ...ement_private_link_resources_operations.py | 18 +- ...private_link_resources_operations_async.py | 18 +- ...commended_sensitivity_labels_operations.py | 16 +- ...ded_sensitivity_labels_operations_async.py | 16 +- ...gement_recoverable_databases_operations.py | 18 +- ..._recoverable_databases_operations_async.py | 18 +- ...ecoverable_managed_databases_operations.py | 18 +- ...able_managed_databases_operations_async.py | 18 +- ...management_replication_links_operations.py | 85 +- ...ment_replication_links_operations_async.py | 91 +- ...restorable_dropped_databases_operations.py | 18 +- ...able_dropped_databases_operations_async.py | 18 +- ...le_dropped_managed_databases_operations.py | 18 +- ...pped_managed_databases_operations_async.py | 18 +- ...ql_management_restore_points_operations.py | 36 +- ...agement_restore_points_operations_async.py | 50 +- ...anagement_sensitivity_labels_operations.py | 150 +- ...ent_sensitivity_labels_operations_async.py | 150 +- ...d_threat_protection_settings_operations.py | 30 +- ...at_protection_settings_operations_async.py | 30 +- ...l_management_server_advisors_operations.py | 177 +- ...gement_server_advisors_operations_async.py | 177 +- ...ment_server_automatic_tuning_operations.py | 22 +- ...erver_automatic_tuning_operations_async.py | 22 +- ...rver_azure_ad_administrators_operations.py | 26 +- ...zure_ad_administrators_operations_async.py | 26 +- ...zure_ad_only_authentications_operations.py | 21 +- ...d_only_authentications_operations_async.py | 21 +- ...erver_blob_auditing_policies_operations.py | 59 +- ...blob_auditing_policies_operations_async.py | 59 +- ...t_server_communication_links_operations.py | 79 - ...er_communication_links_operations_async.py | 82 - ...server_configuration_options_operations.py | 38 +- ..._configuration_options_operations_async.py | 38 +- ...t_server_connection_policies_operations.py | 15 +- ...er_connection_policies_operations_async.py | 15 +- ...erver_dev_ops_audit_settings_operations.py | 41 +- ...dev_ops_audit_settings_operations_async.py | 41 +- ...anagement_server_dns_aliases_operations.py | 7 +- ...ent_server_dns_aliases_operations_async.py | 7 +- ...t_sql_management_server_keys_operations.py | 51 +- ...management_server_keys_operations_async.py | 51 +- ...management_server_operations_operations.py | 3 +- ...ment_server_operations_operations_async.py | 3 +- ...rver_security_alert_policies_operations.py | 23 +- ...ecurity_alert_policies_operations_async.py | 23 +- ...nt_server_trust_certificates_operations.py | 40 +- ...ver_trust_certificates_operations_async.py | 40 +- ...nagement_server_trust_groups_operations.py | 18 +- ...nt_server_trust_groups_operations_async.py | 18 +- ...sql_management_server_usages_operations.py | 3 +- ...nagement_server_usages_operations_async.py | 3 +- ...er_vulnerability_assessments_operations.py | 24 +- ...nerability_assessments_operations_async.py | 24 +- .../test_sql_management_servers_operations.py | 254 +- ...sql_management_servers_operations_async.py | 258 +- ...anagement_service_objectives_operations.py | 44 - ...ent_service_objectives_operations_async.py | 45 - ...est_sql_management_sql_agent_operations.py | 19 +- ...l_management_sql_agent_operations_async.py | 19 +- ...rability_assessment_baseline_operations.py | 22 +- ...ty_assessment_baseline_operations_async.py | 22 +- ...ability_assessment_baselines_operations.py | 8 +- ...y_assessment_baselines_operations_async.py | 8 +- ...lity_assessment_execute_scan_operations.py | 5 +- ...ssessment_execute_scan_operations_async.py | 5 +- ...ity_assessment_rule_baseline_operations.py | 40 +- ...sessment_rule_baseline_operations_async.py | 40 +- ...ty_assessment_rule_baselines_operations.py | 5 +- ...essment_rule_baselines_operations_async.py | 5 +- ...ility_assessment_scan_result_operations.py | 22 +- ...assessment_scan_result_operations_async.py | 22 +- ...lnerability_assessment_scans_operations.py | 22 +- ...ility_assessment_scans_operations_async.py | 22 +- ...ql_vulnerability_assessments_operations.py | 3 +- ...nerability_assessments_operations_async.py | 3 +- ...ability_assessments_settings_operations.py | 29 +- ...y_assessments_settings_operations_async.py | 29 +- ...p_managed_instance_schedules_operations.py | 40 +- ...ged_instance_schedules_operations_async.py | 40 +- ...nagement_subscription_usages_operations.py | 18 +- ...nt_subscription_usages_operations_async.py | 18 +- ...ment_synapse_link_workspaces_operations.py | 3 +- ...ynapse_link_workspaces_operations_async.py | 3 +- ...t_sql_management_sync_agents_operations.py | 31 +- ...management_sync_agents_operations_async.py | 31 +- ...t_sql_management_sync_groups_operations.py | 221 +- ...management_sync_groups_operations_async.py | 261 +- ..._sql_management_sync_members_operations.py | 121 +- ...anagement_sync_members_operations_async.py | 133 +- ..._management_tde_certificates_operations.py | 18 +- ...ement_tde_certificates_operations_async.py | 18 +- ...st_sql_management_time_zones_operations.py | 18 +- ..._management_time_zones_operations_async.py | 18 +- ...transparent_data_encryptions_operations.py | 56 +- ...arent_data_encryptions_operations_async.py | 66 +- .../test_sql_management_usages_operations.py | 3 +- ..._sql_management_usages_operations_async.py | 3 +- ..._management_virtual_clusters_operations.py | 67 +- ...ement_virtual_clusters_operations_async.py | 81 +- ...gement_virtual_network_rules_operations.py | 22 +- ..._virtual_network_rules_operations_async.py | 22 +- ...agement_workload_classifiers_operations.py | 28 +- ...t_workload_classifiers_operations_async.py | 28 +- ...l_management_workload_groups_operations.py | 28 +- ...gement_workload_groups_operations_async.py | 28 +- sdk/sql/azure-mgmt-sql/pyproject.toml | 4 +- .../tests/disable_test_cli_mgmt_sql.py | 1 + .../tests/disable_test_cli_mgmt_sql_auth.py | 1 + .../disable_test_cli_mgmt_sql_database.py | 1 + .../disable_test_cli_mgmt_sql_elastic_pool.py | 1 + ...isable_test_cli_mgmt_sql_failover_group.py | 1 + .../tests/disable_test_cli_mgmt_sql_job.py | 1 + .../disable_test_cli_mgmt_sql_managed_db.py | 1 + .../tests/disable_test_cli_mgmt_sql_server.py | 1 + .../tests/disable_test_cli_mgmt_sql_sync.py | 1 + ...t_cli_mgmt_sql_vulnerability_assessment.py | 1 + .../tests/disable_test_mgmt_sql.py | 1 + .../test_cli_mgmt_sql_managed_instance.py | 1 + sdk/sql/azure-mgmt-sql/tsp-location.yaml | 4 + 1364 files changed, 213130 insertions(+), 190211 deletions(-) rename sdk/sql/azure-mgmt-sql/azure/mgmt/sql/{_sql_management_client.py => _client.py} (96%) create mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_utils/model_base.py create mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_validation.py rename sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/{_sql_management_client.py => _client.py} (96%) delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_backup_short_term_retention_policies_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_capabilities_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_data_masking_policies_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_data_masking_rules_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_data_warehouse_user_activities_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_advanced_threat_protection_settings_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_advisors_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_automatic_tuning_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_blob_auditing_policies_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_columns_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_encryption_protectors_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_extensions_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_operations_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_recommended_actions_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_schemas_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_security_alert_policies_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessment_baselines_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessment_execute_scan_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessment_rule_baselines_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessment_scan_result_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessment_scans_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessments_settings_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_tables_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_usages_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_vulnerability_assessment_rule_baselines_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_vulnerability_assessment_scans_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_vulnerability_assessments_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_databases_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_deleted_servers_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_distributed_availability_groups_operations.py 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 delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_elastic_pool_operations_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_elastic_pools_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_encryption_protectors_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_endpoint_certificates_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_extended_database_blob_auditing_policies_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_extended_server_blob_auditing_policies_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_failover_groups_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_firewall_rules_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_geo_backup_policies_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_instance_failover_groups_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_instance_pools_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_ipv6_firewall_rules_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_agents_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_credentials_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_executions_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_private_endpoints_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_step_executions_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_steps_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_target_executions_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_target_groups_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_versions_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_jobs_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_ledger_digest_uploads_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_long_term_retention_backups_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_long_term_retention_managed_instance_backups_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_long_term_retention_policies_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_maintenance_window_options_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_maintenance_windows_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_backup_short_term_retention_policies_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_advanced_threat_protection_settings_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_columns_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_move_operations_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_queries_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_recommended_sensitivity_labels_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_restore_details_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_schemas_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_security_alert_policies_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_security_events_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_sensitivity_labels_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_tables_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_transparent_data_encryption_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_vulnerability_assessment_rule_baselines_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_vulnerability_assessment_scans_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_vulnerability_assessments_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_databases_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_administrators_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_advanced_threat_protection_settings_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_azure_ad_only_authentications_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_dtcs_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_encryption_protectors_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_keys_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_long_term_retention_policies_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_operations_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_private_endpoint_connections_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_private_link_resources_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_tde_certificates_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_vulnerability_assessments_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instances_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_ledger_digest_uploads_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_restorable_dropped_database_backup_short_term_retention_policies_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_server_dns_aliases_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_server_security_alert_policies_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_outbound_firewall_rules_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_private_endpoint_connections_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_private_link_resources_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_recommended_sensitivity_labels_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_recoverable_databases_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_recoverable_managed_databases_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_replication_links_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_restorable_dropped_databases_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_restorable_dropped_managed_databases_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_restore_points_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sensitivity_labels_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_advanced_threat_protection_settings_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_advisors_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_automatic_tuning_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_azure_ad_administrators_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_azure_ad_only_authentications_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_blob_auditing_policies_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/_server_configuration_options_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_connection_policies_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_dev_ops_audit_settings_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_dns_aliases_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_keys_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_operations_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_security_alert_policies_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_trust_certificates_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_trust_groups_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_usages_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_vulnerability_assessments_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_servers_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/aio/operations/_sql_agent_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_baseline_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_baselines_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_execute_scan_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_rule_baseline_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_rule_baselines_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_scan_result_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_scans_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessments_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessments_settings_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_start_stop_managed_instance_schedules_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_subscription_usages_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_synapse_link_workspaces_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sync_agents_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sync_groups_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sync_members_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_tde_certificates_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_time_zones_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_transparent_data_encryptions_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_usages_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_virtual_clusters_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_virtual_network_rules_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_workload_classifiers_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_workload_groups_operations.py rename sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/{_sql_management_client_enums.py => _enums.py} (71%) create mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_models.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_models_py3.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_backup_short_term_retention_policies_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_capabilities_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_data_masking_policies_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_data_masking_rules_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_data_warehouse_user_activities_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_advanced_threat_protection_settings_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_advisors_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_automatic_tuning_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_blob_auditing_policies_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_columns_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_encryption_protectors_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_extensions_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_operations_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_recommended_actions_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_schemas_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_security_alert_policies_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessment_baselines_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessment_execute_scan_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessment_rule_baselines_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessment_scan_result_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessment_scans_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessments_settings_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_tables_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_usages_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_vulnerability_assessment_rule_baselines_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_vulnerability_assessment_scans_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_vulnerability_assessments_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_databases_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_deleted_servers_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_distributed_availability_groups_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 delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_elastic_pool_operations_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_elastic_pools_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_encryption_protectors_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_endpoint_certificates_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_extended_database_blob_auditing_policies_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_extended_server_blob_auditing_policies_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_failover_groups_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_firewall_rules_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_geo_backup_policies_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_instance_failover_groups_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_instance_pools_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_ipv6_firewall_rules_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_agents_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_credentials_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_executions_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_private_endpoints_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_step_executions_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_steps_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_target_executions_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_target_groups_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_versions_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_jobs_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_ledger_digest_uploads_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_long_term_retention_backups_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_long_term_retention_managed_instance_backups_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_long_term_retention_policies_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_maintenance_window_options_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_maintenance_windows_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_backup_short_term_retention_policies_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_advanced_threat_protection_settings_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_columns_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_move_operations_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_queries_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_recommended_sensitivity_labels_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_restore_details_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_schemas_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_security_alert_policies_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_security_events_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_sensitivity_labels_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_tables_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_transparent_data_encryption_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_vulnerability_assessment_rule_baselines_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_vulnerability_assessment_scans_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_vulnerability_assessments_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_databases_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_administrators_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_advanced_threat_protection_settings_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_azure_ad_only_authentications_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_dtcs_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_encryption_protectors_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_keys_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_long_term_retention_policies_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_operations_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_private_endpoint_connections_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_private_link_resources_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_tde_certificates_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_vulnerability_assessments_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instances_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_ledger_digest_uploads_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_restorable_dropped_database_backup_short_term_retention_policies_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_server_dns_aliases_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_server_security_alert_policies_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_outbound_firewall_rules_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_private_endpoint_connections_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_private_link_resources_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_recommended_sensitivity_labels_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_recoverable_databases_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_recoverable_managed_databases_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_replication_links_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_restorable_dropped_databases_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_restorable_dropped_managed_databases_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_restore_points_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sensitivity_labels_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_advanced_threat_protection_settings_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_advisors_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_automatic_tuning_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_azure_ad_administrators_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_azure_ad_only_authentications_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_blob_auditing_policies_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/_server_configuration_options_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_connection_policies_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_dev_ops_audit_settings_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_dns_aliases_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_keys_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_operations_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_security_alert_policies_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_trust_certificates_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_trust_groups_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_usages_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_vulnerability_assessments_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_servers_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_service_objectives_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_agent_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_baseline_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_baselines_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_execute_scan_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_rule_baseline_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_rule_baselines_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_scan_result_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_scans_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessments_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessments_settings_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_start_stop_managed_instance_schedules_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_subscription_usages_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_synapse_link_workspaces_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sync_agents_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sync_groups_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sync_members_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_tde_certificates_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_time_zones_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_transparent_data_encryptions_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_usages_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_virtual_clusters_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_virtual_network_rules_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_workload_classifiers_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_workload_groups_operations.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/create_database_default_mode_with_versionless_keys_and_versionless_encryption_protector.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/create_database_with_encryption_protector_auto_rotation.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/create_managed_short_term_retention_policy.py rename sdk/sql/azure-mgmt-sql/generated_samples/{elastic_pool_activity_list.py => create_managed_short_term_retention_policy_restorable_dropped.py} (62%) create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_agent_with_identity.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_agent_with_sku.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_min.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/create_short_term_retention_policy.py rename sdk/sql/azure-mgmt-sql/generated_samples/{data_masking_rule_list.py => data_masking_rule_list_by_database.py} (80%) delete mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/database_metrics_definitions_list.py 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/elastic_pool_create_or_update_serverless_properties.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_definitions_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/elastic_pool_update_min.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_update_serverless_properties.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/encryption_protector_create_or_update_key_vault_with_versionless_key.py rename sdk/sql/azure-mgmt-sql/generated_samples/{server_communication_link_get.py => encryption_protector_get_with_versionless_key.py} (73%) create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/export_database_using_database_extensions.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/export_database_using_database_extensions_with_managed_identity.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/export_database_with_managed_identity.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/get_elastic_pool_with_serverless_properties.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/get_instance_pool_operation.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database_with_expand_equals_keys_with_versionless_keys.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/import_database_using_database_extensions.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/import_database_with_managed_identity.py rename sdk/sql/azure-mgmt-sql/generated_samples/{service_objective_list.py => list_instance_pool_operations.py} (71%) create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/list_instance_pool_operations_empty.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/list_operations.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/list_vcore_databases_by_server_with_odata.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/managed_database_reevaluate_inaccessible_database_state.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/managed_database_sensitivity_labels_list_by_database.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/managed_instanc_validate_azure_key_vault_encryption_key.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_backup_list_by_location_max.py 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/managed_instance_reevaluate_inaccessible_database_state.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/managed_server_dns_alias_create_or_update.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} (72%) create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/network_security_perimeter_configurations_reconcile.py rename sdk/sql/azure-mgmt-sql/generated_samples/{server_communication_link_create_or_update.py => outbound_firewall_rule_create.py} (68%) create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_managed_instance_long_term_retention_backup_list_by_location_max.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/resume_transparent_data_encryption_update.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/sensitivity_labels_list_by_database.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/server_key_create_or_update_with_versionless_key.py rename sdk/sql/azure-mgmt-sql/generated_samples/{server_communication_link_delete.py => server_key_get_with_versionless_key.py} (73%) rename sdk/sql/azure-mgmt-sql/generated_samples/{server_usage_metrics_list.py => server_usage_list.py} (78%) create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/suspend_transparent_data_encryption_update.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/sync_group_create_with_identity.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/sync_group_get_with_identity.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/sync_group_patch_add_and_remove_identity.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/sync_group_patch_with_identity.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/sync_member_create_with_identity.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/sync_member_get_with_identity.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/sync_member_patch_add_and_remove_identity.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/sync_member_patch_with_identity.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/update_job_agent_with_identity.py rename sdk/sql/azure-mgmt-sql/generated_samples/{service_objective_get.py => update_job_agent_with_sku.py} (70%) create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/virtual_cluster_create.py delete mode 100644 sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_elastic_pool_activities_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_elastic_pool_activities_operations_async.py delete mode 100644 sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_elastic_pool_database_activities_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_elastic_pool_database_activities_operations_async.py delete mode 100644 sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_communication_links_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_communication_links_operations_async.py delete mode 100644 sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_service_objectives_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_service_objectives_operations_async.py create mode 100644 sdk/sql/azure-mgmt-sql/tsp-location.yaml diff --git a/sdk/sql/azure-mgmt-sql/CHANGELOG.md b/sdk/sql/azure-mgmt-sql/CHANGELOG.md index 62700a667f07..8b4a8043961a 100644 --- a/sdk/sql/azure-mgmt-sql/CHANGELOG.md +++ b/sdk/sql/azure-mgmt-sql/CHANGELOG.md @@ -1,5 +1,660 @@ # Release History +## 4.0.0b25 (2026-05-10) + +### Features Added + + - Client `SqlManagementClient` added method `send_request` + - Client `SqlManagementClient` added operation group `instance_pool_operations` + - Client `SqlManagementClient` added operation group `network_security_perimeter_configurations` + - Model `Advisor` added property `system_data` + - Model `BackupShortTermRetentionPolicy` added property `system_data` + - Enum `CapabilityGroup` added member `SUPPORTED_JOB_AGENT_VERSIONS` + - Model `CheckNameAvailabilityRequest` added property `type` + - Model `DataMaskingPolicy` added property `system_data` + - Model `DataMaskingRule` added property `system_data` + - Model `DataWarehouseUserActivities` added property `system_data` + - Model `Database` added property `system_data` + - Model `DatabaseAdvancedThreatProtection` added property `properties` + - Model `DatabaseAutomaticTuning` added property `system_data` + - Model `DatabaseBlobAuditingPolicy` added property `system_data` + - Model `DatabaseColumn` added property `system_data` + - Model `DatabaseExtensions` added property `system_data` + - Model `DatabaseKey` added property `key_version` + - Model `DatabaseOperation` added property `system_data` + - Model `DatabaseSchema` added property `system_data` + - Model `DatabaseSecurityAlertPolicy` added property `properties` + - Model `DatabaseTable` added property `system_data` + - Model `DatabaseUsage` added property `system_data` + - Model `DatabaseVulnerabilityAssessment` added property `system_data` + - Model `DatabaseVulnerabilityAssessmentRuleBaseline` added property `system_data` + - Model `DatabaseVulnerabilityAssessmentScansExport` added property `properties` + - Model `DatabaseVulnerabilityAssessmentScansExport` added property `system_data` + - Model `DeletedServer` added property `system_data` + - Model `DistributedAvailabilityGroup` added property `system_data` + - Model `EditionCapability` added property `zone_pinning` + - Model `ElasticPool` added property `system_data` + - Model `ElasticPoolEditionCapability` added property `zone_pinning` + - Model `ElasticPoolOperation` added property `system_data` + - Model `ElasticPoolPerDatabaseSettings` added property `auto_pause_delay` + - Model `ElasticPoolPerformanceLevelCapability` added property `supported_min_capacities` + - Model `ElasticPoolPerformanceLevelCapability` added property `supported_auto_pause_delay` + - Model `ElasticPoolPerformanceLevelCapability` added property `supported_per_database_auto_pause_delay` + - Model `ElasticPoolPerformanceLevelCapability` added property `supported_zones` + - Model `EncryptionProtector` added property `system_data` + - Model `EndpointCertificate` added property `system_data` + - Model `ExtendedDatabaseBlobAuditingPolicy` added property `system_data` + - Model `ExtendedServerBlobAuditingPolicy` added property `system_data` + - Model `FailoverGroup` added property `system_data` + - Model `FirewallRule` added property `properties` + - Model `GeoBackupPolicy` added property `system_data` + - Model `IPv6FirewallRule` added property `properties` + - Model `ImportExportExtensionsOperationResult` added property `system_data` + - Model `ImportExportOperationResult` added property `system_data` + - Model `InstanceFailoverGroup` added property `system_data` + - Model `InstancePool` added property `system_data` + - Model `InstancePoolUpdate` added property `properties` + - Model `Job` added property `system_data` + - Model `JobAgent` added property `identity` + - Model `JobAgent` added property `system_data` + - Model `JobAgentUpdate` added property `identity` + - Model `JobAgentUpdate` added property `sku` + - Model `JobCredential` added property `system_data` + - Model `JobExecution` added property `system_data` + - Model `JobPrivateEndpoint` added property `system_data` + - Model `JobStep` added property `system_data` + - Model `JobTargetGroup` added property `system_data` + - Model `JobVersion` added property `system_data` + - Model `LedgerDigestUploads` added property `system_data` + - Model `LocationCapabilities` added property `supported_job_agent_versions` + - Model `LocationCapabilities` added property `is_zone_resilient_provisioning_allowed` + - Model `LogicalDatabaseTransparentDataEncryption` added property `properties` + - Model `LogicalDatabaseTransparentDataEncryption` added property `system_data` + - Model `LongTermRetentionBackup` added property `system_data` + - Model `LongTermRetentionBackupOperationResult` added property `properties` + - Model `LongTermRetentionBackupOperationResult` added property `system_data` + - Model `LongTermRetentionPolicy` added property `system_data` + - Model `MaintenanceWindowOptions` added property `system_data` + - Model `MaintenanceWindows` added property `system_data` + - Model `ManagedBackupShortTermRetentionPolicy` added property `system_data` + - Model `ManagedDatabase` added property `system_data` + - Model `ManagedDatabaseAdvancedThreatProtection` added property `properties` + - Model `ManagedDatabaseMoveOperationResult` added property `system_data` + - Model `ManagedDatabaseRestoreDetailsResult` added property `properties` + - Model `ManagedDatabaseRestoreDetailsResult` added property `system_data` + - Model `ManagedDatabaseSecurityAlertPolicy` added property `properties` + - Model `ManagedDatabaseSecurityAlertPolicy` added property `system_data` + - Model `ManagedDatabaseUpdate` added property `properties` + - Model `ManagedInstance` added property `system_data` + - Model `ManagedInstanceAdministrator` added property `system_data` + - Model `ManagedInstanceAdvancedThreatProtection` added property `properties` + - Model `ManagedInstanceAzureADOnlyAuthentication` added property `properties` + - Model `ManagedInstanceAzureADOnlyAuthentication` added property `system_data` + - Enum `ManagedInstanceDatabaseFormat` added member `SQL_SERVER2025` + - Model `ManagedInstanceDtc` added property `system_data` + - Model `ManagedInstanceEditionCapability` added property `is_general_purpose_v2` + - Model `ManagedInstanceEncryptionProtector` added property `system_data` + - Model `ManagedInstanceFamilyCapability` added property `zone_redundant` + - Model `ManagedInstanceKey` added property `system_data` + - Model `ManagedInstanceLongTermRetentionBackup` added property `system_data` + - Model `ManagedInstanceLongTermRetentionPolicy` added property `system_data` + - Model `ManagedInstanceOperation` added property `system_data` + - Model `ManagedInstancePrivateEndpointConnection` added property `properties` + - Model `ManagedInstancePrivateEndpointConnection` added property `system_data` + - Model `ManagedInstancePrivateLink` added property `system_data` + - Model `ManagedInstancePrivateLinkProperties` added property `required_zone_names` + - Model `ManagedInstanceQuery` added property `properties` + - Model `ManagedInstanceQuery` added property `system_data` + - Model `ManagedInstanceUpdate` added property `properties` + - Model `ManagedInstanceVcoresCapability` added property `supported_memory_sizes_in_gb` + - Model `ManagedInstanceVcoresCapability` added property `supported_memory_limits_mb` + - Model `ManagedInstanceVcoresCapability` added property `included_storage_i_ops` + - Model `ManagedInstanceVcoresCapability` added property `supported_storage_i_ops` + - Model `ManagedInstanceVcoresCapability` added property `iops_min_value_override_factor_per_selected_storage_gb` + - Model `ManagedInstanceVcoresCapability` added property `iops_included_value_override_factor_per_selected_storage_gb` + - Model `ManagedInstanceVcoresCapability` added property `included_storage_throughput_m_bps` + - Model `ManagedInstanceVcoresCapability` added property `supported_storage_throughput_m_bps` + - Model `ManagedInstanceVcoresCapability` added property `throughput_m_bps_min_value_override_factor_per_selected_storage_gb` + - Model `ManagedInstanceVcoresCapability` added property `throughput_m_bps_included_value_override_factor_per_selected_storage_gb` + - Model `ManagedInstanceVulnerabilityAssessment` added property `system_data` + - Model `ManagedLedgerDigestUploads` added property `system_data` + - Model `ManagedServerDnsAlias` added property `system_data` + - Model `ManagedServerSecurityAlertPolicy` added property `properties` + - Model `ManagedTransparentDataEncryption` added property `system_data` + - Enum `OperationMode` added member `EXPORT` + - Enum `OperationMode` added member `IMPORT` + - Model `OutboundFirewallRule` added property `system_data` + - Model `PrivateEndpointConnection` added property `properties` + - Model `PrivateEndpointConnection` added property `system_data` + - Model `PrivateLinkResource` added property `system_data` + - Model `ProxyResource` added property `system_data` + - Model `QueryStatistics` added property `properties` + - Model `QueryStatistics` added property `system_data` + - Model `RecommendedAction` added property `system_data` + - Model `RecommendedSensitivityLabelUpdate` added property `system_data` + - Model `RecoverableDatabase` added property `system_data` + - Model `RecoverableManagedDatabase` added property `system_data` + - Model `RefreshExternalGovernanceStatusOperationResult` added property `system_data` + - Model `RefreshExternalGovernanceStatusOperationResultMI` added property `properties` + - Model `RefreshExternalGovernanceStatusOperationResultMI` added property `system_data` + - Model `ReplicationLink` added property `system_data` + - Model `ReplicationLinkUpdate` added property `system_data` + - Model `Resource` added property `system_data` + - Model `RestorableDroppedDatabase` added property `system_data` + - Model `RestorableDroppedManagedDatabase` added property `system_data` + - Model `RestorePoint` added property `system_data` + - Model `SecurityEvent` added property `system_data` + - Model `SensitivityLabel` added property `system_data` + - Model `SensitivityLabelUpdate` added property `system_data` + - Model `Server` added property `system_data` + - Model `ServerAdvancedThreatProtection` added property `properties` + - Model `ServerAutomaticTuning` added property `properties` + - Model `ServerAutomaticTuning` added property `system_data` + - Model `ServerAzureADAdministrator` added property `properties` + - Model `ServerAzureADAdministrator` added property `system_data` + - Model `ServerAzureADOnlyAuthentication` added property `properties` + - Model `ServerAzureADOnlyAuthentication` added property `system_data` + - Model `ServerBlobAuditingPolicy` added property `system_data` + - Model `ServerConfigurationOption` added property `system_data` + - Model `ServerConnectionPolicy` added property `system_data` + - Model `ServerDevOpsAuditingSettings` added property `properties` + - Model `ServerDnsAlias` added property `system_data` + - Model `ServerKey` added property `system_data` + - Model `ServerOperation` added property `system_data` + - Model `ServerSecurityAlertPolicy` added property `properties` + - Model `ServerTrustCertificate` added property `system_data` + - Model `ServerTrustGroup` added property `system_data` + - Model `ServerUpdate` added property `properties` + - Model `ServerUsage` added property `id` + - Model `ServerUsage` added property `type` + - Model `ServerUsage` added property `system_data` + - Model `ServerVulnerabilityAssessment` added property `system_data` + - Model `ServiceObjectiveCapability` added property `zone_pinning` + - Model `ServiceObjectiveCapability` added property `supported_zones` + - Model `ServiceObjectiveCapability` added property `supported_free_limit_exhaustion_behaviors` + - Model `SqlAgentConfiguration` added property `system_data` + - Model `SqlVulnerabilityAssessment` added property `properties` + - Model `SqlVulnerabilityAssessmentScanResults` added property `properties` + - Enum `StorageCapabilityStorageAccountType` added member `GZRS` + - Model `SubscriptionUsage` added property `system_data` + - Model `SynapseLinkWorkspace` added property `system_data` + - Model `SyncAgent` added property `system_data` + - Model `SyncAgentLinkedDatabase` added property `system_data` + - Model `SyncGroup` added property `identity` + - Model `SyncGroup` added property `system_data` + - Model `SyncMember` added property `identity` + - Model `SyncMember` added property `system_data` + - Model `TdeCertificate` added property `system_data` + - Model `TimeZone` added property `system_data` + - Model `TrackedResource` added property `system_data` + - Model `UpdateVirtualClusterDnsServersOperation` added property `properties` + - Model `UpdateVirtualClusterDnsServersOperation` added property `system_data` + - Model `VirtualCluster` added property `system_data` + - Model `VirtualClusterUpdate` added property `properties` + - Model `VirtualNetworkRule` added property `system_data` + - Model `VulnerabilityAssessmentScanRecord` added property `system_data` + - Model `WorkloadClassifier` added property `system_data` + - Model `WorkloadGroup` added property `system_data` + - Added model `AdministratorProperties` + - Added model `AdvancedThreatProtectionProperties` + - Added model `AutomaticTuningServerProperties` + - Added model `AzureADOnlyAuthProperties` + - Added enum `CheckNameAvailabilityResourceType` + - Added enum `ClientClassificationSource` + - Added model `CopyLongTermRetentionBackupParametersProperties` + - Added enum `DataMaskingPolicyName` + - Added model `DataSyncParticipantIdentity` + - Added enum `DataSyncParticipantIdentityType` + - Added model `DataSyncParticipantUserAssignedIdentity` + - Added model `DatabaseVulnerabilityAssessmentScanExportProperties` + - Added enum `ErrorType` + - Added model `FreeLimitExhaustionBehaviorCapability` + - Added model `IPv6ServerFirewallRuleProperties` + - Added enum `InaccessibilityReason` + - Added model `InstancePoolOperation` + - Added model `InstancePoolOperationProperties` + - Added model `JobAgentEditionCapability` + - Added model `JobAgentIdentity` + - Added enum `JobAgentIdentityType` + - Added model `JobAgentServiceLevelObjectiveCapability` + - Added model `JobAgentUserAssignedIdentity` + - Added model `JobAgentVersionCapability` + - Added model `LongTermRetentionOperationResultProperties` + - Added model `ManagedDatabaseExtendedAccessibilityInfo` + - Added model `ManagedDatabaseRestoreDetailsProperties` + - Added model `ManagedInstanceAzureADOnlyAuthProperties` + - Added model `ManagedInstanceValidateAzureKeyVaultEncryptionKeyRequest` + - Added model `MaxLimitRangeCapability` + - Added model `NSPConfigAccessRule` + - Added model `NSPConfigAccessRuleProperties` + - Added model `NSPConfigAssociation` + - Added model `NSPConfigNetworkSecurityPerimeterRule` + - Added model `NSPConfigPerimeter` + - Added model `NSPConfigProfile` + - Added model `NSPProvisioningIssue` + - Added model `NSPProvisioningIssueProperties` + - Added model `NetworkSecurityPerimeterConfiguration` + - Added model `NetworkSecurityPerimeterConfigurationProperties` + - Added model `PerDatabaseAutoPauseDelayTimeRange` + - Added enum `PricingModel` + - Added model `QueryProperties` + - Added model `RefreshExternalGovernanceStatusOperationResultPropertiesMI` + - Added model `SecurityAlertPolicyProperties` + - Added model `SecurityAlertsPolicyProperties` + - Added model `ServerDevOpsAuditSettingsProperties` + - Added model `ServerFirewallRuleProperties` + - Added model `SqlVulnerabilityAssessmentPolicyProperties` + - Added model `SqlVulnerabilityAssessmentScanResultProperties` + - Added model `TransparentDataEncryptionProperties` + - Added enum `TransparentDataEncryptionScanState` + - Added model `UpdateLongTermRetentionBackupParametersProperties` + - Added model `UpsertManagedServerOperationStepWithEstimatesAndDuration` + - Added enum `UpsertManagedServerOperationStepWithEstimatesAndDurationStatus` + - Added model `VirtualClusterDnsServersProperties` + - Added enum `VulnerabilityAssessmentSystemDatabaseName` + - Added model `ZonePinningCapability` + - Model `DataMaskingRulesOperations` added parameter `skip` in method `list_by_database` + - Model `DatabasesOperations` added parameter `top` in method `list_by_server` + - Model `DatabasesOperations` added parameter `skip` in method `list_by_server` + - Model `DatabasesOperations` added parameter `filter` in method `list_by_server` + - Model `DatabasesOperations` added parameter `orderby` in method `list_by_server` + - Model `GeoBackupPoliciesOperations` added method `list` + - Model `LongTermRetentionManagedInstanceBackupsOperations` added parameter `skip` in method `list_by_location` + - Model `LongTermRetentionManagedInstanceBackupsOperations` added parameter `top` in method `list_by_location` + - Model `LongTermRetentionManagedInstanceBackupsOperations` added parameter `filter` in method `list_by_location` + - Model `LongTermRetentionManagedInstanceBackupsOperations` added parameter `skip` in method `list_by_resource_group_location` + - Model `LongTermRetentionManagedInstanceBackupsOperations` added parameter `top` in method `list_by_resource_group_location` + - Model `LongTermRetentionManagedInstanceBackupsOperations` added parameter `filter` in method `list_by_resource_group_location` + - Model `ManagedDatabaseSensitivityLabelsOperations` added method `list_by_database` + - Model `ManagedDatabasesOperations` added method `begin_reevaluate_inaccessible_database_state` + - Model `ManagedInstanceLongTermRetentionPoliciesOperations` added method `begin_delete` + - Model `ManagedInstancesOperations` added method `begin_reevaluate_inaccessible_database_state` + - Model `ManagedInstancesOperations` added method `begin_validate_azure_key_vault_encryption_key` + - Model `SensitivityLabelsOperations` added method `list_by_database` + - Model `SqlVulnerabilityAssessmentBaselineOperations` added parameter `system_database_name` in method `get` + - Model `SqlVulnerabilityAssessmentBaselineOperations` added parameter `system_database_name` in method `list_by_sql_vulnerability_assessment` + - Model `SqlVulnerabilityAssessmentBaselinesOperations` added parameter `system_database_name` in method `create_or_update` + - Model `SqlVulnerabilityAssessmentExecuteScanOperations` added parameter `system_database_name` in method `begin_execute` + - Model `SqlVulnerabilityAssessmentRuleBaselineOperations` added parameter `system_database_name` in method `create_or_update` + - Model `SqlVulnerabilityAssessmentRuleBaselineOperations` added parameter `system_database_name` in method `get` + - Model `SqlVulnerabilityAssessmentRuleBaselineOperations` added parameter `system_database_name` in method `list_by_baseline` + - Model `SqlVulnerabilityAssessmentRuleBaselinesOperations` added parameter `system_database_name` in method `delete` + - Model `SqlVulnerabilityAssessmentScanResultOperations` added parameter `system_database_name` in method `get` + - Model `SqlVulnerabilityAssessmentScanResultOperations` added parameter `system_database_name` in method `list_by_scan` + - Model `SqlVulnerabilityAssessmentScansOperations` added parameter `system_database_name` in method `get` + - Model `SqlVulnerabilityAssessmentScansOperations` added parameter `system_database_name` in method `list_by_sql_vulnerability_assessments` + - Model `TransparentDataEncryptionsOperations` added method `begin_resume` + - Model `TransparentDataEncryptionsOperations` added method `begin_suspend` + - Model `VirtualClustersOperations` added method `begin_create_or_update` + - Added model `InstancePoolOperationsOperations` + - Added model `NetworkSecurityPerimeterConfigurationsOperations` + +### Breaking Changes + + - Deleted or renamed client operation group `SqlManagementClient.server_communication_links` + - Deleted or renamed client operation group `SqlManagementClient.service_objectives` + - Deleted or renamed client operation group `SqlManagementClient.elastic_pool_activities` + - Deleted or renamed client operation group `SqlManagementClient.elastic_pool_database_activities` + - Model `CopyLongTermRetentionBackupParameters` deleted or renamed its instance variable `target_subscription_id` + - Model `CopyLongTermRetentionBackupParameters` deleted or renamed its instance variable `target_resource_group` + - Model `CopyLongTermRetentionBackupParameters` deleted or renamed its instance variable `target_server_resource_id` + - Model `CopyLongTermRetentionBackupParameters` deleted or renamed its instance variable `target_server_fully_qualified_domain_name` + - Model `CopyLongTermRetentionBackupParameters` deleted or renamed its instance variable `target_database_name` + - Model `CopyLongTermRetentionBackupParameters` deleted or renamed its instance variable `target_backup_storage_redundancy` + - Model `DatabaseAdvancedThreatProtection` deleted or renamed its instance variable `state` + - Model `DatabaseAdvancedThreatProtection` deleted or renamed its instance variable `creation_time` + - Model `DatabaseSecurityAlertPolicy` deleted or renamed its instance variable `state` + - Model `DatabaseSecurityAlertPolicy` deleted or renamed its instance variable `disabled_alerts` + - Model `DatabaseSecurityAlertPolicy` deleted or renamed its instance variable `email_addresses` + - Model `DatabaseSecurityAlertPolicy` deleted or renamed its instance variable `email_account_admins` + - Model `DatabaseSecurityAlertPolicy` deleted or renamed its instance variable `storage_endpoint` + - Model `DatabaseSecurityAlertPolicy` deleted or renamed its instance variable `storage_account_access_key` + - Model `DatabaseSecurityAlertPolicy` deleted or renamed its instance variable `retention_days` + - Model `DatabaseSecurityAlertPolicy` deleted or renamed its instance variable `creation_time` + - Model `DatabaseVulnerabilityAssessmentScansExport` deleted or renamed its instance variable `exported_report_location` + - Model `FirewallRule` deleted or renamed its instance variable `start_ip_address` + - Model `FirewallRule` deleted or renamed its instance variable `end_ip_address` + - Model `FirewallRuleList` deleted or renamed its instance variable `values` + - Model `IPv6FirewallRule` deleted or renamed its instance variable `start_i_pv6_address` + - Model `IPv6FirewallRule` deleted or renamed its instance variable `end_i_pv6_address` + - Model `InstancePoolUpdate` deleted or renamed its instance variable `subnet_id` + - Model `InstancePoolUpdate` deleted or renamed its instance variable `v_cores` + - Model `InstancePoolUpdate` deleted or renamed its instance variable `license_type` + - Model `InstancePoolUpdate` deleted or renamed its instance variable `dns_zone` + - Model `InstancePoolUpdate` deleted or renamed its instance variable `maintenance_configuration_id` + - Model `LogicalDatabaseTransparentDataEncryption` deleted or renamed its instance variable `state` + - Model `LongTermRetentionBackupOperationResult` deleted or renamed its instance variable `request_id` + - Model `LongTermRetentionBackupOperationResult` deleted or renamed its instance variable `operation_type` + - Model `LongTermRetentionBackupOperationResult` deleted or renamed its instance variable `from_backup_resource_id` + - Model `LongTermRetentionBackupOperationResult` deleted or renamed its instance variable `to_backup_resource_id` + - Model `LongTermRetentionBackupOperationResult` deleted or renamed its instance variable `target_backup_storage_redundancy` + - Model `LongTermRetentionBackupOperationResult` deleted or renamed its instance variable `status` + - Model `LongTermRetentionBackupOperationResult` deleted or renamed its instance variable `message` + - Model `ManagedDatabaseAdvancedThreatProtection` deleted or renamed its instance variable `state` + - Model `ManagedDatabaseAdvancedThreatProtection` deleted or renamed its instance variable `creation_time` + - Model `ManagedDatabaseRestoreDetailsResult` deleted or renamed its instance variable `type_properties_type` + - Model `ManagedDatabaseRestoreDetailsResult` deleted or renamed its instance variable `status` + - Model `ManagedDatabaseRestoreDetailsResult` deleted or renamed its instance variable `block_reason` + - Model `ManagedDatabaseRestoreDetailsResult` deleted or renamed its instance variable `last_uploaded_file_name` + - Model `ManagedDatabaseRestoreDetailsResult` deleted or renamed its instance variable `last_uploaded_file_time` + - Model `ManagedDatabaseRestoreDetailsResult` deleted or renamed its instance variable `last_restored_file_name` + - Model `ManagedDatabaseRestoreDetailsResult` deleted or renamed its instance variable `last_restored_file_time` + - Model `ManagedDatabaseRestoreDetailsResult` deleted or renamed its instance variable `percent_completed` + - Model `ManagedDatabaseRestoreDetailsResult` deleted or renamed its instance variable `current_restored_size_mb` + - Model `ManagedDatabaseRestoreDetailsResult` deleted or renamed its instance variable `current_restore_plan_size_mb` + - Model `ManagedDatabaseRestoreDetailsResult` deleted or renamed its instance variable `current_backup_type` + - Model `ManagedDatabaseRestoreDetailsResult` deleted or renamed its instance variable `current_restoring_file_name` + - Model `ManagedDatabaseRestoreDetailsResult` deleted or renamed its instance variable `number_of_files_detected` + - Model `ManagedDatabaseRestoreDetailsResult` deleted or renamed its instance variable `number_of_files_queued` + - Model `ManagedDatabaseRestoreDetailsResult` deleted or renamed its instance variable `number_of_files_skipped` + - Model `ManagedDatabaseRestoreDetailsResult` deleted or renamed its instance variable `number_of_files_restoring` + - Model `ManagedDatabaseRestoreDetailsResult` deleted or renamed its instance variable `number_of_files_restored` + - Model `ManagedDatabaseRestoreDetailsResult` deleted or renamed its instance variable `number_of_files_unrestorable` + - Model `ManagedDatabaseRestoreDetailsResult` deleted or renamed its instance variable `full_backup_sets` + - Model `ManagedDatabaseRestoreDetailsResult` deleted or renamed its instance variable `diff_backup_sets` + - Model `ManagedDatabaseRestoreDetailsResult` deleted or renamed its instance variable `log_backup_sets` + - Model `ManagedDatabaseRestoreDetailsResult` deleted or renamed its instance variable `unrestorable_files` + - Model `ManagedDatabaseSecurityAlertPolicy` deleted or renamed its instance variable `state` + - Model `ManagedDatabaseSecurityAlertPolicy` deleted or renamed its instance variable `disabled_alerts` + - Model `ManagedDatabaseSecurityAlertPolicy` deleted or renamed its instance variable `email_addresses` + - Model `ManagedDatabaseSecurityAlertPolicy` deleted or renamed its instance variable `email_account_admins` + - Model `ManagedDatabaseSecurityAlertPolicy` deleted or renamed its instance variable `storage_endpoint` + - Model `ManagedDatabaseSecurityAlertPolicy` deleted or renamed its instance variable `storage_account_access_key` + - Model `ManagedDatabaseSecurityAlertPolicy` deleted or renamed its instance variable `retention_days` + - Model `ManagedDatabaseSecurityAlertPolicy` deleted or renamed its instance variable `creation_time` + - Model `ManagedDatabaseUpdate` deleted or renamed its instance variable `collation` + - Model `ManagedDatabaseUpdate` deleted or renamed its instance variable `status` + - Model `ManagedDatabaseUpdate` deleted or renamed its instance variable `creation_date` + - Model `ManagedDatabaseUpdate` deleted or renamed its instance variable `earliest_restore_point` + - Model `ManagedDatabaseUpdate` deleted or renamed its instance variable `restore_point_in_time` + - Model `ManagedDatabaseUpdate` deleted or renamed its instance variable `default_secondary_location` + - Model `ManagedDatabaseUpdate` deleted or renamed its instance variable `catalog_collation` + - Model `ManagedDatabaseUpdate` deleted or renamed its instance variable `create_mode` + - Model `ManagedDatabaseUpdate` deleted or renamed its instance variable `storage_container_uri` + - Model `ManagedDatabaseUpdate` deleted or renamed its instance variable `source_database_id` + - Model `ManagedDatabaseUpdate` deleted or renamed its instance variable `cross_subscription_source_database_id` + - Model `ManagedDatabaseUpdate` deleted or renamed its instance variable `restorable_dropped_database_id` + - Model `ManagedDatabaseUpdate` deleted or renamed its instance variable `cross_subscription_restorable_dropped_database_id` + - Model `ManagedDatabaseUpdate` deleted or renamed its instance variable `storage_container_identity` + - Model `ManagedDatabaseUpdate` deleted or renamed its instance variable `storage_container_sas_token` + - Model `ManagedDatabaseUpdate` deleted or renamed its instance variable `failover_group_id` + - Model `ManagedDatabaseUpdate` deleted or renamed its instance variable `recoverable_database_id` + - Model `ManagedDatabaseUpdate` deleted or renamed its instance variable `long_term_retention_backup_resource_id` + - Model `ManagedDatabaseUpdate` deleted or renamed its instance variable `auto_complete_restore` + - Model `ManagedDatabaseUpdate` deleted or renamed its instance variable `last_backup_name` + - Model `ManagedDatabaseUpdate` deleted or renamed its instance variable `cross_subscription_target_managed_instance_id` + - Model `ManagedDatabaseUpdate` deleted or renamed its instance variable `is_ledger_on` + - Model `ManagedInstanceAdvancedThreatProtection` deleted or renamed its instance variable `state` + - Model `ManagedInstanceAdvancedThreatProtection` deleted or renamed its instance variable `creation_time` + - Model `ManagedInstanceAzureADOnlyAuthentication` deleted or renamed its instance variable `azure_ad_only_authentication` + - Model `ManagedInstanceEditionCapability` deleted or renamed its instance variable `zone_redundant` + - Model `ManagedInstancePrivateEndpointConnection` deleted or renamed its instance variable `private_endpoint` + - Model `ManagedInstancePrivateEndpointConnection` deleted or renamed its instance variable `private_link_service_connection_state` + - Model `ManagedInstancePrivateEndpointConnection` deleted or renamed its instance variable `provisioning_state` + - Model `ManagedInstanceQuery` deleted or renamed its instance variable `query_text` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `provisioning_state` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `managed_instance_create_mode` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `fully_qualified_domain_name` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `is_general_purpose_v2` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `administrator_login` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `administrator_login_password` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `subnet_id` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `state` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `license_type` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `hybrid_secondary_usage` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `hybrid_secondary_usage_detected` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `v_cores` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `storage_size_in_gb` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `storage_iops` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `storage_throughput_mbps` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `collation` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `dns_zone` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `dns_zone_partner` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `public_data_endpoint_enabled` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `source_managed_instance_id` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `restore_point_in_time` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `proxy_override` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `timezone_id` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `instance_pool_id` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `maintenance_configuration_id` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `private_endpoint_connections` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `minimal_tls_version` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `current_backup_storage_redundancy` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `requested_backup_storage_redundancy` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `zone_redundant` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `primary_user_assigned_identity_id` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `key_id` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `administrators` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `service_principal` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `virtual_cluster_id` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `external_governance_status` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `pricing_model` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `create_time` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `authentication_metadata` + - Model `ManagedInstanceUpdate` deleted or renamed its instance variable `database_format` + - Model `ManagedServerSecurityAlertPolicy` deleted or renamed its instance variable `state` + - Model `ManagedServerSecurityAlertPolicy` deleted or renamed its instance variable `disabled_alerts` + - Model `ManagedServerSecurityAlertPolicy` deleted or renamed its instance variable `email_addresses` + - Model `ManagedServerSecurityAlertPolicy` deleted or renamed its instance variable `email_account_admins` + - Model `ManagedServerSecurityAlertPolicy` deleted or renamed its instance variable `storage_endpoint` + - Model `ManagedServerSecurityAlertPolicy` deleted or renamed its instance variable `storage_account_access_key` + - Model `ManagedServerSecurityAlertPolicy` deleted or renamed its instance variable `retention_days` + - Model `ManagedServerSecurityAlertPolicy` deleted or renamed its instance variable `creation_time` + - Model `PrivateEndpointConnection` deleted or renamed its instance variable `private_endpoint` + - Model `PrivateEndpointConnection` deleted or renamed its instance variable `group_ids` + - Model `PrivateEndpointConnection` deleted or renamed its instance variable `private_link_service_connection_state` + - Model `PrivateEndpointConnection` deleted or renamed its instance variable `provisioning_state` + - Model `QueryStatistics` deleted or renamed its instance variable `database_name` + - Model `QueryStatistics` deleted or renamed its instance variable `query_id` + - Model `QueryStatistics` deleted or renamed its instance variable `start_time` + - Model `QueryStatistics` deleted or renamed its instance variable `end_time` + - Model `QueryStatistics` deleted or renamed its instance variable `intervals` + - Model `RefreshExternalGovernanceStatusOperationResultMI` deleted or renamed its instance variable `request_id` + - Model `RefreshExternalGovernanceStatusOperationResultMI` deleted or renamed its instance variable `request_type` + - Model `RefreshExternalGovernanceStatusOperationResultMI` deleted or renamed its instance variable `queued_time` + - Model `RefreshExternalGovernanceStatusOperationResultMI` deleted or renamed its instance variable `managed_instance_name` + - Model `RefreshExternalGovernanceStatusOperationResultMI` deleted or renamed its instance variable `status` + - Model `RefreshExternalGovernanceStatusOperationResultMI` deleted or renamed its instance variable `error_message` + - Model `ServerAdvancedThreatProtection` deleted or renamed its instance variable `state` + - Model `ServerAdvancedThreatProtection` deleted or renamed its instance variable `creation_time` + - Model `ServerAutomaticTuning` deleted or renamed its instance variable `desired_state` + - Model `ServerAutomaticTuning` deleted or renamed its instance variable `actual_state` + - Model `ServerAutomaticTuning` deleted or renamed its instance variable `options` + - Model `ServerAzureADAdministrator` deleted or renamed its instance variable `administrator_type` + - Model `ServerAzureADAdministrator` deleted or renamed its instance variable `login` + - Model `ServerAzureADAdministrator` deleted or renamed its instance variable `sid` + - Model `ServerAzureADAdministrator` deleted or renamed its instance variable `tenant_id` + - Model `ServerAzureADAdministrator` deleted or renamed its instance variable `azure_ad_only_authentication` + - Model `ServerAzureADOnlyAuthentication` deleted or renamed its instance variable `azure_ad_only_authentication` + - Model `ServerDevOpsAuditingSettings` deleted or renamed its instance variable `is_azure_monitor_target_enabled` + - Model `ServerDevOpsAuditingSettings` deleted or renamed its instance variable `is_managed_identity_in_use` + - Model `ServerDevOpsAuditingSettings` deleted or renamed its instance variable `state` + - Model `ServerDevOpsAuditingSettings` deleted or renamed its instance variable `storage_endpoint` + - Model `ServerDevOpsAuditingSettings` deleted or renamed its instance variable `storage_account_access_key` + - Model `ServerDevOpsAuditingSettings` deleted or renamed its instance variable `storage_account_subscription_id` + - Model `ServerSecurityAlertPolicy` deleted or renamed its instance variable `state` + - Model `ServerSecurityAlertPolicy` deleted or renamed its instance variable `disabled_alerts` + - Model `ServerSecurityAlertPolicy` deleted or renamed its instance variable `email_addresses` + - Model `ServerSecurityAlertPolicy` deleted or renamed its instance variable `email_account_admins` + - Model `ServerSecurityAlertPolicy` deleted or renamed its instance variable `storage_endpoint` + - Model `ServerSecurityAlertPolicy` deleted or renamed its instance variable `storage_account_access_key` + - Model `ServerSecurityAlertPolicy` deleted or renamed its instance variable `retention_days` + - Model `ServerSecurityAlertPolicy` deleted or renamed its instance variable `creation_time` + - Model `ServerUpdate` deleted or renamed its instance variable `administrator_login` + - Model `ServerUpdate` deleted or renamed its instance variable `administrator_login_password` + - Model `ServerUpdate` deleted or renamed its instance variable `version` + - Model `ServerUpdate` deleted or renamed its instance variable `state` + - Model `ServerUpdate` deleted or renamed its instance variable `fully_qualified_domain_name` + - Model `ServerUpdate` deleted or renamed its instance variable `private_endpoint_connections` + - Model `ServerUpdate` deleted or renamed its instance variable `minimal_tls_version` + - Model `ServerUpdate` deleted or renamed its instance variable `public_network_access` + - Model `ServerUpdate` deleted or renamed its instance variable `workspace_feature` + - Model `ServerUpdate` deleted or renamed its instance variable `primary_user_assigned_identity_id` + - Model `ServerUpdate` deleted or renamed its instance variable `federated_client_id` + - Model `ServerUpdate` deleted or renamed its instance variable `key_id` + - Model `ServerUpdate` deleted or renamed its instance variable `administrators` + - Model `ServerUpdate` deleted or renamed its instance variable `restrict_outbound_network_access` + - Model `ServerUpdate` deleted or renamed its instance variable `is_i_pv6_enabled` + - Model `ServerUpdate` deleted or renamed its instance variable `external_governance_status` + - Model `ServerUpdate` deleted or renamed its instance variable `retention_days` + - Model `ServerUpdate` deleted or renamed its instance variable `create_mode` + - Model `SqlVulnerabilityAssessment` deleted or renamed its instance variable `state` + - Model `SqlVulnerabilityAssessmentScanResults` deleted or renamed its instance variable `rule_id` + - Model `SqlVulnerabilityAssessmentScanResults` deleted or renamed its instance variable `status` + - Model `SqlVulnerabilityAssessmentScanResults` deleted or renamed its instance variable `error_message` + - Model `SqlVulnerabilityAssessmentScanResults` deleted or renamed its instance variable `is_trimmed` + - Model `SqlVulnerabilityAssessmentScanResults` deleted or renamed its instance variable `query_results` + - Model `SqlVulnerabilityAssessmentScanResults` deleted or renamed its instance variable `remediation` + - Model `SqlVulnerabilityAssessmentScanResults` deleted or renamed its instance variable `baseline_adjusted_result` + - Model `SqlVulnerabilityAssessmentScanResults` deleted or renamed its instance variable `rule_metadata` + - Model `UpdateLongTermRetentionBackupParameters` deleted or renamed its instance variable `requested_backup_storage_redundancy` + - Model `UpdateVirtualClusterDnsServersOperation` deleted or renamed its instance variable `status` + - Model `VirtualClusterUpdate` deleted or renamed its instance variable `subnet_id` + - Model `VirtualClusterUpdate` deleted or renamed its instance variable `version` + - Model `VirtualClusterUpdate` deleted or renamed its instance variable `child_resources` + - Deleted or renamed model `ElasticPoolActivity` + - Deleted or renamed model `ElasticPoolDatabaseActivity` + - Deleted or renamed model `FreemiumType` + - Deleted or renamed model `ManagedInstanceQueryStatistics` + - Deleted or renamed model `Metric` + - Deleted or renamed model `MetricAvailability` + - Deleted or renamed model `MetricDefinition` + - Deleted or renamed model `MetricName` + - Deleted or renamed model `MetricValue` + - Deleted or renamed model `OperationImpact` + - Deleted or renamed model `OutboundEnvironmentEndpointCollection` + - Deleted or renamed model `PrimaryAggregationType` + - Deleted or renamed model `QueryMetricIntervalAutoGenerated` + - Deleted or renamed model `SecurityEventCollection` + - Deleted or renamed model `SecurityEventsFilterParameters` + - Deleted or renamed model `ServerCommunicationLink` + - Deleted or renamed model `ServiceObjective` + - Deleted or renamed model `ServiceObjectiveName` + - Deleted or renamed model `SloUsageMetric` + - Deleted or renamed model `UnitDefinitionType` + - Deleted or renamed model `UnitType` + - Deleted or renamed model `UpsertManagedServerOperationStep` + - Deleted or renamed model `UpsertManagedServerOperationStepStatus` + - Method `CapabilitiesOperations.list_by_location` changed its parameter `include` from `positional_or_keyword` to `keyword_only` + - Method `DataMaskingPoliciesOperations.create_or_update` inserted a `positional_or_keyword` parameter `data_masking_policy_name` + - Method `DataMaskingPoliciesOperations.get` inserted a `positional_or_keyword` parameter `data_masking_policy_name` + - Method `DataMaskingRulesOperations.create_or_update` inserted a `positional_or_keyword` parameter `data_masking_policy_name` + - Method `DataMaskingRulesOperations.list_by_database` inserted a `positional_or_keyword` parameter `data_masking_policy_name` + - Method `DatabaseAdvisorsOperations.list_by_database` changed its parameter `expand` from `positional_or_keyword` to `keyword_only` + - Method `DatabaseColumnsOperations.list_by_database` changed its parameter `schema` from `positional_or_keyword` to `keyword_only` + - Method `DatabaseColumnsOperations.list_by_database` changed its parameter `table` from `positional_or_keyword` to `keyword_only` + - Method `DatabaseColumnsOperations.list_by_database` changed its parameter `column` from `positional_or_keyword` to `keyword_only` + - Method `DatabaseColumnsOperations.list_by_database` changed its parameter `order_by` from `positional_or_keyword` to `keyword_only` + - Method `DatabaseColumnsOperations.list_by_database` changed its parameter `skiptoken` from `positional_or_keyword` to `keyword_only` + - Method `DatabasesOperations.begin_failover` changed its parameter `replica_type` from `positional_or_keyword` to `keyword_only` + - Method `DatabasesOperations.get` changed its parameter `expand` from `positional_or_keyword` to `keyword_only` + - Method `DatabasesOperations.list_by_server` deleted or renamed its parameter `skip_token` of kind `positional_or_keyword` + - Deleted or renamed method `DatabasesOperations.list_metric_definitions` + - Deleted or renamed method `DatabasesOperations.list_metrics` + - Deleted or renamed method `ElasticPoolsOperations.list_metric_definitions` + - Deleted or renamed method `ElasticPoolsOperations.list_metrics` + - Deleted or renamed method `GeoBackupPoliciesOperations.list_by_database` + - Method `JobExecutionsOperations.list_by_agent` changed its parameter `create_time_min` from `positional_or_keyword` to `keyword_only` + - Method `JobExecutionsOperations.list_by_agent` changed its parameter `create_time_max` from `positional_or_keyword` to `keyword_only` + - Method `JobExecutionsOperations.list_by_agent` changed its parameter `end_time_min` from `positional_or_keyword` to `keyword_only` + - Method `JobExecutionsOperations.list_by_agent` changed its parameter `end_time_max` from `positional_or_keyword` to `keyword_only` + - Method `JobExecutionsOperations.list_by_agent` changed its parameter `is_active` from `positional_or_keyword` to `keyword_only` + - Method `JobExecutionsOperations.list_by_job` changed its parameter `create_time_min` from `positional_or_keyword` to `keyword_only` + - Method `JobExecutionsOperations.list_by_job` changed its parameter `create_time_max` from `positional_or_keyword` to `keyword_only` + - Method `JobExecutionsOperations.list_by_job` changed its parameter `end_time_min` from `positional_or_keyword` to `keyword_only` + - Method `JobExecutionsOperations.list_by_job` changed its parameter `end_time_max` from `positional_or_keyword` to `keyword_only` + - Method `JobExecutionsOperations.list_by_job` changed its parameter `is_active` from `positional_or_keyword` to `keyword_only` + - Method `JobStepExecutionsOperations.list_by_job_execution` changed its parameter `create_time_min` from `positional_or_keyword` to `keyword_only` + - Method `JobStepExecutionsOperations.list_by_job_execution` changed its parameter `create_time_max` from `positional_or_keyword` to `keyword_only` + - Method `JobStepExecutionsOperations.list_by_job_execution` changed its parameter `end_time_min` from `positional_or_keyword` to `keyword_only` + - Method `JobStepExecutionsOperations.list_by_job_execution` changed its parameter `end_time_max` from `positional_or_keyword` to `keyword_only` + - Method `JobStepExecutionsOperations.list_by_job_execution` changed its parameter `is_active` from `positional_or_keyword` to `keyword_only` + - Method `JobTargetExecutionsOperations.list_by_job_execution` changed its parameter `create_time_min` from `positional_or_keyword` to `keyword_only` + - Method `JobTargetExecutionsOperations.list_by_job_execution` changed its parameter `create_time_max` from `positional_or_keyword` to `keyword_only` + - Method `JobTargetExecutionsOperations.list_by_job_execution` changed its parameter `end_time_min` from `positional_or_keyword` to `keyword_only` + - Method `JobTargetExecutionsOperations.list_by_job_execution` changed its parameter `end_time_max` from `positional_or_keyword` to `keyword_only` + - Method `JobTargetExecutionsOperations.list_by_job_execution` changed its parameter `is_active` from `positional_or_keyword` to `keyword_only` + - Method `JobTargetExecutionsOperations.list_by_step` changed its parameter `create_time_min` from `positional_or_keyword` to `keyword_only` + - Method `JobTargetExecutionsOperations.list_by_step` changed its parameter `create_time_max` from `positional_or_keyword` to `keyword_only` + - Method `JobTargetExecutionsOperations.list_by_step` changed its parameter `end_time_min` from `positional_or_keyword` to `keyword_only` + - Method `JobTargetExecutionsOperations.list_by_step` changed its parameter `end_time_max` from `positional_or_keyword` to `keyword_only` + - Method `JobTargetExecutionsOperations.list_by_step` changed its parameter `is_active` from `positional_or_keyword` to `keyword_only` + - Method `LongTermRetentionBackupsOperations.list_by_database` changed its parameter `only_latest_per_database` from `positional_or_keyword` to `keyword_only` + - Method `LongTermRetentionBackupsOperations.list_by_database` changed its parameter `database_state` from `positional_or_keyword` to `keyword_only` + - Method `LongTermRetentionBackupsOperations.list_by_location` changed its parameter `only_latest_per_database` from `positional_or_keyword` to `keyword_only` + - Method `LongTermRetentionBackupsOperations.list_by_location` changed its parameter `database_state` from `positional_or_keyword` to `keyword_only` + - Method `LongTermRetentionBackupsOperations.list_by_resource_group_database` changed its parameter `only_latest_per_database` from `positional_or_keyword` to `keyword_only` + - Method `LongTermRetentionBackupsOperations.list_by_resource_group_database` changed its parameter `database_state` from `positional_or_keyword` to `keyword_only` + - Method `LongTermRetentionBackupsOperations.list_by_resource_group_location` changed its parameter `only_latest_per_database` from `positional_or_keyword` to `keyword_only` + - Method `LongTermRetentionBackupsOperations.list_by_resource_group_location` changed its parameter `database_state` from `positional_or_keyword` to `keyword_only` + - Method `LongTermRetentionBackupsOperations.list_by_resource_group_server` changed its parameter `only_latest_per_database` from `positional_or_keyword` to `keyword_only` + - Method `LongTermRetentionBackupsOperations.list_by_resource_group_server` changed its parameter `database_state` from `positional_or_keyword` to `keyword_only` + - Method `LongTermRetentionBackupsOperations.list_by_server` changed its parameter `only_latest_per_database` from `positional_or_keyword` to `keyword_only` + - Method `LongTermRetentionBackupsOperations.list_by_server` changed its parameter `database_state` from `positional_or_keyword` to `keyword_only` + - Method `LongTermRetentionManagedInstanceBackupsOperations.list_by_database` changed its parameter `only_latest_per_database` from `positional_or_keyword` to `keyword_only` + - Method `LongTermRetentionManagedInstanceBackupsOperations.list_by_database` changed its parameter `database_state` from `positional_or_keyword` to `keyword_only` + - Method `LongTermRetentionManagedInstanceBackupsOperations.list_by_instance` changed its parameter `only_latest_per_database` from `positional_or_keyword` to `keyword_only` + - Method `LongTermRetentionManagedInstanceBackupsOperations.list_by_instance` changed its parameter `database_state` from `positional_or_keyword` to `keyword_only` + - Method `LongTermRetentionManagedInstanceBackupsOperations.list_by_location` changed its parameter `only_latest_per_database` from `positional_or_keyword` to `keyword_only` + - Method `LongTermRetentionManagedInstanceBackupsOperations.list_by_location` changed its parameter `database_state` from `positional_or_keyword` to `keyword_only` + - Method `LongTermRetentionManagedInstanceBackupsOperations.list_by_resource_group_database` changed its parameter `only_latest_per_database` from `positional_or_keyword` to `keyword_only` + - Method `LongTermRetentionManagedInstanceBackupsOperations.list_by_resource_group_database` changed its parameter `database_state` from `positional_or_keyword` to `keyword_only` + - Method `LongTermRetentionManagedInstanceBackupsOperations.list_by_resource_group_instance` changed its parameter `only_latest_per_database` from `positional_or_keyword` to `keyword_only` + - Method `LongTermRetentionManagedInstanceBackupsOperations.list_by_resource_group_instance` changed its parameter `database_state` from `positional_or_keyword` to `keyword_only` + - Method `LongTermRetentionManagedInstanceBackupsOperations.list_by_resource_group_location` changed its parameter `only_latest_per_database` from `positional_or_keyword` to `keyword_only` + - Method `LongTermRetentionManagedInstanceBackupsOperations.list_by_resource_group_location` changed its parameter `database_state` from `positional_or_keyword` to `keyword_only` + - Method `MaintenanceWindowOptionsOperations.get` changed its parameter `maintenance_window_options_name` from `positional_or_keyword` to `keyword_only` + - Method `MaintenanceWindowsOperations.create_or_update` changed its parameter `maintenance_window_name` from `positional_or_keyword` to `keyword_only` + - Method `MaintenanceWindowsOperations.get` changed its parameter `maintenance_window_name` from `positional_or_keyword` to `keyword_only` + - Method `ManagedDatabaseColumnsOperations.list_by_database` changed its parameter `schema` from `positional_or_keyword` to `keyword_only` + - Method `ManagedDatabaseColumnsOperations.list_by_database` changed its parameter `table` from `positional_or_keyword` to `keyword_only` + - Method `ManagedDatabaseColumnsOperations.list_by_database` changed its parameter `column` from `positional_or_keyword` to `keyword_only` + - Method `ManagedDatabaseColumnsOperations.list_by_database` changed its parameter `order_by` from `positional_or_keyword` to `keyword_only` + - Method `ManagedDatabaseColumnsOperations.list_by_database` changed its parameter `skiptoken` from `positional_or_keyword` to `keyword_only` + - Method `ManagedDatabaseMoveOperationsOperations.list_by_location` changed its parameter `only_latest_per_database` from `positional_or_keyword` to `keyword_only` + - Method `ManagedDatabaseQueriesOperations.list_by_query` changed its parameter `start_time` from `positional_or_keyword` to `keyword_only` + - Method `ManagedDatabaseQueriesOperations.list_by_query` changed its parameter `end_time` from `positional_or_keyword` to `keyword_only` + - Method `ManagedDatabaseQueriesOperations.list_by_query` changed its parameter `interval` from `positional_or_keyword` to `keyword_only` + - Method `ManagedDatabaseSecurityEventsOperations.list_by_database` changed its parameter `skiptoken` from `positional_or_keyword` to `keyword_only` + - Method `ManagedDatabaseSensitivityLabelsOperations.list_current_by_database` changed its parameter `skip_token` from `positional_or_keyword` to `keyword_only` + - Method `ManagedDatabaseSensitivityLabelsOperations.list_current_by_database` changed its parameter `count` from `positional_or_keyword` to `keyword_only` + - Method `ManagedDatabaseSensitivityLabelsOperations.list_recommended_by_database` changed its parameter `skip_token` from `positional_or_keyword` to `keyword_only` + - Method `ManagedDatabaseSensitivityLabelsOperations.list_recommended_by_database` changed its parameter `include_disabled_recommendations` from `positional_or_keyword` to `keyword_only` + - Method `ManagedInstancesOperations.begin_failover` changed its parameter `replica_type` from `positional_or_keyword` to `keyword_only` + - Method `ManagedInstancesOperations.get` changed its parameter `expand` from `positional_or_keyword` to `keyword_only` + - Method `ManagedInstancesOperations.list` changed its parameter `expand` from `positional_or_keyword` to `keyword_only` + - Method `ManagedInstancesOperations.list_by_instance_pool` changed its parameter `expand` from `positional_or_keyword` to `keyword_only` + - Method `ManagedInstancesOperations.list_by_managed_instance` changed its parameter `number_of_queries` from `positional_or_keyword` to `keyword_only` + - Method `ManagedInstancesOperations.list_by_managed_instance` changed its parameter `databases` from `positional_or_keyword` to `keyword_only` + - Method `ManagedInstancesOperations.list_by_managed_instance` changed its parameter `start_time` from `positional_or_keyword` to `keyword_only` + - Method `ManagedInstancesOperations.list_by_managed_instance` changed its parameter `end_time` from `positional_or_keyword` to `keyword_only` + - Method `ManagedInstancesOperations.list_by_managed_instance` changed its parameter `interval` from `positional_or_keyword` to `keyword_only` + - Method `ManagedInstancesOperations.list_by_managed_instance` changed its parameter `aggregation_function` from `positional_or_keyword` to `keyword_only` + - Method `ManagedInstancesOperations.list_by_managed_instance` changed its parameter `observation_metric` from `positional_or_keyword` to `keyword_only` + - Method `ManagedInstancesOperations.list_by_resource_group` changed its parameter `expand` from `positional_or_keyword` to `keyword_only` + - Method `OutboundFirewallRulesOperations.begin_create_or_update` deleted or renamed its parameter `parameters` of kind `positional_or_keyword` + - Method `RecoverableDatabasesOperations.get` changed its parameter `expand` from `positional_or_keyword` to `keyword_only` + - Method `RestorableDroppedDatabasesOperations.get` changed its parameter `expand` from `positional_or_keyword` to `keyword_only` + - Method `SensitivityLabelsOperations.list_current_by_database` changed its parameter `skip_token` from `positional_or_keyword` to `keyword_only` + - Method `SensitivityLabelsOperations.list_current_by_database` changed its parameter `count` from `positional_or_keyword` to `keyword_only` + - Method `SensitivityLabelsOperations.list_recommended_by_database` changed its parameter `skip_token` from `positional_or_keyword` to `keyword_only` + - Method `SensitivityLabelsOperations.list_recommended_by_database` changed its parameter `include_disabled_recommendations` from `positional_or_keyword` to `keyword_only` + - Method `ServerAdvisorsOperations.list_by_server` changed its parameter `expand` from `positional_or_keyword` to `keyword_only` + - Method `ServersOperations.get` changed its parameter `expand` from `positional_or_keyword` to `keyword_only` + - Method `ServersOperations.list` changed its parameter `expand` from `positional_or_keyword` to `keyword_only` + - Method `ServersOperations.list_by_resource_group` changed its parameter `expand` from `positional_or_keyword` to `keyword_only` + - Method `SyncGroupsOperations.list_logs` changed its parameter `start_time` from `positional_or_keyword` to `keyword_only` + - Method `SyncGroupsOperations.list_logs` changed its parameter `end_time` from `positional_or_keyword` to `keyword_only` + - Method `SyncGroupsOperations.list_logs` changed its parameter `type` from `positional_or_keyword` to `keyword_only` + - Method `SyncGroupsOperations.list_logs` changed its parameter `continuation_token_parameter` from `positional_or_keyword` to `keyword_only` + - Method `UsagesOperations.list_by_instance_pool` changed its parameter `expand_children` from `positional_or_keyword` to `keyword_only` + - Deleted or renamed model `ElasticPoolActivitiesOperations` + - Deleted or renamed model `ElasticPoolDatabaseActivitiesOperations` + - Deleted or renamed model `ServerCommunicationLinksOperations` + - Deleted or renamed model `ServiceObjectivesOperations` + - `OutboundFirewallRulesOperations.begin_create_or_update` had all overloads removed + - Method `MaintenanceWindowsOperations.create_or_update` re-ordered its parameters from `['self', 'resource_group_name', 'server_name', 'database_name', 'maintenance_window_name', 'parameters', 'kwargs']` to `['self', 'resource_group_name', 'server_name', 'database_name', 'parameters', 'maintenance_window_name', 'kwargs']` + ## 4.0.0b24 (2025-10-09) ### Bugs Fixed diff --git a/sdk/sql/azure-mgmt-sql/README.md b/sdk/sql/azure-mgmt-sql/README.md index 2301ba3179d0..da6c909b5e59 100644 --- a/sdk/sql/azure-mgmt-sql/README.md +++ b/sdk/sql/azure-mgmt-sql/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure SQL Management Client Library. -This package has been tested with Python 3.9+. +This package has been tested with Python 3.10+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ @@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For ### Prerequisites -- Python 3.9+ is required to use this package. +- Python 3.10+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package diff --git a/sdk/sql/azure-mgmt-sql/_metadata.json b/sdk/sql/azure-mgmt-sql/_metadata.json index 8a79cbe05c94..b4689263f5dc 100644 --- a/sdk/sql/azure-mgmt-sql/_metadata.json +++ b/sdk/sql/azure-mgmt-sql/_metadata.json @@ -1,11 +1,10 @@ { - "commit": "8358c7473dfe057d84a6b6a921225063c040b31a", + "apiVersion": "2025-02-01-preview", + "apiVersions": { + "Microsoft.Sql": "2025-02-01-preview" + }, + "commit": "41784cfad64229e05cb37b1532a686a0cc3a60a9", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.10.2", - "use": [ - "@autorest/python@6.40.0", - "@autorest/modelerfour@4.27.0" - ], - "autorest_command": "autorest specification/sql/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --package-mode=azure-mgmt --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.40.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", - "readme": "specification/sql/resource-manager/readme.md" + "typespec_src": "specification/sql/resource-manager/Microsoft.Sql/SQL", + "emitterVersion": "0.61.3" } \ No newline at end of file diff --git a/sdk/sql/azure-mgmt-sql/apiview-properties.json b/sdk/sql/azure-mgmt-sql/apiview-properties.json index 57dcfec67bab..b5ec0df212b6 100644 --- a/sdk/sql/azure-mgmt-sql/apiview-properties.json +++ b/sdk/sql/azure-mgmt-sql/apiview-properties.json @@ -1,1685 +1,1710 @@ { - "CrossLanguagePackageId": null, + "CrossLanguagePackageId": "Microsoft.Sql", "CrossLanguageDefinitionId": { - "azure.mgmt.sql.models.AdministratorListResult": null, - "azure.mgmt.sql.models.Resource": null, - "azure.mgmt.sql.models.ProxyResource": null, - "azure.mgmt.sql.models.Advisor": null, - "azure.mgmt.sql.models.AutomaticTuningOptions": null, - "azure.mgmt.sql.models.AutomaticTuningServerOptions": null, - "azure.mgmt.sql.models.AutoPauseDelayTimeRange": null, - "azure.mgmt.sql.models.AzureADOnlyAuthListResult": null, - "azure.mgmt.sql.models.BackupShortTermRetentionPolicy": null, - "azure.mgmt.sql.models.BackupShortTermRetentionPolicyListResult": null, - "azure.mgmt.sql.models.Baseline": null, - "azure.mgmt.sql.models.BaselineAdjustedResult": null, - "azure.mgmt.sql.models.BenchmarkReference": null, - "azure.mgmt.sql.models.CertificateInfo": null, - "azure.mgmt.sql.models.ChangeLongTermRetentionBackupAccessTierParameters": null, - "azure.mgmt.sql.models.CheckNameAvailabilityRequest": null, - "azure.mgmt.sql.models.CheckNameAvailabilityResponse": null, - "azure.mgmt.sql.models.CompleteDatabaseRestoreDefinition": null, - "azure.mgmt.sql.models.CopyLongTermRetentionBackupParameters": null, - "azure.mgmt.sql.models.CreateDatabaseRestorePointDefinition": null, - "azure.mgmt.sql.models.TrackedResource": null, - "azure.mgmt.sql.models.Database": null, - "azure.mgmt.sql.models.DatabaseAdvancedThreatProtection": null, - "azure.mgmt.sql.models.DatabaseAdvancedThreatProtectionListResult": null, - "azure.mgmt.sql.models.DatabaseAutomaticTuning": null, - "azure.mgmt.sql.models.DatabaseBlobAuditingPolicy": null, - "azure.mgmt.sql.models.DatabaseBlobAuditingPolicyListResult": null, - "azure.mgmt.sql.models.DatabaseColumn": null, - "azure.mgmt.sql.models.DatabaseColumnListResult": null, - "azure.mgmt.sql.models.DatabaseExtensions": null, - "azure.mgmt.sql.models.DatabaseIdentity": null, - "azure.mgmt.sql.models.DatabaseKey": null, - "azure.mgmt.sql.models.DatabaseListResult": null, - "azure.mgmt.sql.models.DatabaseOperation": null, - "azure.mgmt.sql.models.DatabaseOperationListResult": null, - "azure.mgmt.sql.models.DatabaseSchema": null, - "azure.mgmt.sql.models.DatabaseSchemaListResult": null, - "azure.mgmt.sql.models.DatabaseSecurityAlertListResult": null, - "azure.mgmt.sql.models.DatabaseSecurityAlertPolicy": null, - "azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet": null, - "azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSetListResult": null, - "azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline": null, - "azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput": null, - "azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput": null, - "azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListResult": null, - "azure.mgmt.sql.models.DatabaseTable": null, - "azure.mgmt.sql.models.DatabaseTableListResult": null, - "azure.mgmt.sql.models.DatabaseUpdate": null, - "azure.mgmt.sql.models.DatabaseUsage": null, - "azure.mgmt.sql.models.DatabaseUsageListResult": null, - "azure.mgmt.sql.models.DatabaseUserIdentity": null, - "azure.mgmt.sql.models.DatabaseVulnerabilityAssessment": null, - "azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentListResult": null, - "azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline": null, - "azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaselineItem": null, - "azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentScansExport": null, - "azure.mgmt.sql.models.DataMaskingPolicy": null, - "azure.mgmt.sql.models.DataMaskingRule": null, - "azure.mgmt.sql.models.DataMaskingRuleListResult": null, - "azure.mgmt.sql.models.DataWarehouseUserActivities": null, - "azure.mgmt.sql.models.DataWarehouseUserActivitiesListResult": null, - "azure.mgmt.sql.models.DeletedServer": null, - "azure.mgmt.sql.models.DeletedServerListResult": null, - "azure.mgmt.sql.models.DistributedAvailabilityGroup": null, - "azure.mgmt.sql.models.DistributedAvailabilityGroupDatabase": null, - "azure.mgmt.sql.models.DistributedAvailabilityGroupSetRole": null, - "azure.mgmt.sql.models.DistributedAvailabilityGroupsFailoverRequest": null, - "azure.mgmt.sql.models.DistributedAvailabilityGroupsListResult": null, - "azure.mgmt.sql.models.EditionCapability": null, - "azure.mgmt.sql.models.ElasticPool": null, - "azure.mgmt.sql.models.ElasticPoolActivity": null, - "azure.mgmt.sql.models.ElasticPoolActivityListResult": null, - "azure.mgmt.sql.models.ElasticPoolDatabaseActivity": null, - "azure.mgmt.sql.models.ElasticPoolDatabaseActivityListResult": null, - "azure.mgmt.sql.models.ElasticPoolEditionCapability": null, - "azure.mgmt.sql.models.ElasticPoolListResult": null, - "azure.mgmt.sql.models.ElasticPoolOperation": null, - "azure.mgmt.sql.models.ElasticPoolOperationListResult": null, - "azure.mgmt.sql.models.ElasticPoolPerDatabaseMaxPerformanceLevelCapability": null, - "azure.mgmt.sql.models.ElasticPoolPerDatabaseMinPerformanceLevelCapability": null, - "azure.mgmt.sql.models.ElasticPoolPerDatabaseSettings": null, - "azure.mgmt.sql.models.ElasticPoolPerformanceLevelCapability": null, - "azure.mgmt.sql.models.ElasticPoolUpdate": null, - "azure.mgmt.sql.models.EncryptionProtector": null, - "azure.mgmt.sql.models.EncryptionProtectorListResult": null, - "azure.mgmt.sql.models.EndpointCertificate": null, - "azure.mgmt.sql.models.EndpointCertificateListResult": null, - "azure.mgmt.sql.models.EndpointDependency": null, - "azure.mgmt.sql.models.EndpointDetail": null, - "azure.mgmt.sql.models.ErrorAdditionalInfo": null, - "azure.mgmt.sql.models.ErrorDetail": null, - "azure.mgmt.sql.models.ErrorResponse": null, - "azure.mgmt.sql.models.ExportDatabaseDefinition": null, - "azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicy": null, - "azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicyListResult": null, - "azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy": null, - "azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicyListResult": null, - "azure.mgmt.sql.models.FailoverGroup": null, - "azure.mgmt.sql.models.FailoverGroupListResult": null, - "azure.mgmt.sql.models.FailoverGroupReadOnlyEndpoint": null, - "azure.mgmt.sql.models.FailoverGroupReadWriteEndpoint": null, - "azure.mgmt.sql.models.FailoverGroupUpdate": null, - "azure.mgmt.sql.models.ResourceWithWritableName": null, - "azure.mgmt.sql.models.ProxyResourceWithWritableName": null, - "azure.mgmt.sql.models.FirewallRule": null, - "azure.mgmt.sql.models.FirewallRuleList": null, - "azure.mgmt.sql.models.FirewallRuleListResult": null, - "azure.mgmt.sql.models.GeoBackupPolicy": null, - "azure.mgmt.sql.models.GeoBackupPolicyListResult": null, - "azure.mgmt.sql.models.ImportExistingDatabaseDefinition": null, - "azure.mgmt.sql.models.ImportExportExtensionsOperationListResult": null, - "azure.mgmt.sql.models.ImportExportExtensionsOperationResult": null, - "azure.mgmt.sql.models.ImportExportOperationResult": null, - "azure.mgmt.sql.models.ImportNewDatabaseDefinition": null, - "azure.mgmt.sql.models.InstanceFailoverGroup": null, - "azure.mgmt.sql.models.InstanceFailoverGroupListResult": null, - "azure.mgmt.sql.models.InstanceFailoverGroupReadOnlyEndpoint": null, - "azure.mgmt.sql.models.InstanceFailoverGroupReadWriteEndpoint": null, - "azure.mgmt.sql.models.InstancePool": null, - "azure.mgmt.sql.models.InstancePoolEditionCapability": null, - "azure.mgmt.sql.models.InstancePoolFamilyCapability": null, - "azure.mgmt.sql.models.InstancePoolListResult": null, - "azure.mgmt.sql.models.InstancePoolUpdate": null, - "azure.mgmt.sql.models.InstancePoolVcoresCapability": null, - "azure.mgmt.sql.models.IPv6FirewallRule": null, - "azure.mgmt.sql.models.IPv6FirewallRuleListResult": null, - "azure.mgmt.sql.models.Job": null, - "azure.mgmt.sql.models.JobAgent": null, - "azure.mgmt.sql.models.JobAgentListResult": null, - "azure.mgmt.sql.models.JobAgentUpdate": null, - "azure.mgmt.sql.models.JobCredential": null, - "azure.mgmt.sql.models.JobCredentialListResult": null, - "azure.mgmt.sql.models.JobExecution": null, - "azure.mgmt.sql.models.JobExecutionListResult": null, - "azure.mgmt.sql.models.JobExecutionTarget": null, - "azure.mgmt.sql.models.JobListResult": null, - "azure.mgmt.sql.models.JobPrivateEndpoint": null, - "azure.mgmt.sql.models.JobPrivateEndpointListResult": null, - "azure.mgmt.sql.models.JobSchedule": null, - "azure.mgmt.sql.models.JobStep": null, - "azure.mgmt.sql.models.JobStepAction": null, - "azure.mgmt.sql.models.JobStepExecutionOptions": null, - "azure.mgmt.sql.models.JobStepListResult": null, - "azure.mgmt.sql.models.JobStepOutput": null, - "azure.mgmt.sql.models.JobTarget": null, - "azure.mgmt.sql.models.JobTargetGroup": null, - "azure.mgmt.sql.models.JobTargetGroupListResult": null, - "azure.mgmt.sql.models.JobVersion": null, - "azure.mgmt.sql.models.JobVersionListResult": null, - "azure.mgmt.sql.models.LedgerDigestUploads": null, - "azure.mgmt.sql.models.LedgerDigestUploadsListResult": null, - "azure.mgmt.sql.models.LicenseTypeCapability": null, - "azure.mgmt.sql.models.LocationCapabilities": null, - "azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption": null, - "azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryptionListResult": null, - "azure.mgmt.sql.models.LogicalServerAdvancedThreatProtectionListResult": null, - "azure.mgmt.sql.models.LogicalServerSecurityAlertPolicyListResult": null, - "azure.mgmt.sql.models.LogSizeCapability": null, - "azure.mgmt.sql.models.LongTermRetentionBackup": null, - "azure.mgmt.sql.models.LongTermRetentionBackupListResult": null, - "azure.mgmt.sql.models.LongTermRetentionBackupOperationResult": null, - "azure.mgmt.sql.models.LongTermRetentionPolicy": null, - "azure.mgmt.sql.models.LongTermRetentionPolicyListResult": null, - "azure.mgmt.sql.models.MaintenanceConfigurationCapability": null, - "azure.mgmt.sql.models.MaintenanceWindowOptions": null, - "azure.mgmt.sql.models.MaintenanceWindows": null, - "azure.mgmt.sql.models.MaintenanceWindowTimeRange": null, - "azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy": null, - "azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicyListResult": null, - "azure.mgmt.sql.models.ManagedDatabase": null, - "azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection": null, - "azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtectionListResult": null, - "azure.mgmt.sql.models.ManagedDatabaseListResult": null, - "azure.mgmt.sql.models.ManagedDatabaseMoveDefinition": null, - "azure.mgmt.sql.models.ManagedDatabaseMoveOperationListResult": null, - "azure.mgmt.sql.models.ManagedDatabaseMoveOperationResult": null, - "azure.mgmt.sql.models.ManagedDatabaseRestoreDetailsBackupSetProperties": null, - "azure.mgmt.sql.models.ManagedDatabaseRestoreDetailsResult": null, - "azure.mgmt.sql.models.ManagedDatabaseRestoreDetailsUnrestorableFileProperties": null, - "azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy": null, - "azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicyListResult": null, - "azure.mgmt.sql.models.ManagedDatabaseStartMoveDefinition": null, - "azure.mgmt.sql.models.ManagedDatabaseUpdate": null, - "azure.mgmt.sql.models.ManagedInstance": null, - "azure.mgmt.sql.models.ManagedInstanceAdministrator": null, - "azure.mgmt.sql.models.ManagedInstanceAdministratorListResult": null, - "azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection": null, - "azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtectionListResult": null, - "azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication": null, - "azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthListResult": null, - "azure.mgmt.sql.models.ManagedInstanceDtc": null, - "azure.mgmt.sql.models.ManagedInstanceDtcListResult": null, - "azure.mgmt.sql.models.ManagedInstanceDtcSecuritySettings": null, - "azure.mgmt.sql.models.ManagedInstanceDtcTransactionManagerCommunicationSettings": null, - "azure.mgmt.sql.models.ManagedInstanceEditionCapability": null, - "azure.mgmt.sql.models.ManagedInstanceEncryptionProtector": null, - "azure.mgmt.sql.models.ManagedInstanceEncryptionProtectorListResult": null, - "azure.mgmt.sql.models.ManagedInstanceExternalAdministrator": null, - "azure.mgmt.sql.models.ManagedInstanceFamilyCapability": null, - "azure.mgmt.sql.models.ManagedInstanceKey": null, - "azure.mgmt.sql.models.ManagedInstanceKeyListResult": null, - "azure.mgmt.sql.models.ManagedInstanceListResult": null, - "azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup": null, - "azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackupListResult": null, - "azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy": null, - "azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicyListResult": null, - "azure.mgmt.sql.models.ManagedInstanceMaintenanceConfigurationCapability": null, - "azure.mgmt.sql.models.ManagedInstanceOperation": null, - "azure.mgmt.sql.models.ManagedInstanceOperationListResult": null, - "azure.mgmt.sql.models.ManagedInstanceOperationParametersPair": null, - "azure.mgmt.sql.models.ManagedInstanceOperationSteps": null, - "azure.mgmt.sql.models.ManagedInstancePairInfo": null, - "azure.mgmt.sql.models.ManagedInstancePecProperty": null, - "azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection": null, - "azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnectionListResult": null, - "azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnectionProperties": null, - "azure.mgmt.sql.models.ManagedInstancePrivateEndpointProperty": null, - "azure.mgmt.sql.models.ManagedInstancePrivateLink": null, - "azure.mgmt.sql.models.ManagedInstancePrivateLinkListResult": null, - "azure.mgmt.sql.models.ManagedInstancePrivateLinkProperties": null, - "azure.mgmt.sql.models.ManagedInstancePrivateLinkServiceConnectionStateProperty": null, - "azure.mgmt.sql.models.ManagedInstanceQuery": null, - "azure.mgmt.sql.models.ManagedInstanceQueryStatistics": null, - "azure.mgmt.sql.models.ManagedInstanceUpdate": null, - "azure.mgmt.sql.models.ManagedInstanceVcoresCapability": null, - "azure.mgmt.sql.models.ManagedInstanceVersionCapability": null, - "azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment": null, - "azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessmentListResult": null, - "azure.mgmt.sql.models.ManagedLedgerDigestUploads": null, - "azure.mgmt.sql.models.ManagedLedgerDigestUploadsListResult": null, - "azure.mgmt.sql.models.ManagedServerDnsAlias": null, - "azure.mgmt.sql.models.ManagedServerDnsAliasAcquisition": null, - "azure.mgmt.sql.models.ManagedServerDnsAliasCreation": null, - "azure.mgmt.sql.models.ManagedServerDnsAliasListResult": null, - "azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy": null, - "azure.mgmt.sql.models.ManagedServerSecurityAlertPolicyListResult": null, - "azure.mgmt.sql.models.ManagedTransparentDataEncryption": null, - "azure.mgmt.sql.models.ManagedTransparentDataEncryptionListResult": null, - "azure.mgmt.sql.models.MaxSizeCapability": null, - "azure.mgmt.sql.models.MaxSizeRangeCapability": null, - "azure.mgmt.sql.models.Metric": null, - "azure.mgmt.sql.models.MetricAvailability": null, - "azure.mgmt.sql.models.MetricDefinition": null, - "azure.mgmt.sql.models.MetricDefinitionListResult": null, - "azure.mgmt.sql.models.MetricListResult": null, - "azure.mgmt.sql.models.MetricName": null, - "azure.mgmt.sql.models.MetricValue": null, - "azure.mgmt.sql.models.MinCapacityCapability": null, - "azure.mgmt.sql.models.Name": null, - "azure.mgmt.sql.models.NetworkIsolationSettings": null, - "azure.mgmt.sql.models.Operation": null, - "azure.mgmt.sql.models.OperationDisplay": null, - "azure.mgmt.sql.models.OperationImpact": null, - "azure.mgmt.sql.models.OperationListResult": null, - "azure.mgmt.sql.models.OutboundEnvironmentEndpoint": null, - "azure.mgmt.sql.models.OutboundEnvironmentEndpointCollection": null, - "azure.mgmt.sql.models.OutboundFirewallRule": null, - "azure.mgmt.sql.models.OutboundFirewallRuleListResult": null, - "azure.mgmt.sql.models.PartnerInfo": null, - "azure.mgmt.sql.models.PartnerRegionInfo": null, - "azure.mgmt.sql.models.PerformanceLevelCapability": null, - "azure.mgmt.sql.models.PhaseDetails": null, - "azure.mgmt.sql.models.PrivateEndpointConnection": null, - "azure.mgmt.sql.models.PrivateEndpointConnectionListResult": null, - "azure.mgmt.sql.models.PrivateEndpointConnectionProperties": null, - "azure.mgmt.sql.models.PrivateEndpointConnectionRequestStatus": null, - "azure.mgmt.sql.models.PrivateEndpointProperty": null, - "azure.mgmt.sql.models.PrivateLinkResource": null, - "azure.mgmt.sql.models.PrivateLinkResourceListResult": null, - "azure.mgmt.sql.models.PrivateLinkResourceProperties": null, - "azure.mgmt.sql.models.PrivateLinkServiceConnectionStateProperty": null, - "azure.mgmt.sql.models.QueryCheck": null, - "azure.mgmt.sql.models.QueryMetricInterval": null, - "azure.mgmt.sql.models.QueryMetricIntervalAutoGenerated": null, - "azure.mgmt.sql.models.QueryMetricProperties": null, - "azure.mgmt.sql.models.QueryStatistics": null, - "azure.mgmt.sql.models.QueryStatisticsProperties": null, - "azure.mgmt.sql.models.ReadScaleCapability": null, - "azure.mgmt.sql.models.RecommendedAction": null, - "azure.mgmt.sql.models.RecommendedActionErrorInfo": null, - "azure.mgmt.sql.models.RecommendedActionImpactRecord": null, - "azure.mgmt.sql.models.RecommendedActionImplementationInfo": null, - "azure.mgmt.sql.models.RecommendedActionMetricInfo": null, - "azure.mgmt.sql.models.RecommendedActionStateInfo": null, - "azure.mgmt.sql.models.RecommendedSensitivityLabelUpdate": null, - "azure.mgmt.sql.models.RecommendedSensitivityLabelUpdateList": null, - "azure.mgmt.sql.models.RecoverableDatabase": null, - "azure.mgmt.sql.models.RecoverableDatabaseListResult": null, - "azure.mgmt.sql.models.RecoverableManagedDatabase": null, - "azure.mgmt.sql.models.RecoverableManagedDatabaseListResult": null, - "azure.mgmt.sql.models.RefreshExternalGovernanceStatusOperationResult": null, - "azure.mgmt.sql.models.RefreshExternalGovernanceStatusOperationResultMI": null, - "azure.mgmt.sql.models.Remediation": null, - "azure.mgmt.sql.models.ReplicationLink": null, - "azure.mgmt.sql.models.ReplicationLinkListResult": null, - "azure.mgmt.sql.models.ReplicationLinkUpdate": null, - "azure.mgmt.sql.models.ResourceIdentity": null, - "azure.mgmt.sql.models.ResourceMoveDefinition": null, - "azure.mgmt.sql.models.RestorableDroppedDatabase": null, - "azure.mgmt.sql.models.RestorableDroppedDatabaseListResult": null, - "azure.mgmt.sql.models.RestorableDroppedManagedDatabase": null, - "azure.mgmt.sql.models.RestorableDroppedManagedDatabaseListResult": null, - "azure.mgmt.sql.models.RestorePoint": null, - "azure.mgmt.sql.models.RestorePointListResult": null, - "azure.mgmt.sql.models.ScheduleItem": null, - "azure.mgmt.sql.models.SecurityEvent": null, - "azure.mgmt.sql.models.SecurityEventCollection": null, - "azure.mgmt.sql.models.SecurityEventsFilterParameters": null, - "azure.mgmt.sql.models.SecurityEventSqlInjectionAdditionalProperties": null, - "azure.mgmt.sql.models.SensitivityLabel": null, - "azure.mgmt.sql.models.SensitivityLabelListResult": null, - "azure.mgmt.sql.models.SensitivityLabelUpdate": null, - "azure.mgmt.sql.models.SensitivityLabelUpdateList": null, - "azure.mgmt.sql.models.Server": null, - "azure.mgmt.sql.models.ServerAdvancedThreatProtection": null, - "azure.mgmt.sql.models.ServerAutomaticTuning": null, - "azure.mgmt.sql.models.ServerAzureADAdministrator": null, - "azure.mgmt.sql.models.ServerAzureADOnlyAuthentication": null, - "azure.mgmt.sql.models.ServerBlobAuditingPolicy": null, - "azure.mgmt.sql.models.ServerBlobAuditingPolicyListResult": null, - "azure.mgmt.sql.models.ServerCommunicationLink": null, - "azure.mgmt.sql.models.ServerCommunicationLinkListResult": null, - "azure.mgmt.sql.models.ServerConfigurationOption": null, - "azure.mgmt.sql.models.ServerConfigurationOptionListResult": null, - "azure.mgmt.sql.models.ServerConnectionPolicy": null, - "azure.mgmt.sql.models.ServerConnectionPolicyListResult": null, - "azure.mgmt.sql.models.ServerDevOpsAuditingSettings": null, - "azure.mgmt.sql.models.ServerDevOpsAuditSettingsListResult": null, - "azure.mgmt.sql.models.ServerDnsAlias": null, - "azure.mgmt.sql.models.ServerDnsAliasAcquisition": null, - "azure.mgmt.sql.models.ServerDnsAliasListResult": null, - "azure.mgmt.sql.models.ServerExternalAdministrator": null, - "azure.mgmt.sql.models.ServerInfo": null, - "azure.mgmt.sql.models.ServerKey": null, - "azure.mgmt.sql.models.ServerKeyListResult": null, - "azure.mgmt.sql.models.ServerListResult": null, - "azure.mgmt.sql.models.ServerOperation": null, - "azure.mgmt.sql.models.ServerOperationListResult": null, - "azure.mgmt.sql.models.ServerPrivateEndpointConnection": null, - "azure.mgmt.sql.models.ServerSecurityAlertPolicy": null, - "azure.mgmt.sql.models.ServerTrustCertificate": null, - "azure.mgmt.sql.models.ServerTrustCertificatesListResult": null, - "azure.mgmt.sql.models.ServerTrustGroup": null, - "azure.mgmt.sql.models.ServerTrustGroupListResult": null, - "azure.mgmt.sql.models.ServerUpdate": null, - "azure.mgmt.sql.models.ServerUsage": null, - "azure.mgmt.sql.models.ServerUsageListResult": null, - "azure.mgmt.sql.models.ServerVersionCapability": null, - "azure.mgmt.sql.models.ServerVulnerabilityAssessment": null, - "azure.mgmt.sql.models.ServerVulnerabilityAssessmentListResult": null, - "azure.mgmt.sql.models.ServiceObjective": null, - "azure.mgmt.sql.models.ServiceObjectiveCapability": null, - "azure.mgmt.sql.models.ServiceObjectiveListResult": null, - "azure.mgmt.sql.models.ServicePrincipal": null, - "azure.mgmt.sql.models.Sku": null, - "azure.mgmt.sql.models.SloUsageMetric": null, - "azure.mgmt.sql.models.SqlAgentConfiguration": null, - "azure.mgmt.sql.models.SqlVulnerabilityAssessment": null, - "azure.mgmt.sql.models.SqlVulnerabilityAssessmentListResult": null, - "azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanError": null, - "azure.mgmt.sql.models.SQLVulnerabilityAssessmentScanListResult": null, - "azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanRecord": null, - "azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanRecordListResult": null, - "azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanResults": null, - "azure.mgmt.sql.models.StartStopManagedInstanceSchedule": null, - "azure.mgmt.sql.models.StartStopManagedInstanceScheduleListResult": null, - "azure.mgmt.sql.models.StorageCapability": null, - "azure.mgmt.sql.models.SubscriptionUsage": null, - "azure.mgmt.sql.models.SubscriptionUsageListResult": null, - "azure.mgmt.sql.models.SynapseLinkWorkspace": null, - "azure.mgmt.sql.models.SynapseLinkWorkspaceInfoProperties": null, - "azure.mgmt.sql.models.SynapseLinkWorkspaceListResult": null, - "azure.mgmt.sql.models.SyncAgent": null, - "azure.mgmt.sql.models.SyncAgentKeyProperties": null, - "azure.mgmt.sql.models.SyncAgentLinkedDatabase": null, - "azure.mgmt.sql.models.SyncAgentLinkedDatabaseListResult": null, - "azure.mgmt.sql.models.SyncAgentListResult": null, - "azure.mgmt.sql.models.SyncDatabaseIdListResult": null, - "azure.mgmt.sql.models.SyncDatabaseIdProperties": null, - "azure.mgmt.sql.models.SyncFullSchemaProperties": null, - "azure.mgmt.sql.models.SyncFullSchemaPropertiesListResult": null, - "azure.mgmt.sql.models.SyncFullSchemaTable": null, - "azure.mgmt.sql.models.SyncFullSchemaTableColumn": null, - "azure.mgmt.sql.models.SyncGroup": null, - "azure.mgmt.sql.models.SyncGroupListResult": null, - "azure.mgmt.sql.models.SyncGroupLogListResult": null, - "azure.mgmt.sql.models.SyncGroupLogProperties": null, - "azure.mgmt.sql.models.SyncGroupSchema": null, - "azure.mgmt.sql.models.SyncGroupSchemaTable": null, - "azure.mgmt.sql.models.SyncGroupSchemaTableColumn": null, - "azure.mgmt.sql.models.SyncMember": null, - "azure.mgmt.sql.models.SyncMemberListResult": null, - "azure.mgmt.sql.models.SystemData": null, - "azure.mgmt.sql.models.TdeCertificate": null, - "azure.mgmt.sql.models.TimeZone": null, - "azure.mgmt.sql.models.TimeZoneListResult": null, - "azure.mgmt.sql.models.TopQueries": null, - "azure.mgmt.sql.models.TopQueriesListResult": null, - "azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters": null, - "azure.mgmt.sql.models.UpdateVirtualClusterDnsServersOperation": null, - "azure.mgmt.sql.models.UpsertManagedServerOperationParameters": null, - "azure.mgmt.sql.models.UpsertManagedServerOperationStep": null, - "azure.mgmt.sql.models.Usage": null, - "azure.mgmt.sql.models.UsageListResult": null, - "azure.mgmt.sql.models.UserIdentity": null, - "azure.mgmt.sql.models.VaRule": null, - "azure.mgmt.sql.models.VirtualCluster": null, - "azure.mgmt.sql.models.VirtualClusterListResult": null, - "azure.mgmt.sql.models.VirtualClusterUpdate": null, - "azure.mgmt.sql.models.VirtualNetworkRule": null, - "azure.mgmt.sql.models.VirtualNetworkRuleListResult": null, - "azure.mgmt.sql.models.VulnerabilityAssessmentRecurringScansProperties": null, - "azure.mgmt.sql.models.VulnerabilityAssessmentScanError": null, - "azure.mgmt.sql.models.VulnerabilityAssessmentScanRecord": null, - "azure.mgmt.sql.models.VulnerabilityAssessmentScanRecordListResult": null, - "azure.mgmt.sql.models.WorkloadClassifier": null, - "azure.mgmt.sql.models.WorkloadClassifierListResult": null, - "azure.mgmt.sql.models.WorkloadGroup": null, - "azure.mgmt.sql.models.WorkloadGroupListResult": null, - "azure.mgmt.sql.models.DataMaskingRuleState": null, - "azure.mgmt.sql.models.DataMaskingFunction": null, - "azure.mgmt.sql.models.GeoBackupPolicyState": null, - "azure.mgmt.sql.models.UnitType": null, - "azure.mgmt.sql.models.PrimaryAggregationType": null, - "azure.mgmt.sql.models.UnitDefinitionType": null, - "azure.mgmt.sql.models.RecommendedActionCurrentState": null, - "azure.mgmt.sql.models.RecommendedActionInitiatedBy": null, - "azure.mgmt.sql.models.ImplementationMethod": null, - "azure.mgmt.sql.models.IsRetryable": null, - "azure.mgmt.sql.models.AdvisorStatus": null, - "azure.mgmt.sql.models.AutoExecuteStatus": null, - "azure.mgmt.sql.models.AutoExecuteStatusInheritedFrom": null, - "azure.mgmt.sql.models.ColumnDataType": null, - "azure.mgmt.sql.models.TableTemporalType": null, - "azure.mgmt.sql.models.CreatedByType": null, - "azure.mgmt.sql.models.SecurityAlertsPolicyState": null, - "azure.mgmt.sql.models.VulnerabilityAssessmentScanTriggerType": null, - "azure.mgmt.sql.models.VulnerabilityAssessmentScanState": null, - "azure.mgmt.sql.models.ServerKeyType": null, - "azure.mgmt.sql.models.JobAgentState": null, - "azure.mgmt.sql.models.JobExecutionLifecycle": null, - "azure.mgmt.sql.models.ProvisioningState": null, - "azure.mgmt.sql.models.JobTargetType": null, - "azure.mgmt.sql.models.JobScheduleType": null, - "azure.mgmt.sql.models.JobStepActionType": null, - "azure.mgmt.sql.models.JobStepActionSource": null, - "azure.mgmt.sql.models.JobStepOutputType": null, - "azure.mgmt.sql.models.JobTargetGroupMembershipType": null, - "azure.mgmt.sql.models.MaxSizeUnit": null, - "azure.mgmt.sql.models.LogSizeUnit": null, - "azure.mgmt.sql.models.CapabilityStatus": null, - "azure.mgmt.sql.models.PerformanceLevelUnit": null, - "azure.mgmt.sql.models.PauseDelayTimeUnit": null, - "azure.mgmt.sql.models.StorageCapabilityStorageAccountType": null, - "azure.mgmt.sql.models.DayOfWeek": null, - "azure.mgmt.sql.models.QueryMetricUnitType": null, - "azure.mgmt.sql.models.QueryTimeGrainType": null, - "azure.mgmt.sql.models.SecurityAlertPolicyState": null, - "azure.mgmt.sql.models.SecurityEventType": null, - "azure.mgmt.sql.models.TransparentDataEncryptionState": null, - "azure.mgmt.sql.models.ManagedInstanceAdministratorType": null, - "azure.mgmt.sql.models.UpsertManagedServerOperationStepStatus": null, - "azure.mgmt.sql.models.ManagementOperationState": null, - "azure.mgmt.sql.models.OperationOrigin": null, - "azure.mgmt.sql.models.PrivateLinkServiceConnectionStateStatus": null, - "azure.mgmt.sql.models.PrivateLinkServiceConnectionStateActionsRequire": null, - "azure.mgmt.sql.models.PrivateEndpointProvisioningState": null, - "azure.mgmt.sql.models.RestorePointType": null, - "azure.mgmt.sql.models.AdministratorType": null, - "azure.mgmt.sql.models.BlobAuditingPolicyState": null, - "azure.mgmt.sql.models.ServerTrustGroupPropertiesTrustScopesItem": null, - "azure.mgmt.sql.models.SyncAgentState": null, - "azure.mgmt.sql.models.SyncMemberDbType": null, - "azure.mgmt.sql.models.SyncGroupLogType": null, - "azure.mgmt.sql.models.SyncConflictResolutionPolicy": null, - "azure.mgmt.sql.models.SyncGroupState": null, - "azure.mgmt.sql.models.SyncDirection": null, - "azure.mgmt.sql.models.SyncMemberState": null, - "azure.mgmt.sql.models.VirtualNetworkRuleState": null, - "azure.mgmt.sql.models.DiffBackupIntervalInHours": null, - "azure.mgmt.sql.models.LedgerDigestUploadsState": null, - "azure.mgmt.sql.models.BackupStorageRedundancy": null, - "azure.mgmt.sql.models.ServerConnectionType": null, - "azure.mgmt.sql.models.SensitivityLabelRank": null, - "azure.mgmt.sql.models.SensitivityLabelUpdateKind": null, - "azure.mgmt.sql.models.RecommendedSensitivityLabelUpdateKind": null, - "azure.mgmt.sql.models.AdvancedThreatProtectionState": null, - "azure.mgmt.sql.models.MoveOperationMode": null, - "azure.mgmt.sql.models.InstanceFailoverGroupReplicationRole": null, - "azure.mgmt.sql.models.SecondaryInstanceType": null, - "azure.mgmt.sql.models.ReadWriteEndpointFailoverPolicy": null, - "azure.mgmt.sql.models.ReadOnlyEndpointFailoverPolicy": null, - "azure.mgmt.sql.models.DatabaseIdentityType": null, - "azure.mgmt.sql.models.CreateMode": null, - "azure.mgmt.sql.models.SampleName": null, - "azure.mgmt.sql.models.DatabaseStatus": null, - "azure.mgmt.sql.models.CatalogCollationType": null, - "azure.mgmt.sql.models.DatabaseLicenseType": null, - "azure.mgmt.sql.models.DatabaseReadScale": null, - "azure.mgmt.sql.models.SecondaryType": null, - "azure.mgmt.sql.models.DatabaseKeyType": null, - "azure.mgmt.sql.models.AlwaysEncryptedEnclaveType": null, - "azure.mgmt.sql.models.FreeLimitExhaustionBehavior": null, - "azure.mgmt.sql.models.AvailabilityZoneType": null, - "azure.mgmt.sql.models.ElasticPoolState": null, - "azure.mgmt.sql.models.ElasticPoolLicenseType": null, - "azure.mgmt.sql.models.ManagedDatabaseStatus": null, - "azure.mgmt.sql.models.ManagedDatabaseCreateMode": null, - "azure.mgmt.sql.models.ManagedLedgerDigestUploadsState": null, - "azure.mgmt.sql.models.RuleStatus": null, - "azure.mgmt.sql.models.RuleSeverity": null, - "azure.mgmt.sql.models.RuleType": null, - "azure.mgmt.sql.models.SqlVulnerabilityAssessmentState": null, - "azure.mgmt.sql.models.FailoverGroupReplicationRole": null, - "azure.mgmt.sql.models.FailoverGroupDatabasesSecondaryType": null, - "azure.mgmt.sql.models.InstancePoolLicenseType": null, - "azure.mgmt.sql.models.IdentityType": null, - "azure.mgmt.sql.models.ManagedServerCreateMode": null, - "azure.mgmt.sql.models.ManagedInstanceLicenseType": null, - "azure.mgmt.sql.models.HybridSecondaryUsage": null, - "azure.mgmt.sql.models.HybridSecondaryUsageDetected": null, - "azure.mgmt.sql.models.ManagedInstanceProxyOverride": null, - "azure.mgmt.sql.models.PrincipalType": null, - "azure.mgmt.sql.models.ServicePrincipalType": null, - "azure.mgmt.sql.models.ExternalGovernanceStatus": null, - "azure.mgmt.sql.models.FreemiumType": null, - "azure.mgmt.sql.models.AuthMetadataLookupModes": null, - "azure.mgmt.sql.models.ManagedInstanceDatabaseFormat": null, - "azure.mgmt.sql.models.ReplicationRole": null, - "azure.mgmt.sql.models.ReplicationState": null, - "azure.mgmt.sql.models.ReplicationLinkType": null, - "azure.mgmt.sql.models.ReplicaSynchronizationHealth": null, - "azure.mgmt.sql.models.ReplicaConnectedState": null, - "azure.mgmt.sql.models.ReplicationModeType": null, - "azure.mgmt.sql.models.LinkRole": null, - "azure.mgmt.sql.models.FailoverModeType": null, - "azure.mgmt.sql.models.SeedingModeType": null, - "azure.mgmt.sql.models.MinimalTlsVersion": null, - "azure.mgmt.sql.models.ServerPublicNetworkAccessFlag": null, - "azure.mgmt.sql.models.ServerWorkspaceFeature": null, - "azure.mgmt.sql.models.ServerNetworkAccessFlag": null, - "azure.mgmt.sql.models.ServerCreateMode": null, - "azure.mgmt.sql.models.TimeBasedImmutability": null, - "azure.mgmt.sql.models.TimeBasedImmutabilityMode": null, - "azure.mgmt.sql.models.SetLegalHoldImmutability": null, - "azure.mgmt.sql.models.BackupStorageAccessTier": null, - "azure.mgmt.sql.models.Phase": null, - "azure.mgmt.sql.models.GeoBackupPolicyName": null, - "azure.mgmt.sql.models.SecurityAlertPolicyName": null, - "azure.mgmt.sql.models.VulnerabilityAssessmentName": null, - "azure.mgmt.sql.models.DataWarehouseUserActivityName": null, - "azure.mgmt.sql.models.EncryptionProtectorName": null, - "azure.mgmt.sql.models.CapabilityGroup": null, - "azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName": null, - "azure.mgmt.sql.models.TransparentDataEncryptionName": null, - "azure.mgmt.sql.models.AdministratorName": null, - "azure.mgmt.sql.models.AuthenticationName": null, - "azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicyName": null, - "azure.mgmt.sql.models.DevOpsAuditingSettingsName": null, - "azure.mgmt.sql.models.SqlAgentConfigurationPropertiesState": null, - "azure.mgmt.sql.models.SyncGroupsType": null, - "azure.mgmt.sql.models.ShortTermRetentionPolicyName": null, - "azure.mgmt.sql.models.OperationMode": null, - "azure.mgmt.sql.models.StorageKeyType": null, - "azure.mgmt.sql.models.LedgerDigestUploadsName": null, - "azure.mgmt.sql.models.DatabaseState": null, - "azure.mgmt.sql.models.ConnectionPolicyName": null, - "azure.mgmt.sql.models.AdvancedThreatProtectionName": null, - "azure.mgmt.sql.models.DtcName": null, - "azure.mgmt.sql.models.DNSRefreshOperationStatus": null, - "azure.mgmt.sql.models.RestoreDetailsName": null, - "azure.mgmt.sql.models.ReplicaType": null, - "azure.mgmt.sql.models.ManagedLedgerDigestUploadsName": null, - "azure.mgmt.sql.models.ServerConfigurationOptionName": null, - "azure.mgmt.sql.models.StartStopScheduleName": null, - "azure.mgmt.sql.models.BaselineName": null, - "azure.mgmt.sql.models.SqlVulnerabilityAssessmentName": null, - "azure.mgmt.sql.models.AggregationFunctionType": null, - "azure.mgmt.sql.models.MetricType": null, - "azure.mgmt.sql.models.FailoverType": null, - "azure.mgmt.sql.models.InstanceRole": null, - "azure.mgmt.sql.models.RoleChangeType": null, - "azure.mgmt.sql.models.LongTermRetentionPolicyName": null, - "azure.mgmt.sql.models.ServiceObjectiveName": null, - "azure.mgmt.sql.models.AutomaticTuningOptionModeDesired": null, - "azure.mgmt.sql.models.AutomaticTuningOptionModeActual": null, - "azure.mgmt.sql.models.AutomaticTuningDisabledReason": null, - "azure.mgmt.sql.models.AutomaticTuningServerReason": null, - "azure.mgmt.sql.models.DataMaskingState": null, - "azure.mgmt.sql.models.AutomaticTuningMode": null, - "azure.mgmt.sql.models.AutomaticTuningServerMode": null, - "azure.mgmt.sql.models.CheckNameAvailabilityReason": null, - "azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName": null, - "azure.mgmt.sql.models.SensitivityLabelSource": null, - "azure.mgmt.sql.operations.DataMaskingPoliciesOperations.create_or_update": null, - "azure.mgmt.sql.aio.operations.DataMaskingPoliciesOperations.create_or_update": null, - "azure.mgmt.sql.operations.DataMaskingPoliciesOperations.get": null, - "azure.mgmt.sql.aio.operations.DataMaskingPoliciesOperations.get": null, - "azure.mgmt.sql.operations.DataMaskingRulesOperations.create_or_update": null, - "azure.mgmt.sql.aio.operations.DataMaskingRulesOperations.create_or_update": null, - "azure.mgmt.sql.operations.DataMaskingRulesOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.DataMaskingRulesOperations.list_by_database": null, - "azure.mgmt.sql.operations.GeoBackupPoliciesOperations.create_or_update": null, - "azure.mgmt.sql.aio.operations.GeoBackupPoliciesOperations.create_or_update": null, - "azure.mgmt.sql.operations.GeoBackupPoliciesOperations.get": null, - "azure.mgmt.sql.aio.operations.GeoBackupPoliciesOperations.get": null, - "azure.mgmt.sql.operations.GeoBackupPoliciesOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.GeoBackupPoliciesOperations.list_by_database": null, - "azure.mgmt.sql.operations.DatabasesOperations.list_metrics": null, - "azure.mgmt.sql.aio.operations.DatabasesOperations.list_metrics": null, - "azure.mgmt.sql.operations.DatabasesOperations.list_metric_definitions": null, - "azure.mgmt.sql.aio.operations.DatabasesOperations.list_metric_definitions": null, - "azure.mgmt.sql.operations.DatabasesOperations.list_by_server": null, - "azure.mgmt.sql.aio.operations.DatabasesOperations.list_by_server": null, - "azure.mgmt.sql.operations.DatabasesOperations.get": null, - "azure.mgmt.sql.aio.operations.DatabasesOperations.get": null, - "azure.mgmt.sql.operations.DatabasesOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.DatabasesOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.DatabasesOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.DatabasesOperations.begin_delete": null, - "azure.mgmt.sql.operations.DatabasesOperations.begin_update": null, - "azure.mgmt.sql.aio.operations.DatabasesOperations.begin_update": null, - "azure.mgmt.sql.operations.DatabasesOperations.begin_export": null, - "azure.mgmt.sql.aio.operations.DatabasesOperations.begin_export": null, - "azure.mgmt.sql.operations.DatabasesOperations.begin_failover": null, - "azure.mgmt.sql.aio.operations.DatabasesOperations.begin_failover": null, - "azure.mgmt.sql.operations.DatabasesOperations.begin_import_method": null, - "azure.mgmt.sql.aio.operations.DatabasesOperations.begin_import_method": null, - "azure.mgmt.sql.operations.DatabasesOperations.rename": null, - "azure.mgmt.sql.aio.operations.DatabasesOperations.rename": null, - "azure.mgmt.sql.operations.DatabasesOperations.begin_pause": null, - "azure.mgmt.sql.aio.operations.DatabasesOperations.begin_pause": null, - "azure.mgmt.sql.operations.DatabasesOperations.begin_resume": null, - "azure.mgmt.sql.aio.operations.DatabasesOperations.begin_resume": null, - "azure.mgmt.sql.operations.DatabasesOperations.begin_upgrade_data_warehouse": null, - "azure.mgmt.sql.aio.operations.DatabasesOperations.begin_upgrade_data_warehouse": null, - "azure.mgmt.sql.operations.DatabasesOperations.list_by_elastic_pool": null, - "azure.mgmt.sql.aio.operations.DatabasesOperations.list_by_elastic_pool": null, - "azure.mgmt.sql.operations.DatabasesOperations.list_inaccessible_by_server": null, - "azure.mgmt.sql.aio.operations.DatabasesOperations.list_inaccessible_by_server": null, - "azure.mgmt.sql.operations.ElasticPoolsOperations.list_metrics": null, - "azure.mgmt.sql.aio.operations.ElasticPoolsOperations.list_metrics": null, - "azure.mgmt.sql.operations.ElasticPoolsOperations.list_metric_definitions": null, - "azure.mgmt.sql.aio.operations.ElasticPoolsOperations.list_metric_definitions": null, - "azure.mgmt.sql.operations.ElasticPoolsOperations.list_by_server": null, - "azure.mgmt.sql.aio.operations.ElasticPoolsOperations.list_by_server": null, - "azure.mgmt.sql.operations.ElasticPoolsOperations.get": null, - "azure.mgmt.sql.aio.operations.ElasticPoolsOperations.get": null, - "azure.mgmt.sql.operations.ElasticPoolsOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.ElasticPoolsOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.ElasticPoolsOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.ElasticPoolsOperations.begin_delete": null, - "azure.mgmt.sql.operations.ElasticPoolsOperations.begin_update": null, - "azure.mgmt.sql.aio.operations.ElasticPoolsOperations.begin_update": null, - "azure.mgmt.sql.operations.ElasticPoolsOperations.begin_failover": null, - "azure.mgmt.sql.aio.operations.ElasticPoolsOperations.begin_failover": null, - "azure.mgmt.sql.operations.ServerCommunicationLinksOperations.delete": null, - "azure.mgmt.sql.aio.operations.ServerCommunicationLinksOperations.delete": null, - "azure.mgmt.sql.operations.ServerCommunicationLinksOperations.get": null, - "azure.mgmt.sql.aio.operations.ServerCommunicationLinksOperations.get": null, - "azure.mgmt.sql.operations.ServerCommunicationLinksOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.ServerCommunicationLinksOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.ServerCommunicationLinksOperations.list_by_server": null, - "azure.mgmt.sql.aio.operations.ServerCommunicationLinksOperations.list_by_server": null, - "azure.mgmt.sql.operations.ServiceObjectivesOperations.get": null, - "azure.mgmt.sql.aio.operations.ServiceObjectivesOperations.get": null, - "azure.mgmt.sql.operations.ServiceObjectivesOperations.list_by_server": null, - "azure.mgmt.sql.aio.operations.ServiceObjectivesOperations.list_by_server": null, - "azure.mgmt.sql.operations.ElasticPoolActivitiesOperations.list_by_elastic_pool": null, - "azure.mgmt.sql.aio.operations.ElasticPoolActivitiesOperations.list_by_elastic_pool": null, - "azure.mgmt.sql.operations.ElasticPoolDatabaseActivitiesOperations.list_by_elastic_pool": null, - "azure.mgmt.sql.aio.operations.ElasticPoolDatabaseActivitiesOperations.list_by_elastic_pool": null, - "azure.mgmt.sql.operations.ServerUsagesOperations.list_by_server": null, - "azure.mgmt.sql.aio.operations.ServerUsagesOperations.list_by_server": null, - "azure.mgmt.sql.operations.DatabaseAdvisorsOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.DatabaseAdvisorsOperations.list_by_database": null, - "azure.mgmt.sql.operations.DatabaseAdvisorsOperations.get": null, - "azure.mgmt.sql.aio.operations.DatabaseAdvisorsOperations.get": null, - "azure.mgmt.sql.operations.DatabaseAdvisorsOperations.update": null, - "azure.mgmt.sql.aio.operations.DatabaseAdvisorsOperations.update": null, - "azure.mgmt.sql.operations.DatabaseAutomaticTuningOperations.get": null, - "azure.mgmt.sql.aio.operations.DatabaseAutomaticTuningOperations.get": null, - "azure.mgmt.sql.operations.DatabaseAutomaticTuningOperations.update": null, - "azure.mgmt.sql.aio.operations.DatabaseAutomaticTuningOperations.update": null, - "azure.mgmt.sql.operations.DatabaseColumnsOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.DatabaseColumnsOperations.list_by_database": null, - "azure.mgmt.sql.operations.DatabaseColumnsOperations.list_by_table": null, - "azure.mgmt.sql.aio.operations.DatabaseColumnsOperations.list_by_table": null, - "azure.mgmt.sql.operations.DatabaseColumnsOperations.get": null, - "azure.mgmt.sql.aio.operations.DatabaseColumnsOperations.get": null, - "azure.mgmt.sql.operations.DatabaseRecommendedActionsOperations.list_by_database_advisor": null, - "azure.mgmt.sql.aio.operations.DatabaseRecommendedActionsOperations.list_by_database_advisor": null, - "azure.mgmt.sql.operations.DatabaseRecommendedActionsOperations.get": null, - "azure.mgmt.sql.aio.operations.DatabaseRecommendedActionsOperations.get": null, - "azure.mgmt.sql.operations.DatabaseRecommendedActionsOperations.update": null, - "azure.mgmt.sql.aio.operations.DatabaseRecommendedActionsOperations.update": null, - "azure.mgmt.sql.operations.DatabaseSchemasOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.DatabaseSchemasOperations.list_by_database": null, - "azure.mgmt.sql.operations.DatabaseSchemasOperations.get": null, - "azure.mgmt.sql.aio.operations.DatabaseSchemasOperations.get": null, - "azure.mgmt.sql.operations.DatabaseSecurityAlertPoliciesOperations.get": null, - "azure.mgmt.sql.aio.operations.DatabaseSecurityAlertPoliciesOperations.get": null, - "azure.mgmt.sql.operations.DatabaseSecurityAlertPoliciesOperations.create_or_update": null, - "azure.mgmt.sql.aio.operations.DatabaseSecurityAlertPoliciesOperations.create_or_update": null, - "azure.mgmt.sql.operations.DatabaseSecurityAlertPoliciesOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.DatabaseSecurityAlertPoliciesOperations.list_by_database": null, - "azure.mgmt.sql.operations.DatabaseTablesOperations.list_by_schema": null, - "azure.mgmt.sql.aio.operations.DatabaseTablesOperations.list_by_schema": null, - "azure.mgmt.sql.operations.DatabaseTablesOperations.get": null, - "azure.mgmt.sql.aio.operations.DatabaseTablesOperations.get": null, - "azure.mgmt.sql.operations.DatabaseVulnerabilityAssessmentRuleBaselinesOperations.get": null, - "azure.mgmt.sql.aio.operations.DatabaseVulnerabilityAssessmentRuleBaselinesOperations.get": null, - "azure.mgmt.sql.operations.DatabaseVulnerabilityAssessmentRuleBaselinesOperations.create_or_update": null, - "azure.mgmt.sql.aio.operations.DatabaseVulnerabilityAssessmentRuleBaselinesOperations.create_or_update": null, - "azure.mgmt.sql.operations.DatabaseVulnerabilityAssessmentRuleBaselinesOperations.delete": null, - "azure.mgmt.sql.aio.operations.DatabaseVulnerabilityAssessmentRuleBaselinesOperations.delete": null, - "azure.mgmt.sql.operations.DatabaseVulnerabilityAssessmentsOperations.get": null, - "azure.mgmt.sql.aio.operations.DatabaseVulnerabilityAssessmentsOperations.get": null, - "azure.mgmt.sql.operations.DatabaseVulnerabilityAssessmentsOperations.create_or_update": null, - "azure.mgmt.sql.aio.operations.DatabaseVulnerabilityAssessmentsOperations.create_or_update": null, - "azure.mgmt.sql.operations.DatabaseVulnerabilityAssessmentsOperations.delete": null, - "azure.mgmt.sql.aio.operations.DatabaseVulnerabilityAssessmentsOperations.delete": null, - "azure.mgmt.sql.operations.DatabaseVulnerabilityAssessmentsOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.DatabaseVulnerabilityAssessmentsOperations.list_by_database": null, - "azure.mgmt.sql.operations.DatabaseVulnerabilityAssessmentScansOperations.begin_initiate_scan": null, - "azure.mgmt.sql.aio.operations.DatabaseVulnerabilityAssessmentScansOperations.begin_initiate_scan": null, - "azure.mgmt.sql.operations.DatabaseVulnerabilityAssessmentScansOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.DatabaseVulnerabilityAssessmentScansOperations.list_by_database": null, - "azure.mgmt.sql.operations.DatabaseVulnerabilityAssessmentScansOperations.get": null, - "azure.mgmt.sql.aio.operations.DatabaseVulnerabilityAssessmentScansOperations.get": null, - "azure.mgmt.sql.operations.DatabaseVulnerabilityAssessmentScansOperations.export": null, - "azure.mgmt.sql.aio.operations.DatabaseVulnerabilityAssessmentScansOperations.export": null, - "azure.mgmt.sql.operations.DataWarehouseUserActivitiesOperations.get": null, - "azure.mgmt.sql.aio.operations.DataWarehouseUserActivitiesOperations.get": null, - "azure.mgmt.sql.operations.DataWarehouseUserActivitiesOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.DataWarehouseUserActivitiesOperations.list_by_database": null, - "azure.mgmt.sql.operations.DeletedServersOperations.list": null, - "azure.mgmt.sql.aio.operations.DeletedServersOperations.list": null, - "azure.mgmt.sql.operations.DeletedServersOperations.get": null, - "azure.mgmt.sql.aio.operations.DeletedServersOperations.get": null, - "azure.mgmt.sql.operations.DeletedServersOperations.list_by_location": null, - "azure.mgmt.sql.aio.operations.DeletedServersOperations.list_by_location": null, - "azure.mgmt.sql.operations.DeletedServersOperations.begin_recover": null, - "azure.mgmt.sql.aio.operations.DeletedServersOperations.begin_recover": null, - "azure.mgmt.sql.operations.ElasticPoolOperationsOperations.cancel": null, - "azure.mgmt.sql.aio.operations.ElasticPoolOperationsOperations.cancel": null, - "azure.mgmt.sql.operations.ElasticPoolOperationsOperations.list_by_elastic_pool": null, - "azure.mgmt.sql.aio.operations.ElasticPoolOperationsOperations.list_by_elastic_pool": null, - "azure.mgmt.sql.operations.EncryptionProtectorsOperations.list_by_server": null, - "azure.mgmt.sql.aio.operations.EncryptionProtectorsOperations.list_by_server": null, - "azure.mgmt.sql.operations.EncryptionProtectorsOperations.get": null, - "azure.mgmt.sql.aio.operations.EncryptionProtectorsOperations.get": null, - "azure.mgmt.sql.operations.EncryptionProtectorsOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.EncryptionProtectorsOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.EncryptionProtectorsOperations.begin_revalidate": null, - "azure.mgmt.sql.aio.operations.EncryptionProtectorsOperations.begin_revalidate": null, - "azure.mgmt.sql.operations.FirewallRulesOperations.get": null, - "azure.mgmt.sql.aio.operations.FirewallRulesOperations.get": null, - "azure.mgmt.sql.operations.FirewallRulesOperations.create_or_update": null, - "azure.mgmt.sql.aio.operations.FirewallRulesOperations.create_or_update": null, - "azure.mgmt.sql.operations.FirewallRulesOperations.delete": null, - "azure.mgmt.sql.aio.operations.FirewallRulesOperations.delete": null, - "azure.mgmt.sql.operations.FirewallRulesOperations.list_by_server": null, - "azure.mgmt.sql.aio.operations.FirewallRulesOperations.list_by_server": null, - "azure.mgmt.sql.operations.FirewallRulesOperations.replace": null, - "azure.mgmt.sql.aio.operations.FirewallRulesOperations.replace": null, - "azure.mgmt.sql.operations.JobAgentsOperations.list_by_server": null, - "azure.mgmt.sql.aio.operations.JobAgentsOperations.list_by_server": null, - "azure.mgmt.sql.operations.JobAgentsOperations.get": null, - "azure.mgmt.sql.aio.operations.JobAgentsOperations.get": null, - "azure.mgmt.sql.operations.JobAgentsOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.JobAgentsOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.JobAgentsOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.JobAgentsOperations.begin_delete": null, - "azure.mgmt.sql.operations.JobAgentsOperations.begin_update": null, - "azure.mgmt.sql.aio.operations.JobAgentsOperations.begin_update": null, - "azure.mgmt.sql.operations.JobCredentialsOperations.list_by_agent": null, - "azure.mgmt.sql.aio.operations.JobCredentialsOperations.list_by_agent": null, - "azure.mgmt.sql.operations.JobCredentialsOperations.get": null, - "azure.mgmt.sql.aio.operations.JobCredentialsOperations.get": null, - "azure.mgmt.sql.operations.JobCredentialsOperations.create_or_update": null, - "azure.mgmt.sql.aio.operations.JobCredentialsOperations.create_or_update": null, - "azure.mgmt.sql.operations.JobCredentialsOperations.delete": null, - "azure.mgmt.sql.aio.operations.JobCredentialsOperations.delete": null, - "azure.mgmt.sql.operations.JobExecutionsOperations.list_by_agent": null, - "azure.mgmt.sql.aio.operations.JobExecutionsOperations.list_by_agent": null, - "azure.mgmt.sql.operations.JobExecutionsOperations.cancel": null, - "azure.mgmt.sql.aio.operations.JobExecutionsOperations.cancel": null, - "azure.mgmt.sql.operations.JobExecutionsOperations.begin_create": null, - "azure.mgmt.sql.aio.operations.JobExecutionsOperations.begin_create": null, - "azure.mgmt.sql.operations.JobExecutionsOperations.list_by_job": null, - "azure.mgmt.sql.aio.operations.JobExecutionsOperations.list_by_job": null, - "azure.mgmt.sql.operations.JobExecutionsOperations.get": null, - "azure.mgmt.sql.aio.operations.JobExecutionsOperations.get": null, - "azure.mgmt.sql.operations.JobExecutionsOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.JobExecutionsOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.JobPrivateEndpointsOperations.list_by_agent": null, - "azure.mgmt.sql.aio.operations.JobPrivateEndpointsOperations.list_by_agent": null, - "azure.mgmt.sql.operations.JobPrivateEndpointsOperations.get": null, - "azure.mgmt.sql.aio.operations.JobPrivateEndpointsOperations.get": null, - "azure.mgmt.sql.operations.JobPrivateEndpointsOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.JobPrivateEndpointsOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.JobPrivateEndpointsOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.JobPrivateEndpointsOperations.begin_delete": null, - "azure.mgmt.sql.operations.JobsOperations.list_by_agent": null, - "azure.mgmt.sql.aio.operations.JobsOperations.list_by_agent": null, - "azure.mgmt.sql.operations.JobsOperations.get": null, - "azure.mgmt.sql.aio.operations.JobsOperations.get": null, - "azure.mgmt.sql.operations.JobsOperations.create_or_update": null, - "azure.mgmt.sql.aio.operations.JobsOperations.create_or_update": null, - "azure.mgmt.sql.operations.JobsOperations.delete": null, - "azure.mgmt.sql.aio.operations.JobsOperations.delete": null, - "azure.mgmt.sql.operations.JobStepExecutionsOperations.list_by_job_execution": null, - "azure.mgmt.sql.aio.operations.JobStepExecutionsOperations.list_by_job_execution": null, - "azure.mgmt.sql.operations.JobStepExecutionsOperations.get": null, - "azure.mgmt.sql.aio.operations.JobStepExecutionsOperations.get": null, - "azure.mgmt.sql.operations.JobStepsOperations.list_by_version": null, - "azure.mgmt.sql.aio.operations.JobStepsOperations.list_by_version": null, - "azure.mgmt.sql.operations.JobStepsOperations.get_by_version": null, - "azure.mgmt.sql.aio.operations.JobStepsOperations.get_by_version": null, - "azure.mgmt.sql.operations.JobStepsOperations.list_by_job": null, - "azure.mgmt.sql.aio.operations.JobStepsOperations.list_by_job": null, - "azure.mgmt.sql.operations.JobStepsOperations.get": null, - "azure.mgmt.sql.aio.operations.JobStepsOperations.get": null, - "azure.mgmt.sql.operations.JobStepsOperations.create_or_update": null, - "azure.mgmt.sql.aio.operations.JobStepsOperations.create_or_update": null, - "azure.mgmt.sql.operations.JobStepsOperations.delete": null, - "azure.mgmt.sql.aio.operations.JobStepsOperations.delete": null, - "azure.mgmt.sql.operations.JobTargetExecutionsOperations.list_by_job_execution": null, - "azure.mgmt.sql.aio.operations.JobTargetExecutionsOperations.list_by_job_execution": null, - "azure.mgmt.sql.operations.JobTargetExecutionsOperations.list_by_step": null, - "azure.mgmt.sql.aio.operations.JobTargetExecutionsOperations.list_by_step": null, - "azure.mgmt.sql.operations.JobTargetExecutionsOperations.get": null, - "azure.mgmt.sql.aio.operations.JobTargetExecutionsOperations.get": null, - "azure.mgmt.sql.operations.JobTargetGroupsOperations.list_by_agent": null, - "azure.mgmt.sql.aio.operations.JobTargetGroupsOperations.list_by_agent": null, - "azure.mgmt.sql.operations.JobTargetGroupsOperations.get": null, - "azure.mgmt.sql.aio.operations.JobTargetGroupsOperations.get": null, - "azure.mgmt.sql.operations.JobTargetGroupsOperations.create_or_update": null, - "azure.mgmt.sql.aio.operations.JobTargetGroupsOperations.create_or_update": null, - "azure.mgmt.sql.operations.JobTargetGroupsOperations.delete": null, - "azure.mgmt.sql.aio.operations.JobTargetGroupsOperations.delete": null, - "azure.mgmt.sql.operations.JobVersionsOperations.list_by_job": null, - "azure.mgmt.sql.aio.operations.JobVersionsOperations.list_by_job": null, - "azure.mgmt.sql.operations.JobVersionsOperations.get": null, - "azure.mgmt.sql.aio.operations.JobVersionsOperations.get": null, - "azure.mgmt.sql.operations.CapabilitiesOperations.list_by_location": null, - "azure.mgmt.sql.aio.operations.CapabilitiesOperations.list_by_location": null, - "azure.mgmt.sql.operations.MaintenanceWindowOptionsOperations.get": null, - "azure.mgmt.sql.aio.operations.MaintenanceWindowOptionsOperations.get": null, - "azure.mgmt.sql.operations.MaintenanceWindowsOperations.get": null, - "azure.mgmt.sql.aio.operations.MaintenanceWindowsOperations.get": null, - "azure.mgmt.sql.operations.MaintenanceWindowsOperations.create_or_update": null, - "azure.mgmt.sql.aio.operations.MaintenanceWindowsOperations.create_or_update": null, - "azure.mgmt.sql.operations.ManagedBackupShortTermRetentionPoliciesOperations.get": null, - "azure.mgmt.sql.aio.operations.ManagedBackupShortTermRetentionPoliciesOperations.get": null, - "azure.mgmt.sql.operations.ManagedBackupShortTermRetentionPoliciesOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.ManagedBackupShortTermRetentionPoliciesOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.ManagedBackupShortTermRetentionPoliciesOperations.begin_update": null, - "azure.mgmt.sql.aio.operations.ManagedBackupShortTermRetentionPoliciesOperations.begin_update": null, - "azure.mgmt.sql.operations.ManagedBackupShortTermRetentionPoliciesOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.ManagedBackupShortTermRetentionPoliciesOperations.list_by_database": null, - "azure.mgmt.sql.operations.ManagedDatabaseColumnsOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseColumnsOperations.list_by_database": null, - "azure.mgmt.sql.operations.ManagedDatabaseColumnsOperations.list_by_table": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseColumnsOperations.list_by_table": null, - "azure.mgmt.sql.operations.ManagedDatabaseColumnsOperations.get": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseColumnsOperations.get": null, - "azure.mgmt.sql.operations.ManagedDatabaseQueriesOperations.get": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseQueriesOperations.get": null, - "azure.mgmt.sql.operations.ManagedDatabaseQueriesOperations.list_by_query": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseQueriesOperations.list_by_query": null, - "azure.mgmt.sql.operations.ManagedDatabaseSchemasOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseSchemasOperations.list_by_database": null, - "azure.mgmt.sql.operations.ManagedDatabaseSchemasOperations.get": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseSchemasOperations.get": null, - "azure.mgmt.sql.operations.ManagedDatabaseSecurityAlertPoliciesOperations.get": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseSecurityAlertPoliciesOperations.get": null, - "azure.mgmt.sql.operations.ManagedDatabaseSecurityAlertPoliciesOperations.create_or_update": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseSecurityAlertPoliciesOperations.create_or_update": null, - "azure.mgmt.sql.operations.ManagedDatabaseSecurityAlertPoliciesOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseSecurityAlertPoliciesOperations.list_by_database": null, - "azure.mgmt.sql.operations.ManagedDatabaseSecurityEventsOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseSecurityEventsOperations.list_by_database": null, - "azure.mgmt.sql.operations.ManagedDatabaseTablesOperations.list_by_schema": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseTablesOperations.list_by_schema": null, - "azure.mgmt.sql.operations.ManagedDatabaseTablesOperations.get": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseTablesOperations.get": null, - "azure.mgmt.sql.operations.ManagedDatabaseTransparentDataEncryptionOperations.get": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseTransparentDataEncryptionOperations.get": null, - "azure.mgmt.sql.operations.ManagedDatabaseTransparentDataEncryptionOperations.create_or_update": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseTransparentDataEncryptionOperations.create_or_update": null, - "azure.mgmt.sql.operations.ManagedDatabaseTransparentDataEncryptionOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseTransparentDataEncryptionOperations.list_by_database": null, - "azure.mgmt.sql.operations.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations.get": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations.get": null, - "azure.mgmt.sql.operations.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations.create_or_update": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations.create_or_update": null, - "azure.mgmt.sql.operations.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations.delete": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations.delete": null, - "azure.mgmt.sql.operations.ManagedDatabaseVulnerabilityAssessmentsOperations.get": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseVulnerabilityAssessmentsOperations.get": null, - "azure.mgmt.sql.operations.ManagedDatabaseVulnerabilityAssessmentsOperations.create_or_update": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseVulnerabilityAssessmentsOperations.create_or_update": null, - "azure.mgmt.sql.operations.ManagedDatabaseVulnerabilityAssessmentsOperations.delete": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseVulnerabilityAssessmentsOperations.delete": null, - "azure.mgmt.sql.operations.ManagedDatabaseVulnerabilityAssessmentsOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseVulnerabilityAssessmentsOperations.list_by_database": null, - "azure.mgmt.sql.operations.ManagedDatabaseVulnerabilityAssessmentScansOperations.begin_initiate_scan": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseVulnerabilityAssessmentScansOperations.begin_initiate_scan": null, - "azure.mgmt.sql.operations.ManagedDatabaseVulnerabilityAssessmentScansOperations.export": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseVulnerabilityAssessmentScansOperations.export": null, - "azure.mgmt.sql.operations.ManagedDatabaseVulnerabilityAssessmentScansOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseVulnerabilityAssessmentScansOperations.list_by_database": null, - "azure.mgmt.sql.operations.ManagedDatabaseVulnerabilityAssessmentScansOperations.get": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseVulnerabilityAssessmentScansOperations.get": null, - "azure.mgmt.sql.operations.ManagedInstanceAdministratorsOperations.list_by_instance": null, - "azure.mgmt.sql.aio.operations.ManagedInstanceAdministratorsOperations.list_by_instance": null, - "azure.mgmt.sql.operations.ManagedInstanceAdministratorsOperations.get": null, - "azure.mgmt.sql.aio.operations.ManagedInstanceAdministratorsOperations.get": null, - "azure.mgmt.sql.operations.ManagedInstanceAdministratorsOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.ManagedInstanceAdministratorsOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.ManagedInstanceAdministratorsOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.ManagedInstanceAdministratorsOperations.begin_delete": null, - "azure.mgmt.sql.operations.ManagedInstanceAzureADOnlyAuthenticationsOperations.get": null, - "azure.mgmt.sql.aio.operations.ManagedInstanceAzureADOnlyAuthenticationsOperations.get": null, - "azure.mgmt.sql.operations.ManagedInstanceAzureADOnlyAuthenticationsOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.ManagedInstanceAzureADOnlyAuthenticationsOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.ManagedInstanceAzureADOnlyAuthenticationsOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.ManagedInstanceAzureADOnlyAuthenticationsOperations.begin_delete": null, - "azure.mgmt.sql.operations.ManagedInstanceAzureADOnlyAuthenticationsOperations.list_by_instance": null, - "azure.mgmt.sql.aio.operations.ManagedInstanceAzureADOnlyAuthenticationsOperations.list_by_instance": null, - "azure.mgmt.sql.operations.ManagedInstanceEncryptionProtectorsOperations.begin_revalidate": null, - "azure.mgmt.sql.aio.operations.ManagedInstanceEncryptionProtectorsOperations.begin_revalidate": null, - "azure.mgmt.sql.operations.ManagedInstanceEncryptionProtectorsOperations.list_by_instance": null, - "azure.mgmt.sql.aio.operations.ManagedInstanceEncryptionProtectorsOperations.list_by_instance": null, - "azure.mgmt.sql.operations.ManagedInstanceEncryptionProtectorsOperations.get": null, - "azure.mgmt.sql.aio.operations.ManagedInstanceEncryptionProtectorsOperations.get": null, - "azure.mgmt.sql.operations.ManagedInstanceEncryptionProtectorsOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.ManagedInstanceEncryptionProtectorsOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.ManagedInstanceKeysOperations.list_by_instance": null, - "azure.mgmt.sql.aio.operations.ManagedInstanceKeysOperations.list_by_instance": null, - "azure.mgmt.sql.operations.ManagedInstanceKeysOperations.get": null, - "azure.mgmt.sql.aio.operations.ManagedInstanceKeysOperations.get": null, - "azure.mgmt.sql.operations.ManagedInstanceKeysOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.ManagedInstanceKeysOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.ManagedInstanceKeysOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.ManagedInstanceKeysOperations.begin_delete": null, - "azure.mgmt.sql.operations.ManagedInstanceLongTermRetentionPoliciesOperations.get": null, - "azure.mgmt.sql.aio.operations.ManagedInstanceLongTermRetentionPoliciesOperations.get": null, - "azure.mgmt.sql.operations.ManagedInstanceLongTermRetentionPoliciesOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.ManagedInstanceLongTermRetentionPoliciesOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.ManagedInstanceLongTermRetentionPoliciesOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.ManagedInstanceLongTermRetentionPoliciesOperations.list_by_database": null, - "azure.mgmt.sql.operations.ManagedInstanceOperationsOperations.list_by_managed_instance": null, - "azure.mgmt.sql.aio.operations.ManagedInstanceOperationsOperations.list_by_managed_instance": null, - "azure.mgmt.sql.operations.ManagedInstanceOperationsOperations.get": null, - "azure.mgmt.sql.aio.operations.ManagedInstanceOperationsOperations.get": null, - "azure.mgmt.sql.operations.ManagedInstanceOperationsOperations.cancel": null, - "azure.mgmt.sql.aio.operations.ManagedInstanceOperationsOperations.cancel": null, - "azure.mgmt.sql.operations.ManagedInstancePrivateEndpointConnectionsOperations.get": null, - "azure.mgmt.sql.aio.operations.ManagedInstancePrivateEndpointConnectionsOperations.get": null, - "azure.mgmt.sql.operations.ManagedInstancePrivateEndpointConnectionsOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.ManagedInstancePrivateEndpointConnectionsOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.ManagedInstancePrivateEndpointConnectionsOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.ManagedInstancePrivateEndpointConnectionsOperations.begin_delete": null, - "azure.mgmt.sql.operations.ManagedInstancePrivateEndpointConnectionsOperations.list_by_managed_instance": null, - "azure.mgmt.sql.aio.operations.ManagedInstancePrivateEndpointConnectionsOperations.list_by_managed_instance": null, - "azure.mgmt.sql.operations.ManagedInstancePrivateLinkResourcesOperations.list_by_managed_instance": null, - "azure.mgmt.sql.aio.operations.ManagedInstancePrivateLinkResourcesOperations.list_by_managed_instance": null, - "azure.mgmt.sql.operations.ManagedInstancePrivateLinkResourcesOperations.get": null, - "azure.mgmt.sql.aio.operations.ManagedInstancePrivateLinkResourcesOperations.get": null, - "azure.mgmt.sql.operations.ManagedInstanceTdeCertificatesOperations.begin_create": null, - "azure.mgmt.sql.aio.operations.ManagedInstanceTdeCertificatesOperations.begin_create": null, - "azure.mgmt.sql.operations.ManagedInstanceVulnerabilityAssessmentsOperations.get": null, - "azure.mgmt.sql.aio.operations.ManagedInstanceVulnerabilityAssessmentsOperations.get": null, - "azure.mgmt.sql.operations.ManagedInstanceVulnerabilityAssessmentsOperations.create_or_update": null, - "azure.mgmt.sql.aio.operations.ManagedInstanceVulnerabilityAssessmentsOperations.create_or_update": null, - "azure.mgmt.sql.operations.ManagedInstanceVulnerabilityAssessmentsOperations.delete": null, - "azure.mgmt.sql.aio.operations.ManagedInstanceVulnerabilityAssessmentsOperations.delete": null, - "azure.mgmt.sql.operations.ManagedInstanceVulnerabilityAssessmentsOperations.list_by_instance": null, - "azure.mgmt.sql.aio.operations.ManagedInstanceVulnerabilityAssessmentsOperations.list_by_instance": null, - "azure.mgmt.sql.operations.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations.get": null, - "azure.mgmt.sql.aio.operations.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations.get": null, - "azure.mgmt.sql.operations.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations.begin_update": null, - "azure.mgmt.sql.aio.operations.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations.begin_update": null, - "azure.mgmt.sql.operations.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations.list_by_restorable_dropped_database": null, - "azure.mgmt.sql.aio.operations.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations.list_by_restorable_dropped_database": null, - "azure.mgmt.sql.operations.ManagedServerSecurityAlertPoliciesOperations.get": null, - "azure.mgmt.sql.aio.operations.ManagedServerSecurityAlertPoliciesOperations.get": null, - "azure.mgmt.sql.operations.ManagedServerSecurityAlertPoliciesOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.ManagedServerSecurityAlertPoliciesOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.ManagedServerSecurityAlertPoliciesOperations.list_by_instance": null, - "azure.mgmt.sql.aio.operations.ManagedServerSecurityAlertPoliciesOperations.list_by_instance": null, - "azure.mgmt.sql.operations.Operations.list": null, - "azure.mgmt.sql.aio.operations.Operations.list": null, - "azure.mgmt.sql.operations.PrivateEndpointConnectionsOperations.list_by_server": null, - "azure.mgmt.sql.aio.operations.PrivateEndpointConnectionsOperations.list_by_server": null, - "azure.mgmt.sql.operations.PrivateEndpointConnectionsOperations.get": null, - "azure.mgmt.sql.aio.operations.PrivateEndpointConnectionsOperations.get": null, - "azure.mgmt.sql.operations.PrivateEndpointConnectionsOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.PrivateEndpointConnectionsOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.PrivateEndpointConnectionsOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.PrivateEndpointConnectionsOperations.begin_delete": null, - "azure.mgmt.sql.operations.PrivateLinkResourcesOperations.list_by_server": null, - "azure.mgmt.sql.aio.operations.PrivateLinkResourcesOperations.list_by_server": null, - "azure.mgmt.sql.operations.PrivateLinkResourcesOperations.get": null, - "azure.mgmt.sql.aio.operations.PrivateLinkResourcesOperations.get": null, - "azure.mgmt.sql.operations.RecoverableManagedDatabasesOperations.list_by_instance": null, - "azure.mgmt.sql.aio.operations.RecoverableManagedDatabasesOperations.list_by_instance": null, - "azure.mgmt.sql.operations.RecoverableManagedDatabasesOperations.get": null, - "azure.mgmt.sql.aio.operations.RecoverableManagedDatabasesOperations.get": null, - "azure.mgmt.sql.operations.RestorePointsOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.RestorePointsOperations.list_by_database": null, - "azure.mgmt.sql.operations.RestorePointsOperations.begin_create": null, - "azure.mgmt.sql.aio.operations.RestorePointsOperations.begin_create": null, - "azure.mgmt.sql.operations.RestorePointsOperations.get": null, - "azure.mgmt.sql.aio.operations.RestorePointsOperations.get": null, - "azure.mgmt.sql.operations.RestorePointsOperations.delete": null, - "azure.mgmt.sql.aio.operations.RestorePointsOperations.delete": null, - "azure.mgmt.sql.operations.ServerAdvisorsOperations.list_by_server": null, - "azure.mgmt.sql.aio.operations.ServerAdvisorsOperations.list_by_server": null, - "azure.mgmt.sql.operations.ServerAdvisorsOperations.get": null, - "azure.mgmt.sql.aio.operations.ServerAdvisorsOperations.get": null, - "azure.mgmt.sql.operations.ServerAdvisorsOperations.update": null, - "azure.mgmt.sql.aio.operations.ServerAdvisorsOperations.update": null, - "azure.mgmt.sql.operations.ServerAutomaticTuningOperations.get": null, - "azure.mgmt.sql.aio.operations.ServerAutomaticTuningOperations.get": null, - "azure.mgmt.sql.operations.ServerAutomaticTuningOperations.update": null, - "azure.mgmt.sql.aio.operations.ServerAutomaticTuningOperations.update": null, - "azure.mgmt.sql.operations.ServerAzureADAdministratorsOperations.get": null, - "azure.mgmt.sql.aio.operations.ServerAzureADAdministratorsOperations.get": null, - "azure.mgmt.sql.operations.ServerAzureADAdministratorsOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.ServerAzureADAdministratorsOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.ServerAzureADAdministratorsOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.ServerAzureADAdministratorsOperations.begin_delete": null, - "azure.mgmt.sql.operations.ServerAzureADAdministratorsOperations.list_by_server": null, - "azure.mgmt.sql.aio.operations.ServerAzureADAdministratorsOperations.list_by_server": null, - "azure.mgmt.sql.operations.ServerAzureADOnlyAuthenticationsOperations.get": null, - "azure.mgmt.sql.aio.operations.ServerAzureADOnlyAuthenticationsOperations.get": null, - "azure.mgmt.sql.operations.ServerAzureADOnlyAuthenticationsOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.ServerAzureADOnlyAuthenticationsOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.ServerAzureADOnlyAuthenticationsOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.ServerAzureADOnlyAuthenticationsOperations.begin_delete": null, - "azure.mgmt.sql.operations.ServerAzureADOnlyAuthenticationsOperations.list_by_server": null, - "azure.mgmt.sql.aio.operations.ServerAzureADOnlyAuthenticationsOperations.list_by_server": null, - "azure.mgmt.sql.operations.ServerDevOpsAuditSettingsOperations.list_by_server": null, - "azure.mgmt.sql.aio.operations.ServerDevOpsAuditSettingsOperations.list_by_server": null, - "azure.mgmt.sql.operations.ServerDevOpsAuditSettingsOperations.get": null, - "azure.mgmt.sql.aio.operations.ServerDevOpsAuditSettingsOperations.get": null, - "azure.mgmt.sql.operations.ServerDevOpsAuditSettingsOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.ServerDevOpsAuditSettingsOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.ServerDnsAliasesOperations.get": null, - "azure.mgmt.sql.aio.operations.ServerDnsAliasesOperations.get": null, - "azure.mgmt.sql.operations.ServerDnsAliasesOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.ServerDnsAliasesOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.ServerDnsAliasesOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.ServerDnsAliasesOperations.begin_delete": null, - "azure.mgmt.sql.operations.ServerDnsAliasesOperations.list_by_server": null, - "azure.mgmt.sql.aio.operations.ServerDnsAliasesOperations.list_by_server": null, - "azure.mgmt.sql.operations.ServerDnsAliasesOperations.begin_acquire": null, - "azure.mgmt.sql.aio.operations.ServerDnsAliasesOperations.begin_acquire": null, - "azure.mgmt.sql.operations.ServerKeysOperations.list_by_server": null, - "azure.mgmt.sql.aio.operations.ServerKeysOperations.list_by_server": null, - "azure.mgmt.sql.operations.ServerKeysOperations.get": null, - "azure.mgmt.sql.aio.operations.ServerKeysOperations.get": null, - "azure.mgmt.sql.operations.ServerKeysOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.ServerKeysOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.ServerKeysOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.ServerKeysOperations.begin_delete": null, - "azure.mgmt.sql.operations.ServerOperationsOperations.list_by_server": null, - "azure.mgmt.sql.aio.operations.ServerOperationsOperations.list_by_server": null, - "azure.mgmt.sql.operations.ServerSecurityAlertPoliciesOperations.get": null, - "azure.mgmt.sql.aio.operations.ServerSecurityAlertPoliciesOperations.get": null, - "azure.mgmt.sql.operations.ServerSecurityAlertPoliciesOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.ServerSecurityAlertPoliciesOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.ServerSecurityAlertPoliciesOperations.list_by_server": null, - "azure.mgmt.sql.aio.operations.ServerSecurityAlertPoliciesOperations.list_by_server": null, - "azure.mgmt.sql.operations.ServerTrustGroupsOperations.get": null, - "azure.mgmt.sql.aio.operations.ServerTrustGroupsOperations.get": null, - "azure.mgmt.sql.operations.ServerTrustGroupsOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.ServerTrustGroupsOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.ServerTrustGroupsOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.ServerTrustGroupsOperations.begin_delete": null, - "azure.mgmt.sql.operations.ServerTrustGroupsOperations.list_by_location": null, - "azure.mgmt.sql.aio.operations.ServerTrustGroupsOperations.list_by_location": null, - "azure.mgmt.sql.operations.ServerTrustGroupsOperations.list_by_instance": null, - "azure.mgmt.sql.aio.operations.ServerTrustGroupsOperations.list_by_instance": null, - "azure.mgmt.sql.operations.ServerVulnerabilityAssessmentsOperations.get": null, - "azure.mgmt.sql.aio.operations.ServerVulnerabilityAssessmentsOperations.get": null, - "azure.mgmt.sql.operations.ServerVulnerabilityAssessmentsOperations.create_or_update": null, - "azure.mgmt.sql.aio.operations.ServerVulnerabilityAssessmentsOperations.create_or_update": null, - "azure.mgmt.sql.operations.ServerVulnerabilityAssessmentsOperations.delete": null, - "azure.mgmt.sql.aio.operations.ServerVulnerabilityAssessmentsOperations.delete": null, - "azure.mgmt.sql.operations.ServerVulnerabilityAssessmentsOperations.list_by_server": null, - "azure.mgmt.sql.aio.operations.ServerVulnerabilityAssessmentsOperations.list_by_server": null, - "azure.mgmt.sql.operations.SqlAgentOperations.get": null, - "azure.mgmt.sql.aio.operations.SqlAgentOperations.get": null, - "azure.mgmt.sql.operations.SqlAgentOperations.create_or_update": null, - "azure.mgmt.sql.aio.operations.SqlAgentOperations.create_or_update": null, - "azure.mgmt.sql.operations.SubscriptionUsagesOperations.list_by_location": null, - "azure.mgmt.sql.aio.operations.SubscriptionUsagesOperations.list_by_location": null, - "azure.mgmt.sql.operations.SubscriptionUsagesOperations.get": null, - "azure.mgmt.sql.aio.operations.SubscriptionUsagesOperations.get": null, - "azure.mgmt.sql.operations.SyncAgentsOperations.get": null, - "azure.mgmt.sql.aio.operations.SyncAgentsOperations.get": null, - "azure.mgmt.sql.operations.SyncAgentsOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.SyncAgentsOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.SyncAgentsOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.SyncAgentsOperations.begin_delete": null, - "azure.mgmt.sql.operations.SyncAgentsOperations.list_by_server": null, - "azure.mgmt.sql.aio.operations.SyncAgentsOperations.list_by_server": null, - "azure.mgmt.sql.operations.SyncAgentsOperations.generate_key": null, - "azure.mgmt.sql.aio.operations.SyncAgentsOperations.generate_key": null, - "azure.mgmt.sql.operations.SyncAgentsOperations.list_linked_databases": null, - "azure.mgmt.sql.aio.operations.SyncAgentsOperations.list_linked_databases": null, - "azure.mgmt.sql.operations.SyncGroupsOperations.list_sync_database_ids": null, - "azure.mgmt.sql.aio.operations.SyncGroupsOperations.list_sync_database_ids": null, - "azure.mgmt.sql.operations.SyncGroupsOperations.begin_refresh_hub_schema": null, - "azure.mgmt.sql.aio.operations.SyncGroupsOperations.begin_refresh_hub_schema": null, - "azure.mgmt.sql.operations.SyncGroupsOperations.list_hub_schemas": null, - "azure.mgmt.sql.aio.operations.SyncGroupsOperations.list_hub_schemas": null, - "azure.mgmt.sql.operations.SyncGroupsOperations.list_logs": null, - "azure.mgmt.sql.aio.operations.SyncGroupsOperations.list_logs": null, - "azure.mgmt.sql.operations.SyncGroupsOperations.cancel_sync": null, - "azure.mgmt.sql.aio.operations.SyncGroupsOperations.cancel_sync": null, - "azure.mgmt.sql.operations.SyncGroupsOperations.trigger_sync": null, - "azure.mgmt.sql.aio.operations.SyncGroupsOperations.trigger_sync": null, - "azure.mgmt.sql.operations.SyncGroupsOperations.get": null, - "azure.mgmt.sql.aio.operations.SyncGroupsOperations.get": null, - "azure.mgmt.sql.operations.SyncGroupsOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.SyncGroupsOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.SyncGroupsOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.SyncGroupsOperations.begin_delete": null, - "azure.mgmt.sql.operations.SyncGroupsOperations.begin_update": null, - "azure.mgmt.sql.aio.operations.SyncGroupsOperations.begin_update": null, - "azure.mgmt.sql.operations.SyncGroupsOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.SyncGroupsOperations.list_by_database": null, - "azure.mgmt.sql.operations.SyncMembersOperations.get": null, - "azure.mgmt.sql.aio.operations.SyncMembersOperations.get": null, - "azure.mgmt.sql.operations.SyncMembersOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.SyncMembersOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.SyncMembersOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.SyncMembersOperations.begin_delete": null, - "azure.mgmt.sql.operations.SyncMembersOperations.begin_update": null, - "azure.mgmt.sql.aio.operations.SyncMembersOperations.begin_update": null, - "azure.mgmt.sql.operations.SyncMembersOperations.list_by_sync_group": null, - "azure.mgmt.sql.aio.operations.SyncMembersOperations.list_by_sync_group": null, - "azure.mgmt.sql.operations.SyncMembersOperations.list_member_schemas": null, - "azure.mgmt.sql.aio.operations.SyncMembersOperations.list_member_schemas": null, - "azure.mgmt.sql.operations.SyncMembersOperations.begin_refresh_member_schema": null, - "azure.mgmt.sql.aio.operations.SyncMembersOperations.begin_refresh_member_schema": null, - "azure.mgmt.sql.operations.TdeCertificatesOperations.begin_create": null, - "azure.mgmt.sql.aio.operations.TdeCertificatesOperations.begin_create": null, - "azure.mgmt.sql.operations.TimeZonesOperations.list_by_location": null, - "azure.mgmt.sql.aio.operations.TimeZonesOperations.list_by_location": null, - "azure.mgmt.sql.operations.TimeZonesOperations.get": null, - "azure.mgmt.sql.aio.operations.TimeZonesOperations.get": null, - "azure.mgmt.sql.operations.VirtualNetworkRulesOperations.get": null, - "azure.mgmt.sql.aio.operations.VirtualNetworkRulesOperations.get": null, - "azure.mgmt.sql.operations.VirtualNetworkRulesOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.VirtualNetworkRulesOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.VirtualNetworkRulesOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.VirtualNetworkRulesOperations.begin_delete": null, - "azure.mgmt.sql.operations.VirtualNetworkRulesOperations.list_by_server": null, - "azure.mgmt.sql.aio.operations.VirtualNetworkRulesOperations.list_by_server": null, - "azure.mgmt.sql.operations.WorkloadClassifiersOperations.get": null, - "azure.mgmt.sql.aio.operations.WorkloadClassifiersOperations.get": null, - "azure.mgmt.sql.operations.WorkloadClassifiersOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.WorkloadClassifiersOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.WorkloadClassifiersOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.WorkloadClassifiersOperations.begin_delete": null, - "azure.mgmt.sql.operations.WorkloadClassifiersOperations.list_by_workload_group": null, - "azure.mgmt.sql.aio.operations.WorkloadClassifiersOperations.list_by_workload_group": null, - "azure.mgmt.sql.operations.WorkloadGroupsOperations.get": null, - "azure.mgmt.sql.aio.operations.WorkloadGroupsOperations.get": null, - "azure.mgmt.sql.operations.WorkloadGroupsOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.WorkloadGroupsOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.WorkloadGroupsOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.WorkloadGroupsOperations.begin_delete": null, - "azure.mgmt.sql.operations.WorkloadGroupsOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.WorkloadGroupsOperations.list_by_database": null, - "azure.mgmt.sql.operations.BackupShortTermRetentionPoliciesOperations.get": null, - "azure.mgmt.sql.aio.operations.BackupShortTermRetentionPoliciesOperations.get": null, - "azure.mgmt.sql.operations.BackupShortTermRetentionPoliciesOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.BackupShortTermRetentionPoliciesOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.BackupShortTermRetentionPoliciesOperations.begin_update": null, - "azure.mgmt.sql.aio.operations.BackupShortTermRetentionPoliciesOperations.begin_update": null, - "azure.mgmt.sql.operations.BackupShortTermRetentionPoliciesOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.BackupShortTermRetentionPoliciesOperations.list_by_database": null, - "azure.mgmt.sql.operations.DatabaseExtensionsOperations.get": null, - "azure.mgmt.sql.aio.operations.DatabaseExtensionsOperations.get": null, - "azure.mgmt.sql.operations.DatabaseExtensionsOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.DatabaseExtensionsOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.DatabaseExtensionsOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.DatabaseExtensionsOperations.list_by_database": null, - "azure.mgmt.sql.operations.DatabaseUsagesOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.DatabaseUsagesOperations.list_by_database": null, - "azure.mgmt.sql.operations.LedgerDigestUploadsOperations.get": null, - "azure.mgmt.sql.aio.operations.LedgerDigestUploadsOperations.get": null, - "azure.mgmt.sql.operations.LedgerDigestUploadsOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.LedgerDigestUploadsOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.LedgerDigestUploadsOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.LedgerDigestUploadsOperations.list_by_database": null, - "azure.mgmt.sql.operations.LedgerDigestUploadsOperations.begin_disable": null, - "azure.mgmt.sql.aio.operations.LedgerDigestUploadsOperations.begin_disable": null, - "azure.mgmt.sql.operations.OutboundFirewallRulesOperations.get": null, - "azure.mgmt.sql.aio.operations.OutboundFirewallRulesOperations.get": null, - "azure.mgmt.sql.operations.OutboundFirewallRulesOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.OutboundFirewallRulesOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.OutboundFirewallRulesOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.OutboundFirewallRulesOperations.begin_delete": null, - "azure.mgmt.sql.operations.OutboundFirewallRulesOperations.list_by_server": null, - "azure.mgmt.sql.aio.operations.OutboundFirewallRulesOperations.list_by_server": null, - "azure.mgmt.sql.operations.UsagesOperations.list_by_instance_pool": null, - "azure.mgmt.sql.aio.operations.UsagesOperations.list_by_instance_pool": null, - "azure.mgmt.sql.operations.LongTermRetentionManagedInstanceBackupsOperations.get": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionManagedInstanceBackupsOperations.get": null, - "azure.mgmt.sql.operations.LongTermRetentionManagedInstanceBackupsOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionManagedInstanceBackupsOperations.begin_delete": null, - "azure.mgmt.sql.operations.LongTermRetentionManagedInstanceBackupsOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionManagedInstanceBackupsOperations.list_by_database": null, - "azure.mgmt.sql.operations.LongTermRetentionManagedInstanceBackupsOperations.list_by_instance": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionManagedInstanceBackupsOperations.list_by_instance": null, - "azure.mgmt.sql.operations.LongTermRetentionManagedInstanceBackupsOperations.list_by_location": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionManagedInstanceBackupsOperations.list_by_location": null, - "azure.mgmt.sql.operations.LongTermRetentionManagedInstanceBackupsOperations.get_by_resource_group": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionManagedInstanceBackupsOperations.get_by_resource_group": null, - "azure.mgmt.sql.operations.LongTermRetentionManagedInstanceBackupsOperations.begin_delete_by_resource_group": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionManagedInstanceBackupsOperations.begin_delete_by_resource_group": null, - "azure.mgmt.sql.operations.LongTermRetentionManagedInstanceBackupsOperations.list_by_resource_group_database": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionManagedInstanceBackupsOperations.list_by_resource_group_database": null, - "azure.mgmt.sql.operations.LongTermRetentionManagedInstanceBackupsOperations.list_by_resource_group_instance": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionManagedInstanceBackupsOperations.list_by_resource_group_instance": null, - "azure.mgmt.sql.operations.LongTermRetentionManagedInstanceBackupsOperations.list_by_resource_group_location": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionManagedInstanceBackupsOperations.list_by_resource_group_location": null, - "azure.mgmt.sql.operations.RestorableDroppedManagedDatabasesOperations.list_by_instance": null, - "azure.mgmt.sql.aio.operations.RestorableDroppedManagedDatabasesOperations.list_by_instance": null, - "azure.mgmt.sql.operations.RestorableDroppedManagedDatabasesOperations.get": null, - "azure.mgmt.sql.aio.operations.RestorableDroppedManagedDatabasesOperations.get": null, - "azure.mgmt.sql.operations.ServerConnectionPoliciesOperations.get": null, - "azure.mgmt.sql.aio.operations.ServerConnectionPoliciesOperations.get": null, - "azure.mgmt.sql.operations.ServerConnectionPoliciesOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.ServerConnectionPoliciesOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.ServerConnectionPoliciesOperations.list_by_server": null, - "azure.mgmt.sql.aio.operations.ServerConnectionPoliciesOperations.list_by_server": null, - "azure.mgmt.sql.operations.ServerTrustCertificatesOperations.list_by_instance": null, - "azure.mgmt.sql.aio.operations.ServerTrustCertificatesOperations.list_by_instance": null, - "azure.mgmt.sql.operations.ServerTrustCertificatesOperations.get": null, - "azure.mgmt.sql.aio.operations.ServerTrustCertificatesOperations.get": null, - "azure.mgmt.sql.operations.ServerTrustCertificatesOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.ServerTrustCertificatesOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.ServerTrustCertificatesOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.ServerTrustCertificatesOperations.begin_delete": null, - "azure.mgmt.sql.operations.EndpointCertificatesOperations.list_by_instance": null, - "azure.mgmt.sql.aio.operations.EndpointCertificatesOperations.list_by_instance": null, - "azure.mgmt.sql.operations.EndpointCertificatesOperations.get": null, - "azure.mgmt.sql.aio.operations.EndpointCertificatesOperations.get": null, - "azure.mgmt.sql.operations.ManagedDatabaseSensitivityLabelsOperations.get": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseSensitivityLabelsOperations.get": null, - "azure.mgmt.sql.operations.ManagedDatabaseSensitivityLabelsOperations.create_or_update": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseSensitivityLabelsOperations.create_or_update": null, - "azure.mgmt.sql.operations.ManagedDatabaseSensitivityLabelsOperations.delete": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseSensitivityLabelsOperations.delete": null, - "azure.mgmt.sql.operations.ManagedDatabaseSensitivityLabelsOperations.disable_recommendation": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseSensitivityLabelsOperations.disable_recommendation": null, - "azure.mgmt.sql.operations.ManagedDatabaseSensitivityLabelsOperations.enable_recommendation": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseSensitivityLabelsOperations.enable_recommendation": null, - "azure.mgmt.sql.operations.ManagedDatabaseSensitivityLabelsOperations.list_current_by_database": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseSensitivityLabelsOperations.list_current_by_database": null, - "azure.mgmt.sql.operations.ManagedDatabaseSensitivityLabelsOperations.update": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseSensitivityLabelsOperations.update": null, - "azure.mgmt.sql.operations.ManagedDatabaseSensitivityLabelsOperations.list_recommended_by_database": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseSensitivityLabelsOperations.list_recommended_by_database": null, - "azure.mgmt.sql.operations.ManagedDatabaseRecommendedSensitivityLabelsOperations.update": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseRecommendedSensitivityLabelsOperations.update": null, - "azure.mgmt.sql.operations.SensitivityLabelsOperations.list_current_by_database": null, - "azure.mgmt.sql.aio.operations.SensitivityLabelsOperations.list_current_by_database": null, - "azure.mgmt.sql.operations.SensitivityLabelsOperations.update": null, - "azure.mgmt.sql.aio.operations.SensitivityLabelsOperations.update": null, - "azure.mgmt.sql.operations.SensitivityLabelsOperations.list_recommended_by_database": null, - "azure.mgmt.sql.aio.operations.SensitivityLabelsOperations.list_recommended_by_database": null, - "azure.mgmt.sql.operations.SensitivityLabelsOperations.enable_recommendation": null, - "azure.mgmt.sql.aio.operations.SensitivityLabelsOperations.enable_recommendation": null, - "azure.mgmt.sql.operations.SensitivityLabelsOperations.disable_recommendation": null, - "azure.mgmt.sql.aio.operations.SensitivityLabelsOperations.disable_recommendation": null, - "azure.mgmt.sql.operations.SensitivityLabelsOperations.get": null, - "azure.mgmt.sql.aio.operations.SensitivityLabelsOperations.get": null, - "azure.mgmt.sql.operations.SensitivityLabelsOperations.create_or_update": null, - "azure.mgmt.sql.aio.operations.SensitivityLabelsOperations.create_or_update": null, - "azure.mgmt.sql.operations.SensitivityLabelsOperations.delete": null, - "azure.mgmt.sql.aio.operations.SensitivityLabelsOperations.delete": null, - "azure.mgmt.sql.operations.RecommendedSensitivityLabelsOperations.update": null, - "azure.mgmt.sql.aio.operations.RecommendedSensitivityLabelsOperations.update": null, - "azure.mgmt.sql.operations.ServerBlobAuditingPoliciesOperations.list_by_server": null, - "azure.mgmt.sql.aio.operations.ServerBlobAuditingPoliciesOperations.list_by_server": null, - "azure.mgmt.sql.operations.ServerBlobAuditingPoliciesOperations.get": null, - "azure.mgmt.sql.aio.operations.ServerBlobAuditingPoliciesOperations.get": null, - "azure.mgmt.sql.operations.ServerBlobAuditingPoliciesOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.ServerBlobAuditingPoliciesOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.DatabaseBlobAuditingPoliciesOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.DatabaseBlobAuditingPoliciesOperations.list_by_database": null, - "azure.mgmt.sql.operations.DatabaseBlobAuditingPoliciesOperations.get": null, - "azure.mgmt.sql.aio.operations.DatabaseBlobAuditingPoliciesOperations.get": null, - "azure.mgmt.sql.operations.DatabaseBlobAuditingPoliciesOperations.create_or_update": null, - "azure.mgmt.sql.aio.operations.DatabaseBlobAuditingPoliciesOperations.create_or_update": null, - "azure.mgmt.sql.operations.ExtendedDatabaseBlobAuditingPoliciesOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.ExtendedDatabaseBlobAuditingPoliciesOperations.list_by_database": null, - "azure.mgmt.sql.operations.ExtendedDatabaseBlobAuditingPoliciesOperations.get": null, - "azure.mgmt.sql.aio.operations.ExtendedDatabaseBlobAuditingPoliciesOperations.get": null, - "azure.mgmt.sql.operations.ExtendedDatabaseBlobAuditingPoliciesOperations.create_or_update": null, - "azure.mgmt.sql.aio.operations.ExtendedDatabaseBlobAuditingPoliciesOperations.create_or_update": null, - "azure.mgmt.sql.operations.ExtendedServerBlobAuditingPoliciesOperations.list_by_server": null, - "azure.mgmt.sql.aio.operations.ExtendedServerBlobAuditingPoliciesOperations.list_by_server": null, - "azure.mgmt.sql.operations.ExtendedServerBlobAuditingPoliciesOperations.get": null, - "azure.mgmt.sql.aio.operations.ExtendedServerBlobAuditingPoliciesOperations.get": null, - "azure.mgmt.sql.operations.ExtendedServerBlobAuditingPoliciesOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.ExtendedServerBlobAuditingPoliciesOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.DatabaseAdvancedThreatProtectionSettingsOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.DatabaseAdvancedThreatProtectionSettingsOperations.list_by_database": null, - "azure.mgmt.sql.operations.DatabaseAdvancedThreatProtectionSettingsOperations.get": null, - "azure.mgmt.sql.aio.operations.DatabaseAdvancedThreatProtectionSettingsOperations.get": null, - "azure.mgmt.sql.operations.DatabaseAdvancedThreatProtectionSettingsOperations.create_or_update": null, - "azure.mgmt.sql.aio.operations.DatabaseAdvancedThreatProtectionSettingsOperations.create_or_update": null, - "azure.mgmt.sql.operations.ServerAdvancedThreatProtectionSettingsOperations.list_by_server": null, - "azure.mgmt.sql.aio.operations.ServerAdvancedThreatProtectionSettingsOperations.list_by_server": null, - "azure.mgmt.sql.operations.ServerAdvancedThreatProtectionSettingsOperations.get": null, - "azure.mgmt.sql.aio.operations.ServerAdvancedThreatProtectionSettingsOperations.get": null, - "azure.mgmt.sql.operations.ServerAdvancedThreatProtectionSettingsOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.ServerAdvancedThreatProtectionSettingsOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.ManagedServerDnsAliasesOperations.list_by_managed_instance": null, - "azure.mgmt.sql.aio.operations.ManagedServerDnsAliasesOperations.list_by_managed_instance": null, - "azure.mgmt.sql.operations.ManagedServerDnsAliasesOperations.get": null, - "azure.mgmt.sql.aio.operations.ManagedServerDnsAliasesOperations.get": null, - "azure.mgmt.sql.operations.ManagedServerDnsAliasesOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.ManagedServerDnsAliasesOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.ManagedServerDnsAliasesOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.ManagedServerDnsAliasesOperations.begin_delete": null, - "azure.mgmt.sql.operations.ManagedServerDnsAliasesOperations.begin_acquire": null, - "azure.mgmt.sql.aio.operations.ManagedServerDnsAliasesOperations.begin_acquire": null, - "azure.mgmt.sql.operations.ManagedDatabaseAdvancedThreatProtectionSettingsOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseAdvancedThreatProtectionSettingsOperations.list_by_database": null, - "azure.mgmt.sql.operations.ManagedDatabaseAdvancedThreatProtectionSettingsOperations.get": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseAdvancedThreatProtectionSettingsOperations.get": null, - "azure.mgmt.sql.operations.ManagedDatabaseAdvancedThreatProtectionSettingsOperations.create_or_update": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseAdvancedThreatProtectionSettingsOperations.create_or_update": null, - "azure.mgmt.sql.operations.ManagedInstanceAdvancedThreatProtectionSettingsOperations.list_by_instance": null, - "azure.mgmt.sql.aio.operations.ManagedInstanceAdvancedThreatProtectionSettingsOperations.list_by_instance": null, - "azure.mgmt.sql.operations.ManagedInstanceAdvancedThreatProtectionSettingsOperations.get": null, - "azure.mgmt.sql.aio.operations.ManagedInstanceAdvancedThreatProtectionSettingsOperations.get": null, - "azure.mgmt.sql.operations.ManagedInstanceAdvancedThreatProtectionSettingsOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.ManagedInstanceAdvancedThreatProtectionSettingsOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.ManagedDatabaseMoveOperationsOperations.list_by_location": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseMoveOperationsOperations.list_by_location": null, - "azure.mgmt.sql.operations.ManagedDatabaseMoveOperationsOperations.get": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseMoveOperationsOperations.get": null, - "azure.mgmt.sql.operations.ManagedInstanceDtcsOperations.list_by_managed_instance": null, - "azure.mgmt.sql.aio.operations.ManagedInstanceDtcsOperations.list_by_managed_instance": null, - "azure.mgmt.sql.operations.ManagedInstanceDtcsOperations.get": null, - "azure.mgmt.sql.aio.operations.ManagedInstanceDtcsOperations.get": null, - "azure.mgmt.sql.operations.ManagedInstanceDtcsOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.ManagedInstanceDtcsOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.SynapseLinkWorkspacesOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.SynapseLinkWorkspacesOperations.list_by_database": null, - "azure.mgmt.sql.operations.VirtualClustersOperations.list": null, - "azure.mgmt.sql.aio.operations.VirtualClustersOperations.list": null, - "azure.mgmt.sql.operations.VirtualClustersOperations.list_by_resource_group": null, - "azure.mgmt.sql.aio.operations.VirtualClustersOperations.list_by_resource_group": null, - "azure.mgmt.sql.operations.VirtualClustersOperations.get": null, - "azure.mgmt.sql.aio.operations.VirtualClustersOperations.get": null, - "azure.mgmt.sql.operations.VirtualClustersOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.VirtualClustersOperations.begin_delete": null, - "azure.mgmt.sql.operations.VirtualClustersOperations.begin_update": null, - "azure.mgmt.sql.aio.operations.VirtualClustersOperations.begin_update": null, - "azure.mgmt.sql.operations.VirtualClustersOperations.begin_update_dns_servers": null, - "azure.mgmt.sql.aio.operations.VirtualClustersOperations.begin_update_dns_servers": null, - "azure.mgmt.sql.operations.InstanceFailoverGroupsOperations.list_by_location": null, - "azure.mgmt.sql.aio.operations.InstanceFailoverGroupsOperations.list_by_location": null, - "azure.mgmt.sql.operations.InstanceFailoverGroupsOperations.get": null, - "azure.mgmt.sql.aio.operations.InstanceFailoverGroupsOperations.get": null, - "azure.mgmt.sql.operations.InstanceFailoverGroupsOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.InstanceFailoverGroupsOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.InstanceFailoverGroupsOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.InstanceFailoverGroupsOperations.begin_delete": null, - "azure.mgmt.sql.operations.InstanceFailoverGroupsOperations.begin_failover": null, - "azure.mgmt.sql.aio.operations.InstanceFailoverGroupsOperations.begin_failover": null, - "azure.mgmt.sql.operations.InstanceFailoverGroupsOperations.begin_force_failover_allow_data_loss": null, - "azure.mgmt.sql.aio.operations.InstanceFailoverGroupsOperations.begin_force_failover_allow_data_loss": null, - "azure.mgmt.sql.operations.ManagedDatabaseRestoreDetailsOperations.get": null, - "azure.mgmt.sql.aio.operations.ManagedDatabaseRestoreDetailsOperations.get": null, - "azure.mgmt.sql.operations.DatabaseEncryptionProtectorsOperations.begin_revalidate": null, - "azure.mgmt.sql.aio.operations.DatabaseEncryptionProtectorsOperations.begin_revalidate": null, - "azure.mgmt.sql.operations.DatabaseEncryptionProtectorsOperations.begin_revert": null, - "azure.mgmt.sql.aio.operations.DatabaseEncryptionProtectorsOperations.begin_revert": null, - "azure.mgmt.sql.operations.ManagedDatabasesOperations.list_by_instance": null, - "azure.mgmt.sql.aio.operations.ManagedDatabasesOperations.list_by_instance": null, - "azure.mgmt.sql.operations.ManagedDatabasesOperations.get": null, - "azure.mgmt.sql.aio.operations.ManagedDatabasesOperations.get": null, - "azure.mgmt.sql.operations.ManagedDatabasesOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.ManagedDatabasesOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.ManagedDatabasesOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.ManagedDatabasesOperations.begin_delete": null, - "azure.mgmt.sql.operations.ManagedDatabasesOperations.begin_update": null, - "azure.mgmt.sql.aio.operations.ManagedDatabasesOperations.begin_update": null, - "azure.mgmt.sql.operations.ManagedDatabasesOperations.begin_cancel_move": null, - "azure.mgmt.sql.aio.operations.ManagedDatabasesOperations.begin_cancel_move": null, - "azure.mgmt.sql.operations.ManagedDatabasesOperations.begin_complete_move": null, - "azure.mgmt.sql.aio.operations.ManagedDatabasesOperations.begin_complete_move": null, - "azure.mgmt.sql.operations.ManagedDatabasesOperations.begin_complete_restore": null, - "azure.mgmt.sql.aio.operations.ManagedDatabasesOperations.begin_complete_restore": null, - "azure.mgmt.sql.operations.ManagedDatabasesOperations.begin_start_move": null, - "azure.mgmt.sql.aio.operations.ManagedDatabasesOperations.begin_start_move": null, - "azure.mgmt.sql.operations.ManagedDatabasesOperations.list_inaccessible_by_instance": null, - "azure.mgmt.sql.aio.operations.ManagedDatabasesOperations.list_inaccessible_by_instance": null, - "azure.mgmt.sql.operations.ManagedLedgerDigestUploadsOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.ManagedLedgerDigestUploadsOperations.list_by_database": null, - "azure.mgmt.sql.operations.ManagedLedgerDigestUploadsOperations.get": null, - "azure.mgmt.sql.aio.operations.ManagedLedgerDigestUploadsOperations.get": null, - "azure.mgmt.sql.operations.ManagedLedgerDigestUploadsOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.ManagedLedgerDigestUploadsOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.ManagedLedgerDigestUploadsOperations.begin_disable": null, - "azure.mgmt.sql.aio.operations.ManagedLedgerDigestUploadsOperations.begin_disable": null, - "azure.mgmt.sql.operations.RecoverableDatabasesOperations.list_by_server": null, - "azure.mgmt.sql.aio.operations.RecoverableDatabasesOperations.list_by_server": null, - "azure.mgmt.sql.operations.RecoverableDatabasesOperations.get": null, - "azure.mgmt.sql.aio.operations.RecoverableDatabasesOperations.get": null, - "azure.mgmt.sql.operations.RestorableDroppedDatabasesOperations.list_by_server": null, - "azure.mgmt.sql.aio.operations.RestorableDroppedDatabasesOperations.list_by_server": null, - "azure.mgmt.sql.operations.RestorableDroppedDatabasesOperations.get": null, - "azure.mgmt.sql.aio.operations.RestorableDroppedDatabasesOperations.get": null, - "azure.mgmt.sql.operations.ServerConfigurationOptionsOperations.list_by_managed_instance": null, - "azure.mgmt.sql.aio.operations.ServerConfigurationOptionsOperations.list_by_managed_instance": null, - "azure.mgmt.sql.operations.ServerConfigurationOptionsOperations.get": null, - "azure.mgmt.sql.aio.operations.ServerConfigurationOptionsOperations.get": null, - "azure.mgmt.sql.operations.ServerConfigurationOptionsOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.ServerConfigurationOptionsOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.StartStopManagedInstanceSchedulesOperations.list_by_instance": null, - "azure.mgmt.sql.aio.operations.StartStopManagedInstanceSchedulesOperations.list_by_instance": null, - "azure.mgmt.sql.operations.StartStopManagedInstanceSchedulesOperations.get": null, - "azure.mgmt.sql.aio.operations.StartStopManagedInstanceSchedulesOperations.get": null, - "azure.mgmt.sql.operations.StartStopManagedInstanceSchedulesOperations.create_or_update": null, - "azure.mgmt.sql.aio.operations.StartStopManagedInstanceSchedulesOperations.create_or_update": null, - "azure.mgmt.sql.operations.StartStopManagedInstanceSchedulesOperations.delete": null, - "azure.mgmt.sql.aio.operations.StartStopManagedInstanceSchedulesOperations.delete": null, - "azure.mgmt.sql.operations.TransparentDataEncryptionsOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.TransparentDataEncryptionsOperations.list_by_database": null, - "azure.mgmt.sql.operations.TransparentDataEncryptionsOperations.get": null, - "azure.mgmt.sql.aio.operations.TransparentDataEncryptionsOperations.get": null, - "azure.mgmt.sql.operations.TransparentDataEncryptionsOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.TransparentDataEncryptionsOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.IPv6FirewallRulesOperations.list_by_server": null, - "azure.mgmt.sql.aio.operations.IPv6FirewallRulesOperations.list_by_server": null, - "azure.mgmt.sql.operations.IPv6FirewallRulesOperations.get": null, - "azure.mgmt.sql.aio.operations.IPv6FirewallRulesOperations.get": null, - "azure.mgmt.sql.operations.IPv6FirewallRulesOperations.create_or_update": null, - "azure.mgmt.sql.aio.operations.IPv6FirewallRulesOperations.create_or_update": null, - "azure.mgmt.sql.operations.IPv6FirewallRulesOperations.delete": null, - "azure.mgmt.sql.aio.operations.IPv6FirewallRulesOperations.delete": null, - "azure.mgmt.sql.operations.SqlVulnerabilityAssessmentBaselineOperations.list_by_sql_vulnerability_assessment": null, - "azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentBaselineOperations.list_by_sql_vulnerability_assessment": null, - "azure.mgmt.sql.operations.SqlVulnerabilityAssessmentBaselineOperations.get": null, - "azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentBaselineOperations.get": null, - "azure.mgmt.sql.operations.SqlVulnerabilityAssessmentBaselinesOperations.create_or_update": null, - "azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentBaselinesOperations.create_or_update": null, - "azure.mgmt.sql.operations.SqlVulnerabilityAssessmentExecuteScanOperations.begin_execute": null, - "azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentExecuteScanOperations.begin_execute": null, - "azure.mgmt.sql.operations.SqlVulnerabilityAssessmentRuleBaselineOperations.list_by_baseline": null, - "azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentRuleBaselineOperations.list_by_baseline": null, - "azure.mgmt.sql.operations.SqlVulnerabilityAssessmentRuleBaselineOperations.get": null, - "azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentRuleBaselineOperations.get": null, - "azure.mgmt.sql.operations.SqlVulnerabilityAssessmentRuleBaselineOperations.create_or_update": null, - "azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentRuleBaselineOperations.create_or_update": null, - "azure.mgmt.sql.operations.SqlVulnerabilityAssessmentRuleBaselinesOperations.delete": null, - "azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentRuleBaselinesOperations.delete": null, - "azure.mgmt.sql.operations.SqlVulnerabilityAssessmentScanResultOperations.list_by_scan": null, - "azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentScanResultOperations.list_by_scan": null, - "azure.mgmt.sql.operations.SqlVulnerabilityAssessmentScanResultOperations.get": null, - "azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentScanResultOperations.get": null, - "azure.mgmt.sql.operations.SqlVulnerabilityAssessmentScansOperations.list_by_sql_vulnerability_assessments": null, - "azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentScansOperations.list_by_sql_vulnerability_assessments": null, - "azure.mgmt.sql.operations.SqlVulnerabilityAssessmentScansOperations.get": null, - "azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentScansOperations.get": null, - "azure.mgmt.sql.operations.SqlVulnerabilityAssessmentsSettingsOperations.list_by_server": null, - "azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentsSettingsOperations.list_by_server": null, - "azure.mgmt.sql.operations.SqlVulnerabilityAssessmentsSettingsOperations.get": null, - "azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentsSettingsOperations.get": null, - "azure.mgmt.sql.operations.SqlVulnerabilityAssessmentsSettingsOperations.create_or_update": null, - "azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentsSettingsOperations.create_or_update": null, - "azure.mgmt.sql.operations.SqlVulnerabilityAssessmentsOperations.delete": null, - "azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentsOperations.delete": null, - "azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentBaselinesOperations.list_by_sql_vulnerability_assessment": null, - "azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentBaselinesOperations.list_by_sql_vulnerability_assessment": null, - "azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentBaselinesOperations.get": null, - "azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentBaselinesOperations.get": null, - "azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentBaselinesOperations.create_or_update": null, - "azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentBaselinesOperations.create_or_update": null, - "azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentExecuteScanOperations.begin_execute": null, - "azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentExecuteScanOperations.begin_execute": null, - "azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations.list_by_baseline": null, - "azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations.list_by_baseline": null, - "azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations.get": null, - "azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations.get": null, - "azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations.create_or_update": null, - "azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations.create_or_update": null, - "azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations.delete": null, - "azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations.delete": null, - "azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentScanResultOperations.list_by_scan": null, - "azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentScanResultOperations.list_by_scan": null, - "azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentScanResultOperations.get": null, - "azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentScanResultOperations.get": null, - "azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentScansOperations.list_by_sql_vulnerability_assessments": null, - "azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentScansOperations.list_by_sql_vulnerability_assessments": null, - "azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentScansOperations.get": null, - "azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentScansOperations.get": null, - "azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentsSettingsOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentsSettingsOperations.list_by_database": null, - "azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentsSettingsOperations.get": null, - "azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentsSettingsOperations.get": null, - "azure.mgmt.sql.operations.FailoverGroupsOperations.list_by_server": null, - "azure.mgmt.sql.aio.operations.FailoverGroupsOperations.list_by_server": null, - "azure.mgmt.sql.operations.FailoverGroupsOperations.get": null, - "azure.mgmt.sql.aio.operations.FailoverGroupsOperations.get": null, - "azure.mgmt.sql.operations.FailoverGroupsOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.FailoverGroupsOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.FailoverGroupsOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.FailoverGroupsOperations.begin_delete": null, - "azure.mgmt.sql.operations.FailoverGroupsOperations.begin_update": null, - "azure.mgmt.sql.aio.operations.FailoverGroupsOperations.begin_update": null, - "azure.mgmt.sql.operations.FailoverGroupsOperations.begin_failover": null, - "azure.mgmt.sql.aio.operations.FailoverGroupsOperations.begin_failover": null, - "azure.mgmt.sql.operations.FailoverGroupsOperations.begin_force_failover_allow_data_loss": null, - "azure.mgmt.sql.aio.operations.FailoverGroupsOperations.begin_force_failover_allow_data_loss": null, - "azure.mgmt.sql.operations.FailoverGroupsOperations.begin_try_planned_before_forced_failover": null, - "azure.mgmt.sql.aio.operations.FailoverGroupsOperations.begin_try_planned_before_forced_failover": null, - "azure.mgmt.sql.operations.InstancePoolsOperations.list": null, - "azure.mgmt.sql.aio.operations.InstancePoolsOperations.list": null, - "azure.mgmt.sql.operations.InstancePoolsOperations.list_by_resource_group": null, - "azure.mgmt.sql.aio.operations.InstancePoolsOperations.list_by_resource_group": null, - "azure.mgmt.sql.operations.InstancePoolsOperations.get": null, - "azure.mgmt.sql.aio.operations.InstancePoolsOperations.get": null, - "azure.mgmt.sql.operations.InstancePoolsOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.InstancePoolsOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.InstancePoolsOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.InstancePoolsOperations.begin_delete": null, - "azure.mgmt.sql.operations.InstancePoolsOperations.begin_update": null, - "azure.mgmt.sql.aio.operations.InstancePoolsOperations.begin_update": null, - "azure.mgmt.sql.operations.ManagedInstancesOperations.list": null, - "azure.mgmt.sql.aio.operations.ManagedInstancesOperations.list": null, - "azure.mgmt.sql.operations.ManagedInstancesOperations.list_by_instance_pool": null, - "azure.mgmt.sql.aio.operations.ManagedInstancesOperations.list_by_instance_pool": null, - "azure.mgmt.sql.operations.ManagedInstancesOperations.list_by_resource_group": null, - "azure.mgmt.sql.aio.operations.ManagedInstancesOperations.list_by_resource_group": null, - "azure.mgmt.sql.operations.ManagedInstancesOperations.get": null, - "azure.mgmt.sql.aio.operations.ManagedInstancesOperations.get": null, - "azure.mgmt.sql.operations.ManagedInstancesOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.ManagedInstancesOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.ManagedInstancesOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.ManagedInstancesOperations.begin_delete": null, - "azure.mgmt.sql.operations.ManagedInstancesOperations.begin_update": null, - "azure.mgmt.sql.aio.operations.ManagedInstancesOperations.begin_update": null, - "azure.mgmt.sql.operations.ManagedInstancesOperations.begin_failover": null, - "azure.mgmt.sql.aio.operations.ManagedInstancesOperations.begin_failover": null, - "azure.mgmt.sql.operations.ManagedInstancesOperations.list_outbound_network_dependencies_by_managed_instance": null, - "azure.mgmt.sql.aio.operations.ManagedInstancesOperations.list_outbound_network_dependencies_by_managed_instance": null, - "azure.mgmt.sql.operations.ManagedInstancesOperations.begin_refresh_status": null, - "azure.mgmt.sql.aio.operations.ManagedInstancesOperations.begin_refresh_status": null, - "azure.mgmt.sql.operations.ManagedInstancesOperations.begin_start": null, - "azure.mgmt.sql.aio.operations.ManagedInstancesOperations.begin_start": null, - "azure.mgmt.sql.operations.ManagedInstancesOperations.begin_stop": null, - "azure.mgmt.sql.aio.operations.ManagedInstancesOperations.begin_stop": null, - "azure.mgmt.sql.operations.ManagedInstancesOperations.list_by_managed_instance": null, - "azure.mgmt.sql.aio.operations.ManagedInstancesOperations.list_by_managed_instance": null, - "azure.mgmt.sql.operations.ReplicationLinksOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.ReplicationLinksOperations.list_by_database": null, - "azure.mgmt.sql.operations.ReplicationLinksOperations.get": null, - "azure.mgmt.sql.aio.operations.ReplicationLinksOperations.get": null, - "azure.mgmt.sql.operations.ReplicationLinksOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.ReplicationLinksOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.ReplicationLinksOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.ReplicationLinksOperations.begin_delete": null, - "azure.mgmt.sql.operations.ReplicationLinksOperations.begin_update": null, - "azure.mgmt.sql.aio.operations.ReplicationLinksOperations.begin_update": null, - "azure.mgmt.sql.operations.ReplicationLinksOperations.begin_failover": null, - "azure.mgmt.sql.aio.operations.ReplicationLinksOperations.begin_failover": null, - "azure.mgmt.sql.operations.ReplicationLinksOperations.begin_failover_allow_data_loss": null, - "azure.mgmt.sql.aio.operations.ReplicationLinksOperations.begin_failover_allow_data_loss": null, - "azure.mgmt.sql.operations.ReplicationLinksOperations.list_by_server": null, - "azure.mgmt.sql.aio.operations.ReplicationLinksOperations.list_by_server": null, - "azure.mgmt.sql.operations.DistributedAvailabilityGroupsOperations.list_by_instance": null, - "azure.mgmt.sql.aio.operations.DistributedAvailabilityGroupsOperations.list_by_instance": null, - "azure.mgmt.sql.operations.DistributedAvailabilityGroupsOperations.get": null, - "azure.mgmt.sql.aio.operations.DistributedAvailabilityGroupsOperations.get": null, - "azure.mgmt.sql.operations.DistributedAvailabilityGroupsOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.DistributedAvailabilityGroupsOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.DistributedAvailabilityGroupsOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.DistributedAvailabilityGroupsOperations.begin_delete": null, - "azure.mgmt.sql.operations.DistributedAvailabilityGroupsOperations.begin_update": null, - "azure.mgmt.sql.aio.operations.DistributedAvailabilityGroupsOperations.begin_update": null, - "azure.mgmt.sql.operations.DistributedAvailabilityGroupsOperations.begin_failover": null, - "azure.mgmt.sql.aio.operations.DistributedAvailabilityGroupsOperations.begin_failover": null, - "azure.mgmt.sql.operations.DistributedAvailabilityGroupsOperations.begin_set_role": null, - "azure.mgmt.sql.aio.operations.DistributedAvailabilityGroupsOperations.begin_set_role": null, - "azure.mgmt.sql.operations.ServersOperations.check_name_availability": null, - "azure.mgmt.sql.aio.operations.ServersOperations.check_name_availability": null, - "azure.mgmt.sql.operations.ServersOperations.list": null, - "azure.mgmt.sql.aio.operations.ServersOperations.list": null, - "azure.mgmt.sql.operations.ServersOperations.list_by_resource_group": null, - "azure.mgmt.sql.aio.operations.ServersOperations.list_by_resource_group": null, - "azure.mgmt.sql.operations.ServersOperations.get": null, - "azure.mgmt.sql.aio.operations.ServersOperations.get": null, - "azure.mgmt.sql.operations.ServersOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.ServersOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.ServersOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.ServersOperations.begin_delete": null, - "azure.mgmt.sql.operations.ServersOperations.begin_update": null, - "azure.mgmt.sql.aio.operations.ServersOperations.begin_update": null, - "azure.mgmt.sql.operations.ServersOperations.begin_import_database": null, - "azure.mgmt.sql.aio.operations.ServersOperations.begin_import_database": null, - "azure.mgmt.sql.operations.ServersOperations.begin_refresh_status": null, - "azure.mgmt.sql.aio.operations.ServersOperations.begin_refresh_status": null, - "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.list_by_location": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.list_by_location": null, - "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.list_by_server": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.list_by_server": null, - "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.list_by_database": null, - "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.get": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.get": null, - "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.begin_delete": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.begin_delete": null, - "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.begin_change_access_tier": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.begin_change_access_tier": null, - "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.begin_copy": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.begin_copy": null, - "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.begin_lock_time_based_immutability": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.begin_lock_time_based_immutability": null, - "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.begin_remove_legal_hold_immutability": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.begin_remove_legal_hold_immutability": null, - "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.begin_remove_time_based_immutability": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.begin_remove_time_based_immutability": null, - "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.begin_set_legal_hold_immutability": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.begin_set_legal_hold_immutability": null, - "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.begin_update": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.begin_update": null, - "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.list_by_resource_group_location": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.list_by_resource_group_location": null, - "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.list_by_resource_group_server": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.list_by_resource_group_server": null, - "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.list_by_resource_group_database": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.list_by_resource_group_database": null, - "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.get_by_resource_group": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.get_by_resource_group": null, - "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.begin_delete_by_resource_group": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.begin_delete_by_resource_group": null, - "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.begin_change_access_tier_by_resource_group": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.begin_change_access_tier_by_resource_group": null, - "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.begin_copy_by_resource_group": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.begin_copy_by_resource_group": null, - "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.begin_lock_time_based_immutability_by_resource_group": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.begin_lock_time_based_immutability_by_resource_group": null, - "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.begin_remove_legal_hold_immutability_by_resource_group": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.begin_remove_legal_hold_immutability_by_resource_group": null, - "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.begin_remove_time_based_immutability_by_resource_group": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.begin_remove_time_based_immutability_by_resource_group": null, - "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.begin_set_legal_hold_immutability_by_resource_group": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.begin_set_legal_hold_immutability_by_resource_group": null, - "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.begin_update_by_resource_group": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.begin_update_by_resource_group": null, - "azure.mgmt.sql.operations.LongTermRetentionPoliciesOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionPoliciesOperations.list_by_database": null, - "azure.mgmt.sql.operations.LongTermRetentionPoliciesOperations.get": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionPoliciesOperations.get": null, - "azure.mgmt.sql.operations.LongTermRetentionPoliciesOperations.begin_create_or_update": null, - "azure.mgmt.sql.aio.operations.LongTermRetentionPoliciesOperations.begin_create_or_update": null, - "azure.mgmt.sql.operations.DatabaseOperationsOperations.list_by_database": null, - "azure.mgmt.sql.aio.operations.DatabaseOperationsOperations.list_by_database": null, - "azure.mgmt.sql.operations.DatabaseOperationsOperations.cancel": null, - "azure.mgmt.sql.aio.operations.DatabaseOperationsOperations.cancel": null + "azure.mgmt.sql.models.AdministratorProperties": "Microsoft.Sql.AdministratorProperties", + "azure.mgmt.sql.models.AdvancedThreatProtectionProperties": "Microsoft.Sql.AdvancedThreatProtectionProperties", + "azure.mgmt.sql.models.Resource": "Azure.ResourceManager.CommonTypes.Resource", + "azure.mgmt.sql.models.ProxyResource": "Azure.ResourceManager.CommonTypes.ProxyResource", + "azure.mgmt.sql.models.Advisor": "Microsoft.Sql.Advisor", + "azure.mgmt.sql.models.AdvisorProperties": "Microsoft.Sql.AdvisorProperties", + "azure.mgmt.sql.models.AutomaticTuningOptions": "Microsoft.Sql.AutomaticTuningOptions", + "azure.mgmt.sql.models.AutomaticTuningServerOptions": "Microsoft.Sql.AutomaticTuningServerOptions", + "azure.mgmt.sql.models.AutomaticTuningServerProperties": "Microsoft.Sql.AutomaticTuningServerProperties", + "azure.mgmt.sql.models.AutoPauseDelayTimeRange": "Microsoft.Sql.AutoPauseDelayTimeRange", + "azure.mgmt.sql.models.AzureADOnlyAuthProperties": "Microsoft.Sql.AzureADOnlyAuthProperties", + "azure.mgmt.sql.models.BackupShortTermRetentionPolicy": "Microsoft.Sql.BackupShortTermRetentionPolicy", + "azure.mgmt.sql.models.BackupShortTermRetentionPolicyProperties": "Microsoft.Sql.BackupShortTermRetentionPolicyProperties", + "azure.mgmt.sql.models.Baseline": "Microsoft.Sql.Baseline", + "azure.mgmt.sql.models.BaselineAdjustedResult": "Microsoft.Sql.BaselineAdjustedResult", + "azure.mgmt.sql.models.BenchmarkReference": "Microsoft.Sql.BenchmarkReference", + "azure.mgmt.sql.models.CertificateInfo": "Microsoft.Sql.CertificateInfo", + "azure.mgmt.sql.models.ChangeLongTermRetentionBackupAccessTierParameters": "Microsoft.Sql.ChangeLongTermRetentionBackupAccessTierParameters", + "azure.mgmt.sql.models.CheckNameAvailabilityRequest": "Microsoft.Sql.CheckNameAvailabilityRequest", + "azure.mgmt.sql.models.CheckNameAvailabilityResponse": "Microsoft.Sql.CheckNameAvailabilityResponse", + "azure.mgmt.sql.models.CompleteDatabaseRestoreDefinition": "Microsoft.Sql.CompleteDatabaseRestoreDefinition", + "azure.mgmt.sql.models.CopyLongTermRetentionBackupParameters": "Microsoft.Sql.CopyLongTermRetentionBackupParameters", + "azure.mgmt.sql.models.CopyLongTermRetentionBackupParametersProperties": "Microsoft.Sql.CopyLongTermRetentionBackupParametersProperties", + "azure.mgmt.sql.models.CreateDatabaseRestorePointDefinition": "Microsoft.Sql.CreateDatabaseRestorePointDefinition", + "azure.mgmt.sql.models.TrackedResource": "Azure.ResourceManager.CommonTypes.TrackedResource", + "azure.mgmt.sql.models.Database": "Microsoft.Sql.Database", + "azure.mgmt.sql.models.DatabaseAdvancedThreatProtection": "Microsoft.Sql.DatabaseAdvancedThreatProtection", + "azure.mgmt.sql.models.DatabaseAutomaticTuning": "Microsoft.Sql.DatabaseAutomaticTuning", + "azure.mgmt.sql.models.DatabaseAutomaticTuningProperties": "Microsoft.Sql.DatabaseAutomaticTuningProperties", + "azure.mgmt.sql.models.DatabaseBlobAuditingPolicy": "Microsoft.Sql.DatabaseBlobAuditingPolicy", + "azure.mgmt.sql.models.DatabaseBlobAuditingPolicyProperties": "Microsoft.Sql.DatabaseBlobAuditingPolicyProperties", + "azure.mgmt.sql.models.DatabaseColumn": "Microsoft.Sql.DatabaseColumn", + "azure.mgmt.sql.models.DatabaseColumnProperties": "Microsoft.Sql.DatabaseColumnProperties", + "azure.mgmt.sql.models.DatabaseExtensions": "Microsoft.Sql.DatabaseExtensions", + "azure.mgmt.sql.models.DatabaseExtensionsProperties": "Microsoft.Sql.DatabaseExtensionsProperties", + "azure.mgmt.sql.models.DatabaseIdentity": "Microsoft.Sql.DatabaseIdentity", + "azure.mgmt.sql.models.DatabaseKey": "Microsoft.Sql.DatabaseKey", + "azure.mgmt.sql.models.DatabaseOperation": "Microsoft.Sql.DatabaseOperation", + "azure.mgmt.sql.models.DatabaseOperationProperties": "Microsoft.Sql.DatabaseOperationProperties", + "azure.mgmt.sql.models.DatabaseProperties": "Microsoft.Sql.DatabaseProperties", + "azure.mgmt.sql.models.DatabaseSchema": "Microsoft.Sql.DatabaseSchema", + "azure.mgmt.sql.models.DatabaseSecurityAlertPolicy": "Microsoft.Sql.DatabaseSecurityAlertPolicy", + "azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet": "Microsoft.Sql.DatabaseSqlVulnerabilityAssessmentBaselineSet", + "azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSetProperties": "Microsoft.Sql.DatabaseSqlVulnerabilityAssessmentBaselineSetProperties", + "azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline": "Microsoft.Sql.DatabaseSqlVulnerabilityAssessmentRuleBaseline", + "azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput": "Microsoft.Sql.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput", + "azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInputProperties": "Microsoft.Sql.DatabaseSqlVulnerabilityAssessmentRuleBaselineInputProperties", + "azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput": "Microsoft.Sql.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput", + "azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInputProperties": "Microsoft.Sql.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInputProperties", + "azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineProperties": "Microsoft.Sql.DatabaseSqlVulnerabilityAssessmentRuleBaselineProperties", + "azure.mgmt.sql.models.DatabaseTable": "Microsoft.Sql.DatabaseTable", + "azure.mgmt.sql.models.DatabaseTableProperties": "Microsoft.Sql.DatabaseTableProperties", + "azure.mgmt.sql.models.DatabaseUpdate": "Microsoft.Sql.DatabaseUpdate", + "azure.mgmt.sql.models.DatabaseUpdateProperties": "Microsoft.Sql.DatabaseUpdateProperties", + "azure.mgmt.sql.models.DatabaseUsage": "Microsoft.Sql.DatabaseUsage", + "azure.mgmt.sql.models.DatabaseUsageProperties": "Microsoft.Sql.DatabaseUsageProperties", + "azure.mgmt.sql.models.DatabaseUserIdentity": "Microsoft.Sql.DatabaseUserIdentity", + "azure.mgmt.sql.models.DatabaseVulnerabilityAssessment": "Microsoft.Sql.DatabaseVulnerabilityAssessment", + "azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentProperties": "Microsoft.Sql.DatabaseVulnerabilityAssessmentProperties", + "azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline": "Microsoft.Sql.DatabaseVulnerabilityAssessmentRuleBaseline", + "azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaselineItem": "Microsoft.Sql.DatabaseVulnerabilityAssessmentRuleBaselineItem", + "azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaselineProperties": "Microsoft.Sql.DatabaseVulnerabilityAssessmentRuleBaselineProperties", + "azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentScanExportProperties": "Microsoft.Sql.DatabaseVulnerabilityAssessmentScanExportProperties", + "azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentScansExport": "Microsoft.Sql.DatabaseVulnerabilityAssessmentScansExport", + "azure.mgmt.sql.models.DataMaskingPolicy": "Microsoft.Sql.DataMaskingPolicy", + "azure.mgmt.sql.models.DataMaskingPolicyProperties": "Microsoft.Sql.DataMaskingPolicyProperties", + "azure.mgmt.sql.models.DataMaskingRule": "Microsoft.Sql.DataMaskingRule", + "azure.mgmt.sql.models.DataMaskingRuleProperties": "Microsoft.Sql.DataMaskingRuleProperties", + "azure.mgmt.sql.models.DataSyncParticipantIdentity": "Microsoft.Sql.DataSyncParticipantIdentity", + "azure.mgmt.sql.models.DataSyncParticipantUserAssignedIdentity": "Microsoft.Sql.DataSyncParticipantUserAssignedIdentity", + "azure.mgmt.sql.models.DataWarehouseUserActivities": "Microsoft.Sql.DataWarehouseUserActivities", + "azure.mgmt.sql.models.DataWarehouseUserActivitiesProperties": "Microsoft.Sql.DataWarehouseUserActivitiesProperties", + "azure.mgmt.sql.models.DeletedServer": "Microsoft.Sql.DeletedServer", + "azure.mgmt.sql.models.DeletedServerProperties": "Microsoft.Sql.DeletedServerProperties", + "azure.mgmt.sql.models.DistributedAvailabilityGroup": "Microsoft.Sql.DistributedAvailabilityGroup", + "azure.mgmt.sql.models.DistributedAvailabilityGroupDatabase": "Microsoft.Sql.DistributedAvailabilityGroupDatabase", + "azure.mgmt.sql.models.DistributedAvailabilityGroupProperties": "Microsoft.Sql.DistributedAvailabilityGroupProperties", + "azure.mgmt.sql.models.DistributedAvailabilityGroupSetRole": "Microsoft.Sql.DistributedAvailabilityGroupSetRole", + "azure.mgmt.sql.models.DistributedAvailabilityGroupsFailoverRequest": "Microsoft.Sql.DistributedAvailabilityGroupsFailoverRequest", + "azure.mgmt.sql.models.EditionCapability": "Microsoft.Sql.EditionCapability", + "azure.mgmt.sql.models.ElasticPool": "Microsoft.Sql.ElasticPool", + "azure.mgmt.sql.models.ElasticPoolEditionCapability": "Microsoft.Sql.ElasticPoolEditionCapability", + "azure.mgmt.sql.models.ElasticPoolOperation": "Microsoft.Sql.ElasticPoolOperation", + "azure.mgmt.sql.models.ElasticPoolOperationProperties": "Microsoft.Sql.ElasticPoolOperationProperties", + "azure.mgmt.sql.models.ElasticPoolPerDatabaseMaxPerformanceLevelCapability": "Microsoft.Sql.ElasticPoolPerDatabaseMaxPerformanceLevelCapability", + "azure.mgmt.sql.models.ElasticPoolPerDatabaseMinPerformanceLevelCapability": "Microsoft.Sql.ElasticPoolPerDatabaseMinPerformanceLevelCapability", + "azure.mgmt.sql.models.ElasticPoolPerDatabaseSettings": "Microsoft.Sql.ElasticPoolPerDatabaseSettings", + "azure.mgmt.sql.models.ElasticPoolPerformanceLevelCapability": "Microsoft.Sql.ElasticPoolPerformanceLevelCapability", + "azure.mgmt.sql.models.ElasticPoolProperties": "Microsoft.Sql.ElasticPoolProperties", + "azure.mgmt.sql.models.ElasticPoolUpdate": "Microsoft.Sql.ElasticPoolUpdate", + "azure.mgmt.sql.models.ElasticPoolUpdateProperties": "Microsoft.Sql.ElasticPoolUpdateProperties", + "azure.mgmt.sql.models.EncryptionProtector": "Microsoft.Sql.EncryptionProtector", + "azure.mgmt.sql.models.EncryptionProtectorProperties": "Microsoft.Sql.EncryptionProtectorProperties", + "azure.mgmt.sql.models.EndpointCertificate": "Microsoft.Sql.EndpointCertificate", + "azure.mgmt.sql.models.EndpointCertificateProperties": "Microsoft.Sql.EndpointCertificateProperties", + "azure.mgmt.sql.models.EndpointDependency": "Microsoft.Sql.EndpointDependency", + "azure.mgmt.sql.models.EndpointDetail": "Microsoft.Sql.EndpointDetail", + "azure.mgmt.sql.models.ErrorAdditionalInfo": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo", + "azure.mgmt.sql.models.ErrorDetail": "Azure.ResourceManager.CommonTypes.ErrorDetail", + "azure.mgmt.sql.models.ErrorResponse": "Azure.ResourceManager.CommonTypes.ErrorResponse", + "azure.mgmt.sql.models.ExportDatabaseDefinition": "Microsoft.Sql.ExportDatabaseDefinition", + "azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicy": "Microsoft.Sql.ExtendedDatabaseBlobAuditingPolicy", + "azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicyProperties": "Microsoft.Sql.ExtendedDatabaseBlobAuditingPolicyProperties", + "azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy": "Microsoft.Sql.ExtendedServerBlobAuditingPolicy", + "azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicyProperties": "Microsoft.Sql.ExtendedServerBlobAuditingPolicyProperties", + "azure.mgmt.sql.models.FailoverGroup": "Microsoft.Sql.FailoverGroup", + "azure.mgmt.sql.models.FailoverGroupProperties": "Microsoft.Sql.FailoverGroupProperties", + "azure.mgmt.sql.models.FailoverGroupReadOnlyEndpoint": "Microsoft.Sql.FailoverGroupReadOnlyEndpoint", + "azure.mgmt.sql.models.FailoverGroupReadWriteEndpoint": "Microsoft.Sql.FailoverGroupReadWriteEndpoint", + "azure.mgmt.sql.models.FailoverGroupUpdate": "Microsoft.Sql.FailoverGroupUpdate", + "azure.mgmt.sql.models.FailoverGroupUpdateProperties": "Microsoft.Sql.FailoverGroupUpdateProperties", + "azure.mgmt.sql.models.ResourceWithWritableName": "Microsoft.Sql.ResourceWithWritableName", + "azure.mgmt.sql.models.ProxyResourceWithWritableName": "Microsoft.Sql.ProxyResourceWithWritableName", + "azure.mgmt.sql.models.FirewallRule": "Microsoft.Sql.FirewallRule", + "azure.mgmt.sql.models.FirewallRuleList": "Microsoft.Sql.FirewallRuleList", + "azure.mgmt.sql.models.FreeLimitExhaustionBehaviorCapability": "Microsoft.Sql.FreeLimitExhaustionBehaviorCapability", + "azure.mgmt.sql.models.GeoBackupPolicy": "Microsoft.Sql.GeoBackupPolicy", + "azure.mgmt.sql.models.GeoBackupPolicyProperties": "Microsoft.Sql.GeoBackupPolicyProperties", + "azure.mgmt.sql.models.ImportExistingDatabaseDefinition": "Microsoft.Sql.ImportExistingDatabaseDefinition", + "azure.mgmt.sql.models.ImportExportExtensionsOperationResult": "Microsoft.Sql.ImportExportExtensionsOperationResult", + "azure.mgmt.sql.models.ImportExportExtensionsOperationResultProperties": "Microsoft.Sql.ImportExportExtensionsOperationResultProperties", + "azure.mgmt.sql.models.ImportExportOperationResult": "Microsoft.Sql.ImportExportOperationResult", + "azure.mgmt.sql.models.ImportExportOperationResultProperties": "Microsoft.Sql.ImportExportOperationResultProperties", + "azure.mgmt.sql.models.ImportNewDatabaseDefinition": "Microsoft.Sql.ImportNewDatabaseDefinition", + "azure.mgmt.sql.models.InstanceFailoverGroup": "Microsoft.Sql.InstanceFailoverGroup", + "azure.mgmt.sql.models.InstanceFailoverGroupProperties": "Microsoft.Sql.InstanceFailoverGroupProperties", + "azure.mgmt.sql.models.InstanceFailoverGroupReadOnlyEndpoint": "Microsoft.Sql.InstanceFailoverGroupReadOnlyEndpoint", + "azure.mgmt.sql.models.InstanceFailoverGroupReadWriteEndpoint": "Microsoft.Sql.InstanceFailoverGroupReadWriteEndpoint", + "azure.mgmt.sql.models.InstancePool": "Microsoft.Sql.InstancePool", + "azure.mgmt.sql.models.InstancePoolEditionCapability": "Microsoft.Sql.InstancePoolEditionCapability", + "azure.mgmt.sql.models.InstancePoolFamilyCapability": "Microsoft.Sql.InstancePoolFamilyCapability", + "azure.mgmt.sql.models.InstancePoolOperation": "Microsoft.Sql.InstancePoolOperation", + "azure.mgmt.sql.models.InstancePoolOperationProperties": "Microsoft.Sql.InstancePoolOperationProperties", + "azure.mgmt.sql.models.InstancePoolProperties": "Microsoft.Sql.InstancePoolProperties", + "azure.mgmt.sql.models.InstancePoolUpdate": "Microsoft.Sql.InstancePoolUpdate", + "azure.mgmt.sql.models.InstancePoolVcoresCapability": "Microsoft.Sql.InstancePoolVcoresCapability", + "azure.mgmt.sql.models.IPv6FirewallRule": "Microsoft.Sql.IPv6FirewallRule", + "azure.mgmt.sql.models.IPv6ServerFirewallRuleProperties": "Microsoft.Sql.IPv6ServerFirewallRuleProperties", + "azure.mgmt.sql.models.Job": "Microsoft.Sql.Job", + "azure.mgmt.sql.models.JobAgent": "Microsoft.Sql.JobAgent", + "azure.mgmt.sql.models.JobAgentEditionCapability": "Microsoft.Sql.JobAgentEditionCapability", + "azure.mgmt.sql.models.JobAgentIdentity": "Microsoft.Sql.JobAgentIdentity", + "azure.mgmt.sql.models.JobAgentProperties": "Microsoft.Sql.JobAgentProperties", + "azure.mgmt.sql.models.JobAgentServiceLevelObjectiveCapability": "Microsoft.Sql.JobAgentServiceLevelObjectiveCapability", + "azure.mgmt.sql.models.JobAgentUpdate": "Microsoft.Sql.JobAgentUpdate", + "azure.mgmt.sql.models.JobAgentUserAssignedIdentity": "Microsoft.Sql.JobAgentUserAssignedIdentity", + "azure.mgmt.sql.models.JobAgentVersionCapability": "Microsoft.Sql.JobAgentVersionCapability", + "azure.mgmt.sql.models.JobCredential": "Microsoft.Sql.JobCredential", + "azure.mgmt.sql.models.JobCredentialProperties": "Microsoft.Sql.JobCredentialProperties", + "azure.mgmt.sql.models.JobExecution": "Microsoft.Sql.JobExecution", + "azure.mgmt.sql.models.JobExecutionProperties": "Microsoft.Sql.JobExecutionProperties", + "azure.mgmt.sql.models.JobExecutionTarget": "Microsoft.Sql.JobExecutionTarget", + "azure.mgmt.sql.models.JobPrivateEndpoint": "Microsoft.Sql.JobPrivateEndpoint", + "azure.mgmt.sql.models.JobPrivateEndpointProperties": "Microsoft.Sql.JobPrivateEndpointProperties", + "azure.mgmt.sql.models.JobProperties": "Microsoft.Sql.JobProperties", + "azure.mgmt.sql.models.JobSchedule": "Microsoft.Sql.JobSchedule", + "azure.mgmt.sql.models.JobStep": "Microsoft.Sql.JobStep", + "azure.mgmt.sql.models.JobStepAction": "Microsoft.Sql.JobStepAction", + "azure.mgmt.sql.models.JobStepExecutionOptions": "Microsoft.Sql.JobStepExecutionOptions", + "azure.mgmt.sql.models.JobStepOutput": "Microsoft.Sql.JobStepOutput", + "azure.mgmt.sql.models.JobStepProperties": "Microsoft.Sql.JobStepProperties", + "azure.mgmt.sql.models.JobTarget": "Microsoft.Sql.JobTarget", + "azure.mgmt.sql.models.JobTargetGroup": "Microsoft.Sql.JobTargetGroup", + "azure.mgmt.sql.models.JobTargetGroupProperties": "Microsoft.Sql.JobTargetGroupProperties", + "azure.mgmt.sql.models.JobVersion": "Microsoft.Sql.JobVersion", + "azure.mgmt.sql.models.LedgerDigestUploads": "Microsoft.Sql.LedgerDigestUploads", + "azure.mgmt.sql.models.LedgerDigestUploadsProperties": "Microsoft.Sql.LedgerDigestUploadsProperties", + "azure.mgmt.sql.models.LicenseTypeCapability": "Microsoft.Sql.LicenseTypeCapability", + "azure.mgmt.sql.models.LocationCapabilities": "Microsoft.Sql.LocationCapabilities", + "azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption": "Microsoft.Sql.LogicalDatabaseTransparentDataEncryption", + "azure.mgmt.sql.models.LogSizeCapability": "Microsoft.Sql.LogSizeCapability", + "azure.mgmt.sql.models.LongTermRetentionBackup": "Microsoft.Sql.LongTermRetentionBackup", + "azure.mgmt.sql.models.LongTermRetentionBackupOperationResult": "Microsoft.Sql.LongTermRetentionBackupOperationResult", + "azure.mgmt.sql.models.LongTermRetentionBackupProperties": "Microsoft.Sql.LongTermRetentionBackupProperties", + "azure.mgmt.sql.models.LongTermRetentionOperationResultProperties": "Microsoft.Sql.LongTermRetentionOperationResultProperties", + "azure.mgmt.sql.models.LongTermRetentionPolicy": "Microsoft.Sql.LongTermRetentionPolicy", + "azure.mgmt.sql.models.LongTermRetentionPolicyProperties": "Microsoft.Sql.LongTermRetentionPolicyProperties", + "azure.mgmt.sql.models.MaintenanceConfigurationCapability": "Microsoft.Sql.MaintenanceConfigurationCapability", + "azure.mgmt.sql.models.MaintenanceWindowOptions": "Microsoft.Sql.MaintenanceWindowOptions", + "azure.mgmt.sql.models.MaintenanceWindowOptionsProperties": "Microsoft.Sql.MaintenanceWindowOptionsProperties", + "azure.mgmt.sql.models.MaintenanceWindows": "Microsoft.Sql.MaintenanceWindows", + "azure.mgmt.sql.models.MaintenanceWindowsProperties": "Microsoft.Sql.MaintenanceWindowsProperties", + "azure.mgmt.sql.models.MaintenanceWindowTimeRange": "Microsoft.Sql.MaintenanceWindowTimeRange", + "azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy": "Microsoft.Sql.ManagedBackupShortTermRetentionPolicy", + "azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicyProperties": "Microsoft.Sql.ManagedBackupShortTermRetentionPolicyProperties", + "azure.mgmt.sql.models.ManagedDatabase": "Microsoft.Sql.ManagedDatabase", + "azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection": "Microsoft.Sql.ManagedDatabaseAdvancedThreatProtection", + "azure.mgmt.sql.models.ManagedDatabaseExtendedAccessibilityInfo": "Microsoft.Sql.ManagedDatabaseExtendedAccessibilityInfo", + "azure.mgmt.sql.models.ManagedDatabaseMoveDefinition": "Microsoft.Sql.ManagedDatabaseMoveDefinition", + "azure.mgmt.sql.models.ManagedDatabaseMoveOperationResult": "Microsoft.Sql.ManagedDatabaseMoveOperationResult", + "azure.mgmt.sql.models.ManagedDatabaseMoveOperationResultProperties": "Microsoft.Sql.ManagedDatabaseMoveOperationResultProperties", + "azure.mgmt.sql.models.ManagedDatabaseProperties": "Microsoft.Sql.ManagedDatabaseProperties", + "azure.mgmt.sql.models.ManagedDatabaseRestoreDetailsBackupSetProperties": "Microsoft.Sql.ManagedDatabaseRestoreDetailsBackupSetProperties", + "azure.mgmt.sql.models.ManagedDatabaseRestoreDetailsProperties": "Microsoft.Sql.ManagedDatabaseRestoreDetailsProperties", + "azure.mgmt.sql.models.ManagedDatabaseRestoreDetailsResult": "Microsoft.Sql.ManagedDatabaseRestoreDetailsResult", + "azure.mgmt.sql.models.ManagedDatabaseRestoreDetailsUnrestorableFileProperties": "Microsoft.Sql.ManagedDatabaseRestoreDetailsUnrestorableFileProperties", + "azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy": "Microsoft.Sql.ManagedDatabaseSecurityAlertPolicy", + "azure.mgmt.sql.models.ManagedDatabaseStartMoveDefinition": "Microsoft.Sql.ManagedDatabaseStartMoveDefinition", + "azure.mgmt.sql.models.ManagedDatabaseUpdate": "Microsoft.Sql.ManagedDatabaseUpdate", + "azure.mgmt.sql.models.ManagedInstance": "Microsoft.Sql.ManagedInstance", + "azure.mgmt.sql.models.ManagedInstanceAdministrator": "Microsoft.Sql.ManagedInstanceAdministrator", + "azure.mgmt.sql.models.ManagedInstanceAdministratorProperties": "Microsoft.Sql.ManagedInstanceAdministratorProperties", + "azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection": "Microsoft.Sql.ManagedInstanceAdvancedThreatProtection", + "azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication": "Microsoft.Sql.ManagedInstanceAzureADOnlyAuthentication", + "azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthProperties": "Microsoft.Sql.ManagedInstanceAzureADOnlyAuthProperties", + "azure.mgmt.sql.models.ManagedInstanceDtc": "Microsoft.Sql.ManagedInstanceDtc", + "azure.mgmt.sql.models.ManagedInstanceDtcProperties": "Microsoft.Sql.ManagedInstanceDtcProperties", + "azure.mgmt.sql.models.ManagedInstanceDtcSecuritySettings": "Microsoft.Sql.ManagedInstanceDtcSecuritySettings", + "azure.mgmt.sql.models.ManagedInstanceDtcTransactionManagerCommunicationSettings": "Microsoft.Sql.ManagedInstanceDtcTransactionManagerCommunicationSettings", + "azure.mgmt.sql.models.ManagedInstanceEditionCapability": "Microsoft.Sql.ManagedInstanceEditionCapability", + "azure.mgmt.sql.models.ManagedInstanceEncryptionProtector": "Microsoft.Sql.ManagedInstanceEncryptionProtector", + "azure.mgmt.sql.models.ManagedInstanceEncryptionProtectorProperties": "Microsoft.Sql.ManagedInstanceEncryptionProtectorProperties", + "azure.mgmt.sql.models.ManagedInstanceExternalAdministrator": "Microsoft.Sql.ManagedInstanceExternalAdministrator", + "azure.mgmt.sql.models.ManagedInstanceFamilyCapability": "Microsoft.Sql.ManagedInstanceFamilyCapability", + "azure.mgmt.sql.models.ManagedInstanceKey": "Microsoft.Sql.ManagedInstanceKey", + "azure.mgmt.sql.models.ManagedInstanceKeyProperties": "Microsoft.Sql.ManagedInstanceKeyProperties", + "azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup": "Microsoft.Sql.ManagedInstanceLongTermRetentionBackup", + "azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackupProperties": "Microsoft.Sql.ManagedInstanceLongTermRetentionBackupProperties", + "azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy": "Microsoft.Sql.ManagedInstanceLongTermRetentionPolicy", + "azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicyProperties": "Microsoft.Sql.ManagedInstanceLongTermRetentionPolicyProperties", + "azure.mgmt.sql.models.ManagedInstanceMaintenanceConfigurationCapability": "Microsoft.Sql.ManagedInstanceMaintenanceConfigurationCapability", + "azure.mgmt.sql.models.ManagedInstanceOperation": "Microsoft.Sql.ManagedInstanceOperation", + "azure.mgmt.sql.models.ManagedInstanceOperationParametersPair": "Microsoft.Sql.ManagedInstanceOperationParametersPair", + "azure.mgmt.sql.models.ManagedInstanceOperationProperties": "Microsoft.Sql.ManagedInstanceOperationProperties", + "azure.mgmt.sql.models.ManagedInstanceOperationSteps": "Microsoft.Sql.ManagedInstanceOperationSteps", + "azure.mgmt.sql.models.ManagedInstancePairInfo": "Microsoft.Sql.ManagedInstancePairInfo", + "azure.mgmt.sql.models.ManagedInstancePecProperty": "Microsoft.Sql.ManagedInstancePecProperty", + "azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection": "Microsoft.Sql.ManagedInstancePrivateEndpointConnection", + "azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnectionProperties": "Microsoft.Sql.ManagedInstancePrivateEndpointConnectionProperties", + "azure.mgmt.sql.models.ManagedInstancePrivateEndpointProperty": "Microsoft.Sql.ManagedInstancePrivateEndpointProperty", + "azure.mgmt.sql.models.ManagedInstancePrivateLink": "Microsoft.Sql.ManagedInstancePrivateLink", + "azure.mgmt.sql.models.ManagedInstancePrivateLinkProperties": "Microsoft.Sql.ManagedInstancePrivateLinkProperties", + "azure.mgmt.sql.models.ManagedInstancePrivateLinkServiceConnectionStateProperty": "Microsoft.Sql.ManagedInstancePrivateLinkServiceConnectionStateProperty", + "azure.mgmt.sql.models.ManagedInstanceProperties": "Microsoft.Sql.ManagedInstanceProperties", + "azure.mgmt.sql.models.ManagedInstanceQuery": "Microsoft.Sql.ManagedInstanceQuery", + "azure.mgmt.sql.models.ManagedInstanceUpdate": "Microsoft.Sql.ManagedInstanceUpdate", + "azure.mgmt.sql.models.ManagedInstanceValidateAzureKeyVaultEncryptionKeyRequest": "Microsoft.Sql.ManagedInstanceValidateAzureKeyVaultEncryptionKeyRequest", + "azure.mgmt.sql.models.ManagedInstanceVcoresCapability": "Microsoft.Sql.ManagedInstanceVcoresCapability", + "azure.mgmt.sql.models.ManagedInstanceVersionCapability": "Microsoft.Sql.ManagedInstanceVersionCapability", + "azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment": "Microsoft.Sql.ManagedInstanceVulnerabilityAssessment", + "azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessmentProperties": "Microsoft.Sql.ManagedInstanceVulnerabilityAssessmentProperties", + "azure.mgmt.sql.models.ManagedLedgerDigestUploads": "Microsoft.Sql.ManagedLedgerDigestUploads", + "azure.mgmt.sql.models.ManagedLedgerDigestUploadsProperties": "Microsoft.Sql.ManagedLedgerDigestUploadsProperties", + "azure.mgmt.sql.models.ManagedServerDnsAlias": "Microsoft.Sql.ManagedServerDnsAlias", + "azure.mgmt.sql.models.ManagedServerDnsAliasAcquisition": "Microsoft.Sql.ManagedServerDnsAliasAcquisition", + "azure.mgmt.sql.models.ManagedServerDnsAliasCreation": "Microsoft.Sql.ManagedServerDnsAliasCreation", + "azure.mgmt.sql.models.ManagedServerDnsAliasProperties": "Microsoft.Sql.ManagedServerDnsAliasProperties", + "azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy": "Microsoft.Sql.ManagedServerSecurityAlertPolicy", + "azure.mgmt.sql.models.ManagedTransparentDataEncryption": "Microsoft.Sql.ManagedTransparentDataEncryption", + "azure.mgmt.sql.models.ManagedTransparentDataEncryptionProperties": "Microsoft.Sql.ManagedTransparentDataEncryptionProperties", + "azure.mgmt.sql.models.MaxLimitRangeCapability": "Microsoft.Sql.MaxLimitRangeCapability", + "azure.mgmt.sql.models.MaxSizeCapability": "Microsoft.Sql.MaxSizeCapability", + "azure.mgmt.sql.models.MaxSizeRangeCapability": "Microsoft.Sql.MaxSizeRangeCapability", + "azure.mgmt.sql.models.MinCapacityCapability": "Microsoft.Sql.MinCapacityCapability", + "azure.mgmt.sql.models.Name": "Microsoft.Sql.Name", + "azure.mgmt.sql.models.NetworkIsolationSettings": "Microsoft.Sql.NetworkIsolationSettings", + "azure.mgmt.sql.models.NetworkSecurityPerimeterConfiguration": "Microsoft.Sql.NetworkSecurityPerimeterConfiguration", + "azure.mgmt.sql.models.NetworkSecurityPerimeterConfigurationProperties": "Microsoft.Sql.NetworkSecurityPerimeterConfigurationProperties", + "azure.mgmt.sql.models.NSPConfigAccessRule": "Microsoft.Sql.NSPConfigAccessRule", + "azure.mgmt.sql.models.NSPConfigAccessRuleProperties": "Microsoft.Sql.NSPConfigAccessRuleProperties", + "azure.mgmt.sql.models.NSPConfigAssociation": "Microsoft.Sql.NSPConfigAssociation", + "azure.mgmt.sql.models.NSPConfigNetworkSecurityPerimeterRule": "Microsoft.Sql.NSPConfigNetworkSecurityPerimeterRule", + "azure.mgmt.sql.models.NSPConfigPerimeter": "Microsoft.Sql.NSPConfigPerimeter", + "azure.mgmt.sql.models.NSPConfigProfile": "Microsoft.Sql.NSPConfigProfile", + "azure.mgmt.sql.models.NSPProvisioningIssue": "Microsoft.Sql.NSPProvisioningIssue", + "azure.mgmt.sql.models.NSPProvisioningIssueProperties": "Microsoft.Sql.NSPProvisioningIssueProperties", + "azure.mgmt.sql.models.Operation": "Microsoft.Sql.Operation", + "azure.mgmt.sql.models.OperationDisplay": "Microsoft.Sql.OperationDisplay", + "azure.mgmt.sql.models.OutboundEnvironmentEndpoint": "Microsoft.Sql.OutboundEnvironmentEndpoint", + "azure.mgmt.sql.models.OutboundFirewallRule": "Microsoft.Sql.OutboundFirewallRule", + "azure.mgmt.sql.models.OutboundFirewallRuleProperties": "Microsoft.Sql.OutboundFirewallRuleProperties", + "azure.mgmt.sql.models.PartnerInfo": "Microsoft.Sql.PartnerInfo", + "azure.mgmt.sql.models.PartnerRegionInfo": "Microsoft.Sql.PartnerRegionInfo", + "azure.mgmt.sql.models.PerDatabaseAutoPauseDelayTimeRange": "Microsoft.Sql.PerDatabaseAutoPauseDelayTimeRange", + "azure.mgmt.sql.models.PerformanceLevelCapability": "Microsoft.Sql.PerformanceLevelCapability", + "azure.mgmt.sql.models.PhaseDetails": "Microsoft.Sql.PhaseDetails", + "azure.mgmt.sql.models.PrivateEndpointConnection": "Microsoft.Sql.PrivateEndpointConnection", + "azure.mgmt.sql.models.PrivateEndpointConnectionProperties": "Microsoft.Sql.PrivateEndpointConnectionProperties", + "azure.mgmt.sql.models.PrivateEndpointConnectionRequestStatus": "Microsoft.Sql.PrivateEndpointConnectionRequestStatus", + "azure.mgmt.sql.models.PrivateEndpointProperty": "Microsoft.Sql.PrivateEndpointProperty", + "azure.mgmt.sql.models.PrivateLinkResource": "Microsoft.Sql.PrivateLinkResource", + "azure.mgmt.sql.models.PrivateLinkResourceProperties": "Microsoft.Sql.PrivateLinkResourceProperties", + "azure.mgmt.sql.models.PrivateLinkServiceConnectionStateProperty": "Microsoft.Sql.PrivateLinkServiceConnectionStateProperty", + "azure.mgmt.sql.models.QueryCheck": "Microsoft.Sql.QueryCheck", + "azure.mgmt.sql.models.QueryMetricInterval": "Microsoft.Sql.QueryMetricInterval", + "azure.mgmt.sql.models.QueryMetricProperties": "Microsoft.Sql.QueryMetricProperties", + "azure.mgmt.sql.models.QueryProperties": "Microsoft.Sql.QueryProperties", + "azure.mgmt.sql.models.QueryStatistics": "Microsoft.Sql.QueryStatistics", + "azure.mgmt.sql.models.QueryStatisticsProperties": "Microsoft.Sql.QueryStatisticsProperties", + "azure.mgmt.sql.models.ReadScaleCapability": "Microsoft.Sql.ReadScaleCapability", + "azure.mgmt.sql.models.RecommendedAction": "Microsoft.Sql.RecommendedAction", + "azure.mgmt.sql.models.RecommendedActionErrorInfo": "Microsoft.Sql.RecommendedActionErrorInfo", + "azure.mgmt.sql.models.RecommendedActionImpactRecord": "Microsoft.Sql.RecommendedActionImpactRecord", + "azure.mgmt.sql.models.RecommendedActionImplementationInfo": "Microsoft.Sql.RecommendedActionImplementationInfo", + "azure.mgmt.sql.models.RecommendedActionMetricInfo": "Microsoft.Sql.RecommendedActionMetricInfo", + "azure.mgmt.sql.models.RecommendedActionProperties": "Microsoft.Sql.RecommendedActionProperties", + "azure.mgmt.sql.models.RecommendedActionStateInfo": "Microsoft.Sql.RecommendedActionStateInfo", + "azure.mgmt.sql.models.RecommendedSensitivityLabelUpdate": "Microsoft.Sql.RecommendedSensitivityLabelUpdate", + "azure.mgmt.sql.models.RecommendedSensitivityLabelUpdateList": "Microsoft.Sql.RecommendedSensitivityLabelUpdateList", + "azure.mgmt.sql.models.RecommendedSensitivityLabelUpdateProperties": "Microsoft.Sql.RecommendedSensitivityLabelUpdateProperties", + "azure.mgmt.sql.models.RecoverableDatabase": "Microsoft.Sql.RecoverableDatabase", + "azure.mgmt.sql.models.RecoverableDatabaseProperties": "Microsoft.Sql.RecoverableDatabaseProperties", + "azure.mgmt.sql.models.RecoverableManagedDatabase": "Microsoft.Sql.RecoverableManagedDatabase", + "azure.mgmt.sql.models.RecoverableManagedDatabaseProperties": "Microsoft.Sql.RecoverableManagedDatabaseProperties", + "azure.mgmt.sql.models.RefreshExternalGovernanceStatusOperationResult": "Microsoft.Sql.RefreshExternalGovernanceStatusOperationResult", + "azure.mgmt.sql.models.RefreshExternalGovernanceStatusOperationResultMI": "Microsoft.Sql.RefreshExternalGovernanceStatusOperationResultMI", + "azure.mgmt.sql.models.RefreshExternalGovernanceStatusOperationResultProperties": "Microsoft.Sql.RefreshExternalGovernanceStatusOperationResultProperties", + "azure.mgmt.sql.models.RefreshExternalGovernanceStatusOperationResultPropertiesMI": "Microsoft.Sql.RefreshExternalGovernanceStatusOperationResultPropertiesMI", + "azure.mgmt.sql.models.Remediation": "Microsoft.Sql.Remediation", + "azure.mgmt.sql.models.ReplicationLink": "Microsoft.Sql.ReplicationLink", + "azure.mgmt.sql.models.ReplicationLinkProperties": "Microsoft.Sql.ReplicationLinkProperties", + "azure.mgmt.sql.models.ReplicationLinkUpdate": "Microsoft.Sql.ReplicationLinkUpdate", + "azure.mgmt.sql.models.ReplicationLinkUpdateProperties": "Microsoft.Sql.ReplicationLinkUpdateProperties", + "azure.mgmt.sql.models.ResourceIdentity": "Microsoft.Sql.ResourceIdentity", + "azure.mgmt.sql.models.ResourceMoveDefinition": "Microsoft.Sql.ResourceMoveDefinition", + "azure.mgmt.sql.models.RestorableDroppedDatabase": "Microsoft.Sql.RestorableDroppedDatabase", + "azure.mgmt.sql.models.RestorableDroppedDatabaseProperties": "Microsoft.Sql.RestorableDroppedDatabaseProperties", + "azure.mgmt.sql.models.RestorableDroppedManagedDatabase": "Microsoft.Sql.RestorableDroppedManagedDatabase", + "azure.mgmt.sql.models.RestorableDroppedManagedDatabaseProperties": "Microsoft.Sql.RestorableDroppedManagedDatabaseProperties", + "azure.mgmt.sql.models.RestorePoint": "Microsoft.Sql.RestorePoint", + "azure.mgmt.sql.models.RestorePointProperties": "Microsoft.Sql.RestorePointProperties", + "azure.mgmt.sql.models.ScheduleItem": "Microsoft.Sql.ScheduleItem", + "azure.mgmt.sql.models.SecurityAlertPolicyProperties": "Microsoft.Sql.SecurityAlertPolicyProperties", + "azure.mgmt.sql.models.SecurityAlertsPolicyProperties": "Microsoft.Sql.SecurityAlertsPolicyProperties", + "azure.mgmt.sql.models.SecurityEvent": "Microsoft.Sql.SecurityEvent", + "azure.mgmt.sql.models.SecurityEventProperties": "Microsoft.Sql.SecurityEventProperties", + "azure.mgmt.sql.models.SecurityEventSqlInjectionAdditionalProperties": "Microsoft.Sql.SecurityEventSqlInjectionAdditionalProperties", + "azure.mgmt.sql.models.SensitivityLabel": "Microsoft.Sql.SensitivityLabel", + "azure.mgmt.sql.models.SensitivityLabelProperties": "Microsoft.Sql.SensitivityLabelProperties", + "azure.mgmt.sql.models.SensitivityLabelUpdate": "Microsoft.Sql.SensitivityLabelUpdate", + "azure.mgmt.sql.models.SensitivityLabelUpdateList": "Microsoft.Sql.SensitivityLabelUpdateList", + "azure.mgmt.sql.models.SensitivityLabelUpdateProperties": "Microsoft.Sql.SensitivityLabelUpdateProperties", + "azure.mgmt.sql.models.Server": "Microsoft.Sql.Server", + "azure.mgmt.sql.models.ServerAdvancedThreatProtection": "Microsoft.Sql.ServerAdvancedThreatProtection", + "azure.mgmt.sql.models.ServerAutomaticTuning": "Microsoft.Sql.ServerAutomaticTuning", + "azure.mgmt.sql.models.ServerAzureADAdministrator": "Microsoft.Sql.ServerAzureADAdministrator", + "azure.mgmt.sql.models.ServerAzureADOnlyAuthentication": "Microsoft.Sql.ServerAzureADOnlyAuthentication", + "azure.mgmt.sql.models.ServerBlobAuditingPolicy": "Microsoft.Sql.ServerBlobAuditingPolicy", + "azure.mgmt.sql.models.ServerBlobAuditingPolicyProperties": "Microsoft.Sql.ServerBlobAuditingPolicyProperties", + "azure.mgmt.sql.models.ServerConfigurationOption": "Microsoft.Sql.ServerConfigurationOption", + "azure.mgmt.sql.models.ServerConfigurationOptionProperties": "Microsoft.Sql.ServerConfigurationOptionProperties", + "azure.mgmt.sql.models.ServerConnectionPolicy": "Microsoft.Sql.ServerConnectionPolicy", + "azure.mgmt.sql.models.ServerConnectionPolicyProperties": "Microsoft.Sql.ServerConnectionPolicyProperties", + "azure.mgmt.sql.models.ServerDevOpsAuditingSettings": "Microsoft.Sql.ServerDevOpsAuditingSettings", + "azure.mgmt.sql.models.ServerDevOpsAuditSettingsProperties": "Microsoft.Sql.ServerDevOpsAuditSettingsProperties", + "azure.mgmt.sql.models.ServerDnsAlias": "Microsoft.Sql.ServerDnsAlias", + "azure.mgmt.sql.models.ServerDnsAliasAcquisition": "Microsoft.Sql.ServerDnsAliasAcquisition", + "azure.mgmt.sql.models.ServerDnsAliasProperties": "Microsoft.Sql.ServerDnsAliasProperties", + "azure.mgmt.sql.models.ServerExternalAdministrator": "Microsoft.Sql.ServerExternalAdministrator", + "azure.mgmt.sql.models.ServerFirewallRuleProperties": "Microsoft.Sql.ServerFirewallRuleProperties", + "azure.mgmt.sql.models.ServerInfo": "Microsoft.Sql.ServerInfo", + "azure.mgmt.sql.models.ServerKey": "Microsoft.Sql.ServerKey", + "azure.mgmt.sql.models.ServerKeyProperties": "Microsoft.Sql.ServerKeyProperties", + "azure.mgmt.sql.models.ServerOperation": "Microsoft.Sql.ServerOperation", + "azure.mgmt.sql.models.ServerOperationProperties": "Microsoft.Sql.ServerOperationProperties", + "azure.mgmt.sql.models.ServerPrivateEndpointConnection": "Microsoft.Sql.ServerPrivateEndpointConnection", + "azure.mgmt.sql.models.ServerProperties": "Microsoft.Sql.ServerProperties", + "azure.mgmt.sql.models.ServerSecurityAlertPolicy": "Microsoft.Sql.ServerSecurityAlertPolicy", + "azure.mgmt.sql.models.ServerTrustCertificate": "Microsoft.Sql.ServerTrustCertificate", + "azure.mgmt.sql.models.ServerTrustCertificateProperties": "Microsoft.Sql.ServerTrustCertificateProperties", + "azure.mgmt.sql.models.ServerTrustGroup": "Microsoft.Sql.ServerTrustGroup", + "azure.mgmt.sql.models.ServerTrustGroupProperties": "Microsoft.Sql.ServerTrustGroupProperties", + "azure.mgmt.sql.models.ServerUpdate": "Microsoft.Sql.ServerUpdate", + "azure.mgmt.sql.models.ServerUsage": "Microsoft.Sql.ServerUsage", + "azure.mgmt.sql.models.ServerUsageProperties": "Microsoft.Sql.ServerUsageProperties", + "azure.mgmt.sql.models.ServerVersionCapability": "Microsoft.Sql.ServerVersionCapability", + "azure.mgmt.sql.models.ServerVulnerabilityAssessment": "Microsoft.Sql.ServerVulnerabilityAssessment", + "azure.mgmt.sql.models.ServerVulnerabilityAssessmentProperties": "Microsoft.Sql.ServerVulnerabilityAssessmentProperties", + "azure.mgmt.sql.models.ServiceObjectiveCapability": "Microsoft.Sql.ServiceObjectiveCapability", + "azure.mgmt.sql.models.ServicePrincipal": "Microsoft.Sql.ServicePrincipal", + "azure.mgmt.sql.models.Sku": "Microsoft.Sql.Sku", + "azure.mgmt.sql.models.SqlAgentConfiguration": "Microsoft.Sql.SqlAgentConfiguration", + "azure.mgmt.sql.models.SqlAgentConfigurationProperties": "Microsoft.Sql.SqlAgentConfigurationProperties", + "azure.mgmt.sql.models.SqlVulnerabilityAssessment": "Microsoft.Sql.SqlVulnerabilityAssessment", + "azure.mgmt.sql.models.SqlVulnerabilityAssessmentPolicyProperties": "Microsoft.Sql.SqlVulnerabilityAssessmentPolicyProperties", + "azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanError": "Microsoft.Sql.SqlVulnerabilityAssessmentScanError", + "azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanRecord": "Microsoft.Sql.SqlVulnerabilityAssessmentScanRecord", + "azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanRecordProperties": "Microsoft.Sql.SqlVulnerabilityAssessmentScanRecordProperties", + "azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanResultProperties": "Microsoft.Sql.SqlVulnerabilityAssessmentScanResultProperties", + "azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanResults": "Microsoft.Sql.SqlVulnerabilityAssessmentScanResults", + "azure.mgmt.sql.models.StartStopManagedInstanceSchedule": "Microsoft.Sql.StartStopManagedInstanceSchedule", + "azure.mgmt.sql.models.StartStopManagedInstanceScheduleProperties": "Microsoft.Sql.StartStopManagedInstanceScheduleProperties", + "azure.mgmt.sql.models.StorageCapability": "Microsoft.Sql.StorageCapability", + "azure.mgmt.sql.models.SubscriptionUsage": "Microsoft.Sql.SubscriptionUsage", + "azure.mgmt.sql.models.SubscriptionUsageProperties": "Microsoft.Sql.SubscriptionUsageProperties", + "azure.mgmt.sql.models.SynapseLinkWorkspace": "Microsoft.Sql.SynapseLinkWorkspace", + "azure.mgmt.sql.models.SynapseLinkWorkspaceInfoProperties": "Microsoft.Sql.SynapseLinkWorkspaceInfoProperties", + "azure.mgmt.sql.models.SynapseLinkWorkspaceProperties": "Microsoft.Sql.SynapseLinkWorkspaceProperties", + "azure.mgmt.sql.models.SyncAgent": "Microsoft.Sql.SyncAgent", + "azure.mgmt.sql.models.SyncAgentKeyProperties": "Microsoft.Sql.SyncAgentKeyProperties", + "azure.mgmt.sql.models.SyncAgentLinkedDatabase": "Microsoft.Sql.SyncAgentLinkedDatabase", + "azure.mgmt.sql.models.SyncAgentLinkedDatabaseProperties": "Microsoft.Sql.SyncAgentLinkedDatabaseProperties", + "azure.mgmt.sql.models.SyncAgentProperties": "Microsoft.Sql.SyncAgentProperties", + "azure.mgmt.sql.models.SyncDatabaseIdProperties": "Microsoft.Sql.SyncDatabaseIdProperties", + "azure.mgmt.sql.models.SyncFullSchemaProperties": "Microsoft.Sql.SyncFullSchemaProperties", + "azure.mgmt.sql.models.SyncFullSchemaTable": "Microsoft.Sql.SyncFullSchemaTable", + "azure.mgmt.sql.models.SyncFullSchemaTableColumn": "Microsoft.Sql.SyncFullSchemaTableColumn", + "azure.mgmt.sql.models.SyncGroup": "Microsoft.Sql.SyncGroup", + "azure.mgmt.sql.models.SyncGroupLogProperties": "Microsoft.Sql.SyncGroupLogProperties", + "azure.mgmt.sql.models.SyncGroupProperties": "Microsoft.Sql.SyncGroupProperties", + "azure.mgmt.sql.models.SyncGroupSchema": "Microsoft.Sql.SyncGroupSchema", + "azure.mgmt.sql.models.SyncGroupSchemaTable": "Microsoft.Sql.SyncGroupSchemaTable", + "azure.mgmt.sql.models.SyncGroupSchemaTableColumn": "Microsoft.Sql.SyncGroupSchemaTableColumn", + "azure.mgmt.sql.models.SyncMember": "Microsoft.Sql.SyncMember", + "azure.mgmt.sql.models.SyncMemberProperties": "Microsoft.Sql.SyncMemberProperties", + "azure.mgmt.sql.models.SystemData": "Azure.ResourceManager.CommonTypes.SystemData", + "azure.mgmt.sql.models.TdeCertificate": "Microsoft.Sql.TdeCertificate", + "azure.mgmt.sql.models.TdeCertificateProperties": "Microsoft.Sql.TdeCertificateProperties", + "azure.mgmt.sql.models.TimeZone": "Microsoft.Sql.TimeZone", + "azure.mgmt.sql.models.TimeZoneProperties": "Microsoft.Sql.TimeZoneProperties", + "azure.mgmt.sql.models.TopQueries": "Microsoft.Sql.TopQueries", + "azure.mgmt.sql.models.TransparentDataEncryptionProperties": "Microsoft.Sql.TransparentDataEncryptionProperties", + "azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters": "Microsoft.Sql.UpdateLongTermRetentionBackupParameters", + "azure.mgmt.sql.models.UpdateLongTermRetentionBackupParametersProperties": "Microsoft.Sql.UpdateLongTermRetentionBackupParametersProperties", + "azure.mgmt.sql.models.UpdateVirtualClusterDnsServersOperation": "Microsoft.Sql.UpdateVirtualClusterDnsServersOperation", + "azure.mgmt.sql.models.UpsertManagedServerOperationParameters": "Microsoft.Sql.UpsertManagedServerOperationParameters", + "azure.mgmt.sql.models.UpsertManagedServerOperationStepWithEstimatesAndDuration": "Microsoft.Sql.UpsertManagedServerOperationStepWithEstimatesAndDuration", + "azure.mgmt.sql.models.Usage": "Microsoft.Sql.Usage", + "azure.mgmt.sql.models.UserIdentity": "Microsoft.Sql.UserIdentity", + "azure.mgmt.sql.models.VaRule": "Microsoft.Sql.VaRule", + "azure.mgmt.sql.models.VirtualCluster": "Microsoft.Sql.VirtualCluster", + "azure.mgmt.sql.models.VirtualClusterDnsServersProperties": "Microsoft.Sql.VirtualClusterDnsServersProperties", + "azure.mgmt.sql.models.VirtualClusterProperties": "Microsoft.Sql.VirtualClusterProperties", + "azure.mgmt.sql.models.VirtualClusterUpdate": "Microsoft.Sql.VirtualClusterUpdate", + "azure.mgmt.sql.models.VirtualNetworkRule": "Microsoft.Sql.VirtualNetworkRule", + "azure.mgmt.sql.models.VirtualNetworkRuleProperties": "Microsoft.Sql.VirtualNetworkRuleProperties", + "azure.mgmt.sql.models.VulnerabilityAssessmentRecurringScansProperties": "Microsoft.Sql.VulnerabilityAssessmentRecurringScansProperties", + "azure.mgmt.sql.models.VulnerabilityAssessmentScanError": "Microsoft.Sql.VulnerabilityAssessmentScanError", + "azure.mgmt.sql.models.VulnerabilityAssessmentScanRecord": "Microsoft.Sql.VulnerabilityAssessmentScanRecord", + "azure.mgmt.sql.models.VulnerabilityAssessmentScanRecordProperties": "Microsoft.Sql.VulnerabilityAssessmentScanRecordProperties", + "azure.mgmt.sql.models.WorkloadClassifier": "Microsoft.Sql.WorkloadClassifier", + "azure.mgmt.sql.models.WorkloadClassifierProperties": "Microsoft.Sql.WorkloadClassifierProperties", + "azure.mgmt.sql.models.WorkloadGroup": "Microsoft.Sql.WorkloadGroup", + "azure.mgmt.sql.models.WorkloadGroupProperties": "Microsoft.Sql.WorkloadGroupProperties", + "azure.mgmt.sql.models.ZonePinningCapability": "Microsoft.Sql.ZonePinningCapability", + "azure.mgmt.sql.models.OperationOrigin": "Microsoft.Sql.OperationOrigin", + "azure.mgmt.sql.models.CreatedByType": "Azure.ResourceManager.CommonTypes.createdByType", + "azure.mgmt.sql.models.DiffBackupIntervalInHours": "Microsoft.Sql.DiffBackupIntervalInHours", + "azure.mgmt.sql.models.ShortTermRetentionPolicyName": "Microsoft.Sql.ShortTermRetentionPolicyName", + "azure.mgmt.sql.models.ColumnDataType": "Microsoft.Sql.ColumnDataType", + "azure.mgmt.sql.models.TableTemporalType": "Microsoft.Sql.TableTemporalType", + "azure.mgmt.sql.models.RestorePointType": "Microsoft.Sql.RestorePointType", + "azure.mgmt.sql.models.SensitivityLabelRank": "Microsoft.Sql.SensitivityLabelRank", + "azure.mgmt.sql.models.ClientClassificationSource": "Microsoft.Sql.ClientClassificationSource", + "azure.mgmt.sql.models.SensitivityLabelUpdateKind": "Microsoft.Sql.SensitivityLabelUpdateKind", + "azure.mgmt.sql.models.SensitivityLabelSource": "Microsoft.Sql.SensitivityLabelSource", + "azure.mgmt.sql.models.CreateMode": "Microsoft.Sql.CreateMode", + "azure.mgmt.sql.models.SampleName": "Microsoft.Sql.SampleName", + "azure.mgmt.sql.models.DatabaseStatus": "Microsoft.Sql.DatabaseStatus", + "azure.mgmt.sql.models.CatalogCollationType": "Microsoft.Sql.CatalogCollationType", + "azure.mgmt.sql.models.DatabaseLicenseType": "Microsoft.Sql.DatabaseLicenseType", + "azure.mgmt.sql.models.DatabaseReadScale": "Microsoft.Sql.DatabaseReadScale", + "azure.mgmt.sql.models.SecondaryType": "Microsoft.Sql.SecondaryType", + "azure.mgmt.sql.models.BackupStorageRedundancy": "Microsoft.Sql.BackupStorageRedundancy", + "azure.mgmt.sql.models.DatabaseKeyType": "Microsoft.Sql.DatabaseKeyType", + "azure.mgmt.sql.models.AlwaysEncryptedEnclaveType": "Microsoft.Sql.AlwaysEncryptedEnclaveType", + "azure.mgmt.sql.models.FreeLimitExhaustionBehavior": "Microsoft.Sql.FreeLimitExhaustionBehavior", + "azure.mgmt.sql.models.AvailabilityZoneType": "Microsoft.Sql.AvailabilityZoneType", + "azure.mgmt.sql.models.DatabaseIdentityType": "Microsoft.Sql.DatabaseIdentityType", + "azure.mgmt.sql.models.StorageKeyType": "Microsoft.Sql.StorageKeyType", + "azure.mgmt.sql.models.ReplicaType": "Microsoft.Sql.ReplicaType", + "azure.mgmt.sql.models.ReplicationRole": "Microsoft.Sql.ReplicationRole", + "azure.mgmt.sql.models.ReplicationState": "Microsoft.Sql.ReplicationState", + "azure.mgmt.sql.models.ReplicationLinkType": "Microsoft.Sql.ReplicationLinkType", + "azure.mgmt.sql.models.PrivateLinkServiceConnectionStateStatus": "Microsoft.Sql.PrivateLinkServiceConnectionStateStatus", + "azure.mgmt.sql.models.PrivateLinkServiceConnectionStateActionsRequire": "Microsoft.Sql.PrivateLinkServiceConnectionStateActionsRequire", + "azure.mgmt.sql.models.PrivateEndpointProvisioningState": "Microsoft.Sql.PrivateEndpointProvisioningState", + "azure.mgmt.sql.models.MinimalTlsVersion": "Microsoft.Sql.MinimalTlsVersion", + "azure.mgmt.sql.models.ServerPublicNetworkAccessFlag": "Microsoft.Sql.ServerPublicNetworkAccessFlag", + "azure.mgmt.sql.models.ServerWorkspaceFeature": "Microsoft.Sql.ServerWorkspaceFeature", + "azure.mgmt.sql.models.AdministratorType": "Microsoft.Sql.AdministratorType", + "azure.mgmt.sql.models.PrincipalType": "Microsoft.Sql.PrincipalType", + "azure.mgmt.sql.models.ServerNetworkAccessFlag": "Microsoft.Sql.ServerNetworkAccessFlag", + "azure.mgmt.sql.models.ExternalGovernanceStatus": "Microsoft.Sql.ExternalGovernanceStatus", + "azure.mgmt.sql.models.ServerCreateMode": "Microsoft.Sql.ServerCreateMode", + "azure.mgmt.sql.models.IdentityType": "Microsoft.Sql.IdentityType", + "azure.mgmt.sql.models.CheckNameAvailabilityReason": "Microsoft.Sql.CheckNameAvailabilityReason", + "azure.mgmt.sql.models.CheckNameAvailabilityResourceType": "Microsoft.Sql.CheckNameAvailabilityResourceType", + "azure.mgmt.sql.models.BlobAuditingPolicyState": "Microsoft.Sql.BlobAuditingPolicyState", + "azure.mgmt.sql.models.AdvisorStatus": "Microsoft.Sql.AdvisorStatus", + "azure.mgmt.sql.models.AutoExecuteStatus": "Microsoft.Sql.AutoExecuteStatus", + "azure.mgmt.sql.models.AutoExecuteStatusInheritedFrom": "Microsoft.Sql.AutoExecuteStatusInheritedFrom", + "azure.mgmt.sql.models.RecommendedActionCurrentState": "Microsoft.Sql.RecommendedActionCurrentState", + "azure.mgmt.sql.models.RecommendedActionInitiatedBy": "Microsoft.Sql.RecommendedActionInitiatedBy", + "azure.mgmt.sql.models.ImplementationMethod": "Microsoft.Sql.ImplementationMethod", + "azure.mgmt.sql.models.IsRetryable": "Microsoft.Sql.IsRetryable", + "azure.mgmt.sql.models.SecurityAlertsPolicyState": "Microsoft.Sql.SecurityAlertsPolicyState", + "azure.mgmt.sql.models.SecurityAlertPolicyName": "Microsoft.Sql.SecurityAlertPolicyName", + "azure.mgmt.sql.models.VulnerabilityAssessmentName": "Microsoft.Sql.VulnerabilityAssessmentName", + "azure.mgmt.sql.models.BaselineName": "Microsoft.Sql.BaselineName", + "azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName": "Microsoft.Sql.VulnerabilityAssessmentSystemDatabaseName", + "azure.mgmt.sql.models.SqlVulnerabilityAssessmentState": "Microsoft.Sql.SqlVulnerabilityAssessmentState", + "azure.mgmt.sql.models.SqlVulnerabilityAssessmentName": "Microsoft.Sql.SqlVulnerabilityAssessmentName", + "azure.mgmt.sql.models.RuleStatus": "Microsoft.Sql.RuleStatus", + "azure.mgmt.sql.models.RuleSeverity": "Microsoft.Sql.RuleSeverity", + "azure.mgmt.sql.models.RuleType": "Microsoft.Sql.RuleType", + "azure.mgmt.sql.models.VulnerabilityAssessmentScanTriggerType": "Microsoft.Sql.VulnerabilityAssessmentScanTriggerType", + "azure.mgmt.sql.models.VulnerabilityAssessmentScanState": "Microsoft.Sql.VulnerabilityAssessmentScanState", + "azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName": "Microsoft.Sql.VulnerabilityAssessmentPolicyBaselineName", + "azure.mgmt.sql.models.DataMaskingState": "Microsoft.Sql.DataMaskingState", + "azure.mgmt.sql.models.DataMaskingPolicyName": "Microsoft.Sql.DataMaskingPolicyName", + "azure.mgmt.sql.models.ReplicationModeType": "Microsoft.Sql.ReplicationModeType", + "azure.mgmt.sql.models.LinkRole": "Microsoft.Sql.LinkRole", + "azure.mgmt.sql.models.FailoverModeType": "Microsoft.Sql.FailoverModeType", + "azure.mgmt.sql.models.SeedingModeType": "Microsoft.Sql.SeedingModeType", + "azure.mgmt.sql.models.ReplicaSynchronizationHealth": "Microsoft.Sql.ReplicaSynchronizationHealth", + "azure.mgmt.sql.models.ReplicaConnectedState": "Microsoft.Sql.ReplicaConnectedState", + "azure.mgmt.sql.models.FailoverType": "Microsoft.Sql.FailoverType", + "azure.mgmt.sql.models.InstanceRole": "Microsoft.Sql.InstanceRole", + "azure.mgmt.sql.models.RoleChangeType": "Microsoft.Sql.RoleChangeType", + "azure.mgmt.sql.models.ManagedDatabaseStatus": "Microsoft.Sql.ManagedDatabaseStatus", + "azure.mgmt.sql.models.ManagedDatabaseCreateMode": "Microsoft.Sql.ManagedDatabaseCreateMode", + "azure.mgmt.sql.models.InaccessibilityReason": "Microsoft.Sql.InaccessibilityReason", + "azure.mgmt.sql.models.MoveOperationMode": "Microsoft.Sql.MoveOperationMode", + "azure.mgmt.sql.models.ServerTrustGroupPropertiesTrustScopesItem": "Microsoft.Sql.ServerTrustGroupPropertiesTrustScopesItem", + "azure.mgmt.sql.models.ProvisioningState": "Microsoft.Sql.ProvisioningState", + "azure.mgmt.sql.models.ManagedServerCreateMode": "Microsoft.Sql.ManagedServerCreateMode", + "azure.mgmt.sql.models.ManagedInstanceLicenseType": "Microsoft.Sql.ManagedInstanceLicenseType", + "azure.mgmt.sql.models.HybridSecondaryUsage": "Microsoft.Sql.HybridSecondaryUsage", + "azure.mgmt.sql.models.HybridSecondaryUsageDetected": "Microsoft.Sql.HybridSecondaryUsageDetected", + "azure.mgmt.sql.models.ManagedInstanceProxyOverride": "Microsoft.Sql.ManagedInstanceProxyOverride", + "azure.mgmt.sql.models.ServicePrincipalType": "Microsoft.Sql.ServicePrincipalType", + "azure.mgmt.sql.models.PricingModel": "Microsoft.Sql.PricingModel", + "azure.mgmt.sql.models.AuthMetadataLookupModes": "Microsoft.Sql.AuthMetadataLookupModes", + "azure.mgmt.sql.models.ManagedInstanceDatabaseFormat": "Microsoft.Sql.ManagedInstanceDatabaseFormat", + "azure.mgmt.sql.models.QueryTimeGrainType": "Microsoft.Sql.QueryTimeGrainType", + "azure.mgmt.sql.models.QueryMetricUnitType": "Microsoft.Sql.QueryMetricUnitType", + "azure.mgmt.sql.models.AggregationFunctionType": "Microsoft.Sql.AggregationFunctionType", + "azure.mgmt.sql.models.MetricType": "Microsoft.Sql.MetricType", + "azure.mgmt.sql.models.ElasticPoolState": "Microsoft.Sql.ElasticPoolState", + "azure.mgmt.sql.models.ElasticPoolLicenseType": "Microsoft.Sql.ElasticPoolLicenseType", + "azure.mgmt.sql.models.ServerKeyType": "Microsoft.Sql.ServerKeyType", + "azure.mgmt.sql.models.EncryptionProtectorName": "Microsoft.Sql.EncryptionProtectorName", + "azure.mgmt.sql.models.ReadWriteEndpointFailoverPolicy": "Microsoft.Sql.ReadWriteEndpointFailoverPolicy", + "azure.mgmt.sql.models.ReadOnlyEndpointFailoverPolicy": "Microsoft.Sql.ReadOnlyEndpointFailoverPolicy", + "azure.mgmt.sql.models.FailoverGroupReplicationRole": "Microsoft.Sql.FailoverGroupReplicationRole", + "azure.mgmt.sql.models.FailoverGroupDatabasesSecondaryType": "Microsoft.Sql.FailoverGroupDatabasesSecondaryType", + "azure.mgmt.sql.models.GeoBackupPolicyState": "Microsoft.Sql.GeoBackupPolicyState", + "azure.mgmt.sql.models.GeoBackupPolicyName": "Microsoft.Sql.GeoBackupPolicyName", + "azure.mgmt.sql.models.SecondaryInstanceType": "Microsoft.Sql.SecondaryInstanceType", + "azure.mgmt.sql.models.InstanceFailoverGroupReplicationRole": "Microsoft.Sql.InstanceFailoverGroupReplicationRole", + "azure.mgmt.sql.models.ManagementOperationState": "Microsoft.Sql.ManagementOperationState", + "azure.mgmt.sql.models.ErrorType": "Microsoft.Sql.ErrorType", + "azure.mgmt.sql.models.InstancePoolLicenseType": "Microsoft.Sql.InstancePoolLicenseType", + "azure.mgmt.sql.models.JobExecutionLifecycle": "Microsoft.Sql.JobExecutionLifecycle", + "azure.mgmt.sql.models.JobTargetType": "Microsoft.Sql.JobTargetType", + "azure.mgmt.sql.models.JobAgentState": "Microsoft.Sql.JobAgentState", + "azure.mgmt.sql.models.JobAgentIdentityType": "Microsoft.Sql.JobAgentIdentityType", + "azure.mgmt.sql.models.JobScheduleType": "Microsoft.Sql.JobScheduleType", + "azure.mgmt.sql.models.JobStepActionType": "Microsoft.Sql.JobStepActionType", + "azure.mgmt.sql.models.JobStepActionSource": "Microsoft.Sql.JobStepActionSource", + "azure.mgmt.sql.models.JobStepOutputType": "Microsoft.Sql.JobStepOutputType", + "azure.mgmt.sql.models.JobTargetGroupMembershipType": "Microsoft.Sql.JobTargetGroupMembershipType", + "azure.mgmt.sql.models.TimeBasedImmutability": "Microsoft.Sql.TimeBasedImmutability", + "azure.mgmt.sql.models.TimeBasedImmutabilityMode": "Microsoft.Sql.TimeBasedImmutabilityMode", + "azure.mgmt.sql.models.SetLegalHoldImmutability": "Microsoft.Sql.SetLegalHoldImmutability", + "azure.mgmt.sql.models.BackupStorageAccessTier": "Microsoft.Sql.BackupStorageAccessTier", + "azure.mgmt.sql.models.DatabaseState": "Microsoft.Sql.DatabaseState", + "azure.mgmt.sql.models.LongTermRetentionPolicyName": "Microsoft.Sql.LongTermRetentionPolicyName", + "azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName": "Microsoft.Sql.ManagedShortTermRetentionPolicyName", + "azure.mgmt.sql.models.SecurityAlertPolicyState": "Microsoft.Sql.SecurityAlertPolicyState", + "azure.mgmt.sql.models.ManagedInstanceAdministratorType": "Microsoft.Sql.ManagedInstanceAdministratorType", + "azure.mgmt.sql.models.AdministratorName": "Microsoft.Sql.AdministratorName", + "azure.mgmt.sql.models.AuthenticationName": "Microsoft.Sql.AuthenticationName", + "azure.mgmt.sql.models.DtcName": "Microsoft.Sql.DtcName", + "azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicyName": "Microsoft.Sql.ManagedInstanceLongTermRetentionPolicyName", + "azure.mgmt.sql.models.UpsertManagedServerOperationStepWithEstimatesAndDurationStatus": "Microsoft.Sql.UpsertManagedServerOperationStepWithEstimatesAndDurationStatus", + "azure.mgmt.sql.models.ServerConfigurationOptionName": "Microsoft.Sql.ServerConfigurationOptionName", + "azure.mgmt.sql.models.ServerConnectionType": "Microsoft.Sql.ServerConnectionType", + "azure.mgmt.sql.models.ConnectionPolicyName": "Microsoft.Sql.ConnectionPolicyName", + "azure.mgmt.sql.models.DevOpsAuditingSettingsName": "Microsoft.Sql.DevOpsAuditingSettingsName", + "azure.mgmt.sql.models.DayOfWeek": "Microsoft.Sql.DayOfWeek", + "azure.mgmt.sql.models.StartStopScheduleName": "Microsoft.Sql.StartStopScheduleName", + "azure.mgmt.sql.models.SyncAgentState": "Microsoft.Sql.SyncAgentState", + "azure.mgmt.sql.models.SyncMemberDbType": "Microsoft.Sql.SyncMemberDbType", + "azure.mgmt.sql.models.SyncConflictResolutionPolicy": "Microsoft.Sql.SyncConflictResolutionPolicy", + "azure.mgmt.sql.models.SyncGroupState": "Microsoft.Sql.SyncGroupState", + "azure.mgmt.sql.models.DataSyncParticipantIdentityType": "Microsoft.Sql.DataSyncParticipantIdentityType", + "azure.mgmt.sql.models.SyncGroupLogType": "Microsoft.Sql.SyncGroupLogType", + "azure.mgmt.sql.models.SyncGroupsType": "Microsoft.Sql.SyncGroupsType", + "azure.mgmt.sql.models.SyncDirection": "Microsoft.Sql.SyncDirection", + "azure.mgmt.sql.models.SyncMemberState": "Microsoft.Sql.SyncMemberState", + "azure.mgmt.sql.models.DNSRefreshOperationStatus": "Microsoft.Sql.DNSRefreshOperationStatus", + "azure.mgmt.sql.models.VirtualNetworkRuleState": "Microsoft.Sql.VirtualNetworkRuleState", + "azure.mgmt.sql.models.Phase": "Microsoft.Sql.Phase", + "azure.mgmt.sql.models.RecommendedSensitivityLabelUpdateKind": "Microsoft.Sql.RecommendedSensitivityLabelUpdateKind", + "azure.mgmt.sql.models.AdvancedThreatProtectionState": "Microsoft.Sql.AdvancedThreatProtectionState", + "azure.mgmt.sql.models.AdvancedThreatProtectionName": "Microsoft.Sql.AdvancedThreatProtectionName", + "azure.mgmt.sql.models.AutomaticTuningMode": "Microsoft.Sql.AutomaticTuningMode", + "azure.mgmt.sql.models.AutomaticTuningOptionModeDesired": "Microsoft.Sql.AutomaticTuningOptionModeDesired", + "azure.mgmt.sql.models.AutomaticTuningOptionModeActual": "Microsoft.Sql.AutomaticTuningOptionModeActual", + "azure.mgmt.sql.models.AutomaticTuningDisabledReason": "Microsoft.Sql.AutomaticTuningDisabledReason", + "azure.mgmt.sql.models.OperationMode": "Microsoft.Sql.OperationMode", + "azure.mgmt.sql.models.DataMaskingRuleState": "Microsoft.Sql.DataMaskingRuleState", + "azure.mgmt.sql.models.DataMaskingFunction": "Microsoft.Sql.DataMaskingFunction", + "azure.mgmt.sql.models.DataWarehouseUserActivityName": "Microsoft.Sql.DataWarehouseUserActivityName", + "azure.mgmt.sql.models.SecurityEventType": "Microsoft.Sql.SecurityEventType", + "azure.mgmt.sql.models.LedgerDigestUploadsState": "Microsoft.Sql.LedgerDigestUploadsState", + "azure.mgmt.sql.models.LedgerDigestUploadsName": "Microsoft.Sql.LedgerDigestUploadsName", + "azure.mgmt.sql.models.RestoreDetailsName": "Microsoft.Sql.RestoreDetailsName", + "azure.mgmt.sql.models.TransparentDataEncryptionState": "Microsoft.Sql.TransparentDataEncryptionState", + "azure.mgmt.sql.models.TransparentDataEncryptionName": "Microsoft.Sql.TransparentDataEncryptionName", + "azure.mgmt.sql.models.ManagedLedgerDigestUploadsState": "Microsoft.Sql.ManagedLedgerDigestUploadsState", + "azure.mgmt.sql.models.ManagedLedgerDigestUploadsName": "Microsoft.Sql.ManagedLedgerDigestUploadsName", + "azure.mgmt.sql.models.AutomaticTuningServerMode": "Microsoft.Sql.AutomaticTuningServerMode", + "azure.mgmt.sql.models.AutomaticTuningServerReason": "Microsoft.Sql.AutomaticTuningServerReason", + "azure.mgmt.sql.models.SqlAgentConfigurationPropertiesState": "Microsoft.Sql.SqlAgentConfigurationPropertiesState", + "azure.mgmt.sql.models.TransparentDataEncryptionScanState": "Microsoft.Sql.TransparentDataEncryptionScanState", + "azure.mgmt.sql.models.MaxSizeUnit": "Microsoft.Sql.MaxSizeUnit", + "azure.mgmt.sql.models.LogSizeUnit": "Microsoft.Sql.LogSizeUnit", + "azure.mgmt.sql.models.CapabilityStatus": "Microsoft.Sql.CapabilityStatus", + "azure.mgmt.sql.models.PerformanceLevelUnit": "Microsoft.Sql.PerformanceLevelUnit", + "azure.mgmt.sql.models.PauseDelayTimeUnit": "Microsoft.Sql.PauseDelayTimeUnit", + "azure.mgmt.sql.models.StorageCapabilityStorageAccountType": "Microsoft.Sql.StorageCapabilityStorageAccountType", + "azure.mgmt.sql.models.CapabilityGroup": "Microsoft.Sql.CapabilityGroup", + "azure.mgmt.sql.operations.Operations.list": "Azure.ResourceManager.Legacy.Operations.list", + "azure.mgmt.sql.aio.operations.Operations.list": "Azure.ResourceManager.Legacy.Operations.list", + "azure.mgmt.sql.operations.BackupShortTermRetentionPoliciesOperations.get": "Microsoft.Sql.BackupShortTermRetentionPolicies.get", + "azure.mgmt.sql.aio.operations.BackupShortTermRetentionPoliciesOperations.get": "Microsoft.Sql.BackupShortTermRetentionPolicies.get", + "azure.mgmt.sql.operations.BackupShortTermRetentionPoliciesOperations.begin_create_or_update": "Microsoft.Sql.BackupShortTermRetentionPolicies.createOrUpdate", + "azure.mgmt.sql.aio.operations.BackupShortTermRetentionPoliciesOperations.begin_create_or_update": "Microsoft.Sql.BackupShortTermRetentionPolicies.createOrUpdate", + "azure.mgmt.sql.operations.BackupShortTermRetentionPoliciesOperations.begin_update": "Microsoft.Sql.BackupShortTermRetentionPolicies.update", + "azure.mgmt.sql.aio.operations.BackupShortTermRetentionPoliciesOperations.begin_update": "Microsoft.Sql.BackupShortTermRetentionPolicies.update", + "azure.mgmt.sql.operations.BackupShortTermRetentionPoliciesOperations.list_by_database": "Microsoft.Sql.BackupShortTermRetentionPolicies.listByDatabase", + "azure.mgmt.sql.aio.operations.BackupShortTermRetentionPoliciesOperations.list_by_database": "Microsoft.Sql.BackupShortTermRetentionPolicies.listByDatabase", + "azure.mgmt.sql.operations.DatabaseColumnsOperations.get": "Microsoft.Sql.DatabaseColumns.get", + "azure.mgmt.sql.aio.operations.DatabaseColumnsOperations.get": "Microsoft.Sql.DatabaseColumns.get", + "azure.mgmt.sql.operations.DatabaseColumnsOperations.list_by_table": "Microsoft.Sql.DatabaseColumns.listByTable", + "azure.mgmt.sql.aio.operations.DatabaseColumnsOperations.list_by_table": "Microsoft.Sql.DatabaseColumns.listByTable", + "azure.mgmt.sql.operations.DatabaseColumnsOperations.list_by_database": "Microsoft.Sql.Databases.listByDatabase", + "azure.mgmt.sql.aio.operations.DatabaseColumnsOperations.list_by_database": "Microsoft.Sql.Databases.listByDatabase", + "azure.mgmt.sql.operations.RestorePointsOperations.get": "Microsoft.Sql.RestorePoints.get", + "azure.mgmt.sql.aio.operations.RestorePointsOperations.get": "Microsoft.Sql.RestorePoints.get", + "azure.mgmt.sql.operations.RestorePointsOperations.delete": "Microsoft.Sql.RestorePoints.delete", + "azure.mgmt.sql.aio.operations.RestorePointsOperations.delete": "Microsoft.Sql.RestorePoints.delete", + "azure.mgmt.sql.operations.RestorePointsOperations.list_by_database": "Microsoft.Sql.RestorePoints.listByDatabase", + "azure.mgmt.sql.aio.operations.RestorePointsOperations.list_by_database": "Microsoft.Sql.RestorePoints.listByDatabase", + "azure.mgmt.sql.operations.RestorePointsOperations.begin_create": "Microsoft.Sql.Databases.create", + "azure.mgmt.sql.aio.operations.RestorePointsOperations.begin_create": "Microsoft.Sql.Databases.create", + "azure.mgmt.sql.operations.SensitivityLabelsOperations.list_current_by_database": "Microsoft.Sql.Databases.listCurrentByDatabase", + "azure.mgmt.sql.aio.operations.SensitivityLabelsOperations.list_current_by_database": "Microsoft.Sql.Databases.listCurrentByDatabase", + "azure.mgmt.sql.operations.SensitivityLabelsOperations.update": "Microsoft.Sql.Databases.sensitivityLabelsUpdate", + "azure.mgmt.sql.aio.operations.SensitivityLabelsOperations.update": "Microsoft.Sql.Databases.sensitivityLabelsUpdate", + "azure.mgmt.sql.operations.SensitivityLabelsOperations.list_recommended_by_database": "Microsoft.Sql.Databases.listRecommendedByDatabase", + "azure.mgmt.sql.aio.operations.SensitivityLabelsOperations.list_recommended_by_database": "Microsoft.Sql.Databases.listRecommendedByDatabase", + "azure.mgmt.sql.operations.SensitivityLabelsOperations.list_by_database": "Microsoft.Sql.Databases.sensitivityLabelsListByDatabase", + "azure.mgmt.sql.aio.operations.SensitivityLabelsOperations.list_by_database": "Microsoft.Sql.Databases.sensitivityLabelsListByDatabase", + "azure.mgmt.sql.operations.SensitivityLabelsOperations.get": "Microsoft.Sql.SensitivityLabelOperationGroup.get", + "azure.mgmt.sql.aio.operations.SensitivityLabelsOperations.get": "Microsoft.Sql.SensitivityLabelOperationGroup.get", + "azure.mgmt.sql.operations.SensitivityLabelsOperations.create_or_update": "Microsoft.Sql.SensitivityLabelOperationGroup.createOrUpdate", + "azure.mgmt.sql.aio.operations.SensitivityLabelsOperations.create_or_update": "Microsoft.Sql.SensitivityLabelOperationGroup.createOrUpdate", + "azure.mgmt.sql.operations.SensitivityLabelsOperations.delete": "Microsoft.Sql.SensitivityLabelOperationGroup.delete", + "azure.mgmt.sql.aio.operations.SensitivityLabelsOperations.delete": "Microsoft.Sql.SensitivityLabelOperationGroup.delete", + "azure.mgmt.sql.operations.SensitivityLabelsOperations.disable_recommendation": "Microsoft.Sql.SensitivityLabelOperationGroup.disableRecommendation", + "azure.mgmt.sql.aio.operations.SensitivityLabelsOperations.disable_recommendation": "Microsoft.Sql.SensitivityLabelOperationGroup.disableRecommendation", + "azure.mgmt.sql.operations.SensitivityLabelsOperations.enable_recommendation": "Microsoft.Sql.SensitivityLabelOperationGroup.enableRecommendation", + "azure.mgmt.sql.aio.operations.SensitivityLabelsOperations.enable_recommendation": "Microsoft.Sql.SensitivityLabelOperationGroup.enableRecommendation", + "azure.mgmt.sql.operations.DatabasesOperations.get": "Microsoft.Sql.Databases.get", + "azure.mgmt.sql.aio.operations.DatabasesOperations.get": "Microsoft.Sql.Databases.get", + "azure.mgmt.sql.operations.DatabasesOperations.begin_create_or_update": "Microsoft.Sql.Databases.createOrUpdate", + "azure.mgmt.sql.aio.operations.DatabasesOperations.begin_create_or_update": "Microsoft.Sql.Databases.createOrUpdate", + "azure.mgmt.sql.operations.DatabasesOperations.begin_update": "Microsoft.Sql.Databases.update", + "azure.mgmt.sql.aio.operations.DatabasesOperations.begin_update": "Microsoft.Sql.Databases.update", + "azure.mgmt.sql.operations.DatabasesOperations.begin_delete": "Microsoft.Sql.Databases.delete", + "azure.mgmt.sql.aio.operations.DatabasesOperations.begin_delete": "Microsoft.Sql.Databases.delete", + "azure.mgmt.sql.operations.DatabasesOperations.list_by_server": "Microsoft.Sql.Databases.listByServer", + "azure.mgmt.sql.aio.operations.DatabasesOperations.list_by_server": "Microsoft.Sql.Databases.listByServer", + "azure.mgmt.sql.operations.DatabasesOperations.begin_export": "Microsoft.Sql.Databases.export", + "azure.mgmt.sql.aio.operations.DatabasesOperations.begin_export": "Microsoft.Sql.Databases.export", + "azure.mgmt.sql.operations.DatabasesOperations.begin_failover": "Microsoft.Sql.Databases.failover", + "azure.mgmt.sql.aio.operations.DatabasesOperations.begin_failover": "Microsoft.Sql.Databases.failover", + "azure.mgmt.sql.operations.DatabasesOperations.begin_import_method": "Microsoft.Sql.Databases.importDatabase", + "azure.mgmt.sql.aio.operations.DatabasesOperations.begin_import_method": "Microsoft.Sql.Databases.importDatabase", + "azure.mgmt.sql.operations.DatabasesOperations.rename": "Microsoft.Sql.Databases.rename", + "azure.mgmt.sql.aio.operations.DatabasesOperations.rename": "Microsoft.Sql.Databases.rename", + "azure.mgmt.sql.operations.DatabasesOperations.begin_pause": "Microsoft.Sql.Databases.pause", + "azure.mgmt.sql.aio.operations.DatabasesOperations.begin_pause": "Microsoft.Sql.Databases.pause", + "azure.mgmt.sql.operations.DatabasesOperations.begin_resume": "Microsoft.Sql.Databases.resume", + "azure.mgmt.sql.aio.operations.DatabasesOperations.begin_resume": "Microsoft.Sql.Databases.resume", + "azure.mgmt.sql.operations.DatabasesOperations.begin_upgrade_data_warehouse": "Microsoft.Sql.Databases.upgradeDataWarehouse", + "azure.mgmt.sql.aio.operations.DatabasesOperations.begin_upgrade_data_warehouse": "Microsoft.Sql.Databases.upgradeDataWarehouse", + "azure.mgmt.sql.operations.DatabasesOperations.list_inaccessible_by_server": "Microsoft.Sql.Servers.listInaccessibleByServer", + "azure.mgmt.sql.aio.operations.DatabasesOperations.list_inaccessible_by_server": "Microsoft.Sql.Servers.listInaccessibleByServer", + "azure.mgmt.sql.operations.DatabasesOperations.list_by_elastic_pool": "Microsoft.Sql.ElasticPools.listByElasticPool", + "azure.mgmt.sql.aio.operations.DatabasesOperations.list_by_elastic_pool": "Microsoft.Sql.ElasticPools.listByElasticPool", + "azure.mgmt.sql.operations.FirewallRulesOperations.get": "Microsoft.Sql.FirewallRules.get", + "azure.mgmt.sql.aio.operations.FirewallRulesOperations.get": "Microsoft.Sql.FirewallRules.get", + "azure.mgmt.sql.operations.FirewallRulesOperations.create_or_update": "Microsoft.Sql.FirewallRules.createOrUpdate", + "azure.mgmt.sql.aio.operations.FirewallRulesOperations.create_or_update": "Microsoft.Sql.FirewallRules.createOrUpdate", + "azure.mgmt.sql.operations.FirewallRulesOperations.delete": "Microsoft.Sql.FirewallRules.delete", + "azure.mgmt.sql.aio.operations.FirewallRulesOperations.delete": "Microsoft.Sql.FirewallRules.delete", + "azure.mgmt.sql.operations.FirewallRulesOperations.list_by_server": "Microsoft.Sql.FirewallRules.listByServer", + "azure.mgmt.sql.aio.operations.FirewallRulesOperations.list_by_server": "Microsoft.Sql.FirewallRules.listByServer", + "azure.mgmt.sql.operations.FirewallRulesOperations.replace": "Microsoft.Sql.Servers.replace", + "azure.mgmt.sql.aio.operations.FirewallRulesOperations.replace": "Microsoft.Sql.Servers.replace", + "azure.mgmt.sql.operations.ReplicationLinksOperations.get": "Microsoft.Sql.ReplicationLinks.get", + "azure.mgmt.sql.aio.operations.ReplicationLinksOperations.get": "Microsoft.Sql.ReplicationLinks.get", + "azure.mgmt.sql.operations.ReplicationLinksOperations.begin_create_or_update": "Microsoft.Sql.ReplicationLinks.createOrUpdate", + "azure.mgmt.sql.aio.operations.ReplicationLinksOperations.begin_create_or_update": "Microsoft.Sql.ReplicationLinks.createOrUpdate", + "azure.mgmt.sql.operations.ReplicationLinksOperations.begin_update": "Microsoft.Sql.ReplicationLinks.update", + "azure.mgmt.sql.aio.operations.ReplicationLinksOperations.begin_update": "Microsoft.Sql.ReplicationLinks.update", + "azure.mgmt.sql.operations.ReplicationLinksOperations.begin_delete": "Microsoft.Sql.ReplicationLinks.delete", + "azure.mgmt.sql.aio.operations.ReplicationLinksOperations.begin_delete": "Microsoft.Sql.ReplicationLinks.delete", + "azure.mgmt.sql.operations.ReplicationLinksOperations.list_by_database": "Microsoft.Sql.ReplicationLinks.listByDatabase", + "azure.mgmt.sql.aio.operations.ReplicationLinksOperations.list_by_database": "Microsoft.Sql.ReplicationLinks.listByDatabase", + "azure.mgmt.sql.operations.ReplicationLinksOperations.begin_failover": "Microsoft.Sql.ReplicationLinks.failover", + "azure.mgmt.sql.aio.operations.ReplicationLinksOperations.begin_failover": "Microsoft.Sql.ReplicationLinks.failover", + "azure.mgmt.sql.operations.ReplicationLinksOperations.begin_failover_allow_data_loss": "Microsoft.Sql.ReplicationLinks.failoverAllowDataLoss", + "azure.mgmt.sql.aio.operations.ReplicationLinksOperations.begin_failover_allow_data_loss": "Microsoft.Sql.ReplicationLinks.failoverAllowDataLoss", + "azure.mgmt.sql.operations.ReplicationLinksOperations.list_by_server": "Microsoft.Sql.Servers.listByServer", + "azure.mgmt.sql.aio.operations.ReplicationLinksOperations.list_by_server": "Microsoft.Sql.Servers.listByServer", + "azure.mgmt.sql.operations.ServersOperations.get": "Microsoft.Sql.Servers.get", + "azure.mgmt.sql.aio.operations.ServersOperations.get": "Microsoft.Sql.Servers.get", + "azure.mgmt.sql.operations.ServersOperations.begin_create_or_update": "Microsoft.Sql.Servers.createOrUpdate", + "azure.mgmt.sql.aio.operations.ServersOperations.begin_create_or_update": "Microsoft.Sql.Servers.createOrUpdate", + "azure.mgmt.sql.operations.ServersOperations.begin_update": "Microsoft.Sql.Servers.update", + "azure.mgmt.sql.aio.operations.ServersOperations.begin_update": "Microsoft.Sql.Servers.update", + "azure.mgmt.sql.operations.ServersOperations.begin_delete": "Microsoft.Sql.Servers.delete", + "azure.mgmt.sql.aio.operations.ServersOperations.begin_delete": "Microsoft.Sql.Servers.delete", + "azure.mgmt.sql.operations.ServersOperations.list_by_resource_group": "Microsoft.Sql.Servers.listByResourceGroup", + "azure.mgmt.sql.aio.operations.ServersOperations.list_by_resource_group": "Microsoft.Sql.Servers.listByResourceGroup", + "azure.mgmt.sql.operations.ServersOperations.list": "Microsoft.Sql.Servers.list", + "azure.mgmt.sql.aio.operations.ServersOperations.list": "Microsoft.Sql.Servers.list", + "azure.mgmt.sql.operations.ServersOperations.begin_import_database": "Microsoft.Sql.Servers.importDatabase", + "azure.mgmt.sql.aio.operations.ServersOperations.begin_import_database": "Microsoft.Sql.Servers.importDatabase", + "azure.mgmt.sql.operations.ServersOperations.begin_refresh_status": "Microsoft.Sql.Servers.refreshStatus", + "azure.mgmt.sql.aio.operations.ServersOperations.begin_refresh_status": "Microsoft.Sql.Servers.refreshStatus", + "azure.mgmt.sql.operations.ServersOperations.check_name_availability": "Microsoft.Sql.ServersOperationGroup.checkNameAvailability", + "azure.mgmt.sql.aio.operations.ServersOperations.check_name_availability": "Microsoft.Sql.ServersOperationGroup.checkNameAvailability", + "azure.mgmt.sql.operations.ServerBlobAuditingPoliciesOperations.get": "Microsoft.Sql.ServerBlobAuditingPolicies.get", + "azure.mgmt.sql.aio.operations.ServerBlobAuditingPoliciesOperations.get": "Microsoft.Sql.ServerBlobAuditingPolicies.get", + "azure.mgmt.sql.operations.ServerBlobAuditingPoliciesOperations.begin_create_or_update": "Microsoft.Sql.ServerBlobAuditingPolicies.createOrUpdate", + "azure.mgmt.sql.aio.operations.ServerBlobAuditingPoliciesOperations.begin_create_or_update": "Microsoft.Sql.ServerBlobAuditingPolicies.createOrUpdate", + "azure.mgmt.sql.operations.ServerBlobAuditingPoliciesOperations.list_by_server": "Microsoft.Sql.ServerBlobAuditingPolicies.listByServer", + "azure.mgmt.sql.aio.operations.ServerBlobAuditingPoliciesOperations.list_by_server": "Microsoft.Sql.ServerBlobAuditingPolicies.listByServer", + "azure.mgmt.sql.operations.DatabaseBlobAuditingPoliciesOperations.get": "Microsoft.Sql.DatabaseBlobAuditingPolicies.get", + "azure.mgmt.sql.aio.operations.DatabaseBlobAuditingPoliciesOperations.get": "Microsoft.Sql.DatabaseBlobAuditingPolicies.get", + "azure.mgmt.sql.operations.DatabaseBlobAuditingPoliciesOperations.create_or_update": "Microsoft.Sql.DatabaseBlobAuditingPolicies.createOrUpdate", + "azure.mgmt.sql.aio.operations.DatabaseBlobAuditingPoliciesOperations.create_or_update": "Microsoft.Sql.DatabaseBlobAuditingPolicies.createOrUpdate", + "azure.mgmt.sql.operations.DatabaseBlobAuditingPoliciesOperations.list_by_database": "Microsoft.Sql.DatabaseBlobAuditingPolicies.listByDatabase", + "azure.mgmt.sql.aio.operations.DatabaseBlobAuditingPoliciesOperations.list_by_database": "Microsoft.Sql.DatabaseBlobAuditingPolicies.listByDatabase", + "azure.mgmt.sql.operations.ExtendedDatabaseBlobAuditingPoliciesOperations.get": "Microsoft.Sql.ExtendedDatabaseBlobAuditingPolicies.get", + "azure.mgmt.sql.aio.operations.ExtendedDatabaseBlobAuditingPoliciesOperations.get": "Microsoft.Sql.ExtendedDatabaseBlobAuditingPolicies.get", + "azure.mgmt.sql.operations.ExtendedDatabaseBlobAuditingPoliciesOperations.create_or_update": "Microsoft.Sql.ExtendedDatabaseBlobAuditingPolicies.createOrUpdate", + "azure.mgmt.sql.aio.operations.ExtendedDatabaseBlobAuditingPoliciesOperations.create_or_update": "Microsoft.Sql.ExtendedDatabaseBlobAuditingPolicies.createOrUpdate", + "azure.mgmt.sql.operations.ExtendedDatabaseBlobAuditingPoliciesOperations.list_by_database": "Microsoft.Sql.ExtendedDatabaseBlobAuditingPolicies.listByDatabase", + "azure.mgmt.sql.aio.operations.ExtendedDatabaseBlobAuditingPoliciesOperations.list_by_database": "Microsoft.Sql.ExtendedDatabaseBlobAuditingPolicies.listByDatabase", + "azure.mgmt.sql.operations.ExtendedServerBlobAuditingPoliciesOperations.get": "Microsoft.Sql.ExtendedServerBlobAuditingPolicies.get", + "azure.mgmt.sql.aio.operations.ExtendedServerBlobAuditingPoliciesOperations.get": "Microsoft.Sql.ExtendedServerBlobAuditingPolicies.get", + "azure.mgmt.sql.operations.ExtendedServerBlobAuditingPoliciesOperations.begin_create_or_update": "Microsoft.Sql.ExtendedServerBlobAuditingPolicies.createOrUpdate", + "azure.mgmt.sql.aio.operations.ExtendedServerBlobAuditingPoliciesOperations.begin_create_or_update": "Microsoft.Sql.ExtendedServerBlobAuditingPolicies.createOrUpdate", + "azure.mgmt.sql.operations.ExtendedServerBlobAuditingPoliciesOperations.list_by_server": "Microsoft.Sql.ExtendedServerBlobAuditingPolicies.listByServer", + "azure.mgmt.sql.aio.operations.ExtendedServerBlobAuditingPoliciesOperations.list_by_server": "Microsoft.Sql.ExtendedServerBlobAuditingPolicies.listByServer", + "azure.mgmt.sql.operations.ServerAdvisorsOperations.get": "Microsoft.Sql.ServerAdvisors.get", + "azure.mgmt.sql.aio.operations.ServerAdvisorsOperations.get": "Microsoft.Sql.ServerAdvisors.get", + "azure.mgmt.sql.operations.ServerAdvisorsOperations.update": "Microsoft.Sql.ServerAdvisors.update", + "azure.mgmt.sql.aio.operations.ServerAdvisorsOperations.update": "Microsoft.Sql.ServerAdvisors.update", + "azure.mgmt.sql.operations.ServerAdvisorsOperations.list_by_server": "Microsoft.Sql.ServerAdvisors.listByServer", + "azure.mgmt.sql.aio.operations.ServerAdvisorsOperations.list_by_server": "Microsoft.Sql.ServerAdvisors.listByServer", + "azure.mgmt.sql.operations.ManagedDatabaseColumnsOperations.get": "Microsoft.Sql.ManagedDatabaseColumns.get", + "azure.mgmt.sql.aio.operations.ManagedDatabaseColumnsOperations.get": "Microsoft.Sql.ManagedDatabaseColumns.get", + "azure.mgmt.sql.operations.ManagedDatabaseColumnsOperations.list_by_table": "Microsoft.Sql.ManagedDatabaseColumns.listByTable", + "azure.mgmt.sql.aio.operations.ManagedDatabaseColumnsOperations.list_by_table": "Microsoft.Sql.ManagedDatabaseColumns.listByTable", + "azure.mgmt.sql.operations.ManagedDatabaseColumnsOperations.list_by_database": "Microsoft.Sql.ManagedDatabases.listByDatabase", + "azure.mgmt.sql.aio.operations.ManagedDatabaseColumnsOperations.list_by_database": "Microsoft.Sql.ManagedDatabases.listByDatabase", + "azure.mgmt.sql.operations.DatabaseTablesOperations.get": "Microsoft.Sql.DatabaseTables.get", + "azure.mgmt.sql.aio.operations.DatabaseTablesOperations.get": "Microsoft.Sql.DatabaseTables.get", + "azure.mgmt.sql.operations.DatabaseTablesOperations.list_by_schema": "Microsoft.Sql.DatabaseTables.listBySchema", + "azure.mgmt.sql.aio.operations.DatabaseTablesOperations.list_by_schema": "Microsoft.Sql.DatabaseTables.listBySchema", + "azure.mgmt.sql.operations.ManagedDatabaseTablesOperations.get": "Microsoft.Sql.ManagedDatabaseTables.get", + "azure.mgmt.sql.aio.operations.ManagedDatabaseTablesOperations.get": "Microsoft.Sql.ManagedDatabaseTables.get", + "azure.mgmt.sql.operations.ManagedDatabaseTablesOperations.list_by_schema": "Microsoft.Sql.ManagedDatabaseTables.listBySchema", + "azure.mgmt.sql.aio.operations.ManagedDatabaseTablesOperations.list_by_schema": "Microsoft.Sql.ManagedDatabaseTables.listBySchema", + "azure.mgmt.sql.operations.DatabaseSchemasOperations.get": "Microsoft.Sql.DatabaseSchemas.get", + "azure.mgmt.sql.aio.operations.DatabaseSchemasOperations.get": "Microsoft.Sql.DatabaseSchemas.get", + "azure.mgmt.sql.operations.DatabaseSchemasOperations.list_by_database": "Microsoft.Sql.DatabaseSchemas.listByDatabase", + "azure.mgmt.sql.aio.operations.DatabaseSchemasOperations.list_by_database": "Microsoft.Sql.DatabaseSchemas.listByDatabase", + "azure.mgmt.sql.operations.ManagedDatabaseSchemasOperations.get": "Microsoft.Sql.ManagedDatabaseSchemas.get", + "azure.mgmt.sql.aio.operations.ManagedDatabaseSchemasOperations.get": "Microsoft.Sql.ManagedDatabaseSchemas.get", + "azure.mgmt.sql.operations.ManagedDatabaseSchemasOperations.list_by_database": "Microsoft.Sql.ManagedDatabaseSchemas.listByDatabase", + "azure.mgmt.sql.aio.operations.ManagedDatabaseSchemasOperations.list_by_database": "Microsoft.Sql.ManagedDatabaseSchemas.listByDatabase", + "azure.mgmt.sql.operations.DatabaseSecurityAlertPoliciesOperations.get": "Microsoft.Sql.DatabaseSecurityAlertPolicies.get", + "azure.mgmt.sql.aio.operations.DatabaseSecurityAlertPoliciesOperations.get": "Microsoft.Sql.DatabaseSecurityAlertPolicies.get", + "azure.mgmt.sql.operations.DatabaseSecurityAlertPoliciesOperations.create_or_update": "Microsoft.Sql.DatabaseSecurityAlertPolicies.createOrUpdate", + "azure.mgmt.sql.aio.operations.DatabaseSecurityAlertPoliciesOperations.create_or_update": "Microsoft.Sql.DatabaseSecurityAlertPolicies.createOrUpdate", + "azure.mgmt.sql.operations.DatabaseSecurityAlertPoliciesOperations.list_by_database": "Microsoft.Sql.DatabaseSecurityAlertPolicies.listByDatabase", + "azure.mgmt.sql.aio.operations.DatabaseSecurityAlertPoliciesOperations.list_by_database": "Microsoft.Sql.DatabaseSecurityAlertPolicies.listByDatabase", + "azure.mgmt.sql.operations.SqlVulnerabilityAssessmentBaselineOperations.get": "Microsoft.Sql.SqlVulnerabilityAssessmentBaseline.get", + "azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentBaselineOperations.get": "Microsoft.Sql.SqlVulnerabilityAssessmentBaseline.get", + "azure.mgmt.sql.operations.SqlVulnerabilityAssessmentBaselineOperations.list_by_sql_vulnerability_assessment": "Microsoft.Sql.SqlVulnerabilityAssessmentBaseline.listBySqlVulnerabilityAssessment", + "azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentBaselineOperations.list_by_sql_vulnerability_assessment": "Microsoft.Sql.SqlVulnerabilityAssessmentBaseline.listBySqlVulnerabilityAssessment", + "azure.mgmt.sql.operations.SqlVulnerabilityAssessmentsOperations.delete": "Microsoft.Sql.SqlVulnerabilityAssessmentsSettings.delete", + "azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentsOperations.delete": "Microsoft.Sql.SqlVulnerabilityAssessmentsSettings.delete", + "azure.mgmt.sql.operations.SqlVulnerabilityAssessmentsSettingsOperations.get": "Microsoft.Sql.SqlVulnerabilityAssessmentsSettings.get", + "azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentsSettingsOperations.get": "Microsoft.Sql.SqlVulnerabilityAssessmentsSettings.get", + "azure.mgmt.sql.operations.SqlVulnerabilityAssessmentsSettingsOperations.create_or_update": "Microsoft.Sql.SqlVulnerabilityAssessmentsSettings.createOrUpdate", + "azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentsSettingsOperations.create_or_update": "Microsoft.Sql.SqlVulnerabilityAssessmentsSettings.createOrUpdate", + "azure.mgmt.sql.operations.SqlVulnerabilityAssessmentsSettingsOperations.list_by_server": "Microsoft.Sql.SqlVulnerabilityAssessmentsSettings.listByServer", + "azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentsSettingsOperations.list_by_server": "Microsoft.Sql.SqlVulnerabilityAssessmentsSettings.listByServer", + "azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations.get": "Microsoft.Sql.DatabaseSqlVulnerabilityAssessmentRuleBaselines.get", + "azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations.get": "Microsoft.Sql.DatabaseSqlVulnerabilityAssessmentRuleBaselines.get", + "azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations.create_or_update": "Microsoft.Sql.DatabaseSqlVulnerabilityAssessmentRuleBaselines.createOrUpdate", + "azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations.create_or_update": "Microsoft.Sql.DatabaseSqlVulnerabilityAssessmentRuleBaselines.createOrUpdate", + "azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations.delete": "Microsoft.Sql.DatabaseSqlVulnerabilityAssessmentRuleBaselines.delete", + "azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations.delete": "Microsoft.Sql.DatabaseSqlVulnerabilityAssessmentRuleBaselines.delete", + "azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations.list_by_baseline": "Microsoft.Sql.DatabaseSqlVulnerabilityAssessmentRuleBaselines.listByBaseline", + "azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations.list_by_baseline": "Microsoft.Sql.DatabaseSqlVulnerabilityAssessmentRuleBaselines.listByBaseline", + "azure.mgmt.sql.operations.SqlVulnerabilityAssessmentRuleBaselineOperations.get": "Microsoft.Sql.SqlVulnerabilityAssessmentRuleBaseline.get", + "azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentRuleBaselineOperations.get": "Microsoft.Sql.SqlVulnerabilityAssessmentRuleBaseline.get", + "azure.mgmt.sql.operations.SqlVulnerabilityAssessmentRuleBaselineOperations.create_or_update": "Microsoft.Sql.SqlVulnerabilityAssessmentRuleBaseline.createOrUpdate", + "azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentRuleBaselineOperations.create_or_update": "Microsoft.Sql.SqlVulnerabilityAssessmentRuleBaseline.createOrUpdate", + "azure.mgmt.sql.operations.SqlVulnerabilityAssessmentRuleBaselineOperations.list_by_baseline": "Microsoft.Sql.SqlVulnerabilityAssessmentRuleBaseline.listByBaseline", + "azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentRuleBaselineOperations.list_by_baseline": "Microsoft.Sql.SqlVulnerabilityAssessmentRuleBaseline.listByBaseline", + "azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentScanResultOperations.get": "Microsoft.Sql.DatabaseSqlVulnerabilityAssessmentScanResult.get", + "azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentScanResultOperations.get": "Microsoft.Sql.DatabaseSqlVulnerabilityAssessmentScanResult.get", + "azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentScanResultOperations.list_by_scan": "Microsoft.Sql.DatabaseSqlVulnerabilityAssessmentScanResult.listByScan", + "azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentScanResultOperations.list_by_scan": "Microsoft.Sql.DatabaseSqlVulnerabilityAssessmentScanResult.listByScan", + "azure.mgmt.sql.operations.SqlVulnerabilityAssessmentScanResultOperations.get": "Microsoft.Sql.SqlVulnerabilityAssessmentScanResult.get", + "azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentScanResultOperations.get": "Microsoft.Sql.SqlVulnerabilityAssessmentScanResult.get", + "azure.mgmt.sql.operations.SqlVulnerabilityAssessmentScanResultOperations.list_by_scan": "Microsoft.Sql.SqlVulnerabilityAssessmentScanResult.listByScan", + "azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentScanResultOperations.list_by_scan": "Microsoft.Sql.SqlVulnerabilityAssessmentScanResult.listByScan", + "azure.mgmt.sql.operations.SqlVulnerabilityAssessmentScansOperations.get": "Microsoft.Sql.SqlVulnerabilityAssessmentScans.get", + "azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentScansOperations.get": "Microsoft.Sql.SqlVulnerabilityAssessmentScans.get", + "azure.mgmt.sql.operations.SqlVulnerabilityAssessmentScansOperations.list_by_sql_vulnerability_assessments": "Microsoft.Sql.SqlVulnerabilityAssessmentScans.listBySqlVulnerabilityAssessments", + "azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentScansOperations.list_by_sql_vulnerability_assessments": "Microsoft.Sql.SqlVulnerabilityAssessmentScans.listBySqlVulnerabilityAssessments", + "azure.mgmt.sql.operations.DatabaseVulnerabilityAssessmentRuleBaselinesOperations.get": "Microsoft.Sql.DatabaseVulnerabilityAssessmentRuleBaselines.get", + "azure.mgmt.sql.aio.operations.DatabaseVulnerabilityAssessmentRuleBaselinesOperations.get": "Microsoft.Sql.DatabaseVulnerabilityAssessmentRuleBaselines.get", + "azure.mgmt.sql.operations.DatabaseVulnerabilityAssessmentRuleBaselinesOperations.create_or_update": "Microsoft.Sql.DatabaseVulnerabilityAssessmentRuleBaselines.createOrUpdate", + "azure.mgmt.sql.aio.operations.DatabaseVulnerabilityAssessmentRuleBaselinesOperations.create_or_update": "Microsoft.Sql.DatabaseVulnerabilityAssessmentRuleBaselines.createOrUpdate", + "azure.mgmt.sql.operations.DatabaseVulnerabilityAssessmentRuleBaselinesOperations.delete": "Microsoft.Sql.DatabaseVulnerabilityAssessmentRuleBaselines.delete", + "azure.mgmt.sql.aio.operations.DatabaseVulnerabilityAssessmentRuleBaselinesOperations.delete": "Microsoft.Sql.DatabaseVulnerabilityAssessmentRuleBaselines.delete", + "azure.mgmt.sql.operations.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations.get": "Microsoft.Sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselines.get", + "azure.mgmt.sql.aio.operations.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations.get": "Microsoft.Sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselines.get", + "azure.mgmt.sql.operations.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations.create_or_update": "Microsoft.Sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselines.createOrUpdate", + "azure.mgmt.sql.aio.operations.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations.create_or_update": "Microsoft.Sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselines.createOrUpdate", + "azure.mgmt.sql.operations.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations.delete": "Microsoft.Sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselines.delete", + "azure.mgmt.sql.aio.operations.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations.delete": "Microsoft.Sql.ManagedDatabaseVulnerabilityAssessmentRuleBaselines.delete", + "azure.mgmt.sql.operations.DatabaseVulnerabilityAssessmentsOperations.get": "Microsoft.Sql.DatabaseVulnerabilityAssessments.get", + "azure.mgmt.sql.aio.operations.DatabaseVulnerabilityAssessmentsOperations.get": "Microsoft.Sql.DatabaseVulnerabilityAssessments.get", + "azure.mgmt.sql.operations.DatabaseVulnerabilityAssessmentsOperations.create_or_update": "Microsoft.Sql.DatabaseVulnerabilityAssessments.createOrUpdate", + "azure.mgmt.sql.aio.operations.DatabaseVulnerabilityAssessmentsOperations.create_or_update": "Microsoft.Sql.DatabaseVulnerabilityAssessments.createOrUpdate", + "azure.mgmt.sql.operations.DatabaseVulnerabilityAssessmentsOperations.delete": "Microsoft.Sql.DatabaseVulnerabilityAssessments.delete", + "azure.mgmt.sql.aio.operations.DatabaseVulnerabilityAssessmentsOperations.delete": "Microsoft.Sql.DatabaseVulnerabilityAssessments.delete", + "azure.mgmt.sql.operations.DatabaseVulnerabilityAssessmentsOperations.list_by_database": "Microsoft.Sql.DatabaseVulnerabilityAssessments.listByDatabase", + "azure.mgmt.sql.aio.operations.DatabaseVulnerabilityAssessmentsOperations.list_by_database": "Microsoft.Sql.DatabaseVulnerabilityAssessments.listByDatabase", + "azure.mgmt.sql.operations.ManagedDatabaseVulnerabilityAssessmentsOperations.get": "Microsoft.Sql.ManagedDatabaseVulnerabilityAssessments.get", + "azure.mgmt.sql.aio.operations.ManagedDatabaseVulnerabilityAssessmentsOperations.get": "Microsoft.Sql.ManagedDatabaseVulnerabilityAssessments.get", + "azure.mgmt.sql.operations.ManagedDatabaseVulnerabilityAssessmentsOperations.create_or_update": "Microsoft.Sql.ManagedDatabaseVulnerabilityAssessments.createOrUpdate", + "azure.mgmt.sql.aio.operations.ManagedDatabaseVulnerabilityAssessmentsOperations.create_or_update": "Microsoft.Sql.ManagedDatabaseVulnerabilityAssessments.createOrUpdate", + "azure.mgmt.sql.operations.ManagedDatabaseVulnerabilityAssessmentsOperations.delete": "Microsoft.Sql.ManagedDatabaseVulnerabilityAssessments.delete", + "azure.mgmt.sql.aio.operations.ManagedDatabaseVulnerabilityAssessmentsOperations.delete": "Microsoft.Sql.ManagedDatabaseVulnerabilityAssessments.delete", + "azure.mgmt.sql.operations.ManagedDatabaseVulnerabilityAssessmentsOperations.list_by_database": "Microsoft.Sql.ManagedDatabaseVulnerabilityAssessments.listByDatabase", + "azure.mgmt.sql.aio.operations.ManagedDatabaseVulnerabilityAssessmentsOperations.list_by_database": "Microsoft.Sql.ManagedDatabaseVulnerabilityAssessments.listByDatabase", + "azure.mgmt.sql.operations.ManagedDatabaseVulnerabilityAssessmentScansOperations.get": "Microsoft.Sql.ManagedDatabaseVulnerabilityAssessmentScans.get", + "azure.mgmt.sql.aio.operations.ManagedDatabaseVulnerabilityAssessmentScansOperations.get": "Microsoft.Sql.ManagedDatabaseVulnerabilityAssessmentScans.get", + "azure.mgmt.sql.operations.ManagedDatabaseVulnerabilityAssessmentScansOperations.list_by_database": "Microsoft.Sql.ManagedDatabaseVulnerabilityAssessmentScans.listByDatabase", + "azure.mgmt.sql.aio.operations.ManagedDatabaseVulnerabilityAssessmentScansOperations.list_by_database": "Microsoft.Sql.ManagedDatabaseVulnerabilityAssessmentScans.listByDatabase", + "azure.mgmt.sql.operations.ManagedDatabaseVulnerabilityAssessmentScansOperations.export": "Microsoft.Sql.ManagedDatabaseVulnerabilityAssessmentScans.export", + "azure.mgmt.sql.aio.operations.ManagedDatabaseVulnerabilityAssessmentScansOperations.export": "Microsoft.Sql.ManagedDatabaseVulnerabilityAssessmentScans.export", + "azure.mgmt.sql.operations.ManagedDatabaseVulnerabilityAssessmentScansOperations.begin_initiate_scan": "Microsoft.Sql.ManagedDatabaseVulnerabilityAssessmentScans.initiateScan", + "azure.mgmt.sql.aio.operations.ManagedDatabaseVulnerabilityAssessmentScansOperations.begin_initiate_scan": "Microsoft.Sql.ManagedDatabaseVulnerabilityAssessmentScans.initiateScan", + "azure.mgmt.sql.operations.DataMaskingPoliciesOperations.get": "Microsoft.Sql.DataMaskingPolicies.get", + "azure.mgmt.sql.aio.operations.DataMaskingPoliciesOperations.get": "Microsoft.Sql.DataMaskingPolicies.get", + "azure.mgmt.sql.operations.DataMaskingPoliciesOperations.create_or_update": "Microsoft.Sql.DataMaskingPolicies.createOrUpdate", + "azure.mgmt.sql.aio.operations.DataMaskingPoliciesOperations.create_or_update": "Microsoft.Sql.DataMaskingPolicies.createOrUpdate", + "azure.mgmt.sql.operations.DeletedServersOperations.get": "Microsoft.Sql.DeletedServers.get", + "azure.mgmt.sql.aio.operations.DeletedServersOperations.get": "Microsoft.Sql.DeletedServers.get", + "azure.mgmt.sql.operations.DeletedServersOperations.list_by_location": "Microsoft.Sql.DeletedServers.listByLocation", + "azure.mgmt.sql.aio.operations.DeletedServersOperations.list_by_location": "Microsoft.Sql.DeletedServers.listByLocation", + "azure.mgmt.sql.operations.DeletedServersOperations.begin_recover": "Microsoft.Sql.DeletedServers.recover", + "azure.mgmt.sql.aio.operations.DeletedServersOperations.begin_recover": "Microsoft.Sql.DeletedServers.recover", + "azure.mgmt.sql.operations.DeletedServersOperations.list": "Microsoft.Sql.DeletedServersOperationGroup.list", + "azure.mgmt.sql.aio.operations.DeletedServersOperations.list": "Microsoft.Sql.DeletedServersOperationGroup.list", + "azure.mgmt.sql.operations.DistributedAvailabilityGroupsOperations.get": "Microsoft.Sql.DistributedAvailabilityGroups.get", + "azure.mgmt.sql.aio.operations.DistributedAvailabilityGroupsOperations.get": "Microsoft.Sql.DistributedAvailabilityGroups.get", + "azure.mgmt.sql.operations.DistributedAvailabilityGroupsOperations.begin_create_or_update": "Microsoft.Sql.DistributedAvailabilityGroups.createOrUpdate", + "azure.mgmt.sql.aio.operations.DistributedAvailabilityGroupsOperations.begin_create_or_update": "Microsoft.Sql.DistributedAvailabilityGroups.createOrUpdate", + "azure.mgmt.sql.operations.DistributedAvailabilityGroupsOperations.begin_update": "Microsoft.Sql.DistributedAvailabilityGroups.update", + "azure.mgmt.sql.aio.operations.DistributedAvailabilityGroupsOperations.begin_update": "Microsoft.Sql.DistributedAvailabilityGroups.update", + "azure.mgmt.sql.operations.DistributedAvailabilityGroupsOperations.begin_delete": "Microsoft.Sql.DistributedAvailabilityGroups.delete", + "azure.mgmt.sql.aio.operations.DistributedAvailabilityGroupsOperations.begin_delete": "Microsoft.Sql.DistributedAvailabilityGroups.delete", + "azure.mgmt.sql.operations.DistributedAvailabilityGroupsOperations.list_by_instance": "Microsoft.Sql.DistributedAvailabilityGroups.listByInstance", + "azure.mgmt.sql.aio.operations.DistributedAvailabilityGroupsOperations.list_by_instance": "Microsoft.Sql.DistributedAvailabilityGroups.listByInstance", + "azure.mgmt.sql.operations.DistributedAvailabilityGroupsOperations.begin_failover": "Microsoft.Sql.DistributedAvailabilityGroups.failover", + "azure.mgmt.sql.aio.operations.DistributedAvailabilityGroupsOperations.begin_failover": "Microsoft.Sql.DistributedAvailabilityGroups.failover", + "azure.mgmt.sql.operations.DistributedAvailabilityGroupsOperations.begin_set_role": "Microsoft.Sql.DistributedAvailabilityGroups.setRole", + "azure.mgmt.sql.aio.operations.DistributedAvailabilityGroupsOperations.begin_set_role": "Microsoft.Sql.DistributedAvailabilityGroups.setRole", + "azure.mgmt.sql.operations.ManagedDatabasesOperations.get": "Microsoft.Sql.ManagedDatabases.get", + "azure.mgmt.sql.aio.operations.ManagedDatabasesOperations.get": "Microsoft.Sql.ManagedDatabases.get", + "azure.mgmt.sql.operations.ManagedDatabasesOperations.begin_create_or_update": "Microsoft.Sql.ManagedDatabases.createOrUpdate", + "azure.mgmt.sql.aio.operations.ManagedDatabasesOperations.begin_create_or_update": "Microsoft.Sql.ManagedDatabases.createOrUpdate", + "azure.mgmt.sql.operations.ManagedDatabasesOperations.begin_update": "Microsoft.Sql.ManagedDatabases.update", + "azure.mgmt.sql.aio.operations.ManagedDatabasesOperations.begin_update": "Microsoft.Sql.ManagedDatabases.update", + "azure.mgmt.sql.operations.ManagedDatabasesOperations.begin_delete": "Microsoft.Sql.ManagedDatabases.delete", + "azure.mgmt.sql.aio.operations.ManagedDatabasesOperations.begin_delete": "Microsoft.Sql.ManagedDatabases.delete", + "azure.mgmt.sql.operations.ManagedDatabasesOperations.list_by_instance": "Microsoft.Sql.ManagedDatabases.listByInstance", + "azure.mgmt.sql.aio.operations.ManagedDatabasesOperations.list_by_instance": "Microsoft.Sql.ManagedDatabases.listByInstance", + "azure.mgmt.sql.operations.ManagedDatabasesOperations.begin_cancel_move": "Microsoft.Sql.ManagedDatabases.cancelMove", + "azure.mgmt.sql.aio.operations.ManagedDatabasesOperations.begin_cancel_move": "Microsoft.Sql.ManagedDatabases.cancelMove", + "azure.mgmt.sql.operations.ManagedDatabasesOperations.begin_complete_move": "Microsoft.Sql.ManagedDatabases.completeMove", + "azure.mgmt.sql.aio.operations.ManagedDatabasesOperations.begin_complete_move": "Microsoft.Sql.ManagedDatabases.completeMove", + "azure.mgmt.sql.operations.ManagedDatabasesOperations.begin_complete_restore": "Microsoft.Sql.ManagedDatabases.completeRestore", + "azure.mgmt.sql.aio.operations.ManagedDatabasesOperations.begin_complete_restore": "Microsoft.Sql.ManagedDatabases.completeRestore", + "azure.mgmt.sql.operations.ManagedDatabasesOperations.begin_reevaluate_inaccessible_database_state": "Microsoft.Sql.ManagedDatabases.reevaluateInaccessibleDatabaseState", + "azure.mgmt.sql.aio.operations.ManagedDatabasesOperations.begin_reevaluate_inaccessible_database_state": "Microsoft.Sql.ManagedDatabases.reevaluateInaccessibleDatabaseState", + "azure.mgmt.sql.operations.ManagedDatabasesOperations.begin_start_move": "Microsoft.Sql.ManagedDatabases.startMove", + "azure.mgmt.sql.aio.operations.ManagedDatabasesOperations.begin_start_move": "Microsoft.Sql.ManagedDatabases.startMove", + "azure.mgmt.sql.operations.ManagedDatabasesOperations.list_inaccessible_by_instance": "Microsoft.Sql.ManagedInstances.listInaccessibleByInstance", + "azure.mgmt.sql.aio.operations.ManagedDatabasesOperations.list_inaccessible_by_instance": "Microsoft.Sql.ManagedInstances.listInaccessibleByInstance", + "azure.mgmt.sql.operations.ServerTrustGroupsOperations.get": "Microsoft.Sql.ServerTrustGroups.get", + "azure.mgmt.sql.aio.operations.ServerTrustGroupsOperations.get": "Microsoft.Sql.ServerTrustGroups.get", + "azure.mgmt.sql.operations.ServerTrustGroupsOperations.begin_create_or_update": "Microsoft.Sql.ServerTrustGroups.createOrUpdate", + "azure.mgmt.sql.aio.operations.ServerTrustGroupsOperations.begin_create_or_update": "Microsoft.Sql.ServerTrustGroups.createOrUpdate", + "azure.mgmt.sql.operations.ServerTrustGroupsOperations.begin_delete": "Microsoft.Sql.ServerTrustGroups.delete", + "azure.mgmt.sql.aio.operations.ServerTrustGroupsOperations.begin_delete": "Microsoft.Sql.ServerTrustGroups.delete", + "azure.mgmt.sql.operations.ServerTrustGroupsOperations.list_by_location": "Microsoft.Sql.ServerTrustGroups.listByLocation", + "azure.mgmt.sql.aio.operations.ServerTrustGroupsOperations.list_by_location": "Microsoft.Sql.ServerTrustGroups.listByLocation", + "azure.mgmt.sql.operations.ServerTrustGroupsOperations.list_by_instance": "Microsoft.Sql.ManagedInstances.listByInstance", + "azure.mgmt.sql.aio.operations.ServerTrustGroupsOperations.list_by_instance": "Microsoft.Sql.ManagedInstances.listByInstance", + "azure.mgmt.sql.operations.ManagedInstancesOperations.get": "Microsoft.Sql.ManagedInstances.get", + "azure.mgmt.sql.aio.operations.ManagedInstancesOperations.get": "Microsoft.Sql.ManagedInstances.get", + "azure.mgmt.sql.operations.ManagedInstancesOperations.begin_create_or_update": "Microsoft.Sql.ManagedInstances.createOrUpdate", + "azure.mgmt.sql.aio.operations.ManagedInstancesOperations.begin_create_or_update": "Microsoft.Sql.ManagedInstances.createOrUpdate", + "azure.mgmt.sql.operations.ManagedInstancesOperations.begin_update": "Microsoft.Sql.ManagedInstances.update", + "azure.mgmt.sql.aio.operations.ManagedInstancesOperations.begin_update": "Microsoft.Sql.ManagedInstances.update", + "azure.mgmt.sql.operations.ManagedInstancesOperations.begin_delete": "Microsoft.Sql.ManagedInstances.delete", + "azure.mgmt.sql.aio.operations.ManagedInstancesOperations.begin_delete": "Microsoft.Sql.ManagedInstances.delete", + "azure.mgmt.sql.operations.ManagedInstancesOperations.list_by_resource_group": "Microsoft.Sql.ManagedInstances.listByResourceGroup", + "azure.mgmt.sql.aio.operations.ManagedInstancesOperations.list_by_resource_group": "Microsoft.Sql.ManagedInstances.listByResourceGroup", + "azure.mgmt.sql.operations.ManagedInstancesOperations.list": "Microsoft.Sql.ManagedInstances.list", + "azure.mgmt.sql.aio.operations.ManagedInstancesOperations.list": "Microsoft.Sql.ManagedInstances.list", + "azure.mgmt.sql.operations.ManagedInstancesOperations.begin_failover": "Microsoft.Sql.ManagedInstances.failover", + "azure.mgmt.sql.aio.operations.ManagedInstancesOperations.begin_failover": "Microsoft.Sql.ManagedInstances.failover", + "azure.mgmt.sql.operations.ManagedInstancesOperations.list_outbound_network_dependencies_by_managed_instance": "Microsoft.Sql.ManagedInstances.listOutboundNetworkDependenciesByManagedInstance", + "azure.mgmt.sql.aio.operations.ManagedInstancesOperations.list_outbound_network_dependencies_by_managed_instance": "Microsoft.Sql.ManagedInstances.listOutboundNetworkDependenciesByManagedInstance", + "azure.mgmt.sql.operations.ManagedInstancesOperations.begin_reevaluate_inaccessible_database_state": "Microsoft.Sql.ManagedInstances.reevaluateInaccessibleDatabaseState", + "azure.mgmt.sql.aio.operations.ManagedInstancesOperations.begin_reevaluate_inaccessible_database_state": "Microsoft.Sql.ManagedInstances.reevaluateInaccessibleDatabaseState", + "azure.mgmt.sql.operations.ManagedInstancesOperations.begin_refresh_status": "Microsoft.Sql.ManagedInstances.refreshStatus", + "azure.mgmt.sql.aio.operations.ManagedInstancesOperations.begin_refresh_status": "Microsoft.Sql.ManagedInstances.refreshStatus", + "azure.mgmt.sql.operations.ManagedInstancesOperations.begin_start": "Microsoft.Sql.ManagedInstances.start", + "azure.mgmt.sql.aio.operations.ManagedInstancesOperations.begin_start": "Microsoft.Sql.ManagedInstances.start", + "azure.mgmt.sql.operations.ManagedInstancesOperations.begin_stop": "Microsoft.Sql.ManagedInstances.stop", + "azure.mgmt.sql.aio.operations.ManagedInstancesOperations.begin_stop": "Microsoft.Sql.ManagedInstances.stop", + "azure.mgmt.sql.operations.ManagedInstancesOperations.list_by_managed_instance": "Microsoft.Sql.ManagedInstances.listByManagedInstance", + "azure.mgmt.sql.aio.operations.ManagedInstancesOperations.list_by_managed_instance": "Microsoft.Sql.ManagedInstances.listByManagedInstance", + "azure.mgmt.sql.operations.ManagedInstancesOperations.begin_validate_azure_key_vault_encryption_key": "Microsoft.Sql.ManagedInstances.validateAzureKeyVaultEncryptionKey", + "azure.mgmt.sql.aio.operations.ManagedInstancesOperations.begin_validate_azure_key_vault_encryption_key": "Microsoft.Sql.ManagedInstances.validateAzureKeyVaultEncryptionKey", + "azure.mgmt.sql.operations.ManagedInstancesOperations.list_by_instance_pool": "Microsoft.Sql.InstancePools.listByInstancePool", + "azure.mgmt.sql.aio.operations.ManagedInstancesOperations.list_by_instance_pool": "Microsoft.Sql.InstancePools.listByInstancePool", + "azure.mgmt.sql.operations.ElasticPoolsOperations.get": "Microsoft.Sql.ElasticPools.get", + "azure.mgmt.sql.aio.operations.ElasticPoolsOperations.get": "Microsoft.Sql.ElasticPools.get", + "azure.mgmt.sql.operations.ElasticPoolsOperations.begin_create_or_update": "Microsoft.Sql.ElasticPools.createOrUpdate", + "azure.mgmt.sql.aio.operations.ElasticPoolsOperations.begin_create_or_update": "Microsoft.Sql.ElasticPools.createOrUpdate", + "azure.mgmt.sql.operations.ElasticPoolsOperations.begin_update": "Microsoft.Sql.ElasticPools.update", + "azure.mgmt.sql.aio.operations.ElasticPoolsOperations.begin_update": "Microsoft.Sql.ElasticPools.update", + "azure.mgmt.sql.operations.ElasticPoolsOperations.begin_delete": "Microsoft.Sql.ElasticPools.delete", + "azure.mgmt.sql.aio.operations.ElasticPoolsOperations.begin_delete": "Microsoft.Sql.ElasticPools.delete", + "azure.mgmt.sql.operations.ElasticPoolsOperations.list_by_server": "Microsoft.Sql.ElasticPools.listByServer", + "azure.mgmt.sql.aio.operations.ElasticPoolsOperations.list_by_server": "Microsoft.Sql.ElasticPools.listByServer", + "azure.mgmt.sql.operations.ElasticPoolsOperations.begin_failover": "Microsoft.Sql.ElasticPools.failover", + "azure.mgmt.sql.aio.operations.ElasticPoolsOperations.begin_failover": "Microsoft.Sql.ElasticPools.failover", + "azure.mgmt.sql.operations.EncryptionProtectorsOperations.get": "Microsoft.Sql.EncryptionProtectors.get", + "azure.mgmt.sql.aio.operations.EncryptionProtectorsOperations.get": "Microsoft.Sql.EncryptionProtectors.get", + "azure.mgmt.sql.operations.EncryptionProtectorsOperations.begin_create_or_update": "Microsoft.Sql.EncryptionProtectors.createOrUpdate", + "azure.mgmt.sql.aio.operations.EncryptionProtectorsOperations.begin_create_or_update": "Microsoft.Sql.EncryptionProtectors.createOrUpdate", + "azure.mgmt.sql.operations.EncryptionProtectorsOperations.list_by_server": "Microsoft.Sql.EncryptionProtectors.listByServer", + "azure.mgmt.sql.aio.operations.EncryptionProtectorsOperations.list_by_server": "Microsoft.Sql.EncryptionProtectors.listByServer", + "azure.mgmt.sql.operations.EncryptionProtectorsOperations.begin_revalidate": "Microsoft.Sql.EncryptionProtectors.revalidate", + "azure.mgmt.sql.aio.operations.EncryptionProtectorsOperations.begin_revalidate": "Microsoft.Sql.EncryptionProtectors.revalidate", + "azure.mgmt.sql.operations.EndpointCertificatesOperations.get": "Microsoft.Sql.EndpointCertificates.get", + "azure.mgmt.sql.aio.operations.EndpointCertificatesOperations.get": "Microsoft.Sql.EndpointCertificates.get", + "azure.mgmt.sql.operations.EndpointCertificatesOperations.list_by_instance": "Microsoft.Sql.EndpointCertificates.listByInstance", + "azure.mgmt.sql.aio.operations.EndpointCertificatesOperations.list_by_instance": "Microsoft.Sql.EndpointCertificates.listByInstance", + "azure.mgmt.sql.operations.FailoverGroupsOperations.get": "Microsoft.Sql.FailoverGroups.get", + "azure.mgmt.sql.aio.operations.FailoverGroupsOperations.get": "Microsoft.Sql.FailoverGroups.get", + "azure.mgmt.sql.operations.FailoverGroupsOperations.begin_create_or_update": "Microsoft.Sql.FailoverGroups.createOrUpdate", + "azure.mgmt.sql.aio.operations.FailoverGroupsOperations.begin_create_or_update": "Microsoft.Sql.FailoverGroups.createOrUpdate", + "azure.mgmt.sql.operations.FailoverGroupsOperations.begin_update": "Microsoft.Sql.FailoverGroups.update", + "azure.mgmt.sql.aio.operations.FailoverGroupsOperations.begin_update": "Microsoft.Sql.FailoverGroups.update", + "azure.mgmt.sql.operations.FailoverGroupsOperations.begin_delete": "Microsoft.Sql.FailoverGroups.delete", + "azure.mgmt.sql.aio.operations.FailoverGroupsOperations.begin_delete": "Microsoft.Sql.FailoverGroups.delete", + "azure.mgmt.sql.operations.FailoverGroupsOperations.list_by_server": "Microsoft.Sql.FailoverGroups.listByServer", + "azure.mgmt.sql.aio.operations.FailoverGroupsOperations.list_by_server": "Microsoft.Sql.FailoverGroups.listByServer", + "azure.mgmt.sql.operations.FailoverGroupsOperations.begin_failover": "Microsoft.Sql.FailoverGroups.failover", + "azure.mgmt.sql.aio.operations.FailoverGroupsOperations.begin_failover": "Microsoft.Sql.FailoverGroups.failover", + "azure.mgmt.sql.operations.FailoverGroupsOperations.begin_force_failover_allow_data_loss": "Microsoft.Sql.FailoverGroups.forceFailoverAllowDataLoss", + "azure.mgmt.sql.aio.operations.FailoverGroupsOperations.begin_force_failover_allow_data_loss": "Microsoft.Sql.FailoverGroups.forceFailoverAllowDataLoss", + "azure.mgmt.sql.operations.FailoverGroupsOperations.begin_try_planned_before_forced_failover": "Microsoft.Sql.FailoverGroups.tryPlannedBeforeForcedFailover", + "azure.mgmt.sql.aio.operations.FailoverGroupsOperations.begin_try_planned_before_forced_failover": "Microsoft.Sql.FailoverGroups.tryPlannedBeforeForcedFailover", + "azure.mgmt.sql.operations.GeoBackupPoliciesOperations.get": "Microsoft.Sql.GeoBackupPolicies.get", + "azure.mgmt.sql.aio.operations.GeoBackupPoliciesOperations.get": "Microsoft.Sql.GeoBackupPolicies.get", + "azure.mgmt.sql.operations.GeoBackupPoliciesOperations.create_or_update": "Microsoft.Sql.GeoBackupPolicies.createOrUpdate", + "azure.mgmt.sql.aio.operations.GeoBackupPoliciesOperations.create_or_update": "Microsoft.Sql.GeoBackupPolicies.createOrUpdate", + "azure.mgmt.sql.operations.GeoBackupPoliciesOperations.list": "Microsoft.Sql.GeoBackupPolicies.list", + "azure.mgmt.sql.aio.operations.GeoBackupPoliciesOperations.list": "Microsoft.Sql.GeoBackupPolicies.list", + "azure.mgmt.sql.operations.InstanceFailoverGroupsOperations.get": "Microsoft.Sql.InstanceFailoverGroups.get", + "azure.mgmt.sql.aio.operations.InstanceFailoverGroupsOperations.get": "Microsoft.Sql.InstanceFailoverGroups.get", + "azure.mgmt.sql.operations.InstanceFailoverGroupsOperations.begin_create_or_update": "Microsoft.Sql.InstanceFailoverGroups.createOrUpdate", + "azure.mgmt.sql.aio.operations.InstanceFailoverGroupsOperations.begin_create_or_update": "Microsoft.Sql.InstanceFailoverGroups.createOrUpdate", + "azure.mgmt.sql.operations.InstanceFailoverGroupsOperations.begin_delete": "Microsoft.Sql.InstanceFailoverGroups.delete", + "azure.mgmt.sql.aio.operations.InstanceFailoverGroupsOperations.begin_delete": "Microsoft.Sql.InstanceFailoverGroups.delete", + "azure.mgmt.sql.operations.InstanceFailoverGroupsOperations.list_by_location": "Microsoft.Sql.InstanceFailoverGroups.listByLocation", + "azure.mgmt.sql.aio.operations.InstanceFailoverGroupsOperations.list_by_location": "Microsoft.Sql.InstanceFailoverGroups.listByLocation", + "azure.mgmt.sql.operations.InstanceFailoverGroupsOperations.begin_failover": "Microsoft.Sql.InstanceFailoverGroups.failover", + "azure.mgmt.sql.aio.operations.InstanceFailoverGroupsOperations.begin_failover": "Microsoft.Sql.InstanceFailoverGroups.failover", + "azure.mgmt.sql.operations.InstanceFailoverGroupsOperations.begin_force_failover_allow_data_loss": "Microsoft.Sql.InstanceFailoverGroups.forceFailoverAllowDataLoss", + "azure.mgmt.sql.aio.operations.InstanceFailoverGroupsOperations.begin_force_failover_allow_data_loss": "Microsoft.Sql.InstanceFailoverGroups.forceFailoverAllowDataLoss", + "azure.mgmt.sql.operations.InstancePoolOperationsOperations.get": "Microsoft.Sql.InstancePoolOperations.get", + "azure.mgmt.sql.aio.operations.InstancePoolOperationsOperations.get": "Microsoft.Sql.InstancePoolOperations.get", + "azure.mgmt.sql.operations.InstancePoolOperationsOperations.list_by_instance_pool": "Microsoft.Sql.InstancePoolOperations.listByInstancePool", + "azure.mgmt.sql.aio.operations.InstancePoolOperationsOperations.list_by_instance_pool": "Microsoft.Sql.InstancePoolOperations.listByInstancePool", + "azure.mgmt.sql.operations.InstancePoolsOperations.get": "Microsoft.Sql.InstancePools.get", + "azure.mgmt.sql.aio.operations.InstancePoolsOperations.get": "Microsoft.Sql.InstancePools.get", + "azure.mgmt.sql.operations.InstancePoolsOperations.begin_create_or_update": "Microsoft.Sql.InstancePools.createOrUpdate", + "azure.mgmt.sql.aio.operations.InstancePoolsOperations.begin_create_or_update": "Microsoft.Sql.InstancePools.createOrUpdate", + "azure.mgmt.sql.operations.InstancePoolsOperations.begin_update": "Microsoft.Sql.InstancePools.update", + "azure.mgmt.sql.aio.operations.InstancePoolsOperations.begin_update": "Microsoft.Sql.InstancePools.update", + "azure.mgmt.sql.operations.InstancePoolsOperations.begin_delete": "Microsoft.Sql.InstancePools.delete", + "azure.mgmt.sql.aio.operations.InstancePoolsOperations.begin_delete": "Microsoft.Sql.InstancePools.delete", + "azure.mgmt.sql.operations.InstancePoolsOperations.list_by_resource_group": "Microsoft.Sql.InstancePools.listByResourceGroup", + "azure.mgmt.sql.aio.operations.InstancePoolsOperations.list_by_resource_group": "Microsoft.Sql.InstancePools.listByResourceGroup", + "azure.mgmt.sql.operations.InstancePoolsOperations.list": "Microsoft.Sql.InstancePools.list", + "azure.mgmt.sql.aio.operations.InstancePoolsOperations.list": "Microsoft.Sql.InstancePools.list", + "azure.mgmt.sql.operations.IPv6FirewallRulesOperations.get": "Microsoft.Sql.IPv6FirewallRules.get", + "azure.mgmt.sql.aio.operations.IPv6FirewallRulesOperations.get": "Microsoft.Sql.IPv6FirewallRules.get", + "azure.mgmt.sql.operations.IPv6FirewallRulesOperations.create_or_update": "Microsoft.Sql.IPv6FirewallRules.createOrUpdate", + "azure.mgmt.sql.aio.operations.IPv6FirewallRulesOperations.create_or_update": "Microsoft.Sql.IPv6FirewallRules.createOrUpdate", + "azure.mgmt.sql.operations.IPv6FirewallRulesOperations.delete": "Microsoft.Sql.IPv6FirewallRules.delete", + "azure.mgmt.sql.aio.operations.IPv6FirewallRulesOperations.delete": "Microsoft.Sql.IPv6FirewallRules.delete", + "azure.mgmt.sql.operations.IPv6FirewallRulesOperations.list_by_server": "Microsoft.Sql.IPv6FirewallRules.listByServer", + "azure.mgmt.sql.aio.operations.IPv6FirewallRulesOperations.list_by_server": "Microsoft.Sql.IPv6FirewallRules.listByServer", + "azure.mgmt.sql.operations.JobExecutionsOperations.get": "Microsoft.Sql.JobExecutions.get", + "azure.mgmt.sql.aio.operations.JobExecutionsOperations.get": "Microsoft.Sql.JobExecutions.get", + "azure.mgmt.sql.operations.JobExecutionsOperations.begin_create_or_update": "Microsoft.Sql.JobExecutions.createOrUpdate", + "azure.mgmt.sql.aio.operations.JobExecutionsOperations.begin_create_or_update": "Microsoft.Sql.JobExecutions.createOrUpdate", + "azure.mgmt.sql.operations.JobExecutionsOperations.cancel": "Microsoft.Sql.JobExecutions.cancel", + "azure.mgmt.sql.aio.operations.JobExecutionsOperations.cancel": "Microsoft.Sql.JobExecutions.cancel", + "azure.mgmt.sql.operations.JobExecutionsOperations.list_by_job": "Microsoft.Sql.JobExecutions.listByJob", + "azure.mgmt.sql.aio.operations.JobExecutionsOperations.list_by_job": "Microsoft.Sql.JobExecutions.listByJob", + "azure.mgmt.sql.operations.JobExecutionsOperations.list_by_agent": "Microsoft.Sql.JobAgents.listByAgent", + "azure.mgmt.sql.aio.operations.JobExecutionsOperations.list_by_agent": "Microsoft.Sql.JobAgents.listByAgent", + "azure.mgmt.sql.operations.JobExecutionsOperations.begin_create": "Microsoft.Sql.Jobs.create", + "azure.mgmt.sql.aio.operations.JobExecutionsOperations.begin_create": "Microsoft.Sql.Jobs.create", + "azure.mgmt.sql.operations.JobAgentsOperations.get": "Microsoft.Sql.JobAgents.get", + "azure.mgmt.sql.aio.operations.JobAgentsOperations.get": "Microsoft.Sql.JobAgents.get", + "azure.mgmt.sql.operations.JobAgentsOperations.begin_create_or_update": "Microsoft.Sql.JobAgents.createOrUpdate", + "azure.mgmt.sql.aio.operations.JobAgentsOperations.begin_create_or_update": "Microsoft.Sql.JobAgents.createOrUpdate", + "azure.mgmt.sql.operations.JobAgentsOperations.begin_update": "Microsoft.Sql.JobAgents.update", + "azure.mgmt.sql.aio.operations.JobAgentsOperations.begin_update": "Microsoft.Sql.JobAgents.update", + "azure.mgmt.sql.operations.JobAgentsOperations.begin_delete": "Microsoft.Sql.JobAgents.delete", + "azure.mgmt.sql.aio.operations.JobAgentsOperations.begin_delete": "Microsoft.Sql.JobAgents.delete", + "azure.mgmt.sql.operations.JobAgentsOperations.list_by_server": "Microsoft.Sql.JobAgents.listByServer", + "azure.mgmt.sql.aio.operations.JobAgentsOperations.list_by_server": "Microsoft.Sql.JobAgents.listByServer", + "azure.mgmt.sql.operations.JobCredentialsOperations.get": "Microsoft.Sql.JobCredentials.get", + "azure.mgmt.sql.aio.operations.JobCredentialsOperations.get": "Microsoft.Sql.JobCredentials.get", + "azure.mgmt.sql.operations.JobCredentialsOperations.create_or_update": "Microsoft.Sql.JobCredentials.createOrUpdate", + "azure.mgmt.sql.aio.operations.JobCredentialsOperations.create_or_update": "Microsoft.Sql.JobCredentials.createOrUpdate", + "azure.mgmt.sql.operations.JobCredentialsOperations.delete": "Microsoft.Sql.JobCredentials.delete", + "azure.mgmt.sql.aio.operations.JobCredentialsOperations.delete": "Microsoft.Sql.JobCredentials.delete", + "azure.mgmt.sql.operations.JobCredentialsOperations.list_by_agent": "Microsoft.Sql.JobCredentials.listByAgent", + "azure.mgmt.sql.aio.operations.JobCredentialsOperations.list_by_agent": "Microsoft.Sql.JobCredentials.listByAgent", + "azure.mgmt.sql.operations.JobStepExecutionsOperations.get": "Microsoft.Sql.JobStepExecutions.get", + "azure.mgmt.sql.aio.operations.JobStepExecutionsOperations.get": "Microsoft.Sql.JobStepExecutions.get", + "azure.mgmt.sql.operations.JobStepExecutionsOperations.list_by_job_execution": "Microsoft.Sql.JobStepExecutions.ListByJobExecution", + "azure.mgmt.sql.aio.operations.JobStepExecutionsOperations.list_by_job_execution": "Microsoft.Sql.JobStepExecutions.ListByJobExecution", + "azure.mgmt.sql.operations.JobTargetExecutionsOperations.get": "Microsoft.Sql.JobTargetExecutions.get", + "azure.mgmt.sql.aio.operations.JobTargetExecutionsOperations.get": "Microsoft.Sql.JobTargetExecutions.get", + "azure.mgmt.sql.operations.JobTargetExecutionsOperations.list_by_step": "Microsoft.Sql.JobTargetExecutions.ListByStep", + "azure.mgmt.sql.aio.operations.JobTargetExecutionsOperations.list_by_step": "Microsoft.Sql.JobTargetExecutions.ListByStep", + "azure.mgmt.sql.operations.JobTargetExecutionsOperations.list_by_job_execution": "Microsoft.Sql.JobTargetExecutions.listByJobExecution", + "azure.mgmt.sql.aio.operations.JobTargetExecutionsOperations.list_by_job_execution": "Microsoft.Sql.JobTargetExecutions.listByJobExecution", + "azure.mgmt.sql.operations.JobsOperations.get": "Microsoft.Sql.Jobs.get", + "azure.mgmt.sql.aio.operations.JobsOperations.get": "Microsoft.Sql.Jobs.get", + "azure.mgmt.sql.operations.JobsOperations.create_or_update": "Microsoft.Sql.Jobs.createOrUpdate", + "azure.mgmt.sql.aio.operations.JobsOperations.create_or_update": "Microsoft.Sql.Jobs.createOrUpdate", + "azure.mgmt.sql.operations.JobsOperations.delete": "Microsoft.Sql.Jobs.delete", + "azure.mgmt.sql.aio.operations.JobsOperations.delete": "Microsoft.Sql.Jobs.delete", + "azure.mgmt.sql.operations.JobsOperations.list_by_agent": "Microsoft.Sql.Jobs.listByAgent", + "azure.mgmt.sql.aio.operations.JobsOperations.list_by_agent": "Microsoft.Sql.Jobs.listByAgent", + "azure.mgmt.sql.operations.JobPrivateEndpointsOperations.get": "Microsoft.Sql.JobPrivateEndpoints.get", + "azure.mgmt.sql.aio.operations.JobPrivateEndpointsOperations.get": "Microsoft.Sql.JobPrivateEndpoints.get", + "azure.mgmt.sql.operations.JobPrivateEndpointsOperations.begin_create_or_update": "Microsoft.Sql.JobPrivateEndpoints.createOrUpdate", + "azure.mgmt.sql.aio.operations.JobPrivateEndpointsOperations.begin_create_or_update": "Microsoft.Sql.JobPrivateEndpoints.createOrUpdate", + "azure.mgmt.sql.operations.JobPrivateEndpointsOperations.begin_delete": "Microsoft.Sql.JobPrivateEndpoints.delete", + "azure.mgmt.sql.aio.operations.JobPrivateEndpointsOperations.begin_delete": "Microsoft.Sql.JobPrivateEndpoints.delete", + "azure.mgmt.sql.operations.JobPrivateEndpointsOperations.list_by_agent": "Microsoft.Sql.JobPrivateEndpoints.listByAgent", + "azure.mgmt.sql.aio.operations.JobPrivateEndpointsOperations.list_by_agent": "Microsoft.Sql.JobPrivateEndpoints.listByAgent", + "azure.mgmt.sql.operations.JobStepsOperations.get": "Microsoft.Sql.JobSteps.get", + "azure.mgmt.sql.aio.operations.JobStepsOperations.get": "Microsoft.Sql.JobSteps.get", + "azure.mgmt.sql.operations.JobStepsOperations.create_or_update": "Microsoft.Sql.JobSteps.createOrUpdate", + "azure.mgmt.sql.aio.operations.JobStepsOperations.create_or_update": "Microsoft.Sql.JobSteps.createOrUpdate", + "azure.mgmt.sql.operations.JobStepsOperations.delete": "Microsoft.Sql.JobSteps.delete", + "azure.mgmt.sql.aio.operations.JobStepsOperations.delete": "Microsoft.Sql.JobSteps.delete", + "azure.mgmt.sql.operations.JobStepsOperations.list_by_job": "Microsoft.Sql.JobSteps.listByJob", + "azure.mgmt.sql.aio.operations.JobStepsOperations.list_by_job": "Microsoft.Sql.JobSteps.listByJob", + "azure.mgmt.sql.operations.JobStepsOperations.get_by_version": "Microsoft.Sql.JobStepOperationGroup.getByVersion", + "azure.mgmt.sql.aio.operations.JobStepsOperations.get_by_version": "Microsoft.Sql.JobStepOperationGroup.getByVersion", + "azure.mgmt.sql.operations.JobStepsOperations.list_by_version": "Microsoft.Sql.JobStepOperationGroup.listByVersion", + "azure.mgmt.sql.aio.operations.JobStepsOperations.list_by_version": "Microsoft.Sql.JobStepOperationGroup.listByVersion", + "azure.mgmt.sql.operations.JobTargetGroupsOperations.get": "Microsoft.Sql.JobTargetGroups.get", + "azure.mgmt.sql.aio.operations.JobTargetGroupsOperations.get": "Microsoft.Sql.JobTargetGroups.get", + "azure.mgmt.sql.operations.JobTargetGroupsOperations.create_or_update": "Microsoft.Sql.JobTargetGroups.createOrUpdate", + "azure.mgmt.sql.aio.operations.JobTargetGroupsOperations.create_or_update": "Microsoft.Sql.JobTargetGroups.createOrUpdate", + "azure.mgmt.sql.operations.JobTargetGroupsOperations.delete": "Microsoft.Sql.JobTargetGroups.delete", + "azure.mgmt.sql.aio.operations.JobTargetGroupsOperations.delete": "Microsoft.Sql.JobTargetGroups.delete", + "azure.mgmt.sql.operations.JobTargetGroupsOperations.list_by_agent": "Microsoft.Sql.JobTargetGroups.listByAgent", + "azure.mgmt.sql.aio.operations.JobTargetGroupsOperations.list_by_agent": "Microsoft.Sql.JobTargetGroups.listByAgent", + "azure.mgmt.sql.operations.JobVersionsOperations.get": "Microsoft.Sql.JobVersions.get", + "azure.mgmt.sql.aio.operations.JobVersionsOperations.get": "Microsoft.Sql.JobVersions.get", + "azure.mgmt.sql.operations.JobVersionsOperations.list_by_job": "Microsoft.Sql.JobVersions.listByJob", + "azure.mgmt.sql.aio.operations.JobVersionsOperations.list_by_job": "Microsoft.Sql.JobVersions.listByJob", + "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.get": "Microsoft.Sql.LongTermRetentionBackups.get", + "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.get": "Microsoft.Sql.LongTermRetentionBackups.get", + "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.begin_delete": "Microsoft.Sql.LongTermRetentionBackups.delete", + "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.begin_delete": "Microsoft.Sql.LongTermRetentionBackups.delete", + "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.list_by_database": "Microsoft.Sql.LongTermRetentionBackups.listByDatabase", + "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.list_by_database": "Microsoft.Sql.LongTermRetentionBackups.listByDatabase", + "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.begin_change_access_tier": "Microsoft.Sql.LongTermRetentionBackups.changeAccessTier", + "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.begin_change_access_tier": "Microsoft.Sql.LongTermRetentionBackups.changeAccessTier", + "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.begin_copy": "Microsoft.Sql.LongTermRetentionBackups.copy", + "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.begin_copy": "Microsoft.Sql.LongTermRetentionBackups.copy", + "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.begin_lock_time_based_immutability": "Microsoft.Sql.LongTermRetentionBackups.lockTimeBasedImmutability", + "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.begin_lock_time_based_immutability": "Microsoft.Sql.LongTermRetentionBackups.lockTimeBasedImmutability", + "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.begin_remove_legal_hold_immutability": "Microsoft.Sql.LongTermRetentionBackups.removeLegalHoldImmutability", + "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.begin_remove_legal_hold_immutability": "Microsoft.Sql.LongTermRetentionBackups.removeLegalHoldImmutability", + "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.begin_remove_time_based_immutability": "Microsoft.Sql.LongTermRetentionBackups.removeTimeBasedImmutability", + "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.begin_remove_time_based_immutability": "Microsoft.Sql.LongTermRetentionBackups.removeTimeBasedImmutability", + "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.begin_set_legal_hold_immutability": "Microsoft.Sql.LongTermRetentionBackups.setLegalHoldImmutability", + "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.begin_set_legal_hold_immutability": "Microsoft.Sql.LongTermRetentionBackups.setLegalHoldImmutability", + "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.begin_update": "Microsoft.Sql.LongTermRetentionBackups.update", + "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.begin_update": "Microsoft.Sql.LongTermRetentionBackups.update", + "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.get_by_resource_group": "Microsoft.Sql.LongTermRetentionBackupOperationGroup.getByResourceGroup", + "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.get_by_resource_group": "Microsoft.Sql.LongTermRetentionBackupOperationGroup.getByResourceGroup", + "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.begin_delete_by_resource_group": "Microsoft.Sql.LongTermRetentionBackupOperationGroup.deleteByResourceGroup", + "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.begin_delete_by_resource_group": "Microsoft.Sql.LongTermRetentionBackupOperationGroup.deleteByResourceGroup", + "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.list_by_resource_group_database": "Microsoft.Sql.LongTermRetentionBackupOperationGroup.listByResourceGroupDatabase", + "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.list_by_resource_group_database": "Microsoft.Sql.LongTermRetentionBackupOperationGroup.listByResourceGroupDatabase", + "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.begin_change_access_tier_by_resource_group": "Microsoft.Sql.LongTermRetentionBackupOperationGroup.changeAccessTierByResourceGroup", + "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.begin_change_access_tier_by_resource_group": "Microsoft.Sql.LongTermRetentionBackupOperationGroup.changeAccessTierByResourceGroup", + "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.begin_copy_by_resource_group": "Microsoft.Sql.LongTermRetentionBackupOperationGroup.copyByResourceGroup", + "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.begin_copy_by_resource_group": "Microsoft.Sql.LongTermRetentionBackupOperationGroup.copyByResourceGroup", + "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.begin_lock_time_based_immutability_by_resource_group": "Microsoft.Sql.LongTermRetentionBackupOperationGroup.lockTimeBasedImmutabilityByResourceGroup", + "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.begin_lock_time_based_immutability_by_resource_group": "Microsoft.Sql.LongTermRetentionBackupOperationGroup.lockTimeBasedImmutabilityByResourceGroup", + "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.begin_remove_legal_hold_immutability_by_resource_group": "Microsoft.Sql.LongTermRetentionBackupOperationGroup.removeLegalHoldImmutabilityByResourceGroup", + "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.begin_remove_legal_hold_immutability_by_resource_group": "Microsoft.Sql.LongTermRetentionBackupOperationGroup.removeLegalHoldImmutabilityByResourceGroup", + "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.begin_remove_time_based_immutability_by_resource_group": "Microsoft.Sql.LongTermRetentionBackupOperationGroup.removeTimeBasedImmutabilityByResourceGroup", + "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.begin_remove_time_based_immutability_by_resource_group": "Microsoft.Sql.LongTermRetentionBackupOperationGroup.removeTimeBasedImmutabilityByResourceGroup", + "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.begin_set_legal_hold_immutability_by_resource_group": "Microsoft.Sql.LongTermRetentionBackupOperationGroup.setLegalHoldImmutabilityByResourceGroup", + "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.begin_set_legal_hold_immutability_by_resource_group": "Microsoft.Sql.LongTermRetentionBackupOperationGroup.setLegalHoldImmutabilityByResourceGroup", + "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.begin_update_by_resource_group": "Microsoft.Sql.LongTermRetentionBackupOperationGroup.updateByResourceGroup", + "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.begin_update_by_resource_group": "Microsoft.Sql.LongTermRetentionBackupOperationGroup.updateByResourceGroup", + "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.list_by_location": "Microsoft.Sql.LongTermRetentionBackupsOperationGroup.listByLocation", + "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.list_by_location": "Microsoft.Sql.LongTermRetentionBackupsOperationGroup.listByLocation", + "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.list_by_server": "Microsoft.Sql.LongTermRetentionBackupsOperationGroup.listByServer", + "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.list_by_server": "Microsoft.Sql.LongTermRetentionBackupsOperationGroup.listByServer", + "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.list_by_resource_group_location": "Microsoft.Sql.LongTermRetentionBackupsOperationGroup.listByResourceGroupLocation", + "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.list_by_resource_group_location": "Microsoft.Sql.LongTermRetentionBackupsOperationGroup.listByResourceGroupLocation", + "azure.mgmt.sql.operations.LongTermRetentionBackupsOperations.list_by_resource_group_server": "Microsoft.Sql.LongTermRetentionBackupsOperationGroup.listByResourceGroupServer", + "azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations.list_by_resource_group_server": "Microsoft.Sql.LongTermRetentionBackupsOperationGroup.listByResourceGroupServer", + "azure.mgmt.sql.operations.LongTermRetentionManagedInstanceBackupsOperations.get_by_resource_group": "Microsoft.Sql.LongTermRetentionManagedInstanceBackups.getByResourceGroup", + "azure.mgmt.sql.aio.operations.LongTermRetentionManagedInstanceBackupsOperations.get_by_resource_group": "Microsoft.Sql.LongTermRetentionManagedInstanceBackups.getByResourceGroup", + "azure.mgmt.sql.operations.LongTermRetentionManagedInstanceBackupsOperations.begin_delete_by_resource_group": "Microsoft.Sql.LongTermRetentionManagedInstanceBackups.deleteByResourceGroup", + "azure.mgmt.sql.aio.operations.LongTermRetentionManagedInstanceBackupsOperations.begin_delete_by_resource_group": "Microsoft.Sql.LongTermRetentionManagedInstanceBackups.deleteByResourceGroup", + "azure.mgmt.sql.operations.LongTermRetentionManagedInstanceBackupsOperations.list_by_resource_group_database": "Microsoft.Sql.LongTermRetentionManagedInstanceBackups.listByResourceGroupDatabase", + "azure.mgmt.sql.aio.operations.LongTermRetentionManagedInstanceBackupsOperations.list_by_resource_group_database": "Microsoft.Sql.LongTermRetentionManagedInstanceBackups.listByResourceGroupDatabase", + "azure.mgmt.sql.operations.LongTermRetentionManagedInstanceBackupsOperations.get": "Microsoft.Sql.ManagedInstanceLongTermRetentionBackups.get", + "azure.mgmt.sql.aio.operations.LongTermRetentionManagedInstanceBackupsOperations.get": "Microsoft.Sql.ManagedInstanceLongTermRetentionBackups.get", + "azure.mgmt.sql.operations.LongTermRetentionManagedInstanceBackupsOperations.begin_delete": "Microsoft.Sql.ManagedInstanceLongTermRetentionBackups.delete", + "azure.mgmt.sql.aio.operations.LongTermRetentionManagedInstanceBackupsOperations.begin_delete": "Microsoft.Sql.ManagedInstanceLongTermRetentionBackups.delete", + "azure.mgmt.sql.operations.LongTermRetentionManagedInstanceBackupsOperations.list_by_database": "Microsoft.Sql.ManagedInstanceLongTermRetentionBackups.listByDatabase", + "azure.mgmt.sql.aio.operations.LongTermRetentionManagedInstanceBackupsOperations.list_by_database": "Microsoft.Sql.ManagedInstanceLongTermRetentionBackups.listByDatabase", + "azure.mgmt.sql.operations.LongTermRetentionManagedInstanceBackupsOperations.list_by_location": "Microsoft.Sql.LongTermRetentionManagedInstanceBackupsOperationGroup.listByLocation", + "azure.mgmt.sql.aio.operations.LongTermRetentionManagedInstanceBackupsOperations.list_by_location": "Microsoft.Sql.LongTermRetentionManagedInstanceBackupsOperationGroup.listByLocation", + "azure.mgmt.sql.operations.LongTermRetentionManagedInstanceBackupsOperations.list_by_instance": "Microsoft.Sql.LongTermRetentionManagedInstanceBackupsOperationGroup.listByInstance", + "azure.mgmt.sql.aio.operations.LongTermRetentionManagedInstanceBackupsOperations.list_by_instance": "Microsoft.Sql.LongTermRetentionManagedInstanceBackupsOperationGroup.listByInstance", + "azure.mgmt.sql.operations.LongTermRetentionManagedInstanceBackupsOperations.list_by_resource_group_location": "Microsoft.Sql.LongTermRetentionManagedInstanceBackupsOperationGroup.listByResourceGroupLocation", + "azure.mgmt.sql.aio.operations.LongTermRetentionManagedInstanceBackupsOperations.list_by_resource_group_location": "Microsoft.Sql.LongTermRetentionManagedInstanceBackupsOperationGroup.listByResourceGroupLocation", + "azure.mgmt.sql.operations.LongTermRetentionManagedInstanceBackupsOperations.list_by_resource_group_instance": "Microsoft.Sql.LongTermRetentionManagedInstanceBackupsOperationGroup.listByResourceGroupInstance", + "azure.mgmt.sql.aio.operations.LongTermRetentionManagedInstanceBackupsOperations.list_by_resource_group_instance": "Microsoft.Sql.LongTermRetentionManagedInstanceBackupsOperationGroup.listByResourceGroupInstance", + "azure.mgmt.sql.operations.LongTermRetentionPoliciesOperations.get": "Microsoft.Sql.LongTermRetentionPolicies.get", + "azure.mgmt.sql.aio.operations.LongTermRetentionPoliciesOperations.get": "Microsoft.Sql.LongTermRetentionPolicies.get", + "azure.mgmt.sql.operations.LongTermRetentionPoliciesOperations.begin_create_or_update": "Microsoft.Sql.LongTermRetentionPolicies.createOrUpdate", + "azure.mgmt.sql.aio.operations.LongTermRetentionPoliciesOperations.begin_create_or_update": "Microsoft.Sql.LongTermRetentionPolicies.createOrUpdate", + "azure.mgmt.sql.operations.LongTermRetentionPoliciesOperations.list_by_database": "Microsoft.Sql.LongTermRetentionPolicies.listByDatabase", + "azure.mgmt.sql.aio.operations.LongTermRetentionPoliciesOperations.list_by_database": "Microsoft.Sql.LongTermRetentionPolicies.listByDatabase", + "azure.mgmt.sql.operations.ManagedBackupShortTermRetentionPoliciesOperations.get": "Microsoft.Sql.ManagedBackupShortTermRetentionPolicies.get", + "azure.mgmt.sql.aio.operations.ManagedBackupShortTermRetentionPoliciesOperations.get": "Microsoft.Sql.ManagedBackupShortTermRetentionPolicies.get", + "azure.mgmt.sql.operations.ManagedBackupShortTermRetentionPoliciesOperations.begin_create_or_update": "Microsoft.Sql.ManagedBackupShortTermRetentionPolicies.createOrUpdate", + "azure.mgmt.sql.aio.operations.ManagedBackupShortTermRetentionPoliciesOperations.begin_create_or_update": "Microsoft.Sql.ManagedBackupShortTermRetentionPolicies.createOrUpdate", + "azure.mgmt.sql.operations.ManagedBackupShortTermRetentionPoliciesOperations.begin_update": "Microsoft.Sql.ManagedBackupShortTermRetentionPolicies.update", + "azure.mgmt.sql.aio.operations.ManagedBackupShortTermRetentionPoliciesOperations.begin_update": "Microsoft.Sql.ManagedBackupShortTermRetentionPolicies.update", + "azure.mgmt.sql.operations.ManagedBackupShortTermRetentionPoliciesOperations.list_by_database": "Microsoft.Sql.ManagedBackupShortTermRetentionPolicies.listByDatabase", + "azure.mgmt.sql.aio.operations.ManagedBackupShortTermRetentionPoliciesOperations.list_by_database": "Microsoft.Sql.ManagedBackupShortTermRetentionPolicies.listByDatabase", + "azure.mgmt.sql.operations.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations.get": "Microsoft.Sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPolicies.get", + "azure.mgmt.sql.aio.operations.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations.get": "Microsoft.Sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPolicies.get", + "azure.mgmt.sql.operations.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations.begin_create_or_update": "Microsoft.Sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPolicies.createOrUpdate", + "azure.mgmt.sql.aio.operations.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations.begin_create_or_update": "Microsoft.Sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPolicies.createOrUpdate", + "azure.mgmt.sql.operations.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations.begin_update": "Microsoft.Sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPolicies.update", + "azure.mgmt.sql.aio.operations.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations.begin_update": "Microsoft.Sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPolicies.update", + "azure.mgmt.sql.operations.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations.list_by_restorable_dropped_database": "Microsoft.Sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPolicies.listByRestorableDroppedDatabase", + "azure.mgmt.sql.aio.operations.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations.list_by_restorable_dropped_database": "Microsoft.Sql.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPolicies.listByRestorableDroppedDatabase", + "azure.mgmt.sql.operations.ManagedDatabaseSecurityAlertPoliciesOperations.get": "Microsoft.Sql.ManagedDatabaseSecurityAlertPolicies.get", + "azure.mgmt.sql.aio.operations.ManagedDatabaseSecurityAlertPoliciesOperations.get": "Microsoft.Sql.ManagedDatabaseSecurityAlertPolicies.get", + "azure.mgmt.sql.operations.ManagedDatabaseSecurityAlertPoliciesOperations.create_or_update": "Microsoft.Sql.ManagedDatabaseSecurityAlertPolicies.createOrUpdate", + "azure.mgmt.sql.aio.operations.ManagedDatabaseSecurityAlertPoliciesOperations.create_or_update": "Microsoft.Sql.ManagedDatabaseSecurityAlertPolicies.createOrUpdate", + "azure.mgmt.sql.operations.ManagedDatabaseSecurityAlertPoliciesOperations.list_by_database": "Microsoft.Sql.ManagedDatabaseSecurityAlertPolicies.listByDatabase", + "azure.mgmt.sql.aio.operations.ManagedDatabaseSecurityAlertPoliciesOperations.list_by_database": "Microsoft.Sql.ManagedDatabaseSecurityAlertPolicies.listByDatabase", + "azure.mgmt.sql.operations.ManagedInstanceAdministratorsOperations.get": "Microsoft.Sql.ManagedInstanceAdministrators.get", + "azure.mgmt.sql.aio.operations.ManagedInstanceAdministratorsOperations.get": "Microsoft.Sql.ManagedInstanceAdministrators.get", + "azure.mgmt.sql.operations.ManagedInstanceAdministratorsOperations.begin_create_or_update": "Microsoft.Sql.ManagedInstanceAdministrators.createOrUpdate", + "azure.mgmt.sql.aio.operations.ManagedInstanceAdministratorsOperations.begin_create_or_update": "Microsoft.Sql.ManagedInstanceAdministrators.createOrUpdate", + "azure.mgmt.sql.operations.ManagedInstanceAdministratorsOperations.begin_delete": "Microsoft.Sql.ManagedInstanceAdministrators.delete", + "azure.mgmt.sql.aio.operations.ManagedInstanceAdministratorsOperations.begin_delete": "Microsoft.Sql.ManagedInstanceAdministrators.delete", + "azure.mgmt.sql.operations.ManagedInstanceAdministratorsOperations.list_by_instance": "Microsoft.Sql.ManagedInstanceAdministrators.listByInstance", + "azure.mgmt.sql.aio.operations.ManagedInstanceAdministratorsOperations.list_by_instance": "Microsoft.Sql.ManagedInstanceAdministrators.listByInstance", + "azure.mgmt.sql.operations.ManagedInstanceAzureADOnlyAuthenticationsOperations.get": "Microsoft.Sql.ManagedInstanceAzureADOnlyAuthentications.get", + "azure.mgmt.sql.aio.operations.ManagedInstanceAzureADOnlyAuthenticationsOperations.get": "Microsoft.Sql.ManagedInstanceAzureADOnlyAuthentications.get", + "azure.mgmt.sql.operations.ManagedInstanceAzureADOnlyAuthenticationsOperations.begin_create_or_update": "Microsoft.Sql.ManagedInstanceAzureADOnlyAuthentications.createOrUpdate", + "azure.mgmt.sql.aio.operations.ManagedInstanceAzureADOnlyAuthenticationsOperations.begin_create_or_update": "Microsoft.Sql.ManagedInstanceAzureADOnlyAuthentications.createOrUpdate", + "azure.mgmt.sql.operations.ManagedInstanceAzureADOnlyAuthenticationsOperations.begin_delete": "Microsoft.Sql.ManagedInstanceAzureADOnlyAuthentications.delete", + "azure.mgmt.sql.aio.operations.ManagedInstanceAzureADOnlyAuthenticationsOperations.begin_delete": "Microsoft.Sql.ManagedInstanceAzureADOnlyAuthentications.delete", + "azure.mgmt.sql.operations.ManagedInstanceAzureADOnlyAuthenticationsOperations.list_by_instance": "Microsoft.Sql.ManagedInstanceAzureADOnlyAuthentications.listByInstance", + "azure.mgmt.sql.aio.operations.ManagedInstanceAzureADOnlyAuthenticationsOperations.list_by_instance": "Microsoft.Sql.ManagedInstanceAzureADOnlyAuthentications.listByInstance", + "azure.mgmt.sql.operations.ManagedInstanceDtcsOperations.get": "Microsoft.Sql.ManagedInstanceDtcs.get", + "azure.mgmt.sql.aio.operations.ManagedInstanceDtcsOperations.get": "Microsoft.Sql.ManagedInstanceDtcs.get", + "azure.mgmt.sql.operations.ManagedInstanceDtcsOperations.begin_create_or_update": "Microsoft.Sql.ManagedInstanceDtcs.createOrUpdate", + "azure.mgmt.sql.aio.operations.ManagedInstanceDtcsOperations.begin_create_or_update": "Microsoft.Sql.ManagedInstanceDtcs.createOrUpdate", + "azure.mgmt.sql.operations.ManagedInstanceDtcsOperations.list_by_managed_instance": "Microsoft.Sql.ManagedInstanceDtcs.listByManagedInstance", + "azure.mgmt.sql.aio.operations.ManagedInstanceDtcsOperations.list_by_managed_instance": "Microsoft.Sql.ManagedInstanceDtcs.listByManagedInstance", + "azure.mgmt.sql.operations.ManagedInstanceEncryptionProtectorsOperations.get": "Microsoft.Sql.ManagedInstanceEncryptionProtectors.get", + "azure.mgmt.sql.aio.operations.ManagedInstanceEncryptionProtectorsOperations.get": "Microsoft.Sql.ManagedInstanceEncryptionProtectors.get", + "azure.mgmt.sql.operations.ManagedInstanceEncryptionProtectorsOperations.begin_create_or_update": "Microsoft.Sql.ManagedInstanceEncryptionProtectors.createOrUpdate", + "azure.mgmt.sql.aio.operations.ManagedInstanceEncryptionProtectorsOperations.begin_create_or_update": "Microsoft.Sql.ManagedInstanceEncryptionProtectors.createOrUpdate", + "azure.mgmt.sql.operations.ManagedInstanceEncryptionProtectorsOperations.list_by_instance": "Microsoft.Sql.ManagedInstanceEncryptionProtectors.listByInstance", + "azure.mgmt.sql.aio.operations.ManagedInstanceEncryptionProtectorsOperations.list_by_instance": "Microsoft.Sql.ManagedInstanceEncryptionProtectors.listByInstance", + "azure.mgmt.sql.operations.ManagedInstanceEncryptionProtectorsOperations.begin_revalidate": "Microsoft.Sql.ManagedInstanceEncryptionProtectors.revalidate", + "azure.mgmt.sql.aio.operations.ManagedInstanceEncryptionProtectorsOperations.begin_revalidate": "Microsoft.Sql.ManagedInstanceEncryptionProtectors.revalidate", + "azure.mgmt.sql.operations.ManagedInstanceKeysOperations.get": "Microsoft.Sql.ManagedInstanceKeys.get", + "azure.mgmt.sql.aio.operations.ManagedInstanceKeysOperations.get": "Microsoft.Sql.ManagedInstanceKeys.get", + "azure.mgmt.sql.operations.ManagedInstanceKeysOperations.begin_create_or_update": "Microsoft.Sql.ManagedInstanceKeys.createOrUpdate", + "azure.mgmt.sql.aio.operations.ManagedInstanceKeysOperations.begin_create_or_update": "Microsoft.Sql.ManagedInstanceKeys.createOrUpdate", + "azure.mgmt.sql.operations.ManagedInstanceKeysOperations.begin_delete": "Microsoft.Sql.ManagedInstanceKeys.delete", + "azure.mgmt.sql.aio.operations.ManagedInstanceKeysOperations.begin_delete": "Microsoft.Sql.ManagedInstanceKeys.delete", + "azure.mgmt.sql.operations.ManagedInstanceKeysOperations.list_by_instance": "Microsoft.Sql.ManagedInstanceKeys.listByInstance", + "azure.mgmt.sql.aio.operations.ManagedInstanceKeysOperations.list_by_instance": "Microsoft.Sql.ManagedInstanceKeys.listByInstance", + "azure.mgmt.sql.operations.ManagedInstanceLongTermRetentionPoliciesOperations.get": "Microsoft.Sql.ManagedInstanceLongTermRetentionPolicies.get", + "azure.mgmt.sql.aio.operations.ManagedInstanceLongTermRetentionPoliciesOperations.get": "Microsoft.Sql.ManagedInstanceLongTermRetentionPolicies.get", + "azure.mgmt.sql.operations.ManagedInstanceLongTermRetentionPoliciesOperations.begin_create_or_update": "Microsoft.Sql.ManagedInstanceLongTermRetentionPolicies.createOrUpdate", + "azure.mgmt.sql.aio.operations.ManagedInstanceLongTermRetentionPoliciesOperations.begin_create_or_update": "Microsoft.Sql.ManagedInstanceLongTermRetentionPolicies.createOrUpdate", + "azure.mgmt.sql.operations.ManagedInstanceLongTermRetentionPoliciesOperations.begin_delete": "Microsoft.Sql.ManagedInstanceLongTermRetentionPolicies.delete", + "azure.mgmt.sql.aio.operations.ManagedInstanceLongTermRetentionPoliciesOperations.begin_delete": "Microsoft.Sql.ManagedInstanceLongTermRetentionPolicies.delete", + "azure.mgmt.sql.operations.ManagedInstanceLongTermRetentionPoliciesOperations.list_by_database": "Microsoft.Sql.ManagedInstanceLongTermRetentionPolicies.listByDatabase", + "azure.mgmt.sql.aio.operations.ManagedInstanceLongTermRetentionPoliciesOperations.list_by_database": "Microsoft.Sql.ManagedInstanceLongTermRetentionPolicies.listByDatabase", + "azure.mgmt.sql.operations.ManagedInstanceOperationsOperations.get": "Microsoft.Sql.ManagedInstanceOperations.get", + "azure.mgmt.sql.aio.operations.ManagedInstanceOperationsOperations.get": "Microsoft.Sql.ManagedInstanceOperations.get", + "azure.mgmt.sql.operations.ManagedInstanceOperationsOperations.list_by_managed_instance": "Microsoft.Sql.ManagedInstanceOperations.listByManagedInstance", + "azure.mgmt.sql.aio.operations.ManagedInstanceOperationsOperations.list_by_managed_instance": "Microsoft.Sql.ManagedInstanceOperations.listByManagedInstance", + "azure.mgmt.sql.operations.ManagedInstanceOperationsOperations.cancel": "Microsoft.Sql.ManagedInstanceOperations.cancel", + "azure.mgmt.sql.aio.operations.ManagedInstanceOperationsOperations.cancel": "Microsoft.Sql.ManagedInstanceOperations.cancel", + "azure.mgmt.sql.operations.ManagedInstancePrivateEndpointConnectionsOperations.get": "Microsoft.Sql.ManagedInstancePrivateEndpointConnections.get", + "azure.mgmt.sql.aio.operations.ManagedInstancePrivateEndpointConnectionsOperations.get": "Microsoft.Sql.ManagedInstancePrivateEndpointConnections.get", + "azure.mgmt.sql.operations.ManagedInstancePrivateEndpointConnectionsOperations.begin_create_or_update": "Microsoft.Sql.ManagedInstancePrivateEndpointConnections.createOrUpdate", + "azure.mgmt.sql.aio.operations.ManagedInstancePrivateEndpointConnectionsOperations.begin_create_or_update": "Microsoft.Sql.ManagedInstancePrivateEndpointConnections.createOrUpdate", + "azure.mgmt.sql.operations.ManagedInstancePrivateEndpointConnectionsOperations.begin_delete": "Microsoft.Sql.ManagedInstancePrivateEndpointConnections.delete", + "azure.mgmt.sql.aio.operations.ManagedInstancePrivateEndpointConnectionsOperations.begin_delete": "Microsoft.Sql.ManagedInstancePrivateEndpointConnections.delete", + "azure.mgmt.sql.operations.ManagedInstancePrivateEndpointConnectionsOperations.list_by_managed_instance": "Microsoft.Sql.ManagedInstancePrivateEndpointConnections.listByManagedInstance", + "azure.mgmt.sql.aio.operations.ManagedInstancePrivateEndpointConnectionsOperations.list_by_managed_instance": "Microsoft.Sql.ManagedInstancePrivateEndpointConnections.listByManagedInstance", + "azure.mgmt.sql.operations.ManagedInstanceVulnerabilityAssessmentsOperations.get": "Microsoft.Sql.ManagedInstanceVulnerabilityAssessments.get", + "azure.mgmt.sql.aio.operations.ManagedInstanceVulnerabilityAssessmentsOperations.get": "Microsoft.Sql.ManagedInstanceVulnerabilityAssessments.get", + "azure.mgmt.sql.operations.ManagedInstanceVulnerabilityAssessmentsOperations.create_or_update": "Microsoft.Sql.ManagedInstanceVulnerabilityAssessments.createOrUpdate", + "azure.mgmt.sql.aio.operations.ManagedInstanceVulnerabilityAssessmentsOperations.create_or_update": "Microsoft.Sql.ManagedInstanceVulnerabilityAssessments.createOrUpdate", + "azure.mgmt.sql.operations.ManagedInstanceVulnerabilityAssessmentsOperations.delete": "Microsoft.Sql.ManagedInstanceVulnerabilityAssessments.delete", + "azure.mgmt.sql.aio.operations.ManagedInstanceVulnerabilityAssessmentsOperations.delete": "Microsoft.Sql.ManagedInstanceVulnerabilityAssessments.delete", + "azure.mgmt.sql.operations.ManagedInstanceVulnerabilityAssessmentsOperations.list_by_instance": "Microsoft.Sql.ManagedInstanceVulnerabilityAssessments.listByInstance", + "azure.mgmt.sql.aio.operations.ManagedInstanceVulnerabilityAssessmentsOperations.list_by_instance": "Microsoft.Sql.ManagedInstanceVulnerabilityAssessments.listByInstance", + "azure.mgmt.sql.operations.ManagedServerDnsAliasesOperations.get": "Microsoft.Sql.ManagedServerDnsAliases.get", + "azure.mgmt.sql.aio.operations.ManagedServerDnsAliasesOperations.get": "Microsoft.Sql.ManagedServerDnsAliases.get", + "azure.mgmt.sql.operations.ManagedServerDnsAliasesOperations.begin_create_or_update": "Microsoft.Sql.ManagedServerDnsAliases.createOrUpdate", + "azure.mgmt.sql.aio.operations.ManagedServerDnsAliasesOperations.begin_create_or_update": "Microsoft.Sql.ManagedServerDnsAliases.createOrUpdate", + "azure.mgmt.sql.operations.ManagedServerDnsAliasesOperations.begin_delete": "Microsoft.Sql.ManagedServerDnsAliases.delete", + "azure.mgmt.sql.aio.operations.ManagedServerDnsAliasesOperations.begin_delete": "Microsoft.Sql.ManagedServerDnsAliases.delete", + "azure.mgmt.sql.operations.ManagedServerDnsAliasesOperations.list_by_managed_instance": "Microsoft.Sql.ManagedServerDnsAliases.listByManagedInstance", + "azure.mgmt.sql.aio.operations.ManagedServerDnsAliasesOperations.list_by_managed_instance": "Microsoft.Sql.ManagedServerDnsAliases.listByManagedInstance", + "azure.mgmt.sql.operations.ManagedServerDnsAliasesOperations.begin_acquire": "Microsoft.Sql.ManagedServerDnsAliases.acquire", + "azure.mgmt.sql.aio.operations.ManagedServerDnsAliasesOperations.begin_acquire": "Microsoft.Sql.ManagedServerDnsAliases.acquire", + "azure.mgmt.sql.operations.ManagedServerSecurityAlertPoliciesOperations.get": "Microsoft.Sql.ManagedServerSecurityAlertPolicies.get", + "azure.mgmt.sql.aio.operations.ManagedServerSecurityAlertPoliciesOperations.get": "Microsoft.Sql.ManagedServerSecurityAlertPolicies.get", + "azure.mgmt.sql.operations.ManagedServerSecurityAlertPoliciesOperations.begin_create_or_update": "Microsoft.Sql.ManagedServerSecurityAlertPolicies.createOrUpdate", + "azure.mgmt.sql.aio.operations.ManagedServerSecurityAlertPoliciesOperations.begin_create_or_update": "Microsoft.Sql.ManagedServerSecurityAlertPolicies.createOrUpdate", + "azure.mgmt.sql.operations.ManagedServerSecurityAlertPoliciesOperations.list_by_instance": "Microsoft.Sql.ManagedServerSecurityAlertPolicies.listByInstance", + "azure.mgmt.sql.aio.operations.ManagedServerSecurityAlertPoliciesOperations.list_by_instance": "Microsoft.Sql.ManagedServerSecurityAlertPolicies.listByInstance", + "azure.mgmt.sql.operations.NetworkSecurityPerimeterConfigurationsOperations.get": "Microsoft.Sql.NetworkSecurityPerimeterConfigurations.get", + "azure.mgmt.sql.aio.operations.NetworkSecurityPerimeterConfigurationsOperations.get": "Microsoft.Sql.NetworkSecurityPerimeterConfigurations.get", + "azure.mgmt.sql.operations.NetworkSecurityPerimeterConfigurationsOperations.list_by_server": "Microsoft.Sql.NetworkSecurityPerimeterConfigurations.listByServer", + "azure.mgmt.sql.aio.operations.NetworkSecurityPerimeterConfigurationsOperations.list_by_server": "Microsoft.Sql.NetworkSecurityPerimeterConfigurations.listByServer", + "azure.mgmt.sql.operations.NetworkSecurityPerimeterConfigurationsOperations.begin_reconcile": "Microsoft.Sql.NetworkSecurityPerimeterConfigurations.reconcile", + "azure.mgmt.sql.aio.operations.NetworkSecurityPerimeterConfigurationsOperations.begin_reconcile": "Microsoft.Sql.NetworkSecurityPerimeterConfigurations.reconcile", + "azure.mgmt.sql.operations.OutboundFirewallRulesOperations.get": "Microsoft.Sql.OutboundFirewallRules.get", + "azure.mgmt.sql.aio.operations.OutboundFirewallRulesOperations.get": "Microsoft.Sql.OutboundFirewallRules.get", + "azure.mgmt.sql.operations.OutboundFirewallRulesOperations.begin_create_or_update": "Microsoft.Sql.OutboundFirewallRules.createOrUpdate", + "azure.mgmt.sql.aio.operations.OutboundFirewallRulesOperations.begin_create_or_update": "Microsoft.Sql.OutboundFirewallRules.createOrUpdate", + "azure.mgmt.sql.operations.OutboundFirewallRulesOperations.begin_delete": "Microsoft.Sql.OutboundFirewallRules.delete", + "azure.mgmt.sql.aio.operations.OutboundFirewallRulesOperations.begin_delete": "Microsoft.Sql.OutboundFirewallRules.delete", + "azure.mgmt.sql.operations.OutboundFirewallRulesOperations.list_by_server": "Microsoft.Sql.OutboundFirewallRules.listByServer", + "azure.mgmt.sql.aio.operations.OutboundFirewallRulesOperations.list_by_server": "Microsoft.Sql.OutboundFirewallRules.listByServer", + "azure.mgmt.sql.operations.PrivateEndpointConnectionsOperations.get": "Microsoft.Sql.PrivateEndpointConnections.get", + "azure.mgmt.sql.aio.operations.PrivateEndpointConnectionsOperations.get": "Microsoft.Sql.PrivateEndpointConnections.get", + "azure.mgmt.sql.operations.PrivateEndpointConnectionsOperations.begin_create_or_update": "Microsoft.Sql.PrivateEndpointConnections.createOrUpdate", + "azure.mgmt.sql.aio.operations.PrivateEndpointConnectionsOperations.begin_create_or_update": "Microsoft.Sql.PrivateEndpointConnections.createOrUpdate", + "azure.mgmt.sql.operations.PrivateEndpointConnectionsOperations.begin_delete": "Microsoft.Sql.PrivateEndpointConnections.delete", + "azure.mgmt.sql.aio.operations.PrivateEndpointConnectionsOperations.begin_delete": "Microsoft.Sql.PrivateEndpointConnections.delete", + "azure.mgmt.sql.operations.PrivateEndpointConnectionsOperations.list_by_server": "Microsoft.Sql.PrivateEndpointConnections.listByServer", + "azure.mgmt.sql.aio.operations.PrivateEndpointConnectionsOperations.list_by_server": "Microsoft.Sql.PrivateEndpointConnections.listByServer", + "azure.mgmt.sql.operations.PrivateLinkResourcesOperations.get": "Microsoft.Sql.PrivateLinkResources.get", + "azure.mgmt.sql.aio.operations.PrivateLinkResourcesOperations.get": "Microsoft.Sql.PrivateLinkResources.get", + "azure.mgmt.sql.operations.PrivateLinkResourcesOperations.list_by_server": "Microsoft.Sql.PrivateLinkResources.listByServer", + "azure.mgmt.sql.aio.operations.PrivateLinkResourcesOperations.list_by_server": "Microsoft.Sql.PrivateLinkResources.listByServer", + "azure.mgmt.sql.operations.RecoverableDatabasesOperations.get": "Microsoft.Sql.RecoverableDatabases.get", + "azure.mgmt.sql.aio.operations.RecoverableDatabasesOperations.get": "Microsoft.Sql.RecoverableDatabases.get", + "azure.mgmt.sql.operations.RecoverableDatabasesOperations.list_by_server": "Microsoft.Sql.RecoverableDatabases.listByServer", + "azure.mgmt.sql.aio.operations.RecoverableDatabasesOperations.list_by_server": "Microsoft.Sql.RecoverableDatabases.listByServer", + "azure.mgmt.sql.operations.RecoverableManagedDatabasesOperations.get": "Microsoft.Sql.RecoverableManagedDatabases.get", + "azure.mgmt.sql.aio.operations.RecoverableManagedDatabasesOperations.get": "Microsoft.Sql.RecoverableManagedDatabases.get", + "azure.mgmt.sql.operations.RecoverableManagedDatabasesOperations.list_by_instance": "Microsoft.Sql.RecoverableManagedDatabases.listByInstance", + "azure.mgmt.sql.aio.operations.RecoverableManagedDatabasesOperations.list_by_instance": "Microsoft.Sql.RecoverableManagedDatabases.listByInstance", + "azure.mgmt.sql.operations.RestorableDroppedDatabasesOperations.get": "Microsoft.Sql.RestorableDroppedDatabases.get", + "azure.mgmt.sql.aio.operations.RestorableDroppedDatabasesOperations.get": "Microsoft.Sql.RestorableDroppedDatabases.get", + "azure.mgmt.sql.operations.RestorableDroppedDatabasesOperations.list_by_server": "Microsoft.Sql.RestorableDroppedDatabases.listByServer", + "azure.mgmt.sql.aio.operations.RestorableDroppedDatabasesOperations.list_by_server": "Microsoft.Sql.RestorableDroppedDatabases.listByServer", + "azure.mgmt.sql.operations.RestorableDroppedManagedDatabasesOperations.get": "Microsoft.Sql.RestorableDroppedManagedDatabases.get", + "azure.mgmt.sql.aio.operations.RestorableDroppedManagedDatabasesOperations.get": "Microsoft.Sql.RestorableDroppedManagedDatabases.get", + "azure.mgmt.sql.operations.RestorableDroppedManagedDatabasesOperations.list_by_instance": "Microsoft.Sql.RestorableDroppedManagedDatabases.listByInstance", + "azure.mgmt.sql.aio.operations.RestorableDroppedManagedDatabasesOperations.list_by_instance": "Microsoft.Sql.RestorableDroppedManagedDatabases.listByInstance", + "azure.mgmt.sql.operations.ServerAzureADAdministratorsOperations.get": "Microsoft.Sql.ServerAzureADAdministrators.get", + "azure.mgmt.sql.aio.operations.ServerAzureADAdministratorsOperations.get": "Microsoft.Sql.ServerAzureADAdministrators.get", + "azure.mgmt.sql.operations.ServerAzureADAdministratorsOperations.begin_create_or_update": "Microsoft.Sql.ServerAzureADAdministrators.createOrUpdate", + "azure.mgmt.sql.aio.operations.ServerAzureADAdministratorsOperations.begin_create_or_update": "Microsoft.Sql.ServerAzureADAdministrators.createOrUpdate", + "azure.mgmt.sql.operations.ServerAzureADAdministratorsOperations.begin_delete": "Microsoft.Sql.ServerAzureADAdministrators.delete", + "azure.mgmt.sql.aio.operations.ServerAzureADAdministratorsOperations.begin_delete": "Microsoft.Sql.ServerAzureADAdministrators.delete", + "azure.mgmt.sql.operations.ServerAzureADAdministratorsOperations.list_by_server": "Microsoft.Sql.ServerAzureADAdministrators.listByServer", + "azure.mgmt.sql.aio.operations.ServerAzureADAdministratorsOperations.list_by_server": "Microsoft.Sql.ServerAzureADAdministrators.listByServer", + "azure.mgmt.sql.operations.ServerAzureADOnlyAuthenticationsOperations.get": "Microsoft.Sql.ServerAzureADOnlyAuthentications.get", + "azure.mgmt.sql.aio.operations.ServerAzureADOnlyAuthenticationsOperations.get": "Microsoft.Sql.ServerAzureADOnlyAuthentications.get", + "azure.mgmt.sql.operations.ServerAzureADOnlyAuthenticationsOperations.begin_create_or_update": "Microsoft.Sql.ServerAzureADOnlyAuthentications.createOrUpdate", + "azure.mgmt.sql.aio.operations.ServerAzureADOnlyAuthenticationsOperations.begin_create_or_update": "Microsoft.Sql.ServerAzureADOnlyAuthentications.createOrUpdate", + "azure.mgmt.sql.operations.ServerAzureADOnlyAuthenticationsOperations.begin_delete": "Microsoft.Sql.ServerAzureADOnlyAuthentications.delete", + "azure.mgmt.sql.aio.operations.ServerAzureADOnlyAuthenticationsOperations.begin_delete": "Microsoft.Sql.ServerAzureADOnlyAuthentications.delete", + "azure.mgmt.sql.operations.ServerAzureADOnlyAuthenticationsOperations.list_by_server": "Microsoft.Sql.ServerAzureADOnlyAuthentications.listByServer", + "azure.mgmt.sql.aio.operations.ServerAzureADOnlyAuthenticationsOperations.list_by_server": "Microsoft.Sql.ServerAzureADOnlyAuthentications.listByServer", + "azure.mgmt.sql.operations.ServerConfigurationOptionsOperations.get": "Microsoft.Sql.ServerConfigurationOptions.get", + "azure.mgmt.sql.aio.operations.ServerConfigurationOptionsOperations.get": "Microsoft.Sql.ServerConfigurationOptions.get", + "azure.mgmt.sql.operations.ServerConfigurationOptionsOperations.begin_create_or_update": "Microsoft.Sql.ServerConfigurationOptions.createOrUpdate", + "azure.mgmt.sql.aio.operations.ServerConfigurationOptionsOperations.begin_create_or_update": "Microsoft.Sql.ServerConfigurationOptions.createOrUpdate", + "azure.mgmt.sql.operations.ServerConfigurationOptionsOperations.list_by_managed_instance": "Microsoft.Sql.ServerConfigurationOptions.listByManagedInstance", + "azure.mgmt.sql.aio.operations.ServerConfigurationOptionsOperations.list_by_managed_instance": "Microsoft.Sql.ServerConfigurationOptions.listByManagedInstance", + "azure.mgmt.sql.operations.ServerConnectionPoliciesOperations.get": "Microsoft.Sql.ServerConnectionPolicies.get", + "azure.mgmt.sql.aio.operations.ServerConnectionPoliciesOperations.get": "Microsoft.Sql.ServerConnectionPolicies.get", + "azure.mgmt.sql.operations.ServerConnectionPoliciesOperations.begin_create_or_update": "Microsoft.Sql.ServerConnectionPolicies.createOrUpdate", + "azure.mgmt.sql.aio.operations.ServerConnectionPoliciesOperations.begin_create_or_update": "Microsoft.Sql.ServerConnectionPolicies.createOrUpdate", + "azure.mgmt.sql.operations.ServerConnectionPoliciesOperations.list_by_server": "Microsoft.Sql.ServerConnectionPolicies.listByServer", + "azure.mgmt.sql.aio.operations.ServerConnectionPoliciesOperations.list_by_server": "Microsoft.Sql.ServerConnectionPolicies.listByServer", + "azure.mgmt.sql.operations.ServerDevOpsAuditSettingsOperations.get": "Microsoft.Sql.ServerDevOpsAuditSettings.get", + "azure.mgmt.sql.aio.operations.ServerDevOpsAuditSettingsOperations.get": "Microsoft.Sql.ServerDevOpsAuditSettings.get", + "azure.mgmt.sql.operations.ServerDevOpsAuditSettingsOperations.begin_create_or_update": "Microsoft.Sql.ServerDevOpsAuditSettings.createOrUpdate", + "azure.mgmt.sql.aio.operations.ServerDevOpsAuditSettingsOperations.begin_create_or_update": "Microsoft.Sql.ServerDevOpsAuditSettings.createOrUpdate", + "azure.mgmt.sql.operations.ServerDevOpsAuditSettingsOperations.list_by_server": "Microsoft.Sql.ServerDevOpsAuditSettings.listByServer", + "azure.mgmt.sql.aio.operations.ServerDevOpsAuditSettingsOperations.list_by_server": "Microsoft.Sql.ServerDevOpsAuditSettings.listByServer", + "azure.mgmt.sql.operations.ServerDnsAliasesOperations.get": "Microsoft.Sql.ServerDnsAliases.get", + "azure.mgmt.sql.aio.operations.ServerDnsAliasesOperations.get": "Microsoft.Sql.ServerDnsAliases.get", + "azure.mgmt.sql.operations.ServerDnsAliasesOperations.begin_create_or_update": "Microsoft.Sql.ServerDnsAliases.createOrUpdate", + "azure.mgmt.sql.aio.operations.ServerDnsAliasesOperations.begin_create_or_update": "Microsoft.Sql.ServerDnsAliases.createOrUpdate", + "azure.mgmt.sql.operations.ServerDnsAliasesOperations.begin_delete": "Microsoft.Sql.ServerDnsAliases.delete", + "azure.mgmt.sql.aio.operations.ServerDnsAliasesOperations.begin_delete": "Microsoft.Sql.ServerDnsAliases.delete", + "azure.mgmt.sql.operations.ServerDnsAliasesOperations.list_by_server": "Microsoft.Sql.ServerDnsAliases.listByServer", + "azure.mgmt.sql.aio.operations.ServerDnsAliasesOperations.list_by_server": "Microsoft.Sql.ServerDnsAliases.listByServer", + "azure.mgmt.sql.operations.ServerDnsAliasesOperations.begin_acquire": "Microsoft.Sql.ServerDnsAliases.acquire", + "azure.mgmt.sql.aio.operations.ServerDnsAliasesOperations.begin_acquire": "Microsoft.Sql.ServerDnsAliases.acquire", + "azure.mgmt.sql.operations.ServerKeysOperations.get": "Microsoft.Sql.ServerKeys.get", + "azure.mgmt.sql.aio.operations.ServerKeysOperations.get": "Microsoft.Sql.ServerKeys.get", + "azure.mgmt.sql.operations.ServerKeysOperations.begin_create_or_update": "Microsoft.Sql.ServerKeys.createOrUpdate", + "azure.mgmt.sql.aio.operations.ServerKeysOperations.begin_create_or_update": "Microsoft.Sql.ServerKeys.createOrUpdate", + "azure.mgmt.sql.operations.ServerKeysOperations.begin_delete": "Microsoft.Sql.ServerKeys.delete", + "azure.mgmt.sql.aio.operations.ServerKeysOperations.begin_delete": "Microsoft.Sql.ServerKeys.delete", + "azure.mgmt.sql.operations.ServerKeysOperations.list_by_server": "Microsoft.Sql.ServerKeys.listByServer", + "azure.mgmt.sql.aio.operations.ServerKeysOperations.list_by_server": "Microsoft.Sql.ServerKeys.listByServer", + "azure.mgmt.sql.operations.ServerSecurityAlertPoliciesOperations.get": "Microsoft.Sql.ServerSecurityAlertPolicies.get", + "azure.mgmt.sql.aio.operations.ServerSecurityAlertPoliciesOperations.get": "Microsoft.Sql.ServerSecurityAlertPolicies.get", + "azure.mgmt.sql.operations.ServerSecurityAlertPoliciesOperations.begin_create_or_update": "Microsoft.Sql.ServerSecurityAlertPolicies.createOrUpdate", + "azure.mgmt.sql.aio.operations.ServerSecurityAlertPoliciesOperations.begin_create_or_update": "Microsoft.Sql.ServerSecurityAlertPolicies.createOrUpdate", + "azure.mgmt.sql.operations.ServerSecurityAlertPoliciesOperations.list_by_server": "Microsoft.Sql.ServerSecurityAlertPolicies.listByServer", + "azure.mgmt.sql.aio.operations.ServerSecurityAlertPoliciesOperations.list_by_server": "Microsoft.Sql.ServerSecurityAlertPolicies.listByServer", + "azure.mgmt.sql.operations.ServerTrustCertificatesOperations.get": "Microsoft.Sql.ServerTrustCertificates.get", + "azure.mgmt.sql.aio.operations.ServerTrustCertificatesOperations.get": "Microsoft.Sql.ServerTrustCertificates.get", + "azure.mgmt.sql.operations.ServerTrustCertificatesOperations.begin_create_or_update": "Microsoft.Sql.ServerTrustCertificates.createOrUpdate", + "azure.mgmt.sql.aio.operations.ServerTrustCertificatesOperations.begin_create_or_update": "Microsoft.Sql.ServerTrustCertificates.createOrUpdate", + "azure.mgmt.sql.operations.ServerTrustCertificatesOperations.begin_delete": "Microsoft.Sql.ServerTrustCertificates.delete", + "azure.mgmt.sql.aio.operations.ServerTrustCertificatesOperations.begin_delete": "Microsoft.Sql.ServerTrustCertificates.delete", + "azure.mgmt.sql.operations.ServerTrustCertificatesOperations.list_by_instance": "Microsoft.Sql.ServerTrustCertificates.listByInstance", + "azure.mgmt.sql.aio.operations.ServerTrustCertificatesOperations.list_by_instance": "Microsoft.Sql.ServerTrustCertificates.listByInstance", + "azure.mgmt.sql.operations.ServerVulnerabilityAssessmentsOperations.get": "Microsoft.Sql.ServerVulnerabilityAssessments.get", + "azure.mgmt.sql.aio.operations.ServerVulnerabilityAssessmentsOperations.get": "Microsoft.Sql.ServerVulnerabilityAssessments.get", + "azure.mgmt.sql.operations.ServerVulnerabilityAssessmentsOperations.create_or_update": "Microsoft.Sql.ServerVulnerabilityAssessments.createOrUpdate", + "azure.mgmt.sql.aio.operations.ServerVulnerabilityAssessmentsOperations.create_or_update": "Microsoft.Sql.ServerVulnerabilityAssessments.createOrUpdate", + "azure.mgmt.sql.operations.ServerVulnerabilityAssessmentsOperations.delete": "Microsoft.Sql.ServerVulnerabilityAssessments.delete", + "azure.mgmt.sql.aio.operations.ServerVulnerabilityAssessmentsOperations.delete": "Microsoft.Sql.ServerVulnerabilityAssessments.delete", + "azure.mgmt.sql.operations.ServerVulnerabilityAssessmentsOperations.list_by_server": "Microsoft.Sql.ServerVulnerabilityAssessments.listByServer", + "azure.mgmt.sql.aio.operations.ServerVulnerabilityAssessmentsOperations.list_by_server": "Microsoft.Sql.ServerVulnerabilityAssessments.listByServer", + "azure.mgmt.sql.operations.StartStopManagedInstanceSchedulesOperations.get": "Microsoft.Sql.StartStopManagedInstanceSchedules.get", + "azure.mgmt.sql.aio.operations.StartStopManagedInstanceSchedulesOperations.get": "Microsoft.Sql.StartStopManagedInstanceSchedules.get", + "azure.mgmt.sql.operations.StartStopManagedInstanceSchedulesOperations.create_or_update": "Microsoft.Sql.StartStopManagedInstanceSchedules.createOrUpdate", + "azure.mgmt.sql.aio.operations.StartStopManagedInstanceSchedulesOperations.create_or_update": "Microsoft.Sql.StartStopManagedInstanceSchedules.createOrUpdate", + "azure.mgmt.sql.operations.StartStopManagedInstanceSchedulesOperations.delete": "Microsoft.Sql.StartStopManagedInstanceSchedules.delete", + "azure.mgmt.sql.aio.operations.StartStopManagedInstanceSchedulesOperations.delete": "Microsoft.Sql.StartStopManagedInstanceSchedules.delete", + "azure.mgmt.sql.operations.StartStopManagedInstanceSchedulesOperations.list_by_instance": "Microsoft.Sql.StartStopManagedInstanceSchedules.listByInstance", + "azure.mgmt.sql.aio.operations.StartStopManagedInstanceSchedulesOperations.list_by_instance": "Microsoft.Sql.StartStopManagedInstanceSchedules.listByInstance", + "azure.mgmt.sql.operations.SubscriptionUsagesOperations.get": "Microsoft.Sql.SubscriptionUsages.get", + "azure.mgmt.sql.aio.operations.SubscriptionUsagesOperations.get": "Microsoft.Sql.SubscriptionUsages.get", + "azure.mgmt.sql.operations.SubscriptionUsagesOperations.list_by_location": "Microsoft.Sql.SubscriptionUsages.listByLocation", + "azure.mgmt.sql.aio.operations.SubscriptionUsagesOperations.list_by_location": "Microsoft.Sql.SubscriptionUsages.listByLocation", + "azure.mgmt.sql.operations.SyncAgentsOperations.get": "Microsoft.Sql.SyncAgents.get", + "azure.mgmt.sql.aio.operations.SyncAgentsOperations.get": "Microsoft.Sql.SyncAgents.get", + "azure.mgmt.sql.operations.SyncAgentsOperations.begin_create_or_update": "Microsoft.Sql.SyncAgents.createOrUpdate", + "azure.mgmt.sql.aio.operations.SyncAgentsOperations.begin_create_or_update": "Microsoft.Sql.SyncAgents.createOrUpdate", + "azure.mgmt.sql.operations.SyncAgentsOperations.begin_delete": "Microsoft.Sql.SyncAgents.delete", + "azure.mgmt.sql.aio.operations.SyncAgentsOperations.begin_delete": "Microsoft.Sql.SyncAgents.delete", + "azure.mgmt.sql.operations.SyncAgentsOperations.list_by_server": "Microsoft.Sql.SyncAgents.listByServer", + "azure.mgmt.sql.aio.operations.SyncAgentsOperations.list_by_server": "Microsoft.Sql.SyncAgents.listByServer", + "azure.mgmt.sql.operations.SyncAgentsOperations.generate_key": "Microsoft.Sql.SyncAgents.generateKey", + "azure.mgmt.sql.aio.operations.SyncAgentsOperations.generate_key": "Microsoft.Sql.SyncAgents.generateKey", + "azure.mgmt.sql.operations.SyncAgentsOperations.list_linked_databases": "Microsoft.Sql.SyncAgents.listLinkedDatabases", + "azure.mgmt.sql.aio.operations.SyncAgentsOperations.list_linked_databases": "Microsoft.Sql.SyncAgents.listLinkedDatabases", + "azure.mgmt.sql.operations.SyncGroupsOperations.get": "Microsoft.Sql.SyncGroups.get", + "azure.mgmt.sql.aio.operations.SyncGroupsOperations.get": "Microsoft.Sql.SyncGroups.get", + "azure.mgmt.sql.operations.SyncGroupsOperations.begin_create_or_update": "Microsoft.Sql.SyncGroups.createOrUpdate", + "azure.mgmt.sql.aio.operations.SyncGroupsOperations.begin_create_or_update": "Microsoft.Sql.SyncGroups.createOrUpdate", + "azure.mgmt.sql.operations.SyncGroupsOperations.begin_update": "Microsoft.Sql.SyncGroups.update", + "azure.mgmt.sql.aio.operations.SyncGroupsOperations.begin_update": "Microsoft.Sql.SyncGroups.update", + "azure.mgmt.sql.operations.SyncGroupsOperations.begin_delete": "Microsoft.Sql.SyncGroups.delete", + "azure.mgmt.sql.aio.operations.SyncGroupsOperations.begin_delete": "Microsoft.Sql.SyncGroups.delete", + "azure.mgmt.sql.operations.SyncGroupsOperations.list_by_database": "Microsoft.Sql.SyncGroups.listByDatabase", + "azure.mgmt.sql.aio.operations.SyncGroupsOperations.list_by_database": "Microsoft.Sql.SyncGroups.listByDatabase", + "azure.mgmt.sql.operations.SyncGroupsOperations.cancel_sync": "Microsoft.Sql.SyncGroups.cancelSync", + "azure.mgmt.sql.aio.operations.SyncGroupsOperations.cancel_sync": "Microsoft.Sql.SyncGroups.cancelSync", + "azure.mgmt.sql.operations.SyncGroupsOperations.list_hub_schemas": "Microsoft.Sql.SyncGroups.listHubSchemas", + "azure.mgmt.sql.aio.operations.SyncGroupsOperations.list_hub_schemas": "Microsoft.Sql.SyncGroups.listHubSchemas", + "azure.mgmt.sql.operations.SyncGroupsOperations.list_logs": "Microsoft.Sql.SyncGroups.listLogs", + "azure.mgmt.sql.aio.operations.SyncGroupsOperations.list_logs": "Microsoft.Sql.SyncGroups.listLogs", + "azure.mgmt.sql.operations.SyncGroupsOperations.begin_refresh_hub_schema": "Microsoft.Sql.SyncGroups.refreshHubSchema", + "azure.mgmt.sql.aio.operations.SyncGroupsOperations.begin_refresh_hub_schema": "Microsoft.Sql.SyncGroups.refreshHubSchema", + "azure.mgmt.sql.operations.SyncGroupsOperations.trigger_sync": "Microsoft.Sql.SyncGroups.triggerSync", + "azure.mgmt.sql.aio.operations.SyncGroupsOperations.trigger_sync": "Microsoft.Sql.SyncGroups.triggerSync", + "azure.mgmt.sql.operations.SyncGroupsOperations.list_sync_database_ids": "Microsoft.Sql.SyncGroupsOperationGroup.listSyncDatabaseIds", + "azure.mgmt.sql.aio.operations.SyncGroupsOperations.list_sync_database_ids": "Microsoft.Sql.SyncGroupsOperationGroup.listSyncDatabaseIds", + "azure.mgmt.sql.operations.SyncMembersOperations.get": "Microsoft.Sql.SyncMembers.get", + "azure.mgmt.sql.aio.operations.SyncMembersOperations.get": "Microsoft.Sql.SyncMembers.get", + "azure.mgmt.sql.operations.SyncMembersOperations.begin_create_or_update": "Microsoft.Sql.SyncMembers.createOrUpdate", + "azure.mgmt.sql.aio.operations.SyncMembersOperations.begin_create_or_update": "Microsoft.Sql.SyncMembers.createOrUpdate", + "azure.mgmt.sql.operations.SyncMembersOperations.begin_update": "Microsoft.Sql.SyncMembers.update", + "azure.mgmt.sql.aio.operations.SyncMembersOperations.begin_update": "Microsoft.Sql.SyncMembers.update", + "azure.mgmt.sql.operations.SyncMembersOperations.begin_delete": "Microsoft.Sql.SyncMembers.delete", + "azure.mgmt.sql.aio.operations.SyncMembersOperations.begin_delete": "Microsoft.Sql.SyncMembers.delete", + "azure.mgmt.sql.operations.SyncMembersOperations.list_by_sync_group": "Microsoft.Sql.SyncMembers.listBySyncGroup", + "azure.mgmt.sql.aio.operations.SyncMembersOperations.list_by_sync_group": "Microsoft.Sql.SyncMembers.listBySyncGroup", + "azure.mgmt.sql.operations.SyncMembersOperations.begin_refresh_member_schema": "Microsoft.Sql.SyncMembers.refreshMemberSchema", + "azure.mgmt.sql.aio.operations.SyncMembersOperations.begin_refresh_member_schema": "Microsoft.Sql.SyncMembers.refreshMemberSchema", + "azure.mgmt.sql.operations.SyncMembersOperations.list_member_schemas": "Microsoft.Sql.SyncMembers.listMemberSchemas", + "azure.mgmt.sql.aio.operations.SyncMembersOperations.list_member_schemas": "Microsoft.Sql.SyncMembers.listMemberSchemas", + "azure.mgmt.sql.operations.TimeZonesOperations.get": "Microsoft.Sql.TimeZones.get", + "azure.mgmt.sql.aio.operations.TimeZonesOperations.get": "Microsoft.Sql.TimeZones.get", + "azure.mgmt.sql.operations.TimeZonesOperations.list_by_location": "Microsoft.Sql.TimeZones.listByLocation", + "azure.mgmt.sql.aio.operations.TimeZonesOperations.list_by_location": "Microsoft.Sql.TimeZones.listByLocation", + "azure.mgmt.sql.operations.VirtualClustersOperations.get": "Microsoft.Sql.VirtualClusters.get", + "azure.mgmt.sql.aio.operations.VirtualClustersOperations.get": "Microsoft.Sql.VirtualClusters.get", + "azure.mgmt.sql.operations.VirtualClustersOperations.begin_create_or_update": "Microsoft.Sql.VirtualClusters.createOrUpdate", + "azure.mgmt.sql.aio.operations.VirtualClustersOperations.begin_create_or_update": "Microsoft.Sql.VirtualClusters.createOrUpdate", + "azure.mgmt.sql.operations.VirtualClustersOperations.begin_update": "Microsoft.Sql.VirtualClusters.update", + "azure.mgmt.sql.aio.operations.VirtualClustersOperations.begin_update": "Microsoft.Sql.VirtualClusters.update", + "azure.mgmt.sql.operations.VirtualClustersOperations.begin_delete": "Microsoft.Sql.VirtualClusters.delete", + "azure.mgmt.sql.aio.operations.VirtualClustersOperations.begin_delete": "Microsoft.Sql.VirtualClusters.delete", + "azure.mgmt.sql.operations.VirtualClustersOperations.list_by_resource_group": "Microsoft.Sql.VirtualClusters.listByResourceGroup", + "azure.mgmt.sql.aio.operations.VirtualClustersOperations.list_by_resource_group": "Microsoft.Sql.VirtualClusters.listByResourceGroup", + "azure.mgmt.sql.operations.VirtualClustersOperations.list": "Microsoft.Sql.VirtualClusters.list", + "azure.mgmt.sql.aio.operations.VirtualClustersOperations.list": "Microsoft.Sql.VirtualClusters.list", + "azure.mgmt.sql.operations.VirtualClustersOperations.begin_update_dns_servers": "Microsoft.Sql.VirtualClusters.updateDnsServers", + "azure.mgmt.sql.aio.operations.VirtualClustersOperations.begin_update_dns_servers": "Microsoft.Sql.VirtualClusters.updateDnsServers", + "azure.mgmt.sql.operations.VirtualNetworkRulesOperations.get": "Microsoft.Sql.VirtualNetworkRules.get", + "azure.mgmt.sql.aio.operations.VirtualNetworkRulesOperations.get": "Microsoft.Sql.VirtualNetworkRules.get", + "azure.mgmt.sql.operations.VirtualNetworkRulesOperations.begin_create_or_update": "Microsoft.Sql.VirtualNetworkRules.createOrUpdate", + "azure.mgmt.sql.aio.operations.VirtualNetworkRulesOperations.begin_create_or_update": "Microsoft.Sql.VirtualNetworkRules.createOrUpdate", + "azure.mgmt.sql.operations.VirtualNetworkRulesOperations.begin_delete": "Microsoft.Sql.VirtualNetworkRules.delete", + "azure.mgmt.sql.aio.operations.VirtualNetworkRulesOperations.begin_delete": "Microsoft.Sql.VirtualNetworkRules.delete", + "azure.mgmt.sql.operations.VirtualNetworkRulesOperations.list_by_server": "Microsoft.Sql.VirtualNetworkRules.listByServer", + "azure.mgmt.sql.aio.operations.VirtualNetworkRulesOperations.list_by_server": "Microsoft.Sql.VirtualNetworkRules.listByServer", + "azure.mgmt.sql.operations.WorkloadClassifiersOperations.get": "Microsoft.Sql.WorkloadClassifiers.get", + "azure.mgmt.sql.aio.operations.WorkloadClassifiersOperations.get": "Microsoft.Sql.WorkloadClassifiers.get", + "azure.mgmt.sql.operations.WorkloadClassifiersOperations.begin_create_or_update": "Microsoft.Sql.WorkloadClassifiers.createOrUpdate", + "azure.mgmt.sql.aio.operations.WorkloadClassifiersOperations.begin_create_or_update": "Microsoft.Sql.WorkloadClassifiers.createOrUpdate", + "azure.mgmt.sql.operations.WorkloadClassifiersOperations.begin_delete": "Microsoft.Sql.WorkloadClassifiers.delete", + "azure.mgmt.sql.aio.operations.WorkloadClassifiersOperations.begin_delete": "Microsoft.Sql.WorkloadClassifiers.delete", + "azure.mgmt.sql.operations.WorkloadClassifiersOperations.list_by_workload_group": "Microsoft.Sql.WorkloadClassifiers.listByWorkloadGroup", + "azure.mgmt.sql.aio.operations.WorkloadClassifiersOperations.list_by_workload_group": "Microsoft.Sql.WorkloadClassifiers.listByWorkloadGroup", + "azure.mgmt.sql.operations.WorkloadGroupsOperations.get": "Microsoft.Sql.WorkloadGroups.get", + "azure.mgmt.sql.aio.operations.WorkloadGroupsOperations.get": "Microsoft.Sql.WorkloadGroups.get", + "azure.mgmt.sql.operations.WorkloadGroupsOperations.begin_create_or_update": "Microsoft.Sql.WorkloadGroups.createOrUpdate", + "azure.mgmt.sql.aio.operations.WorkloadGroupsOperations.begin_create_or_update": "Microsoft.Sql.WorkloadGroups.createOrUpdate", + "azure.mgmt.sql.operations.WorkloadGroupsOperations.begin_delete": "Microsoft.Sql.WorkloadGroups.delete", + "azure.mgmt.sql.aio.operations.WorkloadGroupsOperations.begin_delete": "Microsoft.Sql.WorkloadGroups.delete", + "azure.mgmt.sql.operations.WorkloadGroupsOperations.list_by_database": "Microsoft.Sql.WorkloadGroups.listByDatabase", + "azure.mgmt.sql.aio.operations.WorkloadGroupsOperations.list_by_database": "Microsoft.Sql.WorkloadGroups.listByDatabase", + "azure.mgmt.sql.operations.ManagedDatabaseSensitivityLabelsOperations.get": "Microsoft.Sql.SensitivityLabels.get", + "azure.mgmt.sql.aio.operations.ManagedDatabaseSensitivityLabelsOperations.get": "Microsoft.Sql.SensitivityLabels.get", + "azure.mgmt.sql.operations.ManagedDatabaseSensitivityLabelsOperations.create_or_update": "Microsoft.Sql.SensitivityLabels.createOrUpdate", + "azure.mgmt.sql.aio.operations.ManagedDatabaseSensitivityLabelsOperations.create_or_update": "Microsoft.Sql.SensitivityLabels.createOrUpdate", + "azure.mgmt.sql.operations.ManagedDatabaseSensitivityLabelsOperations.delete": "Microsoft.Sql.SensitivityLabels.delete", + "azure.mgmt.sql.aio.operations.ManagedDatabaseSensitivityLabelsOperations.delete": "Microsoft.Sql.SensitivityLabels.delete", + "azure.mgmt.sql.operations.ManagedDatabaseSensitivityLabelsOperations.disable_recommendation": "Microsoft.Sql.SensitivityLabels.disableRecommendation", + "azure.mgmt.sql.aio.operations.ManagedDatabaseSensitivityLabelsOperations.disable_recommendation": "Microsoft.Sql.SensitivityLabels.disableRecommendation", + "azure.mgmt.sql.operations.ManagedDatabaseSensitivityLabelsOperations.enable_recommendation": "Microsoft.Sql.SensitivityLabels.enableRecommendation", + "azure.mgmt.sql.aio.operations.ManagedDatabaseSensitivityLabelsOperations.enable_recommendation": "Microsoft.Sql.SensitivityLabels.enableRecommendation", + "azure.mgmt.sql.operations.ManagedDatabaseSensitivityLabelsOperations.list_current_by_database": "Microsoft.Sql.ManagedDatabases.listCurrentByDatabase", + "azure.mgmt.sql.aio.operations.ManagedDatabaseSensitivityLabelsOperations.list_current_by_database": "Microsoft.Sql.ManagedDatabases.listCurrentByDatabase", + "azure.mgmt.sql.operations.ManagedDatabaseSensitivityLabelsOperations.update": "Microsoft.Sql.ManagedDatabases.managedDatabaseSensitivityLabelsUpdate", + "azure.mgmt.sql.aio.operations.ManagedDatabaseSensitivityLabelsOperations.update": "Microsoft.Sql.ManagedDatabases.managedDatabaseSensitivityLabelsUpdate", + "azure.mgmt.sql.operations.ManagedDatabaseSensitivityLabelsOperations.list_recommended_by_database": "Microsoft.Sql.ManagedDatabases.listRecommendedByDatabase", + "azure.mgmt.sql.aio.operations.ManagedDatabaseSensitivityLabelsOperations.list_recommended_by_database": "Microsoft.Sql.ManagedDatabases.listRecommendedByDatabase", + "azure.mgmt.sql.operations.ManagedDatabaseSensitivityLabelsOperations.list_by_database": "Microsoft.Sql.ManagedDatabases.managedDatabaseSensitivityLabelsListByDatabase", + "azure.mgmt.sql.aio.operations.ManagedDatabaseSensitivityLabelsOperations.list_by_database": "Microsoft.Sql.ManagedDatabases.managedDatabaseSensitivityLabelsListByDatabase", + "azure.mgmt.sql.operations.DatabaseEncryptionProtectorsOperations.begin_revalidate": "Microsoft.Sql.Databases.revalidate", + "azure.mgmt.sql.aio.operations.DatabaseEncryptionProtectorsOperations.begin_revalidate": "Microsoft.Sql.Databases.revalidate", + "azure.mgmt.sql.operations.DatabaseEncryptionProtectorsOperations.begin_revert": "Microsoft.Sql.Databases.revert", + "azure.mgmt.sql.aio.operations.DatabaseEncryptionProtectorsOperations.begin_revert": "Microsoft.Sql.Databases.revert", + "azure.mgmt.sql.operations.DatabaseOperationsOperations.list_by_database": "Microsoft.Sql.Databases.databaseOperationsListByDatabase", + "azure.mgmt.sql.aio.operations.DatabaseOperationsOperations.list_by_database": "Microsoft.Sql.Databases.databaseOperationsListByDatabase", + "azure.mgmt.sql.operations.DatabaseOperationsOperations.cancel": "Microsoft.Sql.Databases.cancel", + "azure.mgmt.sql.aio.operations.DatabaseOperationsOperations.cancel": "Microsoft.Sql.Databases.cancel", + "azure.mgmt.sql.operations.DatabaseUsagesOperations.list_by_database": "Microsoft.Sql.Databases.databaseUsagesListByDatabase", + "azure.mgmt.sql.aio.operations.DatabaseUsagesOperations.list_by_database": "Microsoft.Sql.Databases.databaseUsagesListByDatabase", + "azure.mgmt.sql.operations.RecommendedSensitivityLabelsOperations.update": "Microsoft.Sql.Databases.recommendedSensitivityLabelsUpdate", + "azure.mgmt.sql.aio.operations.RecommendedSensitivityLabelsOperations.update": "Microsoft.Sql.Databases.recommendedSensitivityLabelsUpdate", + "azure.mgmt.sql.operations.SynapseLinkWorkspacesOperations.list_by_database": "Microsoft.Sql.Databases.synapseLinkWorkspacesListByDatabase", + "azure.mgmt.sql.aio.operations.SynapseLinkWorkspacesOperations.list_by_database": "Microsoft.Sql.Databases.synapseLinkWorkspacesListByDatabase", + "azure.mgmt.sql.operations.ServerOperationsOperations.list_by_server": "Microsoft.Sql.Servers.serverOperationsListByServer", + "azure.mgmt.sql.aio.operations.ServerOperationsOperations.list_by_server": "Microsoft.Sql.Servers.serverOperationsListByServer", + "azure.mgmt.sql.operations.ServerUsagesOperations.list_by_server": "Microsoft.Sql.Servers.serverUsagesListByServer", + "azure.mgmt.sql.aio.operations.ServerUsagesOperations.list_by_server": "Microsoft.Sql.Servers.serverUsagesListByServer", + "azure.mgmt.sql.operations.TdeCertificatesOperations.begin_create": "Microsoft.Sql.Servers.create", + "azure.mgmt.sql.aio.operations.TdeCertificatesOperations.begin_create": "Microsoft.Sql.Servers.create", + "azure.mgmt.sql.operations.DatabaseAdvancedThreatProtectionSettingsOperations.get": "Microsoft.Sql.DatabaseAdvancedThreatProtections.get", + "azure.mgmt.sql.aio.operations.DatabaseAdvancedThreatProtectionSettingsOperations.get": "Microsoft.Sql.DatabaseAdvancedThreatProtections.get", + "azure.mgmt.sql.operations.DatabaseAdvancedThreatProtectionSettingsOperations.create_or_update": "Microsoft.Sql.DatabaseAdvancedThreatProtections.createOrUpdate", + "azure.mgmt.sql.aio.operations.DatabaseAdvancedThreatProtectionSettingsOperations.create_or_update": "Microsoft.Sql.DatabaseAdvancedThreatProtections.createOrUpdate", + "azure.mgmt.sql.operations.DatabaseAdvancedThreatProtectionSettingsOperations.list_by_database": "Microsoft.Sql.DatabaseAdvancedThreatProtections.listByDatabase", + "azure.mgmt.sql.aio.operations.DatabaseAdvancedThreatProtectionSettingsOperations.list_by_database": "Microsoft.Sql.DatabaseAdvancedThreatProtections.listByDatabase", + "azure.mgmt.sql.operations.DatabaseAdvisorsOperations.get": "Microsoft.Sql.Advisors.get", + "azure.mgmt.sql.aio.operations.DatabaseAdvisorsOperations.get": "Microsoft.Sql.Advisors.get", + "azure.mgmt.sql.operations.DatabaseAdvisorsOperations.update": "Microsoft.Sql.Advisors.update", + "azure.mgmt.sql.aio.operations.DatabaseAdvisorsOperations.update": "Microsoft.Sql.Advisors.update", + "azure.mgmt.sql.operations.DatabaseAdvisorsOperations.list_by_database": "Microsoft.Sql.Advisors.listByDatabase", + "azure.mgmt.sql.aio.operations.DatabaseAdvisorsOperations.list_by_database": "Microsoft.Sql.Advisors.listByDatabase", + "azure.mgmt.sql.operations.DatabaseAutomaticTuningOperations.get": "Microsoft.Sql.DatabaseAutomaticTunings.get", + "azure.mgmt.sql.aio.operations.DatabaseAutomaticTuningOperations.get": "Microsoft.Sql.DatabaseAutomaticTunings.get", + "azure.mgmt.sql.operations.DatabaseAutomaticTuningOperations.update": "Microsoft.Sql.DatabaseAutomaticTunings.update", + "azure.mgmt.sql.aio.operations.DatabaseAutomaticTuningOperations.update": "Microsoft.Sql.DatabaseAutomaticTunings.update", + "azure.mgmt.sql.operations.DatabaseExtensionsOperations.get": "Microsoft.Sql.ImportExportExtensionsOperationResults.get", + "azure.mgmt.sql.aio.operations.DatabaseExtensionsOperations.get": "Microsoft.Sql.ImportExportExtensionsOperationResults.get", + "azure.mgmt.sql.operations.DatabaseExtensionsOperations.begin_create_or_update": "Microsoft.Sql.ImportExportExtensionsOperationResults.createOrUpdate", + "azure.mgmt.sql.aio.operations.DatabaseExtensionsOperations.begin_create_or_update": "Microsoft.Sql.ImportExportExtensionsOperationResults.createOrUpdate", + "azure.mgmt.sql.operations.DatabaseExtensionsOperations.list_by_database": "Microsoft.Sql.ImportExportExtensionsOperationResults.listByDatabase", + "azure.mgmt.sql.aio.operations.DatabaseExtensionsOperations.list_by_database": "Microsoft.Sql.ImportExportExtensionsOperationResults.listByDatabase", + "azure.mgmt.sql.operations.DatabaseRecommendedActionsOperations.get": "Microsoft.Sql.RecommendedActions.get", + "azure.mgmt.sql.aio.operations.DatabaseRecommendedActionsOperations.get": "Microsoft.Sql.RecommendedActions.get", + "azure.mgmt.sql.operations.DatabaseRecommendedActionsOperations.update": "Microsoft.Sql.RecommendedActions.update", + "azure.mgmt.sql.aio.operations.DatabaseRecommendedActionsOperations.update": "Microsoft.Sql.RecommendedActions.update", + "azure.mgmt.sql.operations.DatabaseRecommendedActionsOperations.list_by_database_advisor": "Microsoft.Sql.RecommendedActions.listByDatabaseAdvisor", + "azure.mgmt.sql.aio.operations.DatabaseRecommendedActionsOperations.list_by_database_advisor": "Microsoft.Sql.RecommendedActions.listByDatabaseAdvisor", + "azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentBaselinesOperations.get": "Microsoft.Sql.DatabaseSqlVulnerabilityAssessmentBaselineSets.get", + "azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentBaselinesOperations.get": "Microsoft.Sql.DatabaseSqlVulnerabilityAssessmentBaselineSets.get", + "azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentBaselinesOperations.create_or_update": "Microsoft.Sql.DatabaseSqlVulnerabilityAssessmentBaselineSets.createOrUpdate", + "azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentBaselinesOperations.create_or_update": "Microsoft.Sql.DatabaseSqlVulnerabilityAssessmentBaselineSets.createOrUpdate", + "azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentBaselinesOperations.list_by_sql_vulnerability_assessment": "Microsoft.Sql.DatabaseSqlVulnerabilityAssessmentBaselineSets.listBySqlVulnerabilityAssessment", + "azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentBaselinesOperations.list_by_sql_vulnerability_assessment": "Microsoft.Sql.DatabaseSqlVulnerabilityAssessmentBaselineSets.listBySqlVulnerabilityAssessment", + "azure.mgmt.sql.operations.SqlVulnerabilityAssessmentBaselinesOperations.create_or_update": "Microsoft.Sql.SqlVulnerabilityAssessmentBaseline.createOrUpdate", + "azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentBaselinesOperations.create_or_update": "Microsoft.Sql.SqlVulnerabilityAssessmentBaseline.createOrUpdate", + "azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentsSettingsOperations.get": "Microsoft.Sql.SqlVulnerabilityAssessments.get", + "azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentsSettingsOperations.get": "Microsoft.Sql.SqlVulnerabilityAssessments.get", + "azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentsSettingsOperations.list_by_database": "Microsoft.Sql.SqlVulnerabilityAssessments.listByDatabase", + "azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentsSettingsOperations.list_by_database": "Microsoft.Sql.SqlVulnerabilityAssessments.listByDatabase", + "azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentExecuteScanOperations.begin_execute": "Microsoft.Sql.SqlVulnerabilityAssessments.execute", + "azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentExecuteScanOperations.begin_execute": "Microsoft.Sql.SqlVulnerabilityAssessments.execute", + "azure.mgmt.sql.operations.SqlVulnerabilityAssessmentExecuteScanOperations.begin_execute": "Microsoft.Sql.SqlVulnerabilityAssessmentsSettings.execute", + "azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentExecuteScanOperations.begin_execute": "Microsoft.Sql.SqlVulnerabilityAssessmentsSettings.execute", + "azure.mgmt.sql.operations.SqlVulnerabilityAssessmentRuleBaselinesOperations.delete": "Microsoft.Sql.SqlVulnerabilityAssessmentRuleBaseline.delete", + "azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentRuleBaselinesOperations.delete": "Microsoft.Sql.SqlVulnerabilityAssessmentRuleBaseline.delete", + "azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentScansOperations.get": "Microsoft.Sql.SqlVulnerabilityAssessmentScanRecords.get", + "azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentScansOperations.get": "Microsoft.Sql.SqlVulnerabilityAssessmentScanRecords.get", + "azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentScansOperations.list_by_sql_vulnerability_assessments": "Microsoft.Sql.SqlVulnerabilityAssessmentScanRecords.listBySqlVulnerabilityAssessments", + "azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentScansOperations.list_by_sql_vulnerability_assessments": "Microsoft.Sql.SqlVulnerabilityAssessmentScanRecords.listBySqlVulnerabilityAssessments", + "azure.mgmt.sql.operations.DatabaseVulnerabilityAssessmentScansOperations.get": "Microsoft.Sql.VulnerabilityAssessmentScanRecords.get", + "azure.mgmt.sql.aio.operations.DatabaseVulnerabilityAssessmentScansOperations.get": "Microsoft.Sql.VulnerabilityAssessmentScanRecords.get", + "azure.mgmt.sql.operations.DatabaseVulnerabilityAssessmentScansOperations.list_by_database": "Microsoft.Sql.VulnerabilityAssessmentScanRecords.listByDatabase", + "azure.mgmt.sql.aio.operations.DatabaseVulnerabilityAssessmentScansOperations.list_by_database": "Microsoft.Sql.VulnerabilityAssessmentScanRecords.listByDatabase", + "azure.mgmt.sql.operations.DatabaseVulnerabilityAssessmentScansOperations.export": "Microsoft.Sql.VulnerabilityAssessmentScanRecords.export", + "azure.mgmt.sql.aio.operations.DatabaseVulnerabilityAssessmentScansOperations.export": "Microsoft.Sql.VulnerabilityAssessmentScanRecords.export", + "azure.mgmt.sql.operations.DatabaseVulnerabilityAssessmentScansOperations.begin_initiate_scan": "Microsoft.Sql.VulnerabilityAssessmentScanRecords.initiateScan", + "azure.mgmt.sql.aio.operations.DatabaseVulnerabilityAssessmentScansOperations.begin_initiate_scan": "Microsoft.Sql.VulnerabilityAssessmentScanRecords.initiateScan", + "azure.mgmt.sql.operations.DataMaskingRulesOperations.list_by_database": "Microsoft.Sql.DataMaskingPolicies.listByDatabase", + "azure.mgmt.sql.aio.operations.DataMaskingRulesOperations.list_by_database": "Microsoft.Sql.DataMaskingPolicies.listByDatabase", + "azure.mgmt.sql.operations.DataMaskingRulesOperations.create_or_update": "Microsoft.Sql.DataMaskingPolicies.dataMaskingRulesCreateOrUpdate", + "azure.mgmt.sql.aio.operations.DataMaskingRulesOperations.create_or_update": "Microsoft.Sql.DataMaskingPolicies.dataMaskingRulesCreateOrUpdate", + "azure.mgmt.sql.operations.DataWarehouseUserActivitiesOperations.get": "Microsoft.Sql.DataWarehouseUserActivitiesOperationGroup.get", + "azure.mgmt.sql.aio.operations.DataWarehouseUserActivitiesOperations.get": "Microsoft.Sql.DataWarehouseUserActivitiesOperationGroup.get", + "azure.mgmt.sql.operations.DataWarehouseUserActivitiesOperations.list_by_database": "Microsoft.Sql.DataWarehouseUserActivitiesOperationGroup.listByDatabase", + "azure.mgmt.sql.aio.operations.DataWarehouseUserActivitiesOperations.list_by_database": "Microsoft.Sql.DataWarehouseUserActivitiesOperationGroup.listByDatabase", + "azure.mgmt.sql.operations.ManagedDatabaseSecurityEventsOperations.list_by_database": "Microsoft.Sql.ManagedDatabases.managedDatabaseSecurityEventsListByDatabase", + "azure.mgmt.sql.aio.operations.ManagedDatabaseSecurityEventsOperations.list_by_database": "Microsoft.Sql.ManagedDatabases.managedDatabaseSecurityEventsListByDatabase", + "azure.mgmt.sql.operations.ManagedDatabaseRecommendedSensitivityLabelsOperations.update": "Microsoft.Sql.ManagedDatabases.managedDatabaseRecommendedSensitivityLabelsUpdate", + "azure.mgmt.sql.aio.operations.ManagedDatabaseRecommendedSensitivityLabelsOperations.update": "Microsoft.Sql.ManagedDatabases.managedDatabaseRecommendedSensitivityLabelsUpdate", + "azure.mgmt.sql.operations.ManagedInstanceTdeCertificatesOperations.begin_create": "Microsoft.Sql.ManagedInstances.create", + "azure.mgmt.sql.aio.operations.ManagedInstanceTdeCertificatesOperations.begin_create": "Microsoft.Sql.ManagedInstances.create", + "azure.mgmt.sql.operations.ElasticPoolOperationsOperations.list_by_elastic_pool": "Microsoft.Sql.ElasticPools.elasticPoolOperationsListByElasticPool", + "azure.mgmt.sql.aio.operations.ElasticPoolOperationsOperations.list_by_elastic_pool": "Microsoft.Sql.ElasticPools.elasticPoolOperationsListByElasticPool", + "azure.mgmt.sql.operations.ElasticPoolOperationsOperations.cancel": "Microsoft.Sql.ElasticPools.cancel", + "azure.mgmt.sql.aio.operations.ElasticPoolOperationsOperations.cancel": "Microsoft.Sql.ElasticPools.cancel", + "azure.mgmt.sql.operations.UsagesOperations.list_by_instance_pool": "Microsoft.Sql.InstancePools.usagesListByInstancePool", + "azure.mgmt.sql.aio.operations.UsagesOperations.list_by_instance_pool": "Microsoft.Sql.InstancePools.usagesListByInstancePool", + "azure.mgmt.sql.operations.LedgerDigestUploadsOperations.get": "Microsoft.Sql.LedgerDigestUploadsOperationGroup.get", + "azure.mgmt.sql.aio.operations.LedgerDigestUploadsOperations.get": "Microsoft.Sql.LedgerDigestUploadsOperationGroup.get", + "azure.mgmt.sql.operations.LedgerDigestUploadsOperations.begin_create_or_update": "Microsoft.Sql.LedgerDigestUploadsOperationGroup.createOrUpdate", + "azure.mgmt.sql.aio.operations.LedgerDigestUploadsOperations.begin_create_or_update": "Microsoft.Sql.LedgerDigestUploadsOperationGroup.createOrUpdate", + "azure.mgmt.sql.operations.LedgerDigestUploadsOperations.list_by_database": "Microsoft.Sql.LedgerDigestUploadsOperationGroup.listByDatabase", + "azure.mgmt.sql.aio.operations.LedgerDigestUploadsOperations.list_by_database": "Microsoft.Sql.LedgerDigestUploadsOperationGroup.listByDatabase", + "azure.mgmt.sql.operations.LedgerDigestUploadsOperations.begin_disable": "Microsoft.Sql.LedgerDigestUploadsOperationGroup.disable", + "azure.mgmt.sql.aio.operations.LedgerDigestUploadsOperations.begin_disable": "Microsoft.Sql.LedgerDigestUploadsOperationGroup.disable", + "azure.mgmt.sql.operations.MaintenanceWindowOptionsOperations.get": "Microsoft.Sql.MaintenanceWindowOptionsOperationGroup.get", + "azure.mgmt.sql.aio.operations.MaintenanceWindowOptionsOperations.get": "Microsoft.Sql.MaintenanceWindowOptionsOperationGroup.get", + "azure.mgmt.sql.operations.MaintenanceWindowsOperations.get": "Microsoft.Sql.MaintenanceWindowsOperationGroup.get", + "azure.mgmt.sql.aio.operations.MaintenanceWindowsOperations.get": "Microsoft.Sql.MaintenanceWindowsOperationGroup.get", + "azure.mgmt.sql.operations.MaintenanceWindowsOperations.create_or_update": "Microsoft.Sql.MaintenanceWindowsOperationGroup.createOrUpdate", + "azure.mgmt.sql.aio.operations.MaintenanceWindowsOperations.create_or_update": "Microsoft.Sql.MaintenanceWindowsOperationGroup.createOrUpdate", + "azure.mgmt.sql.operations.ManagedDatabaseAdvancedThreatProtectionSettingsOperations.get": "Microsoft.Sql.ManagedDatabaseAdvancedThreatProtections.get", + "azure.mgmt.sql.aio.operations.ManagedDatabaseAdvancedThreatProtectionSettingsOperations.get": "Microsoft.Sql.ManagedDatabaseAdvancedThreatProtections.get", + "azure.mgmt.sql.operations.ManagedDatabaseAdvancedThreatProtectionSettingsOperations.create_or_update": "Microsoft.Sql.ManagedDatabaseAdvancedThreatProtections.createOrUpdate", + "azure.mgmt.sql.aio.operations.ManagedDatabaseAdvancedThreatProtectionSettingsOperations.create_or_update": "Microsoft.Sql.ManagedDatabaseAdvancedThreatProtections.createOrUpdate", + "azure.mgmt.sql.operations.ManagedDatabaseAdvancedThreatProtectionSettingsOperations.list_by_database": "Microsoft.Sql.ManagedDatabaseAdvancedThreatProtections.listByDatabase", + "azure.mgmt.sql.aio.operations.ManagedDatabaseAdvancedThreatProtectionSettingsOperations.list_by_database": "Microsoft.Sql.ManagedDatabaseAdvancedThreatProtections.listByDatabase", + "azure.mgmt.sql.operations.ManagedDatabaseMoveOperationsOperations.get": "Microsoft.Sql.ManagedDatabaseMoveOperationResults.get", + "azure.mgmt.sql.aio.operations.ManagedDatabaseMoveOperationsOperations.get": "Microsoft.Sql.ManagedDatabaseMoveOperationResults.get", + "azure.mgmt.sql.operations.ManagedDatabaseMoveOperationsOperations.list_by_location": "Microsoft.Sql.ManagedDatabaseMoveOperationResults.listByLocation", + "azure.mgmt.sql.aio.operations.ManagedDatabaseMoveOperationsOperations.list_by_location": "Microsoft.Sql.ManagedDatabaseMoveOperationResults.listByLocation", + "azure.mgmt.sql.operations.ManagedDatabaseQueriesOperations.get": "Microsoft.Sql.ManagedInstanceQueries.get", + "azure.mgmt.sql.aio.operations.ManagedDatabaseQueriesOperations.get": "Microsoft.Sql.ManagedInstanceQueries.get", + "azure.mgmt.sql.operations.ManagedDatabaseQueriesOperations.list_by_query": "Microsoft.Sql.ManagedInstanceQueries.listByQuery", + "azure.mgmt.sql.aio.operations.ManagedDatabaseQueriesOperations.list_by_query": "Microsoft.Sql.ManagedInstanceQueries.listByQuery", + "azure.mgmt.sql.operations.ManagedDatabaseRestoreDetailsOperations.get": "Microsoft.Sql.ManagedDatabaseRestoreDetailsResults.get", + "azure.mgmt.sql.aio.operations.ManagedDatabaseRestoreDetailsOperations.get": "Microsoft.Sql.ManagedDatabaseRestoreDetailsResults.get", + "azure.mgmt.sql.operations.ManagedDatabaseTransparentDataEncryptionOperations.get": "Microsoft.Sql.ManagedTransparentDataEncryptions.get", + "azure.mgmt.sql.aio.operations.ManagedDatabaseTransparentDataEncryptionOperations.get": "Microsoft.Sql.ManagedTransparentDataEncryptions.get", + "azure.mgmt.sql.operations.ManagedDatabaseTransparentDataEncryptionOperations.create_or_update": "Microsoft.Sql.ManagedTransparentDataEncryptions.createOrUpdate", + "azure.mgmt.sql.aio.operations.ManagedDatabaseTransparentDataEncryptionOperations.create_or_update": "Microsoft.Sql.ManagedTransparentDataEncryptions.createOrUpdate", + "azure.mgmt.sql.operations.ManagedDatabaseTransparentDataEncryptionOperations.list_by_database": "Microsoft.Sql.ManagedTransparentDataEncryptions.listByDatabase", + "azure.mgmt.sql.aio.operations.ManagedDatabaseTransparentDataEncryptionOperations.list_by_database": "Microsoft.Sql.ManagedTransparentDataEncryptions.listByDatabase", + "azure.mgmt.sql.operations.ManagedInstanceAdvancedThreatProtectionSettingsOperations.get": "Microsoft.Sql.ManagedInstanceAdvancedThreatProtections.get", + "azure.mgmt.sql.aio.operations.ManagedInstanceAdvancedThreatProtectionSettingsOperations.get": "Microsoft.Sql.ManagedInstanceAdvancedThreatProtections.get", + "azure.mgmt.sql.operations.ManagedInstanceAdvancedThreatProtectionSettingsOperations.begin_create_or_update": "Microsoft.Sql.ManagedInstanceAdvancedThreatProtections.createOrUpdate", + "azure.mgmt.sql.aio.operations.ManagedInstanceAdvancedThreatProtectionSettingsOperations.begin_create_or_update": "Microsoft.Sql.ManagedInstanceAdvancedThreatProtections.createOrUpdate", + "azure.mgmt.sql.operations.ManagedInstanceAdvancedThreatProtectionSettingsOperations.list_by_instance": "Microsoft.Sql.ManagedInstanceAdvancedThreatProtections.listByInstance", + "azure.mgmt.sql.aio.operations.ManagedInstanceAdvancedThreatProtectionSettingsOperations.list_by_instance": "Microsoft.Sql.ManagedInstanceAdvancedThreatProtections.listByInstance", + "azure.mgmt.sql.operations.ManagedInstancePrivateLinkResourcesOperations.get": "Microsoft.Sql.ManagedInstancePrivateLinks.get", + "azure.mgmt.sql.aio.operations.ManagedInstancePrivateLinkResourcesOperations.get": "Microsoft.Sql.ManagedInstancePrivateLinks.get", + "azure.mgmt.sql.operations.ManagedInstancePrivateLinkResourcesOperations.list_by_managed_instance": "Microsoft.Sql.ManagedInstancePrivateLinks.listByManagedInstance", + "azure.mgmt.sql.aio.operations.ManagedInstancePrivateLinkResourcesOperations.list_by_managed_instance": "Microsoft.Sql.ManagedInstancePrivateLinks.listByManagedInstance", + "azure.mgmt.sql.operations.ManagedLedgerDigestUploadsOperations.get": "Microsoft.Sql.ManagedLedgerDigestUploadsOperationGroup.get", + "azure.mgmt.sql.aio.operations.ManagedLedgerDigestUploadsOperations.get": "Microsoft.Sql.ManagedLedgerDigestUploadsOperationGroup.get", + "azure.mgmt.sql.operations.ManagedLedgerDigestUploadsOperations.begin_create_or_update": "Microsoft.Sql.ManagedLedgerDigestUploadsOperationGroup.createOrUpdate", + "azure.mgmt.sql.aio.operations.ManagedLedgerDigestUploadsOperations.begin_create_or_update": "Microsoft.Sql.ManagedLedgerDigestUploadsOperationGroup.createOrUpdate", + "azure.mgmt.sql.operations.ManagedLedgerDigestUploadsOperations.list_by_database": "Microsoft.Sql.ManagedLedgerDigestUploadsOperationGroup.listByDatabase", + "azure.mgmt.sql.aio.operations.ManagedLedgerDigestUploadsOperations.list_by_database": "Microsoft.Sql.ManagedLedgerDigestUploadsOperationGroup.listByDatabase", + "azure.mgmt.sql.operations.ManagedLedgerDigestUploadsOperations.begin_disable": "Microsoft.Sql.ManagedLedgerDigestUploadsOperationGroup.disable", + "azure.mgmt.sql.aio.operations.ManagedLedgerDigestUploadsOperations.begin_disable": "Microsoft.Sql.ManagedLedgerDigestUploadsOperationGroup.disable", + "azure.mgmt.sql.operations.ServerAdvancedThreatProtectionSettingsOperations.get": "Microsoft.Sql.ServerAdvancedThreatProtections.get", + "azure.mgmt.sql.aio.operations.ServerAdvancedThreatProtectionSettingsOperations.get": "Microsoft.Sql.ServerAdvancedThreatProtections.get", + "azure.mgmt.sql.operations.ServerAdvancedThreatProtectionSettingsOperations.begin_create_or_update": "Microsoft.Sql.ServerAdvancedThreatProtections.createOrUpdate", + "azure.mgmt.sql.aio.operations.ServerAdvancedThreatProtectionSettingsOperations.begin_create_or_update": "Microsoft.Sql.ServerAdvancedThreatProtections.createOrUpdate", + "azure.mgmt.sql.operations.ServerAdvancedThreatProtectionSettingsOperations.list_by_server": "Microsoft.Sql.ServerAdvancedThreatProtections.listByServer", + "azure.mgmt.sql.aio.operations.ServerAdvancedThreatProtectionSettingsOperations.list_by_server": "Microsoft.Sql.ServerAdvancedThreatProtections.listByServer", + "azure.mgmt.sql.operations.ServerAutomaticTuningOperations.get": "Microsoft.Sql.ServerAutomaticTunings.get", + "azure.mgmt.sql.aio.operations.ServerAutomaticTuningOperations.get": "Microsoft.Sql.ServerAutomaticTunings.get", + "azure.mgmt.sql.operations.ServerAutomaticTuningOperations.update": "Microsoft.Sql.ServerAutomaticTunings.update", + "azure.mgmt.sql.aio.operations.ServerAutomaticTuningOperations.update": "Microsoft.Sql.ServerAutomaticTunings.update", + "azure.mgmt.sql.operations.SqlAgentOperations.get": "Microsoft.Sql.SqlAgentConfigurations.get", + "azure.mgmt.sql.aio.operations.SqlAgentOperations.get": "Microsoft.Sql.SqlAgentConfigurations.get", + "azure.mgmt.sql.operations.SqlAgentOperations.create_or_update": "Microsoft.Sql.SqlAgentConfigurations.createOrUpdate", + "azure.mgmt.sql.aio.operations.SqlAgentOperations.create_or_update": "Microsoft.Sql.SqlAgentConfigurations.createOrUpdate", + "azure.mgmt.sql.operations.TransparentDataEncryptionsOperations.get": "Microsoft.Sql.LogicalDatabaseTransparentDataEncryptions.get", + "azure.mgmt.sql.aio.operations.TransparentDataEncryptionsOperations.get": "Microsoft.Sql.LogicalDatabaseTransparentDataEncryptions.get", + "azure.mgmt.sql.operations.TransparentDataEncryptionsOperations.begin_create_or_update": "Microsoft.Sql.LogicalDatabaseTransparentDataEncryptions.createOrUpdate", + "azure.mgmt.sql.aio.operations.TransparentDataEncryptionsOperations.begin_create_or_update": "Microsoft.Sql.LogicalDatabaseTransparentDataEncryptions.createOrUpdate", + "azure.mgmt.sql.operations.TransparentDataEncryptionsOperations.list_by_database": "Microsoft.Sql.LogicalDatabaseTransparentDataEncryptions.listByDatabase", + "azure.mgmt.sql.aio.operations.TransparentDataEncryptionsOperations.list_by_database": "Microsoft.Sql.LogicalDatabaseTransparentDataEncryptions.listByDatabase", + "azure.mgmt.sql.operations.TransparentDataEncryptionsOperations.begin_resume": "Microsoft.Sql.LogicalDatabaseTransparentDataEncryptions.resume", + "azure.mgmt.sql.aio.operations.TransparentDataEncryptionsOperations.begin_resume": "Microsoft.Sql.LogicalDatabaseTransparentDataEncryptions.resume", + "azure.mgmt.sql.operations.TransparentDataEncryptionsOperations.begin_suspend": "Microsoft.Sql.LogicalDatabaseTransparentDataEncryptions.suspend", + "azure.mgmt.sql.aio.operations.TransparentDataEncryptionsOperations.begin_suspend": "Microsoft.Sql.LogicalDatabaseTransparentDataEncryptions.suspend", + "azure.mgmt.sql.operations.CapabilitiesOperations.list_by_location": "Microsoft.Sql.CapabilitiesOperationGroup.listByLocation", + "azure.mgmt.sql.aio.operations.CapabilitiesOperations.list_by_location": "Microsoft.Sql.CapabilitiesOperationGroup.listByLocation" } } \ No newline at end of file diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/__init__.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/__init__.py index 15b918d384b2..d32b805df448 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/__init__.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/__init__.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -12,7 +12,7 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._sql_management_client import SqlManagementClient # type: ignore +from ._client import SqlManagementClient # type: ignore from ._version import VERSION __version__ = VERSION diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_sql_management_client.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_client.py similarity index 96% rename from sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_sql_management_client.py rename to sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_client.py index 289890219482..2686c5b68499 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_sql_management_client.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_client.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -18,7 +18,6 @@ from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from azure.mgmt.core.tools import get_arm_endpoints -from . import models as _models from ._configuration import SqlManagementClientConfiguration from ._utils.serialization import Deserializer, Serializer from .operations import ( @@ -52,8 +51,6 @@ DatabasesOperations, DeletedServersOperations, DistributedAvailabilityGroupsOperations, - ElasticPoolActivitiesOperations, - ElasticPoolDatabaseActivitiesOperations, ElasticPoolOperationsOperations, ElasticPoolsOperations, EncryptionProtectorsOperations, @@ -65,6 +62,7 @@ GeoBackupPoliciesOperations, IPv6FirewallRulesOperations, InstanceFailoverGroupsOperations, + InstancePoolOperationsOperations, InstancePoolsOperations, JobAgentsOperations, JobCredentialsOperations, @@ -116,6 +114,7 @@ ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations, ManagedServerDnsAliasesOperations, ManagedServerSecurityAlertPoliciesOperations, + NetworkSecurityPerimeterConfigurationsOperations, Operations, OutboundFirewallRulesOperations, PrivateEndpointConnectionsOperations, @@ -134,7 +133,6 @@ ServerAzureADAdministratorsOperations, ServerAzureADOnlyAuthenticationsOperations, ServerBlobAuditingPoliciesOperations, - ServerCommunicationLinksOperations, ServerConfigurationOptionsOperations, ServerConnectionPoliciesOperations, ServerDevOpsAuditSettingsOperations, @@ -147,7 +145,6 @@ ServerUsagesOperations, ServerVulnerabilityAssessmentsOperations, ServersOperations, - ServiceObjectivesOperations, SqlAgentOperations, SqlVulnerabilityAssessmentBaselineOperations, SqlVulnerabilityAssessmentBaselinesOperations, @@ -179,133 +176,182 @@ from azure.core.credentials import TokenCredential -class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes - """The Azure SQL Database management API provides a RESTful set of web services that interact with - Azure SQL Database services to manage your databases. The API enables you to create, retrieve, - update, and delete databases. +class SqlManagementClient: # pylint: disable=too-many-instance-attributes + """The Azure SQL Database management API provides a RESTful set of web APIs that interact with + Azure SQL Database services to manage your databases. The API enables users to create, + retrieve, update, and delete databases, servers, and other entities. - :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 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 operations: Operations operations + :vartype operations: azure.mgmt.sql.operations.Operations + :ivar backup_short_term_retention_policies: BackupShortTermRetentionPoliciesOperations + operations + :vartype backup_short_term_retention_policies: + azure.mgmt.sql.operations.BackupShortTermRetentionPoliciesOperations :ivar database_columns: DatabaseColumnsOperations operations :vartype database_columns: azure.mgmt.sql.operations.DatabaseColumnsOperations - :ivar database_recommended_actions: DatabaseRecommendedActionsOperations operations - :vartype database_recommended_actions: - azure.mgmt.sql.operations.DatabaseRecommendedActionsOperations + :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 databases: DatabasesOperations operations + :vartype databases: azure.mgmt.sql.operations.DatabasesOperations + :ivar firewall_rules: FirewallRulesOperations operations + :vartype firewall_rules: azure.mgmt.sql.operations.FirewallRulesOperations + :ivar replication_links: ReplicationLinksOperations operations + :vartype replication_links: azure.mgmt.sql.operations.ReplicationLinksOperations + :ivar servers: ServersOperations operations + :vartype servers: azure.mgmt.sql.operations.ServersOperations + :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 server_advisors: ServerAdvisorsOperations operations + :vartype server_advisors: azure.mgmt.sql.operations.ServerAdvisorsOperations + :ivar managed_database_columns: ManagedDatabaseColumnsOperations operations + :vartype managed_database_columns: azure.mgmt.sql.operations.ManagedDatabaseColumnsOperations + :ivar database_tables: DatabaseTablesOperations operations + :vartype database_tables: azure.mgmt.sql.operations.DatabaseTablesOperations + :ivar managed_database_tables: ManagedDatabaseTablesOperations operations + :vartype managed_database_tables: azure.mgmt.sql.operations.ManagedDatabaseTablesOperations :ivar database_schemas: DatabaseSchemasOperations operations :vartype database_schemas: azure.mgmt.sql.operations.DatabaseSchemasOperations + :ivar managed_database_schemas: ManagedDatabaseSchemasOperations operations + :vartype managed_database_schemas: azure.mgmt.sql.operations.ManagedDatabaseSchemasOperations :ivar database_security_alert_policies: DatabaseSecurityAlertPoliciesOperations operations :vartype database_security_alert_policies: azure.mgmt.sql.operations.DatabaseSecurityAlertPoliciesOperations - :ivar database_tables: DatabaseTablesOperations operations - :vartype database_tables: azure.mgmt.sql.operations.DatabaseTablesOperations + :ivar sql_vulnerability_assessment_baseline: SqlVulnerabilityAssessmentBaselineOperations + operations + :vartype sql_vulnerability_assessment_baseline: + azure.mgmt.sql.operations.SqlVulnerabilityAssessmentBaselineOperations + :ivar sql_vulnerability_assessments: SqlVulnerabilityAssessmentsOperations operations + :vartype sql_vulnerability_assessments: + azure.mgmt.sql.operations.SqlVulnerabilityAssessmentsOperations + :ivar sql_vulnerability_assessments_settings: SqlVulnerabilityAssessmentsSettingsOperations + operations + :vartype sql_vulnerability_assessments_settings: + azure.mgmt.sql.operations.SqlVulnerabilityAssessmentsSettingsOperations + :ivar database_sql_vulnerability_assessment_rule_baselines: + DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations operations + :vartype database_sql_vulnerability_assessment_rule_baselines: + azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations + :ivar sql_vulnerability_assessment_rule_baseline: + SqlVulnerabilityAssessmentRuleBaselineOperations operations + :vartype sql_vulnerability_assessment_rule_baseline: + azure.mgmt.sql.operations.SqlVulnerabilityAssessmentRuleBaselineOperations + :ivar database_sql_vulnerability_assessment_scan_result: + DatabaseSqlVulnerabilityAssessmentScanResultOperations operations + :vartype database_sql_vulnerability_assessment_scan_result: + azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentScanResultOperations + :ivar sql_vulnerability_assessment_scan_result: SqlVulnerabilityAssessmentScanResultOperations + operations + :vartype sql_vulnerability_assessment_scan_result: + azure.mgmt.sql.operations.SqlVulnerabilityAssessmentScanResultOperations + :ivar sql_vulnerability_assessment_scans: SqlVulnerabilityAssessmentScansOperations operations + :vartype sql_vulnerability_assessment_scans: + azure.mgmt.sql.operations.SqlVulnerabilityAssessmentScansOperations :ivar database_vulnerability_assessment_rule_baselines: DatabaseVulnerabilityAssessmentRuleBaselinesOperations operations :vartype database_vulnerability_assessment_rule_baselines: azure.mgmt.sql.operations.DatabaseVulnerabilityAssessmentRuleBaselinesOperations + :ivar managed_database_vulnerability_assessment_rule_baselines: + ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations operations + :vartype managed_database_vulnerability_assessment_rule_baselines: + azure.mgmt.sql.operations.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations :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 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 data_masking_policies: DataMaskingPoliciesOperations operations + :vartype data_masking_policies: azure.mgmt.sql.operations.DataMaskingPoliciesOperations :ivar deleted_servers: DeletedServersOperations operations :vartype deleted_servers: azure.mgmt.sql.operations.DeletedServersOperations - :ivar elastic_pool_operations: ElasticPoolOperationsOperations operations - :vartype elastic_pool_operations: azure.mgmt.sql.operations.ElasticPoolOperationsOperations + :ivar distributed_availability_groups: DistributedAvailabilityGroupsOperations operations + :vartype distributed_availability_groups: + azure.mgmt.sql.operations.DistributedAvailabilityGroupsOperations + :ivar managed_databases: ManagedDatabasesOperations operations + :vartype managed_databases: azure.mgmt.sql.operations.ManagedDatabasesOperations + :ivar server_trust_groups: ServerTrustGroupsOperations operations + :vartype server_trust_groups: azure.mgmt.sql.operations.ServerTrustGroupsOperations + :ivar managed_instances: ManagedInstancesOperations operations + :vartype managed_instances: azure.mgmt.sql.operations.ManagedInstancesOperations + :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 firewall_rules: FirewallRulesOperations operations - :vartype firewall_rules: azure.mgmt.sql.operations.FirewallRulesOperations + :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 geo_backup_policies: GeoBackupPoliciesOperations operations + :vartype geo_backup_policies: azure.mgmt.sql.operations.GeoBackupPoliciesOperations + :ivar instance_failover_groups: InstanceFailoverGroupsOperations operations + :vartype instance_failover_groups: azure.mgmt.sql.operations.InstanceFailoverGroupsOperations + :ivar instance_pool_operations: InstancePoolOperationsOperations operations + :vartype instance_pool_operations: azure.mgmt.sql.operations.InstancePoolOperationsOperations + :ivar instance_pools: InstancePoolsOperations operations + :vartype instance_pools: azure.mgmt.sql.operations.InstancePoolsOperations + :ivar ipv6_firewall_rules: IPv6FirewallRulesOperations operations + :vartype ipv6_firewall_rules: azure.mgmt.sql.operations.IPv6FirewallRulesOperations + :ivar job_executions: JobExecutionsOperations operations + :vartype job_executions: azure.mgmt.sql.operations.JobExecutionsOperations :ivar job_agents: JobAgentsOperations operations :vartype job_agents: azure.mgmt.sql.operations.JobAgentsOperations :ivar job_credentials: JobCredentialsOperations operations :vartype job_credentials: azure.mgmt.sql.operations.JobCredentialsOperations - :ivar job_executions: JobExecutionsOperations operations - :vartype job_executions: azure.mgmt.sql.operations.JobExecutionsOperations - :ivar job_private_endpoints: JobPrivateEndpointsOperations operations - :vartype job_private_endpoints: azure.mgmt.sql.operations.JobPrivateEndpointsOperations - :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 - :vartype job_steps: azure.mgmt.sql.operations.JobStepsOperations :ivar job_target_executions: JobTargetExecutionsOperations operations :vartype job_target_executions: azure.mgmt.sql.operations.JobTargetExecutionsOperations + :ivar jobs: JobsOperations operations + :vartype jobs: azure.mgmt.sql.operations.JobsOperations + :ivar job_private_endpoints: JobPrivateEndpointsOperations operations + :vartype job_private_endpoints: azure.mgmt.sql.operations.JobPrivateEndpointsOperations + :ivar job_steps: JobStepsOperations operations + :vartype job_steps: azure.mgmt.sql.operations.JobStepsOperations :ivar job_target_groups: JobTargetGroupsOperations operations :vartype job_target_groups: azure.mgmt.sql.operations.JobTargetGroupsOperations :ivar job_versions: JobVersionsOperations operations :vartype job_versions: azure.mgmt.sql.operations.JobVersionsOperations - :ivar capabilities: CapabilitiesOperations operations - :vartype capabilities: azure.mgmt.sql.operations.CapabilitiesOperations - :ivar maintenance_window_options: MaintenanceWindowOptionsOperations operations - :vartype maintenance_window_options: - azure.mgmt.sql.operations.MaintenanceWindowOptionsOperations - :ivar maintenance_windows: MaintenanceWindowsOperations operations - :vartype maintenance_windows: azure.mgmt.sql.operations.MaintenanceWindowsOperations + :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 :ivar managed_backup_short_term_retention_policies: ManagedBackupShortTermRetentionPoliciesOperations operations :vartype managed_backup_short_term_retention_policies: azure.mgmt.sql.operations.ManagedBackupShortTermRetentionPoliciesOperations - :ivar managed_database_columns: ManagedDatabaseColumnsOperations operations - :vartype managed_database_columns: azure.mgmt.sql.operations.ManagedDatabaseColumnsOperations - :ivar managed_database_queries: ManagedDatabaseQueriesOperations operations - :vartype managed_database_queries: azure.mgmt.sql.operations.ManagedDatabaseQueriesOperations - :ivar managed_database_schemas: ManagedDatabaseSchemasOperations operations - :vartype managed_database_schemas: azure.mgmt.sql.operations.ManagedDatabaseSchemasOperations + :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_database_security_alert_policies: ManagedDatabaseSecurityAlertPoliciesOperations operations :vartype managed_database_security_alert_policies: azure.mgmt.sql.operations.ManagedDatabaseSecurityAlertPoliciesOperations - :ivar managed_database_security_events: ManagedDatabaseSecurityEventsOperations operations - :vartype managed_database_security_events: - azure.mgmt.sql.operations.ManagedDatabaseSecurityEventsOperations - :ivar managed_database_tables: ManagedDatabaseTablesOperations operations - :vartype managed_database_tables: azure.mgmt.sql.operations.ManagedDatabaseTablesOperations - :ivar managed_database_transparent_data_encryption: - ManagedDatabaseTransparentDataEncryptionOperations operations - :vartype managed_database_transparent_data_encryption: - azure.mgmt.sql.operations.ManagedDatabaseTransparentDataEncryptionOperations - :ivar managed_database_vulnerability_assessment_rule_baselines: - ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations operations - :vartype managed_database_vulnerability_assessment_rule_baselines: - azure.mgmt.sql.operations.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations - :ivar managed_database_vulnerability_assessments: - ManagedDatabaseVulnerabilityAssessmentsOperations operations - :vartype managed_database_vulnerability_assessments: - azure.mgmt.sql.operations.ManagedDatabaseVulnerabilityAssessmentsOperations - :ivar managed_database_vulnerability_assessment_scans: - ManagedDatabaseVulnerabilityAssessmentScansOperations operations - :vartype managed_database_vulnerability_assessment_scans: - azure.mgmt.sql.operations.ManagedDatabaseVulnerabilityAssessmentScansOperations :ivar managed_instance_administrators: ManagedInstanceAdministratorsOperations operations :vartype managed_instance_administrators: azure.mgmt.sql.operations.ManagedInstanceAdministratorsOperations @@ -313,6 +359,8 @@ class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword 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: @@ -330,41 +378,40 @@ class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword ManagedInstancePrivateEndpointConnectionsOperations operations :vartype managed_instance_private_endpoint_connections: azure.mgmt.sql.operations.ManagedInstancePrivateEndpointConnectionsOperations - :ivar managed_instance_private_link_resources: ManagedInstancePrivateLinkResourcesOperations - operations - :vartype managed_instance_private_link_resources: - azure.mgmt.sql.operations.ManagedInstancePrivateLinkResourcesOperations - :ivar managed_instance_tde_certificates: ManagedInstanceTdeCertificatesOperations operations - :vartype managed_instance_tde_certificates: - azure.mgmt.sql.operations.ManagedInstanceTdeCertificatesOperations :ivar managed_instance_vulnerability_assessments: ManagedInstanceVulnerabilityAssessmentsOperations operations :vartype managed_instance_vulnerability_assessments: azure.mgmt.sql.operations.ManagedInstanceVulnerabilityAssessmentsOperations - :ivar managed_restorable_dropped_database_backup_short_term_retention_policies: - ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations operations - :vartype managed_restorable_dropped_database_backup_short_term_retention_policies: - azure.mgmt.sql.operations.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations + :ivar managed_server_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 operations: Operations operations - :vartype operations: azure.mgmt.sql.operations.Operations + :ivar network_security_perimeter_configurations: + NetworkSecurityPerimeterConfigurationsOperations operations + :vartype network_security_perimeter_configurations: + azure.mgmt.sql.operations.NetworkSecurityPerimeterConfigurationsOperations + :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 restore_points: RestorePointsOperations operations - :vartype restore_points: azure.mgmt.sql.operations.RestorePointsOperations - :ivar server_advisors: ServerAdvisorsOperations operations - :vartype server_advisors: azure.mgmt.sql.operations.ServerAdvisorsOperations - :ivar server_automatic_tuning: ServerAutomaticTuningOperations operations - :vartype server_automatic_tuning: azure.mgmt.sql.operations.ServerAutomaticTuningOperations + :ivar 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 server_azure_ad_administrators: ServerAzureADAdministratorsOperations operations :vartype server_azure_ad_administrators: azure.mgmt.sql.operations.ServerAzureADAdministratorsOperations @@ -372,6 +419,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 @@ -379,18 +432,18 @@ class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword :vartype server_dns_aliases: azure.mgmt.sql.operations.ServerDnsAliasesOperations :ivar server_keys: ServerKeysOperations operations :vartype server_keys: azure.mgmt.sql.operations.ServerKeysOperations - :ivar server_operations: ServerOperationsOperations operations - :vartype server_operations: azure.mgmt.sql.operations.ServerOperationsOperations :ivar server_security_alert_policies: ServerSecurityAlertPoliciesOperations operations :vartype server_security_alert_policies: azure.mgmt.sql.operations.ServerSecurityAlertPoliciesOperations - :ivar server_trust_groups: ServerTrustGroupsOperations operations - :vartype server_trust_groups: azure.mgmt.sql.operations.ServerTrustGroupsOperations + :ivar server_trust_certificates: ServerTrustCertificatesOperations operations + :vartype server_trust_certificates: azure.mgmt.sql.operations.ServerTrustCertificatesOperations :ivar server_vulnerability_assessments: ServerVulnerabilityAssessmentsOperations operations :vartype server_vulnerability_assessments: azure.mgmt.sql.operations.ServerVulnerabilityAssessmentsOperations - :ivar sql_agent: SqlAgentOperations operations - :vartype sql_agent: azure.mgmt.sql.operations.SqlAgentOperations + :ivar 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 sync_agents: SyncAgentsOperations operations @@ -399,218 +452,162 @@ class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword :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_clusters: VirtualClustersOperations operations + :vartype virtual_clusters: azure.mgmt.sql.operations.VirtualClustersOperations :ivar virtual_network_rules: VirtualNetworkRulesOperations operations :vartype virtual_network_rules: azure.mgmt.sql.operations.VirtualNetworkRulesOperations :ivar workload_classifiers: WorkloadClassifiersOperations operations :vartype workload_classifiers: azure.mgmt.sql.operations.WorkloadClassifiersOperations :ivar workload_groups: WorkloadGroupsOperations operations :vartype workload_groups: azure.mgmt.sql.operations.WorkloadGroupsOperations - :ivar backup_short_term_retention_policies: BackupShortTermRetentionPoliciesOperations + :ivar managed_database_sensitivity_labels: ManagedDatabaseSensitivityLabelsOperations 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 + :vartype managed_database_sensitivity_labels: + azure.mgmt.sql.operations.ManagedDatabaseSensitivityLabelsOperations + :ivar database_encryption_protectors: DatabaseEncryptionProtectorsOperations operations + :vartype database_encryption_protectors: + azure.mgmt.sql.operations.DatabaseEncryptionProtectorsOperations + :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_managed_instance_backups: - LongTermRetentionManagedInstanceBackupsOperations operations - :vartype long_term_retention_managed_instance_backups: - azure.mgmt.sql.operations.LongTermRetentionManagedInstanceBackupsOperations - :ivar restorable_dropped_managed_databases: RestorableDroppedManagedDatabasesOperations + :ivar recommended_sensitivity_labels: RecommendedSensitivityLabelsOperations operations + :vartype recommended_sensitivity_labels: + azure.mgmt.sql.operations.RecommendedSensitivityLabelsOperations + :ivar synapse_link_workspaces: SynapseLinkWorkspacesOperations operations + :vartype synapse_link_workspaces: azure.mgmt.sql.operations.SynapseLinkWorkspacesOperations + :ivar server_operations: ServerOperationsOperations operations + :vartype server_operations: azure.mgmt.sql.operations.ServerOperationsOperations + :ivar server_usages: ServerUsagesOperations operations + :vartype server_usages: azure.mgmt.sql.operations.ServerUsagesOperations + :ivar tde_certificates: TdeCertificatesOperations operations + :vartype tde_certificates: azure.mgmt.sql.operations.TdeCertificatesOperations + :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_extensions: DatabaseExtensionsOperations operations + :vartype database_extensions: azure.mgmt.sql.operations.DatabaseExtensionsOperations + :ivar database_recommended_actions: DatabaseRecommendedActionsOperations operations + :vartype database_recommended_actions: + azure.mgmt.sql.operations.DatabaseRecommendedActionsOperations + :ivar database_sql_vulnerability_assessment_baselines: + DatabaseSqlVulnerabilityAssessmentBaselinesOperations operations + :vartype database_sql_vulnerability_assessment_baselines: + azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentBaselinesOperations + :ivar sql_vulnerability_assessment_baselines: SqlVulnerabilityAssessmentBaselinesOperations 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 server_trust_certificates: ServerTrustCertificatesOperations operations - :vartype server_trust_certificates: azure.mgmt.sql.operations.ServerTrustCertificatesOperations - :ivar endpoint_certificates: EndpointCertificatesOperations operations - :vartype endpoint_certificates: azure.mgmt.sql.operations.EndpointCertificatesOperations - :ivar managed_database_sensitivity_labels: ManagedDatabaseSensitivityLabelsOperations + :vartype sql_vulnerability_assessment_baselines: + azure.mgmt.sql.operations.SqlVulnerabilityAssessmentBaselinesOperations + :ivar database_sql_vulnerability_assessments_settings: + DatabaseSqlVulnerabilityAssessmentsSettingsOperations operations + :vartype database_sql_vulnerability_assessments_settings: + azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentsSettingsOperations + :ivar database_sql_vulnerability_assessment_execute_scan: + DatabaseSqlVulnerabilityAssessmentExecuteScanOperations operations + :vartype database_sql_vulnerability_assessment_execute_scan: + azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentExecuteScanOperations + :ivar sql_vulnerability_assessment_execute_scan: + SqlVulnerabilityAssessmentExecuteScanOperations operations + :vartype sql_vulnerability_assessment_execute_scan: + azure.mgmt.sql.operations.SqlVulnerabilityAssessmentExecuteScanOperations + :ivar sql_vulnerability_assessment_rule_baselines: + SqlVulnerabilityAssessmentRuleBaselinesOperations operations + :vartype sql_vulnerability_assessment_rule_baselines: + azure.mgmt.sql.operations.SqlVulnerabilityAssessmentRuleBaselinesOperations + :ivar database_sql_vulnerability_assessment_scans: + DatabaseSqlVulnerabilityAssessmentScansOperations operations + :vartype database_sql_vulnerability_assessment_scans: + azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentScansOperations + :ivar database_vulnerability_assessment_scans: DatabaseVulnerabilityAssessmentScansOperations operations - :vartype managed_database_sensitivity_labels: - azure.mgmt.sql.operations.ManagedDatabaseSensitivityLabelsOperations + :vartype database_vulnerability_assessment_scans: + azure.mgmt.sql.operations.DatabaseVulnerabilityAssessmentScansOperations + :ivar data_masking_rules: DataMaskingRulesOperations operations + :vartype data_masking_rules: azure.mgmt.sql.operations.DataMaskingRulesOperations + :ivar data_warehouse_user_activities: DataWarehouseUserActivitiesOperations operations + :vartype data_warehouse_user_activities: + azure.mgmt.sql.operations.DataWarehouseUserActivitiesOperations + :ivar managed_database_security_events: ManagedDatabaseSecurityEventsOperations operations + :vartype managed_database_security_events: + azure.mgmt.sql.operations.ManagedDatabaseSecurityEventsOperations :ivar managed_database_recommended_sensitivity_labels: ManagedDatabaseRecommendedSensitivityLabelsOperations operations :vartype managed_database_recommended_sensitivity_labels: azure.mgmt.sql.operations.ManagedDatabaseRecommendedSensitivityLabelsOperations - :ivar sensitivity_labels: SensitivityLabelsOperations operations - :vartype sensitivity_labels: azure.mgmt.sql.operations.SensitivityLabelsOperations - :ivar recommended_sensitivity_labels: RecommendedSensitivityLabelsOperations operations - :vartype recommended_sensitivity_labels: - azure.mgmt.sql.operations.RecommendedSensitivityLabelsOperations - :ivar server_blob_auditing_policies: ServerBlobAuditingPoliciesOperations operations - :vartype server_blob_auditing_policies: - azure.mgmt.sql.operations.ServerBlobAuditingPoliciesOperations - :ivar database_blob_auditing_policies: DatabaseBlobAuditingPoliciesOperations operations - :vartype database_blob_auditing_policies: - azure.mgmt.sql.operations.DatabaseBlobAuditingPoliciesOperations - :ivar extended_database_blob_auditing_policies: ExtendedDatabaseBlobAuditingPoliciesOperations - operations - :vartype extended_database_blob_auditing_policies: - azure.mgmt.sql.operations.ExtendedDatabaseBlobAuditingPoliciesOperations - :ivar extended_server_blob_auditing_policies: ExtendedServerBlobAuditingPoliciesOperations - operations - :vartype extended_server_blob_auditing_policies: - azure.mgmt.sql.operations.ExtendedServerBlobAuditingPoliciesOperations - :ivar database_advanced_threat_protection_settings: - DatabaseAdvancedThreatProtectionSettingsOperations operations - :vartype database_advanced_threat_protection_settings: - azure.mgmt.sql.operations.DatabaseAdvancedThreatProtectionSettingsOperations - :ivar server_advanced_threat_protection_settings: - ServerAdvancedThreatProtectionSettingsOperations operations - :vartype server_advanced_threat_protection_settings: - azure.mgmt.sql.operations.ServerAdvancedThreatProtectionSettingsOperations - :ivar managed_server_dns_aliases: ManagedServerDnsAliasesOperations operations - :vartype managed_server_dns_aliases: - azure.mgmt.sql.operations.ManagedServerDnsAliasesOperations + :ivar managed_instance_tde_certificates: ManagedInstanceTdeCertificatesOperations operations + :vartype managed_instance_tde_certificates: + azure.mgmt.sql.operations.ManagedInstanceTdeCertificatesOperations + :ivar elastic_pool_operations: ElasticPoolOperationsOperations operations + :vartype elastic_pool_operations: azure.mgmt.sql.operations.ElasticPoolOperationsOperations + :ivar usages: UsagesOperations operations + :vartype usages: azure.mgmt.sql.operations.UsagesOperations + :ivar ledger_digest_uploads: LedgerDigestUploadsOperations operations + :vartype ledger_digest_uploads: azure.mgmt.sql.operations.LedgerDigestUploadsOperations + :ivar maintenance_window_options: MaintenanceWindowOptionsOperations operations + :vartype maintenance_window_options: + azure.mgmt.sql.operations.MaintenanceWindowOptionsOperations + :ivar maintenance_windows: MaintenanceWindowsOperations operations + :vartype maintenance_windows: azure.mgmt.sql.operations.MaintenanceWindowsOperations :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 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_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 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_database_transparent_data_encryption: + ManagedDatabaseTransparentDataEncryptionOperations operations + :vartype managed_database_transparent_data_encryption: + azure.mgmt.sql.operations.ManagedDatabaseTransparentDataEncryptionOperations + :ivar managed_instance_advanced_threat_protection_settings: + ManagedInstanceAdvancedThreatProtectionSettingsOperations operations + :vartype managed_instance_advanced_threat_protection_settings: + azure.mgmt.sql.operations.ManagedInstanceAdvancedThreatProtectionSettingsOperations + :ivar managed_instance_private_link_resources: ManagedInstancePrivateLinkResourcesOperations + operations + :vartype managed_instance_private_link_resources: + azure.mgmt.sql.operations.ManagedInstancePrivateLinkResourcesOperations :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 start_stop_managed_instance_schedules: StartStopManagedInstanceSchedulesOperations - operations - :vartype start_stop_managed_instance_schedules: - azure.mgmt.sql.operations.StartStopManagedInstanceSchedulesOperations + :ivar server_advanced_threat_protection_settings: + ServerAdvancedThreatProtectionSettingsOperations operations + :vartype server_advanced_threat_protection_settings: + azure.mgmt.sql.operations.ServerAdvancedThreatProtectionSettingsOperations + :ivar server_automatic_tuning: ServerAutomaticTuningOperations operations + :vartype server_automatic_tuning: azure.mgmt.sql.operations.ServerAutomaticTuningOperations + :ivar sql_agent: SqlAgentOperations operations + :vartype sql_agent: azure.mgmt.sql.operations.SqlAgentOperations :ivar transparent_data_encryptions: TransparentDataEncryptionsOperations operations :vartype transparent_data_encryptions: azure.mgmt.sql.operations.TransparentDataEncryptionsOperations - :ivar ipv6_firewall_rules: IPv6FirewallRulesOperations operations - :vartype ipv6_firewall_rules: azure.mgmt.sql.operations.IPv6FirewallRulesOperations - :ivar sql_vulnerability_assessment_baseline: SqlVulnerabilityAssessmentBaselineOperations - operations - :vartype sql_vulnerability_assessment_baseline: - azure.mgmt.sql.operations.SqlVulnerabilityAssessmentBaselineOperations - :ivar sql_vulnerability_assessment_baselines: SqlVulnerabilityAssessmentBaselinesOperations - operations - :vartype sql_vulnerability_assessment_baselines: - azure.mgmt.sql.operations.SqlVulnerabilityAssessmentBaselinesOperations - :ivar sql_vulnerability_assessment_execute_scan: - SqlVulnerabilityAssessmentExecuteScanOperations operations - :vartype sql_vulnerability_assessment_execute_scan: - azure.mgmt.sql.operations.SqlVulnerabilityAssessmentExecuteScanOperations - :ivar sql_vulnerability_assessment_rule_baseline: - SqlVulnerabilityAssessmentRuleBaselineOperations operations - :vartype sql_vulnerability_assessment_rule_baseline: - azure.mgmt.sql.operations.SqlVulnerabilityAssessmentRuleBaselineOperations - :ivar sql_vulnerability_assessment_rule_baselines: - SqlVulnerabilityAssessmentRuleBaselinesOperations operations - :vartype sql_vulnerability_assessment_rule_baselines: - azure.mgmt.sql.operations.SqlVulnerabilityAssessmentRuleBaselinesOperations - :ivar sql_vulnerability_assessment_scan_result: SqlVulnerabilityAssessmentScanResultOperations - operations - :vartype sql_vulnerability_assessment_scan_result: - azure.mgmt.sql.operations.SqlVulnerabilityAssessmentScanResultOperations - :ivar sql_vulnerability_assessment_scans: SqlVulnerabilityAssessmentScansOperations operations - :vartype sql_vulnerability_assessment_scans: - azure.mgmt.sql.operations.SqlVulnerabilityAssessmentScansOperations - :ivar sql_vulnerability_assessments_settings: SqlVulnerabilityAssessmentsSettingsOperations - operations - :vartype sql_vulnerability_assessments_settings: - azure.mgmt.sql.operations.SqlVulnerabilityAssessmentsSettingsOperations - :ivar sql_vulnerability_assessments: SqlVulnerabilityAssessmentsOperations operations - :vartype sql_vulnerability_assessments: - azure.mgmt.sql.operations.SqlVulnerabilityAssessmentsOperations - :ivar database_sql_vulnerability_assessment_baselines: - DatabaseSqlVulnerabilityAssessmentBaselinesOperations operations - :vartype database_sql_vulnerability_assessment_baselines: - azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentBaselinesOperations - :ivar database_sql_vulnerability_assessment_execute_scan: - DatabaseSqlVulnerabilityAssessmentExecuteScanOperations operations - :vartype database_sql_vulnerability_assessment_execute_scan: - azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentExecuteScanOperations - :ivar database_sql_vulnerability_assessment_rule_baselines: - DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations operations - :vartype database_sql_vulnerability_assessment_rule_baselines: - azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations - :ivar database_sql_vulnerability_assessment_scan_result: - DatabaseSqlVulnerabilityAssessmentScanResultOperations operations - :vartype database_sql_vulnerability_assessment_scan_result: - azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentScanResultOperations - :ivar database_sql_vulnerability_assessment_scans: - DatabaseSqlVulnerabilityAssessmentScansOperations operations - :vartype database_sql_vulnerability_assessment_scans: - azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentScansOperations - :ivar database_sql_vulnerability_assessments_settings: - DatabaseSqlVulnerabilityAssessmentsSettingsOperations operations - :vartype database_sql_vulnerability_assessments_settings: - azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentsSettingsOperations - :ivar failover_groups: FailoverGroupsOperations operations - :vartype failover_groups: azure.mgmt.sql.operations.FailoverGroupsOperations - :ivar instance_pools: InstancePoolsOperations operations - :vartype instance_pools: azure.mgmt.sql.operations.InstancePoolsOperations - :ivar managed_instances: ManagedInstancesOperations operations - :vartype managed_instances: azure.mgmt.sql.operations.ManagedInstancesOperations - :ivar replication_links: ReplicationLinksOperations operations - :vartype replication_links: azure.mgmt.sql.operations.ReplicationLinksOperations - :ivar distributed_availability_groups: DistributedAvailabilityGroupsOperations operations - :vartype distributed_availability_groups: - azure.mgmt.sql.operations.DistributedAvailabilityGroupsOperations - :ivar servers: ServersOperations operations - :vartype servers: azure.mgmt.sql.operations.ServersOperations - :ivar long_term_retention_backups: LongTermRetentionBackupsOperations operations - :vartype long_term_retention_backups: - azure.mgmt.sql.operations.LongTermRetentionBackupsOperations - :ivar long_term_retention_policies: LongTermRetentionPoliciesOperations operations - :vartype long_term_retention_policies: - azure.mgmt.sql.operations.LongTermRetentionPoliciesOperations - :ivar database_operations: DatabaseOperationsOperations operations - :vartype database_operations: azure.mgmt.sql.operations.DatabaseOperationsOperations - :param credential: Credential needed for the client to connect to Azure. Required. + :ivar capabilities: CapabilitiesOperations operations + :vartype capabilities: azure.mgmt.sql.operations.CapabilitiesOperations + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription ID that identifies an Azure subscription. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :param base_url: Service URL. Default value is None. + :param base_url: Service host. Default value is None. :type base_url: str :keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is None. :paramtype cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are + "2025-02-01-preview". Default value is "2025-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. """ @@ -624,6 +621,7 @@ def __init__( cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: + _endpoint = "{endpoint}" _cloud = cloud_setting or settings.current.azure_cloud # type: ignore _endpoints = get_arm_endpoints(_cloud) if not base_url: @@ -632,6 +630,7 @@ def __init__( self._config = SqlManagementClientConfiguration( credential=credential, subscription_id=subscription_id, + base_url=cast(str, base_url), cloud_setting=cloud_setting, credential_scopes=credential_scopes, **kwargs @@ -655,163 +654,165 @@ def __init__( policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, _endpoint), policies=_policies, **kwargs) - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) + self._serialize = Serializer() + self._deserialize = Deserializer() self._serialize.client_side_validation = False - self.data_masking_policies = DataMaskingPoliciesOperations( + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.backup_short_term_retention_policies = BackupShortTermRetentionPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.data_masking_rules = DataMaskingRulesOperations( + self.database_columns = DatabaseColumnsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.geo_backup_policies = GeoBackupPoliciesOperations( + 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.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.firewall_rules = FirewallRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.replication_links = ReplicationLinksOperations( self._client, self._config, self._serialize, self._deserialize ) - self.service_objectives = ServiceObjectivesOperations( + self.servers = ServersOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_blob_auditing_policies = ServerBlobAuditingPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.elastic_pool_activities = ElasticPoolActivitiesOperations( + self.database_blob_auditing_policies = DatabaseBlobAuditingPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.elastic_pool_database_activities = ElasticPoolDatabaseActivitiesOperations( + self.extended_database_blob_auditing_policies = ExtendedDatabaseBlobAuditingPoliciesOperations( 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.extended_server_blob_auditing_policies = ExtendedServerBlobAuditingPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_automatic_tuning = DatabaseAutomaticTuningOperations( + self.server_advisors = ServerAdvisorsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_database_columns = ManagedDatabaseColumnsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_columns = DatabaseColumnsOperations( + self.database_tables = DatabaseTablesOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_database_tables = ManagedDatabaseTablesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_recommended_actions = DatabaseRecommendedActionsOperations( + self.database_schemas = DatabaseSchemasOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_schemas = DatabaseSchemasOperations( + self.managed_database_schemas = ManagedDatabaseSchemasOperations( self._client, self._config, self._serialize, self._deserialize ) self.database_security_alert_policies = DatabaseSecurityAlertPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_tables = DatabaseTablesOperations(self._client, self._config, self._serialize, self._deserialize) - self.database_vulnerability_assessment_rule_baselines = DatabaseVulnerabilityAssessmentRuleBaselinesOperations( + self.sql_vulnerability_assessment_baseline = SqlVulnerabilityAssessmentBaselineOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_vulnerability_assessments = DatabaseVulnerabilityAssessmentsOperations( + self.sql_vulnerability_assessments = SqlVulnerabilityAssessmentsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_vulnerability_assessment_scans = DatabaseVulnerabilityAssessmentScansOperations( + self.sql_vulnerability_assessments_settings = SqlVulnerabilityAssessmentsSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.data_warehouse_user_activities = DataWarehouseUserActivitiesOperations( - 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.deleted_servers = DeletedServersOperations(self._client, self._config, self._serialize, self._deserialize) - self.elastic_pool_operations = ElasticPoolOperationsOperations( + self.sql_vulnerability_assessment_rule_baseline = SqlVulnerabilityAssessmentRuleBaselineOperations( self._client, self._config, self._serialize, self._deserialize ) - self.encryption_protectors = EncryptionProtectorsOperations( + self.database_sql_vulnerability_assessment_scan_result = DatabaseSqlVulnerabilityAssessmentScanResultOperations( self._client, self._config, self._serialize, self._deserialize ) - self.firewall_rules = FirewallRulesOperations(self._client, self._config, self._serialize, self._deserialize) - self.job_agents = JobAgentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.job_credentials = JobCredentialsOperations(self._client, self._config, self._serialize, self._deserialize) - self.job_executions = JobExecutionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.job_private_endpoints = JobPrivateEndpointsOperations( + self.sql_vulnerability_assessment_scan_result = SqlVulnerabilityAssessmentScanResultOperations( 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.sql_vulnerability_assessment_scans = SqlVulnerabilityAssessmentScansOperations( self._client, self._config, self._serialize, self._deserialize ) - self.job_steps = JobStepsOperations(self._client, self._config, self._serialize, self._deserialize) - self.job_target_executions = JobTargetExecutionsOperations( + self.database_vulnerability_assessment_rule_baselines = DatabaseVulnerabilityAssessmentRuleBaselinesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.job_target_groups = JobTargetGroupsOperations( - self._client, self._config, self._serialize, self._deserialize + self.managed_database_vulnerability_assessment_rule_baselines = ( + ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) ) - self.job_versions = JobVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.capabilities = CapabilitiesOperations(self._client, self._config, self._serialize, self._deserialize) - self.maintenance_window_options = MaintenanceWindowOptionsOperations( + self.database_vulnerability_assessments = DatabaseVulnerabilityAssessmentsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.maintenance_windows = MaintenanceWindowsOperations( + self.managed_database_vulnerability_assessments = ManagedDatabaseVulnerabilityAssessmentsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_backup_short_term_retention_policies = ManagedBackupShortTermRetentionPoliciesOperations( + self.managed_database_vulnerability_assessment_scans = ManagedDatabaseVulnerabilityAssessmentScansOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_columns = ManagedDatabaseColumnsOperations( + self.data_masking_policies = DataMaskingPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_queries = ManagedDatabaseQueriesOperations( + self.deleted_servers = DeletedServersOperations(self._client, self._config, self._serialize, self._deserialize) + self.distributed_availability_groups = DistributedAvailabilityGroupsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_schemas = ManagedDatabaseSchemasOperations( + self.managed_databases = ManagedDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_security_alert_policies = ManagedDatabaseSecurityAlertPoliciesOperations( + self.server_trust_groups = ServerTrustGroupsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_security_events = ManagedDatabaseSecurityEventsOperations( + self.managed_instances = ManagedInstancesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_tables = ManagedDatabaseTablesOperations( + self.elastic_pools = ElasticPoolsOperations(self._client, self._config, self._serialize, self._deserialize) + self.encryption_protectors = EncryptionProtectorsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_transparent_data_encryption = ManagedDatabaseTransparentDataEncryptionOperations( + self.endpoint_certificates = EndpointCertificatesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_vulnerability_assessment_rule_baselines = ( - ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - ) - self.managed_database_vulnerability_assessments = ManagedDatabaseVulnerabilityAssessmentsOperations( + self.failover_groups = FailoverGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.geo_backup_policies = GeoBackupPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_vulnerability_assessment_scans = ManagedDatabaseVulnerabilityAssessmentScansOperations( + self.instance_failover_groups = InstanceFailoverGroupsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_administrators = ManagedInstanceAdministratorsOperations( + self.instance_pool_operations = InstancePoolOperationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_azure_ad_only_authentications = ManagedInstanceAzureADOnlyAuthenticationsOperations( + self.instance_pools = InstancePoolsOperations(self._client, self._config, self._serialize, self._deserialize) + self.ipv6_firewall_rules = IPv6FirewallRulesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_encryption_protectors = ManagedInstanceEncryptionProtectorsOperations( + self.job_executions = JobExecutionsOperations(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_step_executions = JobStepExecutionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_keys = ManagedInstanceKeysOperations( + self.job_target_executions = JobTargetExecutionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_long_term_retention_policies = ManagedInstanceLongTermRetentionPoliciesOperations( + self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) + self.job_private_endpoints = JobPrivateEndpointsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_operations = ManagedInstanceOperationsOperations( + self.job_steps = JobStepsOperations(self._client, self._config, self._serialize, self._deserialize) + self.job_target_groups = JobTargetGroupsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_private_endpoint_connections = ManagedInstancePrivateEndpointConnectionsOperations( + self.job_versions = JobVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.long_term_retention_backups = LongTermRetentionBackupsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_private_link_resources = ManagedInstancePrivateLinkResourcesOperations( + self.long_term_retention_managed_instance_backups = LongTermRetentionManagedInstanceBackupsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_tde_certificates = ManagedInstanceTdeCertificatesOperations( + self.long_term_retention_policies = LongTermRetentionPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_vulnerability_assessments = ManagedInstanceVulnerabilityAssessmentsOperations( + self.managed_backup_short_term_retention_policies = ManagedBackupShortTermRetentionPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) self.managed_restorable_dropped_database_backup_short_term_retention_policies = ( @@ -819,262 +820,253 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) ) - self.managed_server_security_alert_policies = ManagedServerSecurityAlertPoliciesOperations( + self.managed_database_security_alert_policies = ManagedDatabaseSecurityAlertPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self.managed_instance_administrators = ManagedInstanceAdministratorsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.private_link_resources = PrivateLinkResourcesOperations( + self.managed_instance_azure_ad_only_authentications = ManagedInstanceAzureADOnlyAuthenticationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.recoverable_managed_databases = RecoverableManagedDatabasesOperations( + self.managed_instance_dtcs = ManagedInstanceDtcsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restore_points = RestorePointsOperations(self._client, self._config, self._serialize, self._deserialize) - self.server_advisors = ServerAdvisorsOperations(self._client, self._config, self._serialize, self._deserialize) - self.server_automatic_tuning = ServerAutomaticTuningOperations( + self.managed_instance_encryption_protectors = ManagedInstanceEncryptionProtectorsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_azure_ad_administrators = ServerAzureADAdministratorsOperations( + self.managed_instance_keys = ManagedInstanceKeysOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_azure_ad_only_authentications = ServerAzureADOnlyAuthenticationsOperations( + self.managed_instance_long_term_retention_policies = ManagedInstanceLongTermRetentionPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_dev_ops_audit_settings = ServerDevOpsAuditSettingsOperations( + self.managed_instance_operations = ManagedInstanceOperationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_dns_aliases = ServerDnsAliasesOperations( + self.managed_instance_private_endpoint_connections = ManagedInstancePrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_keys = ServerKeysOperations(self._client, self._config, self._serialize, self._deserialize) - self.server_operations = ServerOperationsOperations( + self.managed_instance_vulnerability_assessments = ManagedInstanceVulnerabilityAssessmentsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_security_alert_policies = ServerSecurityAlertPoliciesOperations( + self.managed_server_dns_aliases = ManagedServerDnsAliasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_trust_groups = ServerTrustGroupsOperations( + self.managed_server_security_alert_policies = ManagedServerSecurityAlertPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_vulnerability_assessments = ServerVulnerabilityAssessmentsOperations( + self.network_security_perimeter_configurations = NetworkSecurityPerimeterConfigurationsOperations( 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.outbound_firewall_rules = OutboundFirewallRulesOperations( 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.private_endpoint_connections = PrivateEndpointConnectionsOperations( 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.private_link_resources = PrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workload_classifiers = WorkloadClassifiersOperations( + self.recoverable_databases = RecoverableDatabasesOperations( 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.recoverable_managed_databases = RecoverableManagedDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_extensions = DatabaseExtensionsOperations( + self.restorable_dropped_databases = RestorableDroppedDatabasesOperations( 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.restorable_dropped_managed_databases = RestorableDroppedManagedDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.outbound_firewall_rules = OutboundFirewallRulesOperations( + self.server_azure_ad_administrators = ServerAzureADAdministratorsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.long_term_retention_managed_instance_backups = LongTermRetentionManagedInstanceBackupsOperations( + self.server_azure_ad_only_authentications = ServerAzureADOnlyAuthenticationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_dropped_managed_databases = RestorableDroppedManagedDatabasesOperations( + self.server_configuration_options = ServerConfigurationOptionsOperations( self._client, self._config, self._serialize, self._deserialize ) self.server_connection_policies = ServerConnectionPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_trust_certificates = ServerTrustCertificatesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.endpoint_certificates = EndpointCertificatesOperations( + self.server_dev_ops_audit_settings = ServerDevOpsAuditSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_sensitivity_labels = ManagedDatabaseSensitivityLabelsOperations( + self.server_dns_aliases = ServerDnsAliasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_recommended_sensitivity_labels = ManagedDatabaseRecommendedSensitivityLabelsOperations( + self.server_keys = ServerKeysOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_security_alert_policies = ServerSecurityAlertPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.sensitivity_labels = SensitivityLabelsOperations( + self.server_trust_certificates = ServerTrustCertificatesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.recommended_sensitivity_labels = RecommendedSensitivityLabelsOperations( + self.server_vulnerability_assessments = ServerVulnerabilityAssessmentsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_blob_auditing_policies = ServerBlobAuditingPoliciesOperations( + self.start_stop_managed_instance_schedules = StartStopManagedInstanceSchedulesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_blob_auditing_policies = DatabaseBlobAuditingPoliciesOperations( + self.subscription_usages = SubscriptionUsagesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.extended_database_blob_auditing_policies = ExtendedDatabaseBlobAuditingPoliciesOperations( + 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.time_zones = TimeZonesOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_clusters = VirtualClustersOperations( self._client, self._config, self._serialize, self._deserialize ) - self.extended_server_blob_auditing_policies = ExtendedServerBlobAuditingPoliciesOperations( + self.virtual_network_rules = VirtualNetworkRulesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_advanced_threat_protection_settings = DatabaseAdvancedThreatProtectionSettingsOperations( + self.workload_classifiers = WorkloadClassifiersOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_advanced_threat_protection_settings = ServerAdvancedThreatProtectionSettingsOperations( + self.workload_groups = WorkloadGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_database_sensitivity_labels = ManagedDatabaseSensitivityLabelsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_server_dns_aliases = ManagedServerDnsAliasesOperations( + self.database_encryption_protectors = DatabaseEncryptionProtectorsOperations( 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.managed_database_move_operations = ManagedDatabaseMoveOperationsOperations( + self.database_operations = DatabaseOperationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_dtcs = ManagedInstanceDtcsOperations( + self.database_usages = DatabaseUsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.recommended_sensitivity_labels = RecommendedSensitivityLabelsOperations( 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.server_operations = ServerOperationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.instance_failover_groups = InstanceFailoverGroupsOperations( + self.server_usages = ServerUsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.tde_certificates = TdeCertificatesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_restore_details = ManagedDatabaseRestoreDetailsOperations( + self.database_advanced_threat_protection_settings = DatabaseAdvancedThreatProtectionSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_encryption_protectors = DatabaseEncryptionProtectorsOperations( + self.database_advisors = DatabaseAdvisorsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_databases = ManagedDatabasesOperations( + self.database_automatic_tuning = DatabaseAutomaticTuningOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_ledger_digest_uploads = ManagedLedgerDigestUploadsOperations( + self.database_extensions = DatabaseExtensionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.recoverable_databases = RecoverableDatabasesOperations( + self.database_recommended_actions = DatabaseRecommendedActionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_dropped_databases = RestorableDroppedDatabasesOperations( + self.database_sql_vulnerability_assessment_baselines = DatabaseSqlVulnerabilityAssessmentBaselinesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_configuration_options = ServerConfigurationOptionsOperations( + self.sql_vulnerability_assessment_baselines = SqlVulnerabilityAssessmentBaselinesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.start_stop_managed_instance_schedules = StartStopManagedInstanceSchedulesOperations( + self.database_sql_vulnerability_assessments_settings = DatabaseSqlVulnerabilityAssessmentsSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.transparent_data_encryptions = TransparentDataEncryptionsOperations( + self.database_sql_vulnerability_assessment_execute_scan = ( + DatabaseSqlVulnerabilityAssessmentExecuteScanOperations( + self._client, self._config, self._serialize, self._deserialize + ) + ) + self.sql_vulnerability_assessment_execute_scan = SqlVulnerabilityAssessmentExecuteScanOperations( self._client, self._config, self._serialize, self._deserialize ) - self.ipv6_firewall_rules = IPv6FirewallRulesOperations( + self.sql_vulnerability_assessment_rule_baselines = SqlVulnerabilityAssessmentRuleBaselinesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.sql_vulnerability_assessment_baseline = SqlVulnerabilityAssessmentBaselineOperations( + self.database_sql_vulnerability_assessment_scans = DatabaseSqlVulnerabilityAssessmentScansOperations( self._client, self._config, self._serialize, self._deserialize ) - self.sql_vulnerability_assessment_baselines = SqlVulnerabilityAssessmentBaselinesOperations( + self.database_vulnerability_assessment_scans = DatabaseVulnerabilityAssessmentScansOperations( self._client, self._config, self._serialize, self._deserialize ) - self.sql_vulnerability_assessment_execute_scan = SqlVulnerabilityAssessmentExecuteScanOperations( + self.data_masking_rules = DataMaskingRulesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.sql_vulnerability_assessment_rule_baseline = SqlVulnerabilityAssessmentRuleBaselineOperations( + self.data_warehouse_user_activities = DataWarehouseUserActivitiesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.sql_vulnerability_assessment_rule_baselines = SqlVulnerabilityAssessmentRuleBaselinesOperations( + self.managed_database_security_events = ManagedDatabaseSecurityEventsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.sql_vulnerability_assessment_scan_result = SqlVulnerabilityAssessmentScanResultOperations( + self.managed_database_recommended_sensitivity_labels = ManagedDatabaseRecommendedSensitivityLabelsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.sql_vulnerability_assessment_scans = SqlVulnerabilityAssessmentScansOperations( + self.managed_instance_tde_certificates = ManagedInstanceTdeCertificatesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.sql_vulnerability_assessments_settings = SqlVulnerabilityAssessmentsSettingsOperations( + self.elastic_pool_operations = ElasticPoolOperationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.sql_vulnerability_assessments = SqlVulnerabilityAssessmentsOperations( + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.ledger_digest_uploads = LedgerDigestUploadsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_sql_vulnerability_assessment_baselines = DatabaseSqlVulnerabilityAssessmentBaselinesOperations( + self.maintenance_window_options = MaintenanceWindowOptionsOperations( 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.maintenance_windows = MaintenanceWindowsOperations( + self._client, self._config, self._serialize, self._deserialize ) - self.database_sql_vulnerability_assessment_rule_baselines = ( - DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations( + self.managed_database_advanced_threat_protection_settings = ( + ManagedDatabaseAdvancedThreatProtectionSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) ) - self.database_sql_vulnerability_assessment_scan_result = DatabaseSqlVulnerabilityAssessmentScanResultOperations( + self.managed_database_move_operations = ManagedDatabaseMoveOperationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_sql_vulnerability_assessment_scans = DatabaseSqlVulnerabilityAssessmentScansOperations( + self.managed_database_queries = ManagedDatabaseQueriesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_sql_vulnerability_assessments_settings = DatabaseSqlVulnerabilityAssessmentsSettingsOperations( + self.managed_database_restore_details = ManagedDatabaseRestoreDetailsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.failover_groups = FailoverGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.instance_pools = InstancePoolsOperations(self._client, self._config, self._serialize, self._deserialize) - self.managed_instances = ManagedInstancesOperations( + self.managed_database_transparent_data_encryption = ManagedDatabaseTransparentDataEncryptionOperations( self._client, self._config, self._serialize, self._deserialize ) - self.replication_links = ReplicationLinksOperations( + self.managed_instance_advanced_threat_protection_settings = ( + ManagedInstanceAdvancedThreatProtectionSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + ) + self.managed_instance_private_link_resources = ManagedInstancePrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.distributed_availability_groups = DistributedAvailabilityGroupsOperations( + self.managed_ledger_digest_uploads = ManagedLedgerDigestUploadsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.servers = ServersOperations(self._client, self._config, self._serialize, self._deserialize) - self.long_term_retention_backups = LongTermRetentionBackupsOperations( + self.server_advanced_threat_protection_settings = ServerAdvancedThreatProtectionSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.long_term_retention_policies = LongTermRetentionPoliciesOperations( + self.server_automatic_tuning = ServerAutomaticTuningOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_operations = DatabaseOperationsOperations( + self.sql_agent = SqlAgentOperations(self._client, self._config, self._serialize, self._deserialize) + self.transparent_data_encryptions = TransparentDataEncryptionsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.capabilities = CapabilitiesOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") - >>> response = client._send_request(request) + >>> response = client.send_request(request) For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request @@ -1087,7 +1079,11 @@ def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: """ request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: 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 0c40e17514d7..d501fed651fe 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_configuration.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_configuration.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -24,22 +24,31 @@ class SqlManagementClientConfiguration: # pylint: disable=too-many-instance-att Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. Required. + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription ID that identifies an Azure subscription. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str + :param base_url: Service host. Default value is "https://management.azure.com". + :type base_url: str :param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is None. :type cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are + "2025-02-01-preview". Default value is "2025-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, + base_url: str = "https://management.azure.com", cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: + api_version: str = kwargs.pop("api_version", "2025-02-01-preview") + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -47,7 +56,9 @@ def __init__( self.credential = credential self.subscription_id = subscription_id + self.base_url = base_url self.cloud_setting = cloud_setting + 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.polling_interval = kwargs.get("polling_interval", 30) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_patch.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_patch.py index 17dbc073e01b..87676c65a8f0 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_patch.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_patch.py @@ -1,32 +1,21 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# # Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------- +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" + + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level -# This file is used for handwritten extensions to the generated code. Example: -# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_utils/__init__.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_utils/__init__.py index 0af9b28f6607..8026245c2abc 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_utils/__init__.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_utils/__init__.py @@ -1,6 +1,6 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_utils/model_base.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_utils/model_base.py new file mode 100644 index 000000000000..eef4e52ed1a0 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_utils/model_base.py @@ -0,0 +1,1459 @@ +# pylint: disable=line-too-long,useless-suppression,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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=protected-access, broad-except + +import copy +import calendar +import decimal +import functools +import sys +import logging +import base64 +import re +import typing +import enum +import email.utils +from datetime import datetime, date, time, timedelta, timezone +from json import JSONEncoder +import xml.etree.ElementTree as ET +from collections.abc import MutableMapping +from typing_extensions import Self +import isodate +from azure.core.exceptions import DeserializationError +from azure.core import CaseInsensitiveEnumMeta +from azure.core.pipeline import PipelineResponse +from azure.core.serialization import _Null +from azure.core.rest import HttpResponse + +_LOGGER = logging.getLogger(__name__) + +__all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"] + +TZ_UTC = timezone.utc +_T = typing.TypeVar("_T") +_NONE_TYPE = type(None) + + +def _timedelta_as_isostr(td: timedelta) -> str: + """Converts a datetime.timedelta object into an ISO 8601 formatted string, e.g. 'P4DT12H30M05S' + + Function adapted from the Tin Can Python project: https://github.com/RusticiSoftware/TinCanPython + + :param timedelta td: The timedelta to convert + :rtype: str + :return: ISO8601 version of this timedelta + """ + + # Split seconds to larger units + seconds = td.total_seconds() + minutes, seconds = divmod(seconds, 60) + hours, minutes = divmod(minutes, 60) + days, hours = divmod(hours, 24) + + days, hours, minutes = list(map(int, (days, hours, minutes))) + seconds = round(seconds, 6) + + # Build date + date_str = "" + if days: + date_str = "%sD" % days + + if hours or minutes or seconds: + # Build time + time_str = "T" + + # Hours + bigger_exists = date_str or hours + if bigger_exists: + time_str += "{:02}H".format(hours) + + # Minutes + bigger_exists = bigger_exists or minutes + if bigger_exists: + time_str += "{:02}M".format(minutes) + + # Seconds + try: + if seconds.is_integer(): + seconds_string = "{:02}".format(int(seconds)) + else: + # 9 chars long w/ leading 0, 6 digits after decimal + seconds_string = "%09.6f" % seconds + # Remove trailing zeros + seconds_string = seconds_string.rstrip("0") + except AttributeError: # int.is_integer() raises + seconds_string = "{:02}".format(seconds) + + time_str += "{}S".format(seconds_string) + else: + time_str = "" + + return "P" + date_str + time_str + + +def _serialize_bytes(o, format: typing.Optional[str] = None) -> str: + encoded = base64.b64encode(o).decode() + if format == "base64url": + return encoded.strip("=").replace("+", "-").replace("/", "_") + return encoded + + +def _serialize_datetime(o, format: typing.Optional[str] = None): + if hasattr(o, "year") and hasattr(o, "hour"): + if format == "rfc7231": + return email.utils.format_datetime(o, usegmt=True) + if format == "unix-timestamp": + return int(calendar.timegm(o.utctimetuple())) + + # astimezone() fails for naive times in Python 2.7, so make make sure o is aware (tzinfo is set) + if not o.tzinfo: + iso_formatted = o.replace(tzinfo=TZ_UTC).isoformat() + else: + iso_formatted = o.astimezone(TZ_UTC).isoformat() + # Replace the trailing "+00:00" UTC offset with "Z" (RFC 3339: https://www.ietf.org/rfc/rfc3339.txt) + return iso_formatted.replace("+00:00", "Z") + # Next try datetime.date or datetime.time + return o.isoformat() + + +def _is_readonly(p): + try: + return p._visibility == ["read"] + except AttributeError: + return False + + +class SdkJSONEncoder(JSONEncoder): + """A JSON encoder that's capable of serializing datetime objects and bytes.""" + + def __init__(self, *args, exclude_readonly: bool = False, format: typing.Optional[str] = None, **kwargs): + super().__init__(*args, **kwargs) + self.exclude_readonly = exclude_readonly + self.format = format + + def default(self, o): # pylint: disable=too-many-return-statements + if _is_model(o): + if self.exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + return {k: v for k, v in o.items() if k not in readonly_props} + return dict(o.items()) + try: + return super(SdkJSONEncoder, self).default(o) + except TypeError: + if isinstance(o, _Null): + return None + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, self.format) + try: + # First try datetime.datetime + return _serialize_datetime(o, self.format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return super(SdkJSONEncoder, self).default(o) + + +_VALID_DATE = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" + r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") +_VALID_RFC7231 = re.compile( + r"(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s\d{2}\s" + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT" +) + +_ARRAY_ENCODE_MAPPING = { + "pipeDelimited": "|", + "spaceDelimited": " ", + "commaDelimited": ",", + "newlineDelimited": "\n", +} + + +def _deserialize_array_encoded(delimit: str, attr): + if isinstance(attr, str): + if attr == "": + return [] + return attr.split(delimit) + return attr + + +def _deserialize_datetime(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + attr = attr.upper() + match = _VALID_DATE.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + return date_obj # type: ignore[no-any-return] + + +def _deserialize_datetime_rfc7231(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize RFC7231 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + match = _VALID_RFC7231.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + return email.utils.parsedate_to_datetime(attr) + + +def _deserialize_datetime_unix_timestamp(attr: typing.Union[float, datetime]) -> datetime: + """Deserialize unix timestamp into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + return datetime.fromtimestamp(attr, TZ_UTC) + + +def _deserialize_date(attr: typing.Union[str, date]) -> date: + """Deserialize ISO-8601 formatted string into Date object. + :param str attr: response string to be deserialized. + :rtype: date + :returns: The date object from that input + """ + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + if isinstance(attr, date): + return attr + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) # type: ignore + + +def _deserialize_time(attr: typing.Union[str, time]) -> time: + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :returns: The time object from that input + """ + if isinstance(attr, time): + return attr + return isodate.parse_time(attr) # type: ignore[no-any-return] + + +def _deserialize_bytes(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + return bytes(base64.b64decode(attr)) + + +def _deserialize_bytes_base64(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return bytes(base64.b64decode(encoded)) + + +def _deserialize_duration(attr): + if isinstance(attr, timedelta): + return attr + return isodate.parse_duration(attr) + + +def _deserialize_decimal(attr): + if isinstance(attr, decimal.Decimal): + return attr + return decimal.Decimal(str(attr)) + + +def _deserialize_int_as_str(attr): + if isinstance(attr, int): + return attr + return int(attr) + + +_DESERIALIZE_MAPPING = { + datetime: _deserialize_datetime, + date: _deserialize_date, + time: _deserialize_time, + bytes: _deserialize_bytes, + bytearray: _deserialize_bytes, + timedelta: _deserialize_duration, + typing.Any: lambda x: x, + decimal.Decimal: _deserialize_decimal, +} + +_DESERIALIZE_MAPPING_WITHFORMAT = { + "rfc3339": _deserialize_datetime, + "rfc7231": _deserialize_datetime_rfc7231, + "unix-timestamp": _deserialize_datetime_unix_timestamp, + "base64": _deserialize_bytes, + "base64url": _deserialize_bytes_base64, +} + + +def get_deserializer(annotation: typing.Any, rf: typing.Optional["_RestField"] = None): + if annotation is int and rf and rf._format == "str": + return _deserialize_int_as_str + if annotation is str and rf and rf._format in _ARRAY_ENCODE_MAPPING: + return functools.partial(_deserialize_array_encoded, _ARRAY_ENCODE_MAPPING[rf._format]) + if rf and rf._format: + return _DESERIALIZE_MAPPING_WITHFORMAT.get(rf._format) + return _DESERIALIZE_MAPPING.get(annotation) # pyright: ignore + + +def _get_type_alias_type(module_name: str, alias_name: str): + types = { + k: v + for k, v in sys.modules[module_name].__dict__.items() + if isinstance(v, typing._GenericAlias) # type: ignore + } + if alias_name not in types: + return alias_name + return types[alias_name] + + +def _get_model(module_name: str, model_name: str): + models = {k: v for k, v in sys.modules[module_name].__dict__.items() if isinstance(v, type)} + module_end = module_name.rsplit(".", 1)[0] + models.update({k: v for k, v in sys.modules[module_end].__dict__.items() if isinstance(v, type)}) + if isinstance(model_name, str): + model_name = model_name.split(".")[-1] + if model_name not in models: + return model_name + return models[model_name] + + +_UNSET = object() + + +class _MyMutableMapping(MutableMapping[str, typing.Any]): + def __init__(self, data: dict[str, typing.Any]) -> None: + self._data = data + + def __contains__(self, key: typing.Any) -> bool: + return key in self._data + + def __getitem__(self, key: str) -> typing.Any: + # If this key has been deserialized (for mutable types), we need to handle serialization + if hasattr(self, "_attr_to_rest_field"): + cache_attr = f"_deserialized_{key}" + if hasattr(self, cache_attr): + rf = _get_rest_field(getattr(self, "_attr_to_rest_field"), key) + if rf: + value = self._data.get(key) + if isinstance(value, (dict, list, set)): + # For mutable types, serialize and return + # But also update _data with serialized form and clear flag + # so mutations via this returned value affect _data + serialized = _serialize(value, rf._format) + # If serialized form is same type (no transformation needed), + # return _data directly so mutations work + if isinstance(serialized, type(value)) and serialized == value: + return self._data.get(key) + # Otherwise return serialized copy and clear flag + try: + object.__delattr__(self, cache_attr) + except AttributeError: + pass + # Store serialized form back + self._data[key] = serialized + return serialized + return self._data.__getitem__(key) + + def __setitem__(self, key: str, value: typing.Any) -> None: + # Clear any cached deserialized value when setting through dictionary access + cache_attr = f"_deserialized_{key}" + try: + object.__delattr__(self, cache_attr) + except AttributeError: + pass + self._data.__setitem__(key, value) + + def __delitem__(self, key: str) -> None: + self._data.__delitem__(key) + + def __iter__(self) -> typing.Iterator[typing.Any]: + return self._data.__iter__() + + def __len__(self) -> int: + return self._data.__len__() + + def __ne__(self, other: typing.Any) -> bool: + return not self.__eq__(other) + + def keys(self) -> typing.KeysView[str]: + """ + :returns: a set-like object providing a view on D's keys + :rtype: ~typing.KeysView + """ + return self._data.keys() + + def values(self) -> typing.ValuesView[typing.Any]: + """ + :returns: an object providing a view on D's values + :rtype: ~typing.ValuesView + """ + return self._data.values() + + def items(self) -> typing.ItemsView[str, typing.Any]: + """ + :returns: set-like object providing a view on D's items + :rtype: ~typing.ItemsView + """ + return self._data.items() + + def get(self, key: str, default: typing.Any = None) -> typing.Any: + """ + Get the value for key if key is in the dictionary, else default. + :param str key: The key to look up. + :param any default: The value to return if key is not in the dictionary. Defaults to None + :returns: D[k] if k in D, else d. + :rtype: any + """ + try: + return self[key] + except KeyError: + return default + + @typing.overload + def pop(self, key: str) -> typing.Any: ... # pylint: disable=arguments-differ + + @typing.overload + def pop(self, key: str, default: _T) -> _T: ... # pylint: disable=signature-differs + + @typing.overload + def pop(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs + + def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Removes specified key and return the corresponding value. + :param str key: The key to pop. + :param any default: The value to return if key is not in the dictionary + :returns: The value corresponding to the key. + :rtype: any + :raises KeyError: If key is not found and default is not given. + """ + if default is _UNSET: + return self._data.pop(key) + return self._data.pop(key, default) + + def popitem(self) -> tuple[str, typing.Any]: + """ + Removes and returns some (key, value) pair + :returns: The (key, value) pair. + :rtype: tuple + :raises KeyError: if D is empty. + """ + return self._data.popitem() + + def clear(self) -> None: + """ + Remove all items from D. + """ + self._data.clear() + + def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: # pylint: disable=arguments-differ + """ + Updates D from mapping/iterable E and F. + :param any args: Either a mapping object or an iterable of key-value pairs. + """ + self._data.update(*args, **kwargs) + + @typing.overload + def setdefault(self, key: str, default: None = None) -> None: ... + + @typing.overload + def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs + + def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Same as calling D.get(k, d), and setting D[k]=d if k not found + :param str key: The key to look up. + :param any default: The value to set if key is not in the dictionary + :returns: D[k] if k in D, else d. + :rtype: any + """ + if default is _UNSET: + return self._data.setdefault(key) + return self._data.setdefault(key, default) + + def __eq__(self, other: typing.Any) -> bool: + if isinstance(other, _MyMutableMapping): + return self._data == other._data + try: + other_model = self.__class__(other) + except Exception: + return False + return self._data == other_model._data + + def __repr__(self) -> str: + return str(self._data) + + +def _is_model(obj: typing.Any) -> bool: + return getattr(obj, "_is_model", False) + + +def _serialize(o, format: typing.Optional[str] = None): # pylint: disable=too-many-return-statements + if isinstance(o, list): + if format in _ARRAY_ENCODE_MAPPING and all(isinstance(x, str) for x in o): + return _ARRAY_ENCODE_MAPPING[format].join(o) + return [_serialize(x, format) for x in o] + if isinstance(o, dict): + return {k: _serialize(v, format) for k, v in o.items()} + if isinstance(o, set): + return {_serialize(x, format) for x in o} + if isinstance(o, tuple): + return tuple(_serialize(x, format) for x in o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, format) + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, enum.Enum): + return o.value + if isinstance(o, int): + if format == "str": + return str(o) + return o + try: + # First try datetime.datetime + return _serialize_datetime(o, format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return o + + +def _get_rest_field(attr_to_rest_field: dict[str, "_RestField"], rest_name: str) -> typing.Optional["_RestField"]: + try: + return next(rf for rf in attr_to_rest_field.values() if rf._rest_name == rest_name) + except StopIteration: + return None + + +def _create_value(rf: typing.Optional["_RestField"], value: typing.Any) -> typing.Any: + if not rf: + return _serialize(value, None) + if rf._is_multipart_file_input: + return value + if rf._is_model: + return _deserialize(rf._type, value) + if isinstance(value, ET.Element): + value = _deserialize(rf._type, value) + return _serialize(value, rf._format) + + +class Model(_MyMutableMapping): + _is_model = True + # label whether current class's _attr_to_rest_field has been calculated + # could not see _attr_to_rest_field directly because subclass inherits it from parent class + _calculated: set[str] = set() + + def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: + class_name = self.__class__.__name__ + if len(args) > 1: + raise TypeError(f"{class_name}.__init__() takes 2 positional arguments but {len(args) + 1} were given") + dict_to_pass = { + rest_field._rest_name: rest_field._default + for rest_field in self._attr_to_rest_field.values() + if rest_field._default is not _UNSET + } + if args: + if isinstance(args[0], ET.Element): + dict_to_pass.update(self._init_from_xml(args[0])) + else: + dict_to_pass.update( + {k: _create_value(_get_rest_field(self._attr_to_rest_field, k), v) for k, v in args[0].items()} + ) + else: + non_attr_kwargs = [k for k in kwargs if k not in self._attr_to_rest_field] + if non_attr_kwargs: + # actual type errors only throw the first wrong keyword arg they see, so following that. + raise TypeError(f"{class_name}.__init__() got an unexpected keyword argument '{non_attr_kwargs[0]}'") + dict_to_pass.update( + { + self._attr_to_rest_field[k]._rest_name: _create_value(self._attr_to_rest_field[k], v) + for k, v in kwargs.items() + if v is not None + } + ) + super().__init__(dict_to_pass) + + def _init_from_xml(self, element: ET.Element) -> dict[str, typing.Any]: + """Deserialize an XML element into a dict mapping rest field names to values. + + :param ET.Element element: The XML element to deserialize from. + :returns: A dictionary of rest_name to deserialized value pairs. + :rtype: dict + """ + result: dict[str, typing.Any] = {} + model_meta = getattr(self, "_xml", {}) + existed_attr_keys: list[str] = [] + + for rf in self._attr_to_rest_field.values(): + prop_meta = getattr(rf, "_xml", {}) + xml_name = prop_meta.get("name", rf._rest_name) + xml_ns = _resolve_xml_ns(prop_meta, model_meta) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + # attribute + if prop_meta.get("attribute", False) and element.get(xml_name) is not None: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = _deserialize(rf._type, element.get(xml_name)) + continue + + # unwrapped element is array + if prop_meta.get("unwrapped", False): + # unwrapped array could either use prop items meta/prop meta + _items_name = prop_meta.get("itemsName") + if _items_name: + xml_name = _items_name + _items_ns = prop_meta.get("itemsNs") + if _items_ns is not None: + xml_ns = _items_ns + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + items = element.findall(xml_name) # pyright: ignore + if len(items) > 0: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = _deserialize(rf._type, items) + elif not rf._is_optional: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = [] + continue + + # text element is primitive type + if prop_meta.get("text", False): + if element.text is not None: + result[rf._rest_name] = _deserialize(rf._type, element.text) + continue + + # wrapped element could be normal property or array, it should only have one element + item = element.find(xml_name) + if item is not None: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = _deserialize(rf._type, item) + + # rest thing is additional properties + for e in element: + if e.tag not in existed_attr_keys: + result[e.tag] = _convert_element(e) + + return result + + def copy(self) -> "Model": + return Model(self.__dict__) + + def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: + if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated: + # we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping', + # 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object' + mros = cls.__mro__[:-9][::-1] # ignore parents, and reverse the mro order + attr_to_rest_field: dict[str, _RestField] = { # map attribute name to rest_field property + k: v for mro_class in mros for k, v in mro_class.__dict__.items() if k[0] != "_" and hasattr(v, "_type") + } + annotations = { + k: v + for mro_class in mros + if hasattr(mro_class, "__annotations__") + for k, v in mro_class.__annotations__.items() + } + for attr, rf in attr_to_rest_field.items(): + rf._module = cls.__module__ + if not rf._type: + rf._type = rf._get_deserialize_callable_from_annotation(annotations.get(attr, None)) + if not rf._rest_name_input: + rf._rest_name_input = attr + cls._attr_to_rest_field: dict[str, _RestField] = dict(attr_to_rest_field.items()) + cls._backcompat_attr_to_rest_field: dict[str, _RestField] = { + Model._get_backcompat_attribute_name(cls._attr_to_rest_field, attr): rf + for attr, rf in cls._attr_to_rest_field.items() + } + cls._calculated.add(f"{cls.__module__}.{cls.__qualname__}") + + return super().__new__(cls) + + def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None: + for base in cls.__bases__: + if hasattr(base, "__mapping__"): + base.__mapping__[discriminator or cls.__name__] = cls # type: ignore + + @classmethod + def _get_backcompat_attribute_name(cls, attr_to_rest_field: dict[str, "_RestField"], attr_name: str) -> str: + rest_field_obj = attr_to_rest_field.get(attr_name) # pylint: disable=protected-access + if rest_field_obj is None: + return attr_name + original_tsp_name = getattr(rest_field_obj, "_original_tsp_name", None) # pylint: disable=protected-access + if original_tsp_name: + return original_tsp_name + return attr_name + + @classmethod + def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]: + for v in cls.__dict__.values(): + if isinstance(v, _RestField) and v._is_discriminator and v._rest_name not in exist_discriminators: + return v + return None + + @classmethod + def _deserialize(cls, data, exist_discriminators): + if not hasattr(cls, "__mapping__"): + return cls(data) + discriminator = cls._get_discriminator(exist_discriminators) + if discriminator is None: + return cls(data) + exist_discriminators.append(discriminator._rest_name) + if isinstance(data, ET.Element): + model_meta = getattr(cls, "_xml", {}) + prop_meta = getattr(discriminator, "_xml", {}) + xml_name = prop_meta.get("name", discriminator._rest_name) + xml_ns = _resolve_xml_ns(prop_meta, model_meta) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + if data.get(xml_name) is not None: + discriminator_value = data.get(xml_name) + else: + discriminator_value = data.find(xml_name).text # pyright: ignore + else: + discriminator_value = data.get(discriminator._rest_name) + mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore # pylint: disable=no-member + return mapped_cls._deserialize(data, exist_discriminators) + + def as_dict(self, *, exclude_readonly: bool = False) -> dict[str, typing.Any]: + """Return a dict that can be turned into json using json.dump. + + :keyword bool exclude_readonly: Whether to remove the readonly properties. + :returns: A dict JSON compatible object + :rtype: dict + """ + + result = {} + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in self._attr_to_rest_field.values() if _is_readonly(p)] + for k, v in self.items(): + if exclude_readonly and k in readonly_props: # pyright: ignore + continue + is_multipart_file_input = False + try: + is_multipart_file_input = next( + rf for rf in self._attr_to_rest_field.values() if rf._rest_name == k + )._is_multipart_file_input + except StopIteration: + pass + result[k] = v if is_multipart_file_input else Model._as_dict_value(v, exclude_readonly=exclude_readonly) + return result + + @staticmethod + def _as_dict_value(v: typing.Any, exclude_readonly: bool = False) -> typing.Any: + if v is None or isinstance(v, _Null): + return None + if isinstance(v, (list, tuple, set)): + return type(v)(Model._as_dict_value(x, exclude_readonly=exclude_readonly) for x in v) + if isinstance(v, dict): + return {dk: Model._as_dict_value(dv, exclude_readonly=exclude_readonly) for dk, dv in v.items()} + return v.as_dict(exclude_readonly=exclude_readonly) if hasattr(v, "as_dict") else v + + +def _deserialize_model(model_deserializer: typing.Optional[typing.Callable], obj): + if _is_model(obj): + return obj + return _deserialize(model_deserializer, obj) + + +def _deserialize_with_optional(if_obj_deserializer: typing.Optional[typing.Callable], obj): + if obj is None: + return obj + return _deserialize_with_callable(if_obj_deserializer, obj) + + +def _deserialize_with_union(deserializers, obj): + for deserializer in deserializers: + try: + return _deserialize(deserializer, obj) + except DeserializationError: + pass + raise DeserializationError() + + +def _deserialize_dict( + value_deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj: dict[typing.Any, typing.Any], +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = {child.tag: child for child in obj} + return {k: _deserialize(value_deserializer, v, module) for k, v in obj.items()} + + +def _deserialize_multiple_sequence( + entry_deserializers: list[typing.Optional[typing.Callable]], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + return type(obj)(_deserialize(deserializer, entry, module) for entry, deserializer in zip(obj, entry_deserializers)) + + +def _is_array_encoded_deserializer(deserializer: functools.partial) -> bool: + return ( + isinstance(deserializer, functools.partial) + and isinstance(deserializer.args[0], functools.partial) + and deserializer.args[0].func == _deserialize_array_encoded # pylint: disable=comparison-with-callable + ) + + +def _deserialize_sequence( + deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = list(obj) + + # encoded string may be deserialized to sequence + if isinstance(obj, str) and isinstance(deserializer, functools.partial): + # for list[str] + if _is_array_encoded_deserializer(deserializer): + return deserializer(obj) + + # for list[Union[...]] + if isinstance(deserializer.args[0], list): + for sub_deserializer in deserializer.args[0]: + if _is_array_encoded_deserializer(sub_deserializer): + return sub_deserializer(obj) + + return type(obj)(_deserialize(deserializer, entry, module) for entry in obj) + + +def _sorted_annotations(types: list[typing.Any]) -> list[typing.Any]: + return sorted( + types, + key=lambda x: hasattr(x, "__name__") and x.__name__.lower() in ("str", "float", "int", "bool"), + ) + + +def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-statements, too-many-branches + annotation: typing.Any, + module: typing.Optional[str], + rf: typing.Optional["_RestField"] = None, +) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + if not annotation: + return None + + # is it a type alias? + if isinstance(annotation, str): + if module is not None: + annotation = _get_type_alias_type(module, annotation) + + # is it a forward ref / in quotes? + if isinstance(annotation, (str, typing.ForwardRef)): + try: + model_name = annotation.__forward_arg__ # type: ignore + except AttributeError: + model_name = annotation + if module is not None: + annotation = _get_model(module, model_name) # type: ignore + + try: + if module and _is_model(annotation): + if rf: + rf._is_model = True + + return functools.partial(_deserialize_model, annotation) # pyright: ignore + except Exception: + pass + + # is it a literal? + try: + if annotation.__origin__ is typing.Literal: # pyright: ignore + return None + except AttributeError: + pass + + # is it optional? + try: + if any(a is _NONE_TYPE for a in annotation.__args__): # pyright: ignore + if rf: + rf._is_optional = True + if len(annotation.__args__) <= 2: # pyright: ignore + if_obj_deserializer = _get_deserialize_callable_from_annotation( + next(a for a in annotation.__args__ if a is not _NONE_TYPE), module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_with_optional, if_obj_deserializer) + # the type is Optional[Union[...]], we need to remove the None type from the Union + annotation_copy = copy.copy(annotation) + annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a is not _NONE_TYPE] # pyright: ignore + return _get_deserialize_callable_from_annotation(annotation_copy, module, rf) + except AttributeError: + pass + + # is it union? + if getattr(annotation, "__origin__", None) is typing.Union: + # initial ordering is we make `string` the last deserialization option, because it is often them most generic + deserializers = [ + _get_deserialize_callable_from_annotation(arg, module, rf) + for arg in _sorted_annotations(annotation.__args__) # pyright: ignore + ] + + return functools.partial(_deserialize_with_union, deserializers) + + try: + annotation_name = ( + annotation.__name__ if hasattr(annotation, "__name__") else annotation._name # pyright: ignore + ) + if annotation_name.lower() == "dict": + value_deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[1], module, rf # pyright: ignore + ) + + return functools.partial( + _deserialize_dict, + value_deserializer, + module, + ) + except (AttributeError, IndexError): + pass + try: + annotation_name = ( + annotation.__name__ if hasattr(annotation, "__name__") else annotation._name # pyright: ignore + ) + if annotation_name.lower() in ["list", "set", "tuple", "sequence"]: + if len(annotation.__args__) > 1: # pyright: ignore + entry_deserializers = [ + _get_deserialize_callable_from_annotation(dt, module, rf) + for dt in annotation.__args__ # pyright: ignore + ] + return functools.partial(_deserialize_multiple_sequence, entry_deserializers, module) + deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[0], module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_sequence, deserializer, module) + except (TypeError, IndexError, AttributeError, SyntaxError): + pass + + def _deserialize_default( + deserializer, + obj, + ): + if obj is None: + return obj + try: + return _deserialize_with_callable(deserializer, obj) + except Exception: + pass + return obj + + if get_deserializer(annotation, rf): + return functools.partial(_deserialize_default, get_deserializer(annotation, rf)) + + return functools.partial(_deserialize_default, annotation) + + +def _deserialize_with_callable( + deserializer: typing.Optional[typing.Callable[[typing.Any], typing.Any]], + value: typing.Any, +): # pylint: disable=too-many-return-statements + try: + if value is None or isinstance(value, _Null): + return None + if isinstance(value, ET.Element): + if deserializer is str: + return value.text or "" + if deserializer is int: + return int(value.text) if value.text else None + if deserializer is float: + return float(value.text) if value.text else None + if deserializer is bool: + return value.text == "true" if value.text else None + if deserializer and deserializer in _DESERIALIZE_MAPPING.values(): + return deserializer(value.text) if value.text else None + if deserializer and deserializer in _DESERIALIZE_MAPPING_WITHFORMAT.values(): + return deserializer(value.text) if value.text else None + if deserializer is None: + return value + if deserializer in [int, float, bool]: + return deserializer(value) + if isinstance(deserializer, CaseInsensitiveEnumMeta): + try: + return deserializer(value.text if isinstance(value, ET.Element) else value) + except ValueError: + # for unknown value, return raw value + return value.text if isinstance(value, ET.Element) else value + if isinstance(deserializer, type) and issubclass(deserializer, Model): + return deserializer._deserialize(value, []) + return typing.cast(typing.Callable[[typing.Any], typing.Any], deserializer)(value) + except Exception as e: + raise DeserializationError() from e + + +def _deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + if isinstance(value, PipelineResponse): + value = value.http_response.json() + if rf is None and format: + rf = _RestField(format=format) + if not isinstance(deserializer, functools.partial): + deserializer = _get_deserialize_callable_from_annotation(deserializer, module, rf) + return _deserialize_with_callable(deserializer, value) + + +def _failsafe_deserialize( + deserializer: typing.Any, + response: HttpResponse, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + try: + return _deserialize(deserializer, response.json(), module, rf, format) + except Exception: # pylint: disable=broad-except + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +def _failsafe_deserialize_xml( + deserializer: typing.Any, + response: HttpResponse, +) -> typing.Any: + try: + return _deserialize_xml(deserializer, response.text()) + except Exception: # pylint: disable=broad-except + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +# pylint: disable=too-many-instance-attributes +class _RestField: + def __init__( + self, + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + is_discriminator: bool = False, + visibility: typing.Optional[list[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[dict[str, typing.Any]] = None, + original_tsp_name: typing.Optional[str] = None, + ): + self._type = type + self._rest_name_input = name + self._module: typing.Optional[str] = None + self._is_discriminator = is_discriminator + self._visibility = visibility + self._is_model = False + self._is_optional = False + self._default = default + self._format = format + self._is_multipart_file_input = is_multipart_file_input + self._xml = xml if xml is not None else {} + self._original_tsp_name = original_tsp_name + + @property + def _class_type(self) -> typing.Any: + result = getattr(self._type, "args", [None])[0] + # type may be wrapped by nested functools.partial so we need to check for that + if isinstance(result, functools.partial): + return getattr(result, "args", [None])[0] + return result + + @property + def _rest_name(self) -> str: + if self._rest_name_input is None: + raise ValueError("Rest name was never set") + return self._rest_name_input + + def __get__(self, obj: Model, type=None): # pylint: disable=redefined-builtin + # by this point, type and rest_name will have a value bc we default + # them in __new__ of the Model class + # Use _data.get() directly to avoid triggering __getitem__ which clears the cache + item = obj._data.get(self._rest_name) + if item is None: + return item + if self._is_model: + return item + + # For mutable types, we want mutations to directly affect _data + # Check if we've already deserialized this value + cache_attr = f"_deserialized_{self._rest_name}" + if hasattr(obj, cache_attr): + # Return the value from _data directly (it's been deserialized in place) + return obj._data.get(self._rest_name) + + deserialized = _deserialize(self._type, _serialize(item, self._format), rf=self) + + # For mutable types, store the deserialized value back in _data + # so mutations directly affect _data + if isinstance(deserialized, (dict, list, set)): + obj._data[self._rest_name] = deserialized + object.__setattr__(obj, cache_attr, True) # Mark as deserialized + return deserialized + + return deserialized + + def __set__(self, obj: Model, value) -> None: + # Clear the cached deserialized object when setting a new value + cache_attr = f"_deserialized_{self._rest_name}" + if hasattr(obj, cache_attr): + object.__delattr__(obj, cache_attr) + + if value is None: + # we want to wipe out entries if users set attr to None + try: + obj.__delitem__(self._rest_name) + except KeyError: + pass + return + if self._is_model: + if not _is_model(value): + value = _deserialize(self._type, value) + obj.__setitem__(self._rest_name, value) + return + obj.__setitem__(self._rest_name, _serialize(value, self._format)) + + def _get_deserialize_callable_from_annotation( + self, annotation: typing.Any + ) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + return _get_deserialize_callable_from_annotation(annotation, self._module, self) + + +def rest_field( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[list[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[dict[str, typing.Any]] = None, + original_tsp_name: typing.Optional[str] = None, +) -> typing.Any: + return _RestField( + name=name, + type=type, + visibility=visibility, + default=default, + format=format, + is_multipart_file_input=is_multipart_file_input, + xml=xml, + original_tsp_name=original_tsp_name, + ) + + +def rest_discriminator( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[list[str]] = None, + xml: typing.Optional[dict[str, typing.Any]] = None, +) -> typing.Any: + return _RestField(name=name, type=type, is_discriminator=True, visibility=visibility, xml=xml) + + +def serialize_xml(model: Model, exclude_readonly: bool = False) -> str: + """Serialize a model to XML. + + :param Model model: The model to serialize. + :param bool exclude_readonly: Whether to exclude readonly properties. + :returns: The XML representation of the model. + :rtype: str + """ + return ET.tostring(_get_element(model, exclude_readonly), encoding="unicode") # type: ignore + + +def _get_xml_ns(meta: dict[str, typing.Any]) -> typing.Optional[str]: + """Return the XML namespace from a metadata dict, checking both 'ns' (old-style) and 'namespace' (DPG) keys. + + :param dict meta: The metadata dictionary to extract namespace from. + :returns: The namespace string if 'ns' or 'namespace' key is present, None otherwise. + :rtype: str or None + """ + ns = meta.get("ns") + if ns is None: + ns = meta.get("namespace") + return ns + + +def _resolve_xml_ns( + prop_meta: dict[str, typing.Any], model_meta: typing.Optional[dict[str, typing.Any]] = None +) -> typing.Optional[str]: + """Resolve XML namespace for a property, falling back to model namespace when appropriate. + + Checks the property metadata first; if no namespace is found and the model does not declare + an explicit prefix, falls back to the model-level namespace. + + :param dict prop_meta: The property metadata dictionary. + :param dict model_meta: The model metadata dictionary, used as fallback. + :returns: The resolved namespace string, or None. + :rtype: str or None + """ + ns = _get_xml_ns(prop_meta) + if ns is None and model_meta is not None and not model_meta.get("prefix"): + ns = _get_xml_ns(model_meta) + return ns + + +def _set_xml_attribute(element: ET.Element, name: str, value: typing.Any, prop_meta: dict[str, typing.Any]) -> None: + """Set an XML attribute on an element, handling namespace prefix registration. + + :param ET.Element element: The element to set the attribute on. + :param str name: The default attribute name (wire name). + :param any value: The attribute value. + :param dict prop_meta: The property metadata dictionary. + """ + xml_name = prop_meta.get("name", name) + _attr_ns = _get_xml_ns(prop_meta) + if _attr_ns: + _attr_prefix = prop_meta.get("prefix") + if _attr_prefix: + _safe_register_namespace(_attr_prefix, _attr_ns) + xml_name = "{" + _attr_ns + "}" + xml_name + element.set(xml_name, _get_primitive_type_value(value)) + + +def _get_element( + o: typing.Any, + exclude_readonly: bool = False, + parent_meta: typing.Optional[dict[str, typing.Any]] = None, + wrapped_element: typing.Optional[ET.Element] = None, +) -> typing.Union[ET.Element, list[ET.Element]]: + if _is_model(o): + model_meta = getattr(o, "_xml", {}) + + # if prop is a model, then use the prop element directly, else generate a wrapper of model + if wrapped_element is None: + # When serializing as an array item (parent_meta is set), check if the parent has an + # explicit itemsName. This ensures correct element names for unwrapped arrays (where + # the element tag is the property/items name, not the model type name). + _items_name = parent_meta.get("itemsName") if parent_meta is not None else None + element_name = _items_name if _items_name else (model_meta.get("name") or o.__class__.__name__) + _model_ns = _get_xml_ns(model_meta) + wrapped_element = _create_xml_element( + element_name, + model_meta.get("prefix"), + _model_ns, + ) + + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + + for k, v in o.items(): + # do not serialize readonly properties + if exclude_readonly and k in readonly_props: + continue + + prop_rest_field = _get_rest_field(o._attr_to_rest_field, k) + if prop_rest_field: + prop_meta = getattr(prop_rest_field, "_xml").copy() + # use the wire name as xml name if no specific name is set + if prop_meta.get("name") is None: + prop_meta["name"] = k + else: + # additional properties will not have rest field, use the wire name as xml name + prop_meta = {"name": k} + + # Propagate model namespace to properties only for old-style "ns"-keyed models. + # DPG-generated models use the "namespace" key and explicitly declare namespace on + # each property that needs it, so propagation is intentionally skipped for them. + if prop_meta.get("ns") is None and model_meta.get("ns"): + prop_meta["ns"] = model_meta.get("ns") + prop_meta["prefix"] = model_meta.get("prefix") + + if prop_meta.get("unwrapped", False): + # unwrapped could only set on array + wrapped_element.extend(_get_element(v, exclude_readonly, prop_meta)) + elif prop_meta.get("text", False): + # text could only set on primitive type + wrapped_element.text = _get_primitive_type_value(v) + elif prop_meta.get("attribute", False): + _set_xml_attribute(wrapped_element, k, v, prop_meta) + else: + # other wrapped prop element + wrapped_element.append(_get_wrapped_element(v, exclude_readonly, prop_meta)) + return wrapped_element + if isinstance(o, list): + return [_get_element(x, exclude_readonly, parent_meta) for x in o] # type: ignore + if isinstance(o, dict): + result = [] + _dict_ns = _get_xml_ns(parent_meta) if parent_meta else None + for k, v in o.items(): + result.append( + _get_wrapped_element( + v, + exclude_readonly, + { + "name": k, + "ns": _dict_ns, + "prefix": parent_meta.get("prefix") if parent_meta else None, + }, + ) + ) + return result + + # primitive case need to create element based on parent_meta + if parent_meta: + _items_ns = parent_meta.get("itemsNs") + if _items_ns is None: + _items_ns = _get_xml_ns(parent_meta) + return _get_wrapped_element( + o, + exclude_readonly, + { + "name": parent_meta.get("itemsName", parent_meta.get("name")), + "prefix": parent_meta.get("itemsPrefix", parent_meta.get("prefix")), + "ns": _items_ns, + }, + ) + + raise ValueError("Could not serialize value into xml: " + o) + + +def _get_wrapped_element( + v: typing.Any, + exclude_readonly: bool, + meta: typing.Optional[dict[str, typing.Any]], +) -> ET.Element: + _meta_ns = _get_xml_ns(meta) if meta else None + wrapped_element = _create_xml_element( + meta.get("name") if meta else None, meta.get("prefix") if meta else None, _meta_ns + ) + if isinstance(v, (dict, list)): + wrapped_element.extend(_get_element(v, exclude_readonly, meta)) + elif _is_model(v): + _get_element(v, exclude_readonly, meta, wrapped_element) + else: + wrapped_element.text = _get_primitive_type_value(v) + return wrapped_element # type: ignore[no-any-return] + + +def _get_primitive_type_value(v) -> str: + if v is True: + return "true" + if v is False: + return "false" + if isinstance(v, _Null): + return "" + return str(v) + + +def _safe_register_namespace(prefix: str, ns: str) -> None: + """Register an XML namespace prefix, handling reserved prefix patterns. + + Some prefixes (e.g. 'ns2') match Python's reserved 'ns\\d+' pattern used for + auto-generated prefixes, causing register_namespace to raise ValueError. + Falls back to directly registering in the internal namespace map. + + :param str prefix: The namespace prefix to register. + :param str ns: The namespace URI. + """ + try: + ET.register_namespace(prefix, ns) + except ValueError: + _ns_map = getattr(ET, "_namespace_map", None) + if _ns_map is not None: + _ns_map[ns] = prefix + + +def _create_xml_element( + tag: typing.Any, prefix: typing.Optional[str] = None, ns: typing.Optional[str] = None +) -> ET.Element: + if prefix and ns: + _safe_register_namespace(prefix, ns) + if ns: + return ET.Element("{" + ns + "}" + tag) + return ET.Element(tag) + + +def _deserialize_xml( + deserializer: typing.Any, + value: str, +) -> typing.Any: + element = ET.fromstring(value) # nosec + return _deserialize(deserializer, element) + + +def _convert_element(e: ET.Element): + # dict case + if len(e.attrib) > 0 or len({child.tag for child in e}) > 1: + dict_result: dict[str, typing.Any] = {} + for child in e: + if dict_result.get(child.tag) is not None: + if isinstance(dict_result[child.tag], list): + dict_result[child.tag].append(_convert_element(child)) + else: + dict_result[child.tag] = [dict_result[child.tag], _convert_element(child)] + else: + dict_result[child.tag] = _convert_element(child) + dict_result.update(e.attrib) + return dict_result + # array case + if len(e) > 0: + array_result: list[typing.Any] = [] + for child in e: + array_result.append(_convert_element(child)) + return array_result + # primitive case + return e.text diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_utils/serialization.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_utils/serialization.py index 5f250836cf4b..81ec1de5922b 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_utils/serialization.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_utils/serialization.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -787,7 +787,7 @@ def serialize_data(self, data, data_type, **kwargs): # If dependencies is empty, try with current data class # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) + enum_type = self.dependencies.get(data_type, cast(type, data.__class__)) if issubclass(enum_type, Enum): return Serializer.serialize_enum(data, enum_obj=enum_type) @@ -821,13 +821,20 @@ def serialize_basic(cls, data, data_type, **kwargs): :param str data_type: Type of object in the iterable. :rtype: str, int, float, bool :return: serialized object + :raises TypeError: raise if data_type is not one of str, int, float, bool. """ custom_serializer = cls._get_custom_serializers(data_type, **kwargs) if custom_serializer: return custom_serializer(data) if data_type == "str": return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec # pylint: disable=eval-used + if data_type == "int": + return int(data) + if data_type == "float": + return float(data) + if data_type == "bool": + return bool(data) + raise TypeError("Unknown basic data type: {}".format(data_type)) @classmethod def serialize_unicode(cls, data): @@ -1757,7 +1764,7 @@ def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return :param str data_type: deserialization data type. :return: Deserialized basic type. :rtype: str, int, float or bool - :raises TypeError: if string format is not valid. + :raises TypeError: if string format is not valid or data_type is not one of str, int, float, bool. """ # If we're here, data is supposed to be a basic type. # If it's still an XML node, take the text @@ -1783,7 +1790,11 @@ def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return if data_type == "str": return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec # pylint: disable=eval-used + if data_type == "int": + return int(attr) + if data_type == "float": + return float(attr) + raise TypeError("Unknown basic data type: {}".format(data_type)) @staticmethod def deserialize_unicode(data): diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_validation.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_validation.py new file mode 100644 index 000000000000..f5af3a4eb8a2 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_validation.py @@ -0,0 +1,66 @@ +# -------------------------------------------------------------------------- +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools + + +def api_version_validation(**kwargs): + params_added_on = kwargs.pop("params_added_on", {}) + method_added_on = kwargs.pop("method_added_on", "") + api_versions_list = kwargs.pop("api_versions_list", []) + + def _index_with_default(value: str, default: int = -1) -> int: + """Get the index of value in lst, or return default if not found. + + :param value: The value to search for in the api_versions_list. + :type value: str + :param default: The default value to return if the value is not found. + :type default: int + :return: The index of the value in the list, or the default value if not found. + :rtype: int + """ + try: + return api_versions_list.index(value) + except ValueError: + return default + + def decorator(func): + @functools.wraps(func) + def wrapper(*args, **kwargs): + try: + # this assumes the client has an _api_version attribute + client = args[0] + client_api_version = client._config.api_version # pylint: disable=protected-access + except AttributeError: + return func(*args, **kwargs) + + if _index_with_default(method_added_on) > _index_with_default(client_api_version): + raise ValueError( + f"'{func.__name__}' is not available in API version " + f"{client_api_version}. Pass service API version {method_added_on} or newer to your client." + ) + + unsupported = { + parameter: api_version + for api_version, parameters in params_added_on.items() + for parameter in parameters + if parameter in kwargs and _index_with_default(api_version) > _index_with_default(client_api_version) + } + if unsupported: + raise ValueError( + "".join( + [ + f"'{param}' is not available in API version {client_api_version}. " + f"Use service API version {version} or newer.\n" + for param, version in unsupported.items() + ] + ) + ) + return func(*args, **kwargs) + + return wrapper + + return decorator 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 f4d8c1dbf0d5..c4b6891834b3 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_version.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_version.py @@ -2,8 +2,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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0b24" +VERSION = "4.0.0b25" diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/__init__.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/__init__.py index 387f4a1f8f8a..f61f8599d104 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/__init__.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/__init__.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -12,7 +12,7 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._sql_management_client import SqlManagementClient # type: ignore +from ._client import SqlManagementClient # type: ignore try: from ._patch import __all__ as _patch_all 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/_client.py similarity index 96% rename from sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/_sql_management_client.py rename to sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/_client.py index b513a77a301c..978df2b25d56 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/_client.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -18,7 +18,6 @@ from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from azure.mgmt.core.tools import get_arm_endpoints -from .. import models as _models from .._utils.serialization import Deserializer, Serializer from ._configuration import SqlManagementClientConfiguration from .operations import ( @@ -52,8 +51,6 @@ DatabasesOperations, DeletedServersOperations, DistributedAvailabilityGroupsOperations, - ElasticPoolActivitiesOperations, - ElasticPoolDatabaseActivitiesOperations, ElasticPoolOperationsOperations, ElasticPoolsOperations, EncryptionProtectorsOperations, @@ -65,6 +62,7 @@ GeoBackupPoliciesOperations, IPv6FirewallRulesOperations, InstanceFailoverGroupsOperations, + InstancePoolOperationsOperations, InstancePoolsOperations, JobAgentsOperations, JobCredentialsOperations, @@ -116,6 +114,7 @@ ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations, ManagedServerDnsAliasesOperations, ManagedServerSecurityAlertPoliciesOperations, + NetworkSecurityPerimeterConfigurationsOperations, Operations, OutboundFirewallRulesOperations, PrivateEndpointConnectionsOperations, @@ -134,7 +133,6 @@ ServerAzureADAdministratorsOperations, ServerAzureADOnlyAuthenticationsOperations, ServerBlobAuditingPoliciesOperations, - ServerCommunicationLinksOperations, ServerConfigurationOptionsOperations, ServerConnectionPoliciesOperations, ServerDevOpsAuditSettingsOperations, @@ -147,7 +145,6 @@ ServerUsagesOperations, ServerVulnerabilityAssessmentsOperations, ServersOperations, - ServiceObjectivesOperations, SqlAgentOperations, SqlVulnerabilityAssessmentBaselineOperations, SqlVulnerabilityAssessmentBaselinesOperations, @@ -179,137 +176,186 @@ from azure.core.credentials_async import AsyncTokenCredential -class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes - """The Azure SQL Database management API provides a RESTful set of web services that interact with - Azure SQL Database services to manage your databases. The API enables you to create, retrieve, - update, and delete databases. +class SqlManagementClient: # pylint: disable=too-many-instance-attributes + """The Azure SQL Database management API provides a RESTful set of web APIs that interact with + Azure SQL Database services to manage your databases. The API enables users to create, + retrieve, update, and delete databases, servers, and other entities. - :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 database_advisors: DatabaseAdvisorsOperations operations - :vartype database_advisors: azure.mgmt.sql.aio.operations.DatabaseAdvisorsOperations - :ivar database_automatic_tuning: DatabaseAutomaticTuningOperations operations - :vartype database_automatic_tuning: - azure.mgmt.sql.aio.operations.DatabaseAutomaticTuningOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.sql.aio.operations.Operations + :ivar backup_short_term_retention_policies: BackupShortTermRetentionPoliciesOperations + operations + :vartype backup_short_term_retention_policies: + azure.mgmt.sql.aio.operations.BackupShortTermRetentionPoliciesOperations :ivar database_columns: DatabaseColumnsOperations operations :vartype database_columns: azure.mgmt.sql.aio.operations.DatabaseColumnsOperations - :ivar database_recommended_actions: DatabaseRecommendedActionsOperations operations - :vartype database_recommended_actions: - azure.mgmt.sql.aio.operations.DatabaseRecommendedActionsOperations + :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 databases: DatabasesOperations operations + :vartype databases: azure.mgmt.sql.aio.operations.DatabasesOperations + :ivar firewall_rules: FirewallRulesOperations operations + :vartype firewall_rules: azure.mgmt.sql.aio.operations.FirewallRulesOperations + :ivar replication_links: ReplicationLinksOperations operations + :vartype replication_links: azure.mgmt.sql.aio.operations.ReplicationLinksOperations + :ivar servers: ServersOperations operations + :vartype servers: azure.mgmt.sql.aio.operations.ServersOperations + :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 server_advisors: ServerAdvisorsOperations operations + :vartype server_advisors: azure.mgmt.sql.aio.operations.ServerAdvisorsOperations + :ivar managed_database_columns: ManagedDatabaseColumnsOperations operations + :vartype managed_database_columns: + azure.mgmt.sql.aio.operations.ManagedDatabaseColumnsOperations + :ivar database_tables: DatabaseTablesOperations operations + :vartype database_tables: azure.mgmt.sql.aio.operations.DatabaseTablesOperations + :ivar managed_database_tables: ManagedDatabaseTablesOperations operations + :vartype managed_database_tables: azure.mgmt.sql.aio.operations.ManagedDatabaseTablesOperations :ivar database_schemas: DatabaseSchemasOperations operations :vartype database_schemas: azure.mgmt.sql.aio.operations.DatabaseSchemasOperations + :ivar managed_database_schemas: ManagedDatabaseSchemasOperations operations + :vartype managed_database_schemas: + azure.mgmt.sql.aio.operations.ManagedDatabaseSchemasOperations :ivar database_security_alert_policies: DatabaseSecurityAlertPoliciesOperations operations :vartype database_security_alert_policies: azure.mgmt.sql.aio.operations.DatabaseSecurityAlertPoliciesOperations - :ivar database_tables: DatabaseTablesOperations operations - :vartype database_tables: azure.mgmt.sql.aio.operations.DatabaseTablesOperations + :ivar sql_vulnerability_assessment_baseline: SqlVulnerabilityAssessmentBaselineOperations + operations + :vartype sql_vulnerability_assessment_baseline: + azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentBaselineOperations + :ivar sql_vulnerability_assessments: SqlVulnerabilityAssessmentsOperations operations + :vartype sql_vulnerability_assessments: + azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentsOperations + :ivar sql_vulnerability_assessments_settings: SqlVulnerabilityAssessmentsSettingsOperations + operations + :vartype sql_vulnerability_assessments_settings: + azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentsSettingsOperations + :ivar database_sql_vulnerability_assessment_rule_baselines: + DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations operations + :vartype database_sql_vulnerability_assessment_rule_baselines: + azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations + :ivar sql_vulnerability_assessment_rule_baseline: + SqlVulnerabilityAssessmentRuleBaselineOperations operations + :vartype sql_vulnerability_assessment_rule_baseline: + azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentRuleBaselineOperations + :ivar database_sql_vulnerability_assessment_scan_result: + DatabaseSqlVulnerabilityAssessmentScanResultOperations operations + :vartype database_sql_vulnerability_assessment_scan_result: + azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentScanResultOperations + :ivar sql_vulnerability_assessment_scan_result: SqlVulnerabilityAssessmentScanResultOperations + operations + :vartype sql_vulnerability_assessment_scan_result: + azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentScanResultOperations + :ivar sql_vulnerability_assessment_scans: SqlVulnerabilityAssessmentScansOperations operations + :vartype sql_vulnerability_assessment_scans: + azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentScansOperations :ivar database_vulnerability_assessment_rule_baselines: DatabaseVulnerabilityAssessmentRuleBaselinesOperations operations :vartype database_vulnerability_assessment_rule_baselines: azure.mgmt.sql.aio.operations.DatabaseVulnerabilityAssessmentRuleBaselinesOperations + :ivar managed_database_vulnerability_assessment_rule_baselines: + ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations operations + :vartype managed_database_vulnerability_assessment_rule_baselines: + azure.mgmt.sql.aio.operations.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations :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 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 data_masking_policies: DataMaskingPoliciesOperations operations + :vartype data_masking_policies: azure.mgmt.sql.aio.operations.DataMaskingPoliciesOperations :ivar deleted_servers: DeletedServersOperations operations :vartype deleted_servers: azure.mgmt.sql.aio.operations.DeletedServersOperations - :ivar elastic_pool_operations: ElasticPoolOperationsOperations operations - :vartype elastic_pool_operations: azure.mgmt.sql.aio.operations.ElasticPoolOperationsOperations + :ivar distributed_availability_groups: DistributedAvailabilityGroupsOperations operations + :vartype distributed_availability_groups: + azure.mgmt.sql.aio.operations.DistributedAvailabilityGroupsOperations + :ivar managed_databases: ManagedDatabasesOperations operations + :vartype managed_databases: azure.mgmt.sql.aio.operations.ManagedDatabasesOperations + :ivar server_trust_groups: ServerTrustGroupsOperations operations + :vartype server_trust_groups: azure.mgmt.sql.aio.operations.ServerTrustGroupsOperations + :ivar managed_instances: ManagedInstancesOperations operations + :vartype managed_instances: azure.mgmt.sql.aio.operations.ManagedInstancesOperations + :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 firewall_rules: FirewallRulesOperations operations - :vartype firewall_rules: azure.mgmt.sql.aio.operations.FirewallRulesOperations + :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 geo_backup_policies: GeoBackupPoliciesOperations operations + :vartype geo_backup_policies: azure.mgmt.sql.aio.operations.GeoBackupPoliciesOperations + :ivar instance_failover_groups: InstanceFailoverGroupsOperations operations + :vartype instance_failover_groups: + azure.mgmt.sql.aio.operations.InstanceFailoverGroupsOperations + :ivar instance_pool_operations: InstancePoolOperationsOperations operations + :vartype instance_pool_operations: + azure.mgmt.sql.aio.operations.InstancePoolOperationsOperations + :ivar instance_pools: InstancePoolsOperations operations + :vartype instance_pools: azure.mgmt.sql.aio.operations.InstancePoolsOperations + :ivar ipv6_firewall_rules: IPv6FirewallRulesOperations operations + :vartype ipv6_firewall_rules: azure.mgmt.sql.aio.operations.IPv6FirewallRulesOperations + :ivar job_executions: JobExecutionsOperations operations + :vartype job_executions: azure.mgmt.sql.aio.operations.JobExecutionsOperations :ivar job_agents: JobAgentsOperations operations :vartype job_agents: azure.mgmt.sql.aio.operations.JobAgentsOperations :ivar job_credentials: JobCredentialsOperations operations :vartype job_credentials: azure.mgmt.sql.aio.operations.JobCredentialsOperations - :ivar job_executions: JobExecutionsOperations operations - :vartype job_executions: azure.mgmt.sql.aio.operations.JobExecutionsOperations - :ivar job_private_endpoints: JobPrivateEndpointsOperations operations - :vartype job_private_endpoints: azure.mgmt.sql.aio.operations.JobPrivateEndpointsOperations - :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 - :vartype job_steps: azure.mgmt.sql.aio.operations.JobStepsOperations :ivar job_target_executions: JobTargetExecutionsOperations operations :vartype job_target_executions: azure.mgmt.sql.aio.operations.JobTargetExecutionsOperations + :ivar jobs: JobsOperations operations + :vartype jobs: azure.mgmt.sql.aio.operations.JobsOperations + :ivar job_private_endpoints: JobPrivateEndpointsOperations operations + :vartype job_private_endpoints: azure.mgmt.sql.aio.operations.JobPrivateEndpointsOperations + :ivar job_steps: JobStepsOperations operations + :vartype job_steps: azure.mgmt.sql.aio.operations.JobStepsOperations :ivar job_target_groups: JobTargetGroupsOperations operations :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 capabilities: CapabilitiesOperations operations - :vartype capabilities: azure.mgmt.sql.aio.operations.CapabilitiesOperations - :ivar maintenance_window_options: MaintenanceWindowOptionsOperations operations - :vartype maintenance_window_options: - azure.mgmt.sql.aio.operations.MaintenanceWindowOptionsOperations - :ivar maintenance_windows: MaintenanceWindowsOperations operations - :vartype maintenance_windows: azure.mgmt.sql.aio.operations.MaintenanceWindowsOperations + :ivar 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 :ivar managed_backup_short_term_retention_policies: ManagedBackupShortTermRetentionPoliciesOperations operations :vartype managed_backup_short_term_retention_policies: azure.mgmt.sql.aio.operations.ManagedBackupShortTermRetentionPoliciesOperations - :ivar managed_database_columns: ManagedDatabaseColumnsOperations operations - :vartype managed_database_columns: - azure.mgmt.sql.aio.operations.ManagedDatabaseColumnsOperations - :ivar managed_database_queries: ManagedDatabaseQueriesOperations operations - :vartype managed_database_queries: - azure.mgmt.sql.aio.operations.ManagedDatabaseQueriesOperations - :ivar managed_database_schemas: ManagedDatabaseSchemasOperations operations - :vartype managed_database_schemas: - azure.mgmt.sql.aio.operations.ManagedDatabaseSchemasOperations + :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_database_security_alert_policies: ManagedDatabaseSecurityAlertPoliciesOperations operations :vartype managed_database_security_alert_policies: azure.mgmt.sql.aio.operations.ManagedDatabaseSecurityAlertPoliciesOperations - :ivar managed_database_security_events: ManagedDatabaseSecurityEventsOperations operations - :vartype managed_database_security_events: - azure.mgmt.sql.aio.operations.ManagedDatabaseSecurityEventsOperations - :ivar managed_database_tables: ManagedDatabaseTablesOperations operations - :vartype managed_database_tables: azure.mgmt.sql.aio.operations.ManagedDatabaseTablesOperations - :ivar managed_database_transparent_data_encryption: - ManagedDatabaseTransparentDataEncryptionOperations operations - :vartype managed_database_transparent_data_encryption: - azure.mgmt.sql.aio.operations.ManagedDatabaseTransparentDataEncryptionOperations - :ivar managed_database_vulnerability_assessment_rule_baselines: - ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations operations - :vartype managed_database_vulnerability_assessment_rule_baselines: - azure.mgmt.sql.aio.operations.ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations - :ivar managed_database_vulnerability_assessments: - ManagedDatabaseVulnerabilityAssessmentsOperations operations - :vartype managed_database_vulnerability_assessments: - azure.mgmt.sql.aio.operations.ManagedDatabaseVulnerabilityAssessmentsOperations - :ivar managed_database_vulnerability_assessment_scans: - ManagedDatabaseVulnerabilityAssessmentScansOperations operations - :vartype managed_database_vulnerability_assessment_scans: - azure.mgmt.sql.aio.operations.ManagedDatabaseVulnerabilityAssessmentScansOperations :ivar managed_instance_administrators: ManagedInstanceAdministratorsOperations operations :vartype managed_instance_administrators: azure.mgmt.sql.aio.operations.ManagedInstanceAdministratorsOperations @@ -317,6 +363,8 @@ class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword 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: @@ -334,41 +382,40 @@ class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword ManagedInstancePrivateEndpointConnectionsOperations operations :vartype managed_instance_private_endpoint_connections: azure.mgmt.sql.aio.operations.ManagedInstancePrivateEndpointConnectionsOperations - :ivar managed_instance_private_link_resources: ManagedInstancePrivateLinkResourcesOperations - operations - :vartype managed_instance_private_link_resources: - azure.mgmt.sql.aio.operations.ManagedInstancePrivateLinkResourcesOperations - :ivar managed_instance_tde_certificates: ManagedInstanceTdeCertificatesOperations operations - :vartype managed_instance_tde_certificates: - azure.mgmt.sql.aio.operations.ManagedInstanceTdeCertificatesOperations :ivar managed_instance_vulnerability_assessments: ManagedInstanceVulnerabilityAssessmentsOperations operations :vartype managed_instance_vulnerability_assessments: azure.mgmt.sql.aio.operations.ManagedInstanceVulnerabilityAssessmentsOperations - :ivar managed_restorable_dropped_database_backup_short_term_retention_policies: - ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations operations - :vartype managed_restorable_dropped_database_backup_short_term_retention_policies: - azure.mgmt.sql.aio.operations.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations + :ivar managed_server_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 operations: Operations operations - :vartype operations: azure.mgmt.sql.aio.operations.Operations + :ivar network_security_perimeter_configurations: + NetworkSecurityPerimeterConfigurationsOperations operations + :vartype network_security_perimeter_configurations: + azure.mgmt.sql.aio.operations.NetworkSecurityPerimeterConfigurationsOperations + :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 restore_points: RestorePointsOperations operations - :vartype restore_points: azure.mgmt.sql.aio.operations.RestorePointsOperations - :ivar server_advisors: ServerAdvisorsOperations operations - :vartype server_advisors: azure.mgmt.sql.aio.operations.ServerAdvisorsOperations - :ivar server_automatic_tuning: ServerAutomaticTuningOperations operations - :vartype server_automatic_tuning: azure.mgmt.sql.aio.operations.ServerAutomaticTuningOperations + :ivar 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 server_azure_ad_administrators: ServerAzureADAdministratorsOperations operations :vartype server_azure_ad_administrators: azure.mgmt.sql.aio.operations.ServerAzureADAdministratorsOperations @@ -376,6 +423,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 @@ -383,18 +436,19 @@ class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword :vartype server_dns_aliases: azure.mgmt.sql.aio.operations.ServerDnsAliasesOperations :ivar server_keys: ServerKeysOperations operations :vartype server_keys: azure.mgmt.sql.aio.operations.ServerKeysOperations - :ivar server_operations: ServerOperationsOperations operations - :vartype server_operations: azure.mgmt.sql.aio.operations.ServerOperationsOperations :ivar server_security_alert_policies: ServerSecurityAlertPoliciesOperations operations :vartype server_security_alert_policies: azure.mgmt.sql.aio.operations.ServerSecurityAlertPoliciesOperations - :ivar server_trust_groups: ServerTrustGroupsOperations operations - :vartype server_trust_groups: azure.mgmt.sql.aio.operations.ServerTrustGroupsOperations + :ivar server_trust_certificates: ServerTrustCertificatesOperations operations + :vartype server_trust_certificates: + azure.mgmt.sql.aio.operations.ServerTrustCertificatesOperations :ivar server_vulnerability_assessments: ServerVulnerabilityAssessmentsOperations operations :vartype server_vulnerability_assessments: azure.mgmt.sql.aio.operations.ServerVulnerabilityAssessmentsOperations - :ivar sql_agent: SqlAgentOperations operations - :vartype sql_agent: azure.mgmt.sql.aio.operations.SqlAgentOperations + :ivar 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 sync_agents: SyncAgentsOperations operations @@ -403,220 +457,164 @@ class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword :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_clusters: VirtualClustersOperations operations + :vartype virtual_clusters: azure.mgmt.sql.aio.operations.VirtualClustersOperations :ivar virtual_network_rules: VirtualNetworkRulesOperations operations :vartype virtual_network_rules: azure.mgmt.sql.aio.operations.VirtualNetworkRulesOperations :ivar workload_classifiers: WorkloadClassifiersOperations operations :vartype workload_classifiers: azure.mgmt.sql.aio.operations.WorkloadClassifiersOperations :ivar workload_groups: WorkloadGroupsOperations operations :vartype workload_groups: azure.mgmt.sql.aio.operations.WorkloadGroupsOperations - :ivar backup_short_term_retention_policies: BackupShortTermRetentionPoliciesOperations + :ivar managed_database_sensitivity_labels: ManagedDatabaseSensitivityLabelsOperations 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 + :vartype managed_database_sensitivity_labels: + azure.mgmt.sql.aio.operations.ManagedDatabaseSensitivityLabelsOperations + :ivar database_encryption_protectors: DatabaseEncryptionProtectorsOperations operations + :vartype database_encryption_protectors: + azure.mgmt.sql.aio.operations.DatabaseEncryptionProtectorsOperations + :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_managed_instance_backups: - LongTermRetentionManagedInstanceBackupsOperations operations - :vartype long_term_retention_managed_instance_backups: - azure.mgmt.sql.aio.operations.LongTermRetentionManagedInstanceBackupsOperations - :ivar restorable_dropped_managed_databases: RestorableDroppedManagedDatabasesOperations + :ivar recommended_sensitivity_labels: RecommendedSensitivityLabelsOperations operations + :vartype recommended_sensitivity_labels: + azure.mgmt.sql.aio.operations.RecommendedSensitivityLabelsOperations + :ivar synapse_link_workspaces: SynapseLinkWorkspacesOperations operations + :vartype synapse_link_workspaces: azure.mgmt.sql.aio.operations.SynapseLinkWorkspacesOperations + :ivar server_operations: ServerOperationsOperations operations + :vartype server_operations: azure.mgmt.sql.aio.operations.ServerOperationsOperations + :ivar server_usages: ServerUsagesOperations operations + :vartype server_usages: azure.mgmt.sql.aio.operations.ServerUsagesOperations + :ivar tde_certificates: TdeCertificatesOperations operations + :vartype tde_certificates: azure.mgmt.sql.aio.operations.TdeCertificatesOperations + :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 + :vartype database_automatic_tuning: + azure.mgmt.sql.aio.operations.DatabaseAutomaticTuningOperations + :ivar database_extensions: DatabaseExtensionsOperations operations + :vartype database_extensions: azure.mgmt.sql.aio.operations.DatabaseExtensionsOperations + :ivar database_recommended_actions: DatabaseRecommendedActionsOperations operations + :vartype database_recommended_actions: + azure.mgmt.sql.aio.operations.DatabaseRecommendedActionsOperations + :ivar database_sql_vulnerability_assessment_baselines: + DatabaseSqlVulnerabilityAssessmentBaselinesOperations operations + :vartype database_sql_vulnerability_assessment_baselines: + azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentBaselinesOperations + :ivar sql_vulnerability_assessment_baselines: SqlVulnerabilityAssessmentBaselinesOperations 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 server_trust_certificates: ServerTrustCertificatesOperations operations - :vartype server_trust_certificates: - azure.mgmt.sql.aio.operations.ServerTrustCertificatesOperations - :ivar endpoint_certificates: EndpointCertificatesOperations operations - :vartype endpoint_certificates: azure.mgmt.sql.aio.operations.EndpointCertificatesOperations - :ivar managed_database_sensitivity_labels: ManagedDatabaseSensitivityLabelsOperations + :vartype sql_vulnerability_assessment_baselines: + azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentBaselinesOperations + :ivar database_sql_vulnerability_assessments_settings: + DatabaseSqlVulnerabilityAssessmentsSettingsOperations operations + :vartype database_sql_vulnerability_assessments_settings: + azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentsSettingsOperations + :ivar database_sql_vulnerability_assessment_execute_scan: + DatabaseSqlVulnerabilityAssessmentExecuteScanOperations operations + :vartype database_sql_vulnerability_assessment_execute_scan: + azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentExecuteScanOperations + :ivar sql_vulnerability_assessment_execute_scan: + SqlVulnerabilityAssessmentExecuteScanOperations operations + :vartype sql_vulnerability_assessment_execute_scan: + azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentExecuteScanOperations + :ivar sql_vulnerability_assessment_rule_baselines: + SqlVulnerabilityAssessmentRuleBaselinesOperations operations + :vartype sql_vulnerability_assessment_rule_baselines: + azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentRuleBaselinesOperations + :ivar database_sql_vulnerability_assessment_scans: + DatabaseSqlVulnerabilityAssessmentScansOperations operations + :vartype database_sql_vulnerability_assessment_scans: + azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentScansOperations + :ivar database_vulnerability_assessment_scans: DatabaseVulnerabilityAssessmentScansOperations operations - :vartype managed_database_sensitivity_labels: - azure.mgmt.sql.aio.operations.ManagedDatabaseSensitivityLabelsOperations + :vartype database_vulnerability_assessment_scans: + azure.mgmt.sql.aio.operations.DatabaseVulnerabilityAssessmentScansOperations + :ivar data_masking_rules: DataMaskingRulesOperations operations + :vartype data_masking_rules: azure.mgmt.sql.aio.operations.DataMaskingRulesOperations + :ivar data_warehouse_user_activities: DataWarehouseUserActivitiesOperations operations + :vartype data_warehouse_user_activities: + azure.mgmt.sql.aio.operations.DataWarehouseUserActivitiesOperations + :ivar managed_database_security_events: ManagedDatabaseSecurityEventsOperations operations + :vartype managed_database_security_events: + azure.mgmt.sql.aio.operations.ManagedDatabaseSecurityEventsOperations :ivar managed_database_recommended_sensitivity_labels: ManagedDatabaseRecommendedSensitivityLabelsOperations operations :vartype managed_database_recommended_sensitivity_labels: azure.mgmt.sql.aio.operations.ManagedDatabaseRecommendedSensitivityLabelsOperations - :ivar sensitivity_labels: SensitivityLabelsOperations operations - :vartype sensitivity_labels: azure.mgmt.sql.aio.operations.SensitivityLabelsOperations - :ivar recommended_sensitivity_labels: RecommendedSensitivityLabelsOperations operations - :vartype recommended_sensitivity_labels: - azure.mgmt.sql.aio.operations.RecommendedSensitivityLabelsOperations - :ivar server_blob_auditing_policies: ServerBlobAuditingPoliciesOperations operations - :vartype server_blob_auditing_policies: - azure.mgmt.sql.aio.operations.ServerBlobAuditingPoliciesOperations - :ivar database_blob_auditing_policies: DatabaseBlobAuditingPoliciesOperations operations - :vartype database_blob_auditing_policies: - azure.mgmt.sql.aio.operations.DatabaseBlobAuditingPoliciesOperations - :ivar extended_database_blob_auditing_policies: ExtendedDatabaseBlobAuditingPoliciesOperations - operations - :vartype extended_database_blob_auditing_policies: - azure.mgmt.sql.aio.operations.ExtendedDatabaseBlobAuditingPoliciesOperations - :ivar extended_server_blob_auditing_policies: ExtendedServerBlobAuditingPoliciesOperations - operations - :vartype extended_server_blob_auditing_policies: - azure.mgmt.sql.aio.operations.ExtendedServerBlobAuditingPoliciesOperations - :ivar database_advanced_threat_protection_settings: - DatabaseAdvancedThreatProtectionSettingsOperations operations - :vartype database_advanced_threat_protection_settings: - azure.mgmt.sql.aio.operations.DatabaseAdvancedThreatProtectionSettingsOperations - :ivar server_advanced_threat_protection_settings: - ServerAdvancedThreatProtectionSettingsOperations operations - :vartype server_advanced_threat_protection_settings: - azure.mgmt.sql.aio.operations.ServerAdvancedThreatProtectionSettingsOperations - :ivar managed_server_dns_aliases: ManagedServerDnsAliasesOperations operations - :vartype managed_server_dns_aliases: - azure.mgmt.sql.aio.operations.ManagedServerDnsAliasesOperations + :ivar managed_instance_tde_certificates: ManagedInstanceTdeCertificatesOperations operations + :vartype managed_instance_tde_certificates: + azure.mgmt.sql.aio.operations.ManagedInstanceTdeCertificatesOperations + :ivar elastic_pool_operations: ElasticPoolOperationsOperations operations + :vartype elastic_pool_operations: azure.mgmt.sql.aio.operations.ElasticPoolOperationsOperations + :ivar usages: UsagesOperations operations + :vartype usages: azure.mgmt.sql.aio.operations.UsagesOperations + :ivar ledger_digest_uploads: LedgerDigestUploadsOperations operations + :vartype ledger_digest_uploads: azure.mgmt.sql.aio.operations.LedgerDigestUploadsOperations + :ivar maintenance_window_options: MaintenanceWindowOptionsOperations operations + :vartype maintenance_window_options: + azure.mgmt.sql.aio.operations.MaintenanceWindowOptionsOperations + :ivar maintenance_windows: MaintenanceWindowsOperations operations + :vartype maintenance_windows: azure.mgmt.sql.aio.operations.MaintenanceWindowsOperations :ivar managed_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 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_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 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_database_transparent_data_encryption: + ManagedDatabaseTransparentDataEncryptionOperations operations + :vartype managed_database_transparent_data_encryption: + azure.mgmt.sql.aio.operations.ManagedDatabaseTransparentDataEncryptionOperations + :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_private_link_resources: ManagedInstancePrivateLinkResourcesOperations + operations + :vartype managed_instance_private_link_resources: + azure.mgmt.sql.aio.operations.ManagedInstancePrivateLinkResourcesOperations :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 start_stop_managed_instance_schedules: StartStopManagedInstanceSchedulesOperations - operations - :vartype start_stop_managed_instance_schedules: - azure.mgmt.sql.aio.operations.StartStopManagedInstanceSchedulesOperations + :ivar server_advanced_threat_protection_settings: + ServerAdvancedThreatProtectionSettingsOperations operations + :vartype server_advanced_threat_protection_settings: + azure.mgmt.sql.aio.operations.ServerAdvancedThreatProtectionSettingsOperations + :ivar server_automatic_tuning: ServerAutomaticTuningOperations operations + :vartype server_automatic_tuning: azure.mgmt.sql.aio.operations.ServerAutomaticTuningOperations + :ivar sql_agent: SqlAgentOperations operations + :vartype sql_agent: azure.mgmt.sql.aio.operations.SqlAgentOperations :ivar transparent_data_encryptions: TransparentDataEncryptionsOperations operations :vartype transparent_data_encryptions: azure.mgmt.sql.aio.operations.TransparentDataEncryptionsOperations - :ivar ipv6_firewall_rules: IPv6FirewallRulesOperations operations - :vartype ipv6_firewall_rules: azure.mgmt.sql.aio.operations.IPv6FirewallRulesOperations - :ivar sql_vulnerability_assessment_baseline: SqlVulnerabilityAssessmentBaselineOperations - operations - :vartype sql_vulnerability_assessment_baseline: - azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentBaselineOperations - :ivar sql_vulnerability_assessment_baselines: SqlVulnerabilityAssessmentBaselinesOperations - operations - :vartype sql_vulnerability_assessment_baselines: - azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentBaselinesOperations - :ivar sql_vulnerability_assessment_execute_scan: - SqlVulnerabilityAssessmentExecuteScanOperations operations - :vartype sql_vulnerability_assessment_execute_scan: - azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentExecuteScanOperations - :ivar sql_vulnerability_assessment_rule_baseline: - SqlVulnerabilityAssessmentRuleBaselineOperations operations - :vartype sql_vulnerability_assessment_rule_baseline: - azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentRuleBaselineOperations - :ivar sql_vulnerability_assessment_rule_baselines: - SqlVulnerabilityAssessmentRuleBaselinesOperations operations - :vartype sql_vulnerability_assessment_rule_baselines: - azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentRuleBaselinesOperations - :ivar sql_vulnerability_assessment_scan_result: SqlVulnerabilityAssessmentScanResultOperations - operations - :vartype sql_vulnerability_assessment_scan_result: - azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentScanResultOperations - :ivar sql_vulnerability_assessment_scans: SqlVulnerabilityAssessmentScansOperations operations - :vartype sql_vulnerability_assessment_scans: - azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentScansOperations - :ivar sql_vulnerability_assessments_settings: SqlVulnerabilityAssessmentsSettingsOperations - operations - :vartype sql_vulnerability_assessments_settings: - azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentsSettingsOperations - :ivar sql_vulnerability_assessments: SqlVulnerabilityAssessmentsOperations operations - :vartype sql_vulnerability_assessments: - azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentsOperations - :ivar database_sql_vulnerability_assessment_baselines: - DatabaseSqlVulnerabilityAssessmentBaselinesOperations operations - :vartype database_sql_vulnerability_assessment_baselines: - azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentBaselinesOperations - :ivar database_sql_vulnerability_assessment_execute_scan: - DatabaseSqlVulnerabilityAssessmentExecuteScanOperations operations - :vartype database_sql_vulnerability_assessment_execute_scan: - azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentExecuteScanOperations - :ivar database_sql_vulnerability_assessment_rule_baselines: - DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations operations - :vartype database_sql_vulnerability_assessment_rule_baselines: - azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations - :ivar database_sql_vulnerability_assessment_scan_result: - DatabaseSqlVulnerabilityAssessmentScanResultOperations operations - :vartype database_sql_vulnerability_assessment_scan_result: - azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentScanResultOperations - :ivar database_sql_vulnerability_assessment_scans: - DatabaseSqlVulnerabilityAssessmentScansOperations operations - :vartype database_sql_vulnerability_assessment_scans: - azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentScansOperations - :ivar database_sql_vulnerability_assessments_settings: - DatabaseSqlVulnerabilityAssessmentsSettingsOperations operations - :vartype database_sql_vulnerability_assessments_settings: - azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentsSettingsOperations - :ivar failover_groups: FailoverGroupsOperations operations - :vartype failover_groups: azure.mgmt.sql.aio.operations.FailoverGroupsOperations - :ivar instance_pools: InstancePoolsOperations operations - :vartype instance_pools: azure.mgmt.sql.aio.operations.InstancePoolsOperations - :ivar managed_instances: ManagedInstancesOperations operations - :vartype managed_instances: azure.mgmt.sql.aio.operations.ManagedInstancesOperations - :ivar replication_links: ReplicationLinksOperations operations - :vartype replication_links: azure.mgmt.sql.aio.operations.ReplicationLinksOperations - :ivar distributed_availability_groups: DistributedAvailabilityGroupsOperations operations - :vartype distributed_availability_groups: - azure.mgmt.sql.aio.operations.DistributedAvailabilityGroupsOperations - :ivar servers: ServersOperations operations - :vartype servers: azure.mgmt.sql.aio.operations.ServersOperations - :ivar long_term_retention_backups: LongTermRetentionBackupsOperations operations - :vartype long_term_retention_backups: - azure.mgmt.sql.aio.operations.LongTermRetentionBackupsOperations - :ivar long_term_retention_policies: LongTermRetentionPoliciesOperations operations - :vartype long_term_retention_policies: - azure.mgmt.sql.aio.operations.LongTermRetentionPoliciesOperations - :ivar database_operations: DatabaseOperationsOperations operations - :vartype database_operations: azure.mgmt.sql.aio.operations.DatabaseOperationsOperations - :param credential: Credential needed for the client to connect to Azure. Required. + :ivar capabilities: CapabilitiesOperations operations + :vartype capabilities: azure.mgmt.sql.aio.operations.CapabilitiesOperations + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription ID that identifies an Azure subscription. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :param base_url: Service URL. Default value is None. + :param base_url: Service host. Default value is None. :type base_url: str :keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is None. :paramtype cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are + "2025-02-01-preview". Default value is "2025-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. """ @@ -630,6 +628,7 @@ def __init__( cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: + _endpoint = "{endpoint}" _cloud = cloud_setting or settings.current.azure_cloud # type: ignore _endpoints = get_arm_endpoints(_cloud) if not base_url: @@ -638,6 +637,7 @@ def __init__( self._config = SqlManagementClientConfiguration( credential=credential, subscription_id=subscription_id, + base_url=cast(str, base_url), cloud_setting=cloud_setting, credential_scopes=credential_scopes, **kwargs @@ -662,164 +662,166 @@ def __init__( self._config.http_logging_policy, ] self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( - base_url=cast(str, base_url), policies=_policies, **kwargs + base_url=cast(str, _endpoint), policies=_policies, **kwargs ) - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) + self._serialize = Serializer() + self._deserialize = Deserializer() self._serialize.client_side_validation = False - self.data_masking_policies = DataMaskingPoliciesOperations( + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.backup_short_term_retention_policies = BackupShortTermRetentionPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.data_masking_rules = DataMaskingRulesOperations( + self.database_columns = DatabaseColumnsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.geo_backup_policies = GeoBackupPoliciesOperations( + 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.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.firewall_rules = FirewallRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.replication_links = ReplicationLinksOperations( self._client, self._config, self._serialize, self._deserialize ) - self.service_objectives = ServiceObjectivesOperations( + self.servers = ServersOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_blob_auditing_policies = ServerBlobAuditingPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.elastic_pool_activities = ElasticPoolActivitiesOperations( + self.database_blob_auditing_policies = DatabaseBlobAuditingPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.elastic_pool_database_activities = ElasticPoolDatabaseActivitiesOperations( + self.extended_database_blob_auditing_policies = ExtendedDatabaseBlobAuditingPoliciesOperations( 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.extended_server_blob_auditing_policies = ExtendedServerBlobAuditingPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_automatic_tuning = DatabaseAutomaticTuningOperations( + self.server_advisors = ServerAdvisorsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_database_columns = ManagedDatabaseColumnsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_columns = DatabaseColumnsOperations( + self.database_tables = DatabaseTablesOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_database_tables = ManagedDatabaseTablesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_recommended_actions = DatabaseRecommendedActionsOperations( + self.database_schemas = DatabaseSchemasOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_schemas = DatabaseSchemasOperations( + self.managed_database_schemas = ManagedDatabaseSchemasOperations( self._client, self._config, self._serialize, self._deserialize ) self.database_security_alert_policies = DatabaseSecurityAlertPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_tables = DatabaseTablesOperations(self._client, self._config, self._serialize, self._deserialize) - self.database_vulnerability_assessment_rule_baselines = DatabaseVulnerabilityAssessmentRuleBaselinesOperations( + self.sql_vulnerability_assessment_baseline = SqlVulnerabilityAssessmentBaselineOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_vulnerability_assessments = DatabaseVulnerabilityAssessmentsOperations( + self.sql_vulnerability_assessments = SqlVulnerabilityAssessmentsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_vulnerability_assessment_scans = DatabaseVulnerabilityAssessmentScansOperations( + self.sql_vulnerability_assessments_settings = SqlVulnerabilityAssessmentsSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.data_warehouse_user_activities = DataWarehouseUserActivitiesOperations( - 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.deleted_servers = DeletedServersOperations(self._client, self._config, self._serialize, self._deserialize) - self.elastic_pool_operations = ElasticPoolOperationsOperations( + self.sql_vulnerability_assessment_rule_baseline = SqlVulnerabilityAssessmentRuleBaselineOperations( self._client, self._config, self._serialize, self._deserialize ) - self.encryption_protectors = EncryptionProtectorsOperations( + self.database_sql_vulnerability_assessment_scan_result = DatabaseSqlVulnerabilityAssessmentScanResultOperations( self._client, self._config, self._serialize, self._deserialize ) - self.firewall_rules = FirewallRulesOperations(self._client, self._config, self._serialize, self._deserialize) - self.job_agents = JobAgentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.job_credentials = JobCredentialsOperations(self._client, self._config, self._serialize, self._deserialize) - self.job_executions = JobExecutionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.job_private_endpoints = JobPrivateEndpointsOperations( + self.sql_vulnerability_assessment_scan_result = SqlVulnerabilityAssessmentScanResultOperations( 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.sql_vulnerability_assessment_scans = SqlVulnerabilityAssessmentScansOperations( self._client, self._config, self._serialize, self._deserialize ) - self.job_steps = JobStepsOperations(self._client, self._config, self._serialize, self._deserialize) - self.job_target_executions = JobTargetExecutionsOperations( + self.database_vulnerability_assessment_rule_baselines = DatabaseVulnerabilityAssessmentRuleBaselinesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.job_target_groups = JobTargetGroupsOperations( - self._client, self._config, self._serialize, self._deserialize + self.managed_database_vulnerability_assessment_rule_baselines = ( + ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) ) - self.job_versions = JobVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.capabilities = CapabilitiesOperations(self._client, self._config, self._serialize, self._deserialize) - self.maintenance_window_options = MaintenanceWindowOptionsOperations( + self.database_vulnerability_assessments = DatabaseVulnerabilityAssessmentsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.maintenance_windows = MaintenanceWindowsOperations( + self.managed_database_vulnerability_assessments = ManagedDatabaseVulnerabilityAssessmentsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_backup_short_term_retention_policies = ManagedBackupShortTermRetentionPoliciesOperations( + self.managed_database_vulnerability_assessment_scans = ManagedDatabaseVulnerabilityAssessmentScansOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_columns = ManagedDatabaseColumnsOperations( + self.data_masking_policies = DataMaskingPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_queries = ManagedDatabaseQueriesOperations( + self.deleted_servers = DeletedServersOperations(self._client, self._config, self._serialize, self._deserialize) + self.distributed_availability_groups = DistributedAvailabilityGroupsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_schemas = ManagedDatabaseSchemasOperations( + self.managed_databases = ManagedDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_security_alert_policies = ManagedDatabaseSecurityAlertPoliciesOperations( + self.server_trust_groups = ServerTrustGroupsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_security_events = ManagedDatabaseSecurityEventsOperations( + self.managed_instances = ManagedInstancesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_tables = ManagedDatabaseTablesOperations( + self.elastic_pools = ElasticPoolsOperations(self._client, self._config, self._serialize, self._deserialize) + self.encryption_protectors = EncryptionProtectorsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_transparent_data_encryption = ManagedDatabaseTransparentDataEncryptionOperations( + self.endpoint_certificates = EndpointCertificatesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_vulnerability_assessment_rule_baselines = ( - ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - ) - self.managed_database_vulnerability_assessments = ManagedDatabaseVulnerabilityAssessmentsOperations( + self.failover_groups = FailoverGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.geo_backup_policies = GeoBackupPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_vulnerability_assessment_scans = ManagedDatabaseVulnerabilityAssessmentScansOperations( + self.instance_failover_groups = InstanceFailoverGroupsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_administrators = ManagedInstanceAdministratorsOperations( + self.instance_pool_operations = InstancePoolOperationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_azure_ad_only_authentications = ManagedInstanceAzureADOnlyAuthenticationsOperations( + self.instance_pools = InstancePoolsOperations(self._client, self._config, self._serialize, self._deserialize) + self.ipv6_firewall_rules = IPv6FirewallRulesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_encryption_protectors = ManagedInstanceEncryptionProtectorsOperations( + self.job_executions = JobExecutionsOperations(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_step_executions = JobStepExecutionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_keys = ManagedInstanceKeysOperations( + self.job_target_executions = JobTargetExecutionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_long_term_retention_policies = ManagedInstanceLongTermRetentionPoliciesOperations( + self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) + self.job_private_endpoints = JobPrivateEndpointsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_operations = ManagedInstanceOperationsOperations( + self.job_steps = JobStepsOperations(self._client, self._config, self._serialize, self._deserialize) + self.job_target_groups = JobTargetGroupsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_private_endpoint_connections = ManagedInstancePrivateEndpointConnectionsOperations( + self.job_versions = JobVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.long_term_retention_backups = LongTermRetentionBackupsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_private_link_resources = ManagedInstancePrivateLinkResourcesOperations( + self.long_term_retention_managed_instance_backups = LongTermRetentionManagedInstanceBackupsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_tde_certificates = ManagedInstanceTdeCertificatesOperations( + self.long_term_retention_policies = LongTermRetentionPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_vulnerability_assessments = ManagedInstanceVulnerabilityAssessmentsOperations( + self.managed_backup_short_term_retention_policies = ManagedBackupShortTermRetentionPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) self.managed_restorable_dropped_database_backup_short_term_retention_policies = ( @@ -827,256 +829,247 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) ) - self.managed_server_security_alert_policies = ManagedServerSecurityAlertPoliciesOperations( + self.managed_database_security_alert_policies = ManagedDatabaseSecurityAlertPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self.managed_instance_administrators = ManagedInstanceAdministratorsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.private_link_resources = PrivateLinkResourcesOperations( + self.managed_instance_azure_ad_only_authentications = ManagedInstanceAzureADOnlyAuthenticationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.recoverable_managed_databases = RecoverableManagedDatabasesOperations( + self.managed_instance_dtcs = ManagedInstanceDtcsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restore_points = RestorePointsOperations(self._client, self._config, self._serialize, self._deserialize) - self.server_advisors = ServerAdvisorsOperations(self._client, self._config, self._serialize, self._deserialize) - self.server_automatic_tuning = ServerAutomaticTuningOperations( + self.managed_instance_encryption_protectors = ManagedInstanceEncryptionProtectorsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_azure_ad_administrators = ServerAzureADAdministratorsOperations( + self.managed_instance_keys = ManagedInstanceKeysOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_azure_ad_only_authentications = ServerAzureADOnlyAuthenticationsOperations( + self.managed_instance_long_term_retention_policies = ManagedInstanceLongTermRetentionPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_dev_ops_audit_settings = ServerDevOpsAuditSettingsOperations( + self.managed_instance_operations = ManagedInstanceOperationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_dns_aliases = ServerDnsAliasesOperations( + self.managed_instance_private_endpoint_connections = ManagedInstancePrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_keys = ServerKeysOperations(self._client, self._config, self._serialize, self._deserialize) - self.server_operations = ServerOperationsOperations( + self.managed_instance_vulnerability_assessments = ManagedInstanceVulnerabilityAssessmentsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_security_alert_policies = ServerSecurityAlertPoliciesOperations( + self.managed_server_dns_aliases = ManagedServerDnsAliasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_trust_groups = ServerTrustGroupsOperations( + self.managed_server_security_alert_policies = ManagedServerSecurityAlertPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_vulnerability_assessments = ServerVulnerabilityAssessmentsOperations( + self.network_security_perimeter_configurations = NetworkSecurityPerimeterConfigurationsOperations( 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.outbound_firewall_rules = OutboundFirewallRulesOperations( 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.private_endpoint_connections = PrivateEndpointConnectionsOperations( 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.private_link_resources = PrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workload_classifiers = WorkloadClassifiersOperations( + self.recoverable_databases = RecoverableDatabasesOperations( 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.recoverable_managed_databases = RecoverableManagedDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_extensions = DatabaseExtensionsOperations( + self.restorable_dropped_databases = RestorableDroppedDatabasesOperations( 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.restorable_dropped_managed_databases = RestorableDroppedManagedDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.outbound_firewall_rules = OutboundFirewallRulesOperations( + self.server_azure_ad_administrators = ServerAzureADAdministratorsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.long_term_retention_managed_instance_backups = LongTermRetentionManagedInstanceBackupsOperations( + self.server_azure_ad_only_authentications = ServerAzureADOnlyAuthenticationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_dropped_managed_databases = RestorableDroppedManagedDatabasesOperations( + self.server_configuration_options = ServerConfigurationOptionsOperations( self._client, self._config, self._serialize, self._deserialize ) self.server_connection_policies = ServerConnectionPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_trust_certificates = ServerTrustCertificatesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.endpoint_certificates = EndpointCertificatesOperations( + self.server_dev_ops_audit_settings = ServerDevOpsAuditSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_sensitivity_labels = ManagedDatabaseSensitivityLabelsOperations( + self.server_dns_aliases = ServerDnsAliasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_recommended_sensitivity_labels = ManagedDatabaseRecommendedSensitivityLabelsOperations( + self.server_keys = ServerKeysOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_security_alert_policies = ServerSecurityAlertPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.sensitivity_labels = SensitivityLabelsOperations( + self.server_trust_certificates = ServerTrustCertificatesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.recommended_sensitivity_labels = RecommendedSensitivityLabelsOperations( + self.server_vulnerability_assessments = ServerVulnerabilityAssessmentsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_blob_auditing_policies = ServerBlobAuditingPoliciesOperations( + self.start_stop_managed_instance_schedules = StartStopManagedInstanceSchedulesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_blob_auditing_policies = DatabaseBlobAuditingPoliciesOperations( + self.subscription_usages = SubscriptionUsagesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.extended_database_blob_auditing_policies = ExtendedDatabaseBlobAuditingPoliciesOperations( + 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.time_zones = TimeZonesOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_clusters = VirtualClustersOperations( self._client, self._config, self._serialize, self._deserialize ) - self.extended_server_blob_auditing_policies = ExtendedServerBlobAuditingPoliciesOperations( + self.virtual_network_rules = VirtualNetworkRulesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_advanced_threat_protection_settings = DatabaseAdvancedThreatProtectionSettingsOperations( + self.workload_classifiers = WorkloadClassifiersOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_advanced_threat_protection_settings = ServerAdvancedThreatProtectionSettingsOperations( + self.workload_groups = WorkloadGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_database_sensitivity_labels = ManagedDatabaseSensitivityLabelsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_server_dns_aliases = ManagedServerDnsAliasesOperations( + self.database_encryption_protectors = DatabaseEncryptionProtectorsOperations( 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.managed_database_move_operations = ManagedDatabaseMoveOperationsOperations( + self.database_operations = DatabaseOperationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_dtcs = ManagedInstanceDtcsOperations( + self.database_usages = DatabaseUsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.recommended_sensitivity_labels = RecommendedSensitivityLabelsOperations( 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.server_operations = ServerOperationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.instance_failover_groups = InstanceFailoverGroupsOperations( + self.server_usages = ServerUsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.tde_certificates = TdeCertificatesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_restore_details = ManagedDatabaseRestoreDetailsOperations( + self.database_advanced_threat_protection_settings = DatabaseAdvancedThreatProtectionSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_encryption_protectors = DatabaseEncryptionProtectorsOperations( + self.database_advisors = DatabaseAdvisorsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_databases = ManagedDatabasesOperations( + self.database_automatic_tuning = DatabaseAutomaticTuningOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_ledger_digest_uploads = ManagedLedgerDigestUploadsOperations( + self.database_extensions = DatabaseExtensionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.recoverable_databases = RecoverableDatabasesOperations( + self.database_recommended_actions = DatabaseRecommendedActionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_dropped_databases = RestorableDroppedDatabasesOperations( + self.database_sql_vulnerability_assessment_baselines = DatabaseSqlVulnerabilityAssessmentBaselinesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_configuration_options = ServerConfigurationOptionsOperations( + self.sql_vulnerability_assessment_baselines = SqlVulnerabilityAssessmentBaselinesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.start_stop_managed_instance_schedules = StartStopManagedInstanceSchedulesOperations( + self.database_sql_vulnerability_assessments_settings = DatabaseSqlVulnerabilityAssessmentsSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.transparent_data_encryptions = TransparentDataEncryptionsOperations( + self.database_sql_vulnerability_assessment_execute_scan = ( + DatabaseSqlVulnerabilityAssessmentExecuteScanOperations( + self._client, self._config, self._serialize, self._deserialize + ) + ) + self.sql_vulnerability_assessment_execute_scan = SqlVulnerabilityAssessmentExecuteScanOperations( self._client, self._config, self._serialize, self._deserialize ) - self.ipv6_firewall_rules = IPv6FirewallRulesOperations( + self.sql_vulnerability_assessment_rule_baselines = SqlVulnerabilityAssessmentRuleBaselinesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.sql_vulnerability_assessment_baseline = SqlVulnerabilityAssessmentBaselineOperations( + self.database_sql_vulnerability_assessment_scans = DatabaseSqlVulnerabilityAssessmentScansOperations( self._client, self._config, self._serialize, self._deserialize ) - self.sql_vulnerability_assessment_baselines = SqlVulnerabilityAssessmentBaselinesOperations( + self.database_vulnerability_assessment_scans = DatabaseVulnerabilityAssessmentScansOperations( self._client, self._config, self._serialize, self._deserialize ) - self.sql_vulnerability_assessment_execute_scan = SqlVulnerabilityAssessmentExecuteScanOperations( + self.data_masking_rules = DataMaskingRulesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.sql_vulnerability_assessment_rule_baseline = SqlVulnerabilityAssessmentRuleBaselineOperations( + self.data_warehouse_user_activities = DataWarehouseUserActivitiesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.sql_vulnerability_assessment_rule_baselines = SqlVulnerabilityAssessmentRuleBaselinesOperations( + self.managed_database_security_events = ManagedDatabaseSecurityEventsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.sql_vulnerability_assessment_scan_result = SqlVulnerabilityAssessmentScanResultOperations( + self.managed_database_recommended_sensitivity_labels = ManagedDatabaseRecommendedSensitivityLabelsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.sql_vulnerability_assessment_scans = SqlVulnerabilityAssessmentScansOperations( + self.managed_instance_tde_certificates = ManagedInstanceTdeCertificatesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.sql_vulnerability_assessments_settings = SqlVulnerabilityAssessmentsSettingsOperations( + self.elastic_pool_operations = ElasticPoolOperationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.sql_vulnerability_assessments = SqlVulnerabilityAssessmentsOperations( + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.ledger_digest_uploads = LedgerDigestUploadsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_sql_vulnerability_assessment_baselines = DatabaseSqlVulnerabilityAssessmentBaselinesOperations( + self.maintenance_window_options = MaintenanceWindowOptionsOperations( 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.maintenance_windows = MaintenanceWindowsOperations( + self._client, self._config, self._serialize, self._deserialize ) - self.database_sql_vulnerability_assessment_rule_baselines = ( - DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations( + self.managed_database_advanced_threat_protection_settings = ( + ManagedDatabaseAdvancedThreatProtectionSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) ) - self.database_sql_vulnerability_assessment_scan_result = DatabaseSqlVulnerabilityAssessmentScanResultOperations( + self.managed_database_move_operations = ManagedDatabaseMoveOperationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_sql_vulnerability_assessment_scans = DatabaseSqlVulnerabilityAssessmentScansOperations( + self.managed_database_queries = ManagedDatabaseQueriesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_sql_vulnerability_assessments_settings = DatabaseSqlVulnerabilityAssessmentsSettingsOperations( + self.managed_database_restore_details = ManagedDatabaseRestoreDetailsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.failover_groups = FailoverGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.instance_pools = InstancePoolsOperations(self._client, self._config, self._serialize, self._deserialize) - self.managed_instances = ManagedInstancesOperations( + self.managed_database_transparent_data_encryption = ManagedDatabaseTransparentDataEncryptionOperations( self._client, self._config, self._serialize, self._deserialize ) - self.replication_links = ReplicationLinksOperations( + self.managed_instance_advanced_threat_protection_settings = ( + ManagedInstanceAdvancedThreatProtectionSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + ) + self.managed_instance_private_link_resources = ManagedInstancePrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.distributed_availability_groups = DistributedAvailabilityGroupsOperations( + self.managed_ledger_digest_uploads = ManagedLedgerDigestUploadsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.servers = ServersOperations(self._client, self._config, self._serialize, self._deserialize) - self.long_term_retention_backups = LongTermRetentionBackupsOperations( + self.server_advanced_threat_protection_settings = ServerAdvancedThreatProtectionSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.long_term_retention_policies = LongTermRetentionPoliciesOperations( + self.server_automatic_tuning = ServerAutomaticTuningOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_operations = DatabaseOperationsOperations( + self.sql_agent = SqlAgentOperations(self._client, self._config, self._serialize, self._deserialize) + self.transparent_data_encryptions = TransparentDataEncryptionsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.capabilities = CapabilitiesOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request( + def send_request( self, request: HttpRequest, *, stream: bool = False, **kwargs: Any ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. @@ -1084,7 +1077,7 @@ def _send_request( >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") - >>> response = await client._send_request(request) + >>> response = await client.send_request(request) For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request @@ -1097,7 +1090,11 @@ def _send_request( """ request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: 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 88546af5b237..601b92a8fb9d 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -24,22 +24,31 @@ class SqlManagementClientConfiguration: # pylint: disable=too-many-instance-att Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. Required. + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription ID that identifies an Azure subscription. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str + :param base_url: Service host. Default value is "https://management.azure.com". + :type base_url: str :param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is None. :type cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are + "2025-02-01-preview". Default value is "2025-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, + base_url: str = "https://management.azure.com", cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: + api_version: str = kwargs.pop("api_version", "2025-02-01-preview") + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -47,7 +56,9 @@ def __init__( self.credential = credential self.subscription_id = subscription_id + self.base_url = base_url self.cloud_setting = cloud_setting + 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.polling_interval = kwargs.get("polling_interval", 30) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/_patch.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/_patch.py index 17dbc073e01b..87676c65a8f0 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/_patch.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/_patch.py @@ -1,32 +1,21 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# # Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------- +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" + + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level -# This file is used for handwritten extensions to the generated code. Example: -# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ 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 88a49faa4a42..52d6388fc113 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -13,312 +12,308 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._data_masking_policies_operations import DataMaskingPoliciesOperations # type: ignore -from ._data_masking_rules_operations import DataMaskingRulesOperations # type: ignore -from ._geo_backup_policies_operations import GeoBackupPoliciesOperations # type: ignore -from ._databases_operations import DatabasesOperations # type: ignore -from ._elastic_pools_operations import ElasticPoolsOperations # type: ignore -from ._server_communication_links_operations import ServerCommunicationLinksOperations # type: ignore -from ._service_objectives_operations import ServiceObjectivesOperations # type: ignore -from ._elastic_pool_activities_operations import ElasticPoolActivitiesOperations # type: ignore -from ._elastic_pool_database_activities_operations import ElasticPoolDatabaseActivitiesOperations # type: ignore -from ._server_usages_operations import ServerUsagesOperations # type: ignore -from ._database_advisors_operations import DatabaseAdvisorsOperations # type: ignore -from ._database_automatic_tuning_operations import DatabaseAutomaticTuningOperations # type: ignore -from ._database_columns_operations import DatabaseColumnsOperations # type: ignore -from ._database_recommended_actions_operations import DatabaseRecommendedActionsOperations # type: ignore -from ._database_schemas_operations import DatabaseSchemasOperations # type: ignore -from ._database_security_alert_policies_operations import DatabaseSecurityAlertPoliciesOperations # type: ignore -from ._database_tables_operations import DatabaseTablesOperations # type: ignore -from ._database_vulnerability_assessment_rule_baselines_operations import DatabaseVulnerabilityAssessmentRuleBaselinesOperations # type: ignore -from ._database_vulnerability_assessments_operations import DatabaseVulnerabilityAssessmentsOperations # type: ignore -from ._database_vulnerability_assessment_scans_operations import DatabaseVulnerabilityAssessmentScansOperations # type: ignore -from ._data_warehouse_user_activities_operations import DataWarehouseUserActivitiesOperations # type: ignore -from ._deleted_servers_operations import DeletedServersOperations # type: ignore -from ._elastic_pool_operations_operations import ElasticPoolOperationsOperations # type: ignore -from ._encryption_protectors_operations import EncryptionProtectorsOperations # type: ignore -from ._firewall_rules_operations import FirewallRulesOperations # type: ignore -from ._job_agents_operations import JobAgentsOperations # type: ignore -from ._job_credentials_operations import JobCredentialsOperations # type: ignore -from ._job_executions_operations import JobExecutionsOperations # type: ignore -from ._job_private_endpoints_operations import JobPrivateEndpointsOperations # type: ignore -from ._jobs_operations import JobsOperations # type: ignore -from ._job_step_executions_operations import JobStepExecutionsOperations # type: ignore -from ._job_steps_operations import JobStepsOperations # type: ignore -from ._job_target_executions_operations import JobTargetExecutionsOperations # type: ignore -from ._job_target_groups_operations import JobTargetGroupsOperations # type: ignore -from ._job_versions_operations import JobVersionsOperations # type: ignore -from ._capabilities_operations import CapabilitiesOperations # type: ignore -from ._maintenance_window_options_operations import MaintenanceWindowOptionsOperations # type: ignore -from ._maintenance_windows_operations import MaintenanceWindowsOperations # type: ignore -from ._managed_backup_short_term_retention_policies_operations import ManagedBackupShortTermRetentionPoliciesOperations # type: ignore -from ._managed_database_columns_operations import ManagedDatabaseColumnsOperations # type: ignore -from ._managed_database_queries_operations import ManagedDatabaseQueriesOperations # type: ignore -from ._managed_database_schemas_operations import ManagedDatabaseSchemasOperations # type: ignore -from ._managed_database_security_alert_policies_operations import ManagedDatabaseSecurityAlertPoliciesOperations # type: ignore -from ._managed_database_security_events_operations import ManagedDatabaseSecurityEventsOperations # type: ignore -from ._managed_database_tables_operations import ManagedDatabaseTablesOperations # type: ignore -from ._managed_database_transparent_data_encryption_operations import ManagedDatabaseTransparentDataEncryptionOperations # type: ignore -from ._managed_database_vulnerability_assessment_rule_baselines_operations import ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations # type: ignore -from ._managed_database_vulnerability_assessments_operations import ManagedDatabaseVulnerabilityAssessmentsOperations # type: ignore -from ._managed_database_vulnerability_assessment_scans_operations import ManagedDatabaseVulnerabilityAssessmentScansOperations # type: ignore -from ._managed_instance_administrators_operations import ManagedInstanceAdministratorsOperations # type: ignore -from ._managed_instance_azure_ad_only_authentications_operations import ManagedInstanceAzureADOnlyAuthenticationsOperations # type: ignore -from ._managed_instance_encryption_protectors_operations import ManagedInstanceEncryptionProtectorsOperations # type: ignore -from ._managed_instance_keys_operations import ManagedInstanceKeysOperations # type: ignore -from ._managed_instance_long_term_retention_policies_operations import ManagedInstanceLongTermRetentionPoliciesOperations # type: ignore -from ._managed_instance_operations_operations import ManagedInstanceOperationsOperations # type: ignore -from ._managed_instance_private_endpoint_connections_operations import ManagedInstancePrivateEndpointConnectionsOperations # type: ignore -from ._managed_instance_private_link_resources_operations import ManagedInstancePrivateLinkResourcesOperations # type: ignore -from ._managed_instance_tde_certificates_operations import ManagedInstanceTdeCertificatesOperations # type: ignore -from ._managed_instance_vulnerability_assessments_operations import ManagedInstanceVulnerabilityAssessmentsOperations # type: ignore -from ._managed_restorable_dropped_database_backup_short_term_retention_policies_operations import ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations # type: ignore -from ._managed_server_security_alert_policies_operations import ManagedServerSecurityAlertPoliciesOperations # type: ignore from ._operations import Operations # type: ignore -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore -from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore -from ._recoverable_managed_databases_operations import RecoverableManagedDatabasesOperations # type: ignore -from ._restore_points_operations import RestorePointsOperations # type: ignore -from ._server_advisors_operations import ServerAdvisorsOperations # type: ignore -from ._server_automatic_tuning_operations import ServerAutomaticTuningOperations # type: ignore -from ._server_azure_ad_administrators_operations import ServerAzureADAdministratorsOperations # type: ignore -from ._server_azure_ad_only_authentications_operations import ServerAzureADOnlyAuthenticationsOperations # type: ignore -from ._server_dev_ops_audit_settings_operations import ServerDevOpsAuditSettingsOperations # type: ignore -from ._server_dns_aliases_operations import ServerDnsAliasesOperations # type: ignore -from ._server_keys_operations import ServerKeysOperations # type: ignore -from ._server_operations_operations import ServerOperationsOperations # type: ignore -from ._server_security_alert_policies_operations import ServerSecurityAlertPoliciesOperations # type: ignore -from ._server_trust_groups_operations import ServerTrustGroupsOperations # type: ignore -from ._server_vulnerability_assessments_operations import ServerVulnerabilityAssessmentsOperations # type: ignore -from ._sql_agent_operations import SqlAgentOperations # type: ignore -from ._subscription_usages_operations import SubscriptionUsagesOperations # type: ignore -from ._sync_agents_operations import SyncAgentsOperations # type: ignore -from ._sync_groups_operations import SyncGroupsOperations # type: ignore -from ._sync_members_operations import SyncMembersOperations # type: ignore -from ._tde_certificates_operations import TdeCertificatesOperations # type: ignore -from ._time_zones_operations import TimeZonesOperations # type: ignore -from ._virtual_network_rules_operations import VirtualNetworkRulesOperations # type: ignore -from ._workload_classifiers_operations import WorkloadClassifiersOperations # type: ignore -from ._workload_groups_operations import WorkloadGroupsOperations # type: ignore -from ._backup_short_term_retention_policies_operations import BackupShortTermRetentionPoliciesOperations # type: ignore -from ._database_extensions_operations import DatabaseExtensionsOperations # type: ignore -from ._database_usages_operations import DatabaseUsagesOperations # type: ignore -from ._ledger_digest_uploads_operations import LedgerDigestUploadsOperations # type: ignore -from ._outbound_firewall_rules_operations import OutboundFirewallRulesOperations # type: ignore -from ._usages_operations import UsagesOperations # type: ignore -from ._long_term_retention_managed_instance_backups_operations import LongTermRetentionManagedInstanceBackupsOperations # type: ignore -from ._restorable_dropped_managed_databases_operations import RestorableDroppedManagedDatabasesOperations # type: ignore -from ._server_connection_policies_operations import ServerConnectionPoliciesOperations # type: ignore -from ._server_trust_certificates_operations import ServerTrustCertificatesOperations # type: ignore -from ._endpoint_certificates_operations import EndpointCertificatesOperations # type: ignore -from ._managed_database_sensitivity_labels_operations import ManagedDatabaseSensitivityLabelsOperations # type: ignore -from ._managed_database_recommended_sensitivity_labels_operations import ManagedDatabaseRecommendedSensitivityLabelsOperations # type: ignore -from ._sensitivity_labels_operations import SensitivityLabelsOperations # type: ignore -from ._recommended_sensitivity_labels_operations import RecommendedSensitivityLabelsOperations # type: ignore -from ._server_blob_auditing_policies_operations import ServerBlobAuditingPoliciesOperations # type: ignore -from ._database_blob_auditing_policies_operations import DatabaseBlobAuditingPoliciesOperations # type: ignore -from ._extended_database_blob_auditing_policies_operations import ExtendedDatabaseBlobAuditingPoliciesOperations # type: ignore -from ._extended_server_blob_auditing_policies_operations import ExtendedServerBlobAuditingPoliciesOperations # type: ignore -from ._database_advanced_threat_protection_settings_operations import DatabaseAdvancedThreatProtectionSettingsOperations # type: ignore -from ._server_advanced_threat_protection_settings_operations import ServerAdvancedThreatProtectionSettingsOperations # type: ignore -from ._managed_server_dns_aliases_operations import ManagedServerDnsAliasesOperations # type: ignore -from ._managed_database_advanced_threat_protection_settings_operations import ManagedDatabaseAdvancedThreatProtectionSettingsOperations # type: ignore -from ._managed_instance_advanced_threat_protection_settings_operations import ManagedInstanceAdvancedThreatProtectionSettingsOperations # type: ignore -from ._managed_database_move_operations_operations import ManagedDatabaseMoveOperationsOperations # type: ignore -from ._managed_instance_dtcs_operations import ManagedInstanceDtcsOperations # type: ignore -from ._synapse_link_workspaces_operations import SynapseLinkWorkspacesOperations # type: ignore -from ._virtual_clusters_operations import VirtualClustersOperations # type: ignore -from ._instance_failover_groups_operations import InstanceFailoverGroupsOperations # type: ignore -from ._managed_database_restore_details_operations import ManagedDatabaseRestoreDetailsOperations # type: ignore -from ._database_encryption_protectors_operations import DatabaseEncryptionProtectorsOperations # type: ignore -from ._managed_databases_operations import ManagedDatabasesOperations # type: ignore -from ._managed_ledger_digest_uploads_operations import ManagedLedgerDigestUploadsOperations # type: ignore -from ._recoverable_databases_operations import RecoverableDatabasesOperations # type: ignore -from ._restorable_dropped_databases_operations import RestorableDroppedDatabasesOperations # type: ignore -from ._server_configuration_options_operations import ServerConfigurationOptionsOperations # type: ignore -from ._start_stop_managed_instance_schedules_operations import StartStopManagedInstanceSchedulesOperations # type: ignore -from ._transparent_data_encryptions_operations import TransparentDataEncryptionsOperations # type: ignore -from ._ipv6_firewall_rules_operations import IPv6FirewallRulesOperations # type: ignore -from ._sql_vulnerability_assessment_baseline_operations import SqlVulnerabilityAssessmentBaselineOperations # type: ignore -from ._sql_vulnerability_assessment_baselines_operations import SqlVulnerabilityAssessmentBaselinesOperations # type: ignore -from ._sql_vulnerability_assessment_execute_scan_operations import SqlVulnerabilityAssessmentExecuteScanOperations # type: ignore -from ._sql_vulnerability_assessment_rule_baseline_operations import SqlVulnerabilityAssessmentRuleBaselineOperations # type: ignore -from ._sql_vulnerability_assessment_rule_baselines_operations import SqlVulnerabilityAssessmentRuleBaselinesOperations # type: ignore -from ._sql_vulnerability_assessment_scan_result_operations import SqlVulnerabilityAssessmentScanResultOperations # type: ignore -from ._sql_vulnerability_assessment_scans_operations import SqlVulnerabilityAssessmentScansOperations # type: ignore -from ._sql_vulnerability_assessments_settings_operations import SqlVulnerabilityAssessmentsSettingsOperations # type: ignore -from ._sql_vulnerability_assessments_operations import SqlVulnerabilityAssessmentsOperations # type: ignore -from ._database_sql_vulnerability_assessment_baselines_operations import DatabaseSqlVulnerabilityAssessmentBaselinesOperations # type: ignore -from ._database_sql_vulnerability_assessment_execute_scan_operations import DatabaseSqlVulnerabilityAssessmentExecuteScanOperations # type: ignore -from ._database_sql_vulnerability_assessment_rule_baselines_operations import DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations # type: ignore -from ._database_sql_vulnerability_assessment_scan_result_operations import DatabaseSqlVulnerabilityAssessmentScanResultOperations # type: ignore -from ._database_sql_vulnerability_assessment_scans_operations import DatabaseSqlVulnerabilityAssessmentScansOperations # type: ignore -from ._database_sql_vulnerability_assessments_settings_operations import DatabaseSqlVulnerabilityAssessmentsSettingsOperations # type: ignore -from ._failover_groups_operations import FailoverGroupsOperations # type: ignore -from ._instance_pools_operations import InstancePoolsOperations # type: ignore -from ._managed_instances_operations import ManagedInstancesOperations # type: ignore -from ._replication_links_operations import ReplicationLinksOperations # type: ignore -from ._distributed_availability_groups_operations import DistributedAvailabilityGroupsOperations # type: ignore -from ._servers_operations import ServersOperations # type: ignore -from ._long_term_retention_backups_operations import LongTermRetentionBackupsOperations # type: ignore -from ._long_term_retention_policies_operations import LongTermRetentionPoliciesOperations # type: ignore -from ._database_operations_operations import DatabaseOperationsOperations # type: ignore +from ._operations import BackupShortTermRetentionPoliciesOperations # type: ignore +from ._operations import DatabaseColumnsOperations # type: ignore +from ._operations import RestorePointsOperations # type: ignore +from ._operations import SensitivityLabelsOperations # type: ignore +from ._operations import DatabasesOperations # type: ignore +from ._operations import FirewallRulesOperations # type: ignore +from ._operations import ReplicationLinksOperations # type: ignore +from ._operations import ServersOperations # type: ignore +from ._operations import ServerBlobAuditingPoliciesOperations # type: ignore +from ._operations import DatabaseBlobAuditingPoliciesOperations # type: ignore +from ._operations import ExtendedDatabaseBlobAuditingPoliciesOperations # type: ignore +from ._operations import ExtendedServerBlobAuditingPoliciesOperations # type: ignore +from ._operations import ServerAdvisorsOperations # type: ignore +from ._operations import ManagedDatabaseColumnsOperations # type: ignore +from ._operations import DatabaseTablesOperations # type: ignore +from ._operations import ManagedDatabaseTablesOperations # type: ignore +from ._operations import DatabaseSchemasOperations # type: ignore +from ._operations import ManagedDatabaseSchemasOperations # type: ignore +from ._operations import DatabaseSecurityAlertPoliciesOperations # type: ignore +from ._operations import SqlVulnerabilityAssessmentBaselineOperations # type: ignore +from ._operations import SqlVulnerabilityAssessmentsOperations # type: ignore +from ._operations import SqlVulnerabilityAssessmentsSettingsOperations # type: ignore +from ._operations import DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations # type: ignore +from ._operations import SqlVulnerabilityAssessmentRuleBaselineOperations # type: ignore +from ._operations import DatabaseSqlVulnerabilityAssessmentScanResultOperations # type: ignore +from ._operations import SqlVulnerabilityAssessmentScanResultOperations # type: ignore +from ._operations import SqlVulnerabilityAssessmentScansOperations # type: ignore +from ._operations import DatabaseVulnerabilityAssessmentRuleBaselinesOperations # type: ignore +from ._operations import ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations # type: ignore +from ._operations import DatabaseVulnerabilityAssessmentsOperations # type: ignore +from ._operations import ManagedDatabaseVulnerabilityAssessmentsOperations # type: ignore +from ._operations import ManagedDatabaseVulnerabilityAssessmentScansOperations # type: ignore +from ._operations import DataMaskingPoliciesOperations # type: ignore +from ._operations import DeletedServersOperations # type: ignore +from ._operations import DistributedAvailabilityGroupsOperations # type: ignore +from ._operations import ManagedDatabasesOperations # type: ignore +from ._operations import ServerTrustGroupsOperations # type: ignore +from ._operations import ManagedInstancesOperations # type: ignore +from ._operations import ElasticPoolsOperations # type: ignore +from ._operations import EncryptionProtectorsOperations # type: ignore +from ._operations import EndpointCertificatesOperations # type: ignore +from ._operations import FailoverGroupsOperations # type: ignore +from ._operations import GeoBackupPoliciesOperations # type: ignore +from ._operations import InstanceFailoverGroupsOperations # type: ignore +from ._operations import InstancePoolOperationsOperations # type: ignore +from ._operations import InstancePoolsOperations # type: ignore +from ._operations import IPv6FirewallRulesOperations # type: ignore +from ._operations import JobExecutionsOperations # type: ignore +from ._operations import JobAgentsOperations # type: ignore +from ._operations import JobCredentialsOperations # type: ignore +from ._operations import JobStepExecutionsOperations # type: ignore +from ._operations import JobTargetExecutionsOperations # type: ignore +from ._operations import JobsOperations # type: ignore +from ._operations import JobPrivateEndpointsOperations # type: ignore +from ._operations import JobStepsOperations # type: ignore +from ._operations import JobTargetGroupsOperations # type: ignore +from ._operations import JobVersionsOperations # type: ignore +from ._operations import LongTermRetentionBackupsOperations # type: ignore +from ._operations import LongTermRetentionManagedInstanceBackupsOperations # type: ignore +from ._operations import LongTermRetentionPoliciesOperations # type: ignore +from ._operations import ManagedBackupShortTermRetentionPoliciesOperations # type: ignore +from ._operations import ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations # type: ignore +from ._operations import ManagedDatabaseSecurityAlertPoliciesOperations # type: ignore +from ._operations import ManagedInstanceAdministratorsOperations # type: ignore +from ._operations import ManagedInstanceAzureADOnlyAuthenticationsOperations # type: ignore +from ._operations import ManagedInstanceDtcsOperations # type: ignore +from ._operations import ManagedInstanceEncryptionProtectorsOperations # type: ignore +from ._operations import ManagedInstanceKeysOperations # type: ignore +from ._operations import ManagedInstanceLongTermRetentionPoliciesOperations # type: ignore +from ._operations import ManagedInstanceOperationsOperations # type: ignore +from ._operations import ManagedInstancePrivateEndpointConnectionsOperations # type: ignore +from ._operations import ManagedInstanceVulnerabilityAssessmentsOperations # type: ignore +from ._operations import ManagedServerDnsAliasesOperations # type: ignore +from ._operations import ManagedServerSecurityAlertPoliciesOperations # type: ignore +from ._operations import NetworkSecurityPerimeterConfigurationsOperations # type: ignore +from ._operations import OutboundFirewallRulesOperations # type: ignore +from ._operations import PrivateEndpointConnectionsOperations # type: ignore +from ._operations import PrivateLinkResourcesOperations # type: ignore +from ._operations import RecoverableDatabasesOperations # type: ignore +from ._operations import RecoverableManagedDatabasesOperations # type: ignore +from ._operations import RestorableDroppedDatabasesOperations # type: ignore +from ._operations import RestorableDroppedManagedDatabasesOperations # type: ignore +from ._operations import ServerAzureADAdministratorsOperations # type: ignore +from ._operations import ServerAzureADOnlyAuthenticationsOperations # type: ignore +from ._operations import ServerConfigurationOptionsOperations # type: ignore +from ._operations import ServerConnectionPoliciesOperations # type: ignore +from ._operations import ServerDevOpsAuditSettingsOperations # type: ignore +from ._operations import ServerDnsAliasesOperations # type: ignore +from ._operations import ServerKeysOperations # type: ignore +from ._operations import ServerSecurityAlertPoliciesOperations # type: ignore +from ._operations import ServerTrustCertificatesOperations # type: ignore +from ._operations import ServerVulnerabilityAssessmentsOperations # type: ignore +from ._operations import StartStopManagedInstanceSchedulesOperations # type: ignore +from ._operations import SubscriptionUsagesOperations # type: ignore +from ._operations import SyncAgentsOperations # type: ignore +from ._operations import SyncGroupsOperations # type: ignore +from ._operations import SyncMembersOperations # type: ignore +from ._operations import TimeZonesOperations # type: ignore +from ._operations import VirtualClustersOperations # type: ignore +from ._operations import VirtualNetworkRulesOperations # type: ignore +from ._operations import WorkloadClassifiersOperations # type: ignore +from ._operations import WorkloadGroupsOperations # type: ignore +from ._operations import ManagedDatabaseSensitivityLabelsOperations # type: ignore +from ._operations import DatabaseEncryptionProtectorsOperations # type: ignore +from ._operations import DatabaseOperationsOperations # type: ignore +from ._operations import DatabaseUsagesOperations # type: ignore +from ._operations import RecommendedSensitivityLabelsOperations # type: ignore +from ._operations import SynapseLinkWorkspacesOperations # type: ignore +from ._operations import ServerOperationsOperations # type: ignore +from ._operations import ServerUsagesOperations # type: ignore +from ._operations import TdeCertificatesOperations # type: ignore +from ._operations import DatabaseAdvancedThreatProtectionSettingsOperations # type: ignore +from ._operations import DatabaseAdvisorsOperations # type: ignore +from ._operations import DatabaseAutomaticTuningOperations # type: ignore +from ._operations import DatabaseExtensionsOperations # type: ignore +from ._operations import DatabaseRecommendedActionsOperations # type: ignore +from ._operations import DatabaseSqlVulnerabilityAssessmentBaselinesOperations # type: ignore +from ._operations import SqlVulnerabilityAssessmentBaselinesOperations # type: ignore +from ._operations import DatabaseSqlVulnerabilityAssessmentsSettingsOperations # type: ignore +from ._operations import DatabaseSqlVulnerabilityAssessmentExecuteScanOperations # type: ignore +from ._operations import SqlVulnerabilityAssessmentExecuteScanOperations # type: ignore +from ._operations import SqlVulnerabilityAssessmentRuleBaselinesOperations # type: ignore +from ._operations import DatabaseSqlVulnerabilityAssessmentScansOperations # type: ignore +from ._operations import DatabaseVulnerabilityAssessmentScansOperations # type: ignore +from ._operations import DataMaskingRulesOperations # type: ignore +from ._operations import DataWarehouseUserActivitiesOperations # type: ignore +from ._operations import ManagedDatabaseSecurityEventsOperations # type: ignore +from ._operations import ManagedDatabaseRecommendedSensitivityLabelsOperations # type: ignore +from ._operations import ManagedInstanceTdeCertificatesOperations # type: ignore +from ._operations import ElasticPoolOperationsOperations # type: ignore +from ._operations import UsagesOperations # type: ignore +from ._operations import LedgerDigestUploadsOperations # type: ignore +from ._operations import MaintenanceWindowOptionsOperations # type: ignore +from ._operations import MaintenanceWindowsOperations # type: ignore +from ._operations import ManagedDatabaseAdvancedThreatProtectionSettingsOperations # type: ignore +from ._operations import ManagedDatabaseMoveOperationsOperations # type: ignore +from ._operations import ManagedDatabaseQueriesOperations # type: ignore +from ._operations import ManagedDatabaseRestoreDetailsOperations # type: ignore +from ._operations import ManagedDatabaseTransparentDataEncryptionOperations # type: ignore +from ._operations import ManagedInstanceAdvancedThreatProtectionSettingsOperations # type: ignore +from ._operations import ManagedInstancePrivateLinkResourcesOperations # type: ignore +from ._operations import ManagedLedgerDigestUploadsOperations # type: ignore +from ._operations import ServerAdvancedThreatProtectionSettingsOperations # type: ignore +from ._operations import ServerAutomaticTuningOperations # type: ignore +from ._operations import SqlAgentOperations # type: ignore +from ._operations import TransparentDataEncryptionsOperations # type: ignore +from ._operations import CapabilitiesOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ - "DataMaskingPoliciesOperations", - "DataMaskingRulesOperations", - "GeoBackupPoliciesOperations", - "DatabasesOperations", - "ElasticPoolsOperations", - "ServerCommunicationLinksOperations", - "ServiceObjectivesOperations", - "ElasticPoolActivitiesOperations", - "ElasticPoolDatabaseActivitiesOperations", - "ServerUsagesOperations", - "DatabaseAdvisorsOperations", - "DatabaseAutomaticTuningOperations", + "Operations", + "BackupShortTermRetentionPoliciesOperations", "DatabaseColumnsOperations", - "DatabaseRecommendedActionsOperations", + "RestorePointsOperations", + "SensitivityLabelsOperations", + "DatabasesOperations", + "FirewallRulesOperations", + "ReplicationLinksOperations", + "ServersOperations", + "ServerBlobAuditingPoliciesOperations", + "DatabaseBlobAuditingPoliciesOperations", + "ExtendedDatabaseBlobAuditingPoliciesOperations", + "ExtendedServerBlobAuditingPoliciesOperations", + "ServerAdvisorsOperations", + "ManagedDatabaseColumnsOperations", + "DatabaseTablesOperations", + "ManagedDatabaseTablesOperations", "DatabaseSchemasOperations", + "ManagedDatabaseSchemasOperations", "DatabaseSecurityAlertPoliciesOperations", - "DatabaseTablesOperations", + "SqlVulnerabilityAssessmentBaselineOperations", + "SqlVulnerabilityAssessmentsOperations", + "SqlVulnerabilityAssessmentsSettingsOperations", + "DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations", + "SqlVulnerabilityAssessmentRuleBaselineOperations", + "DatabaseSqlVulnerabilityAssessmentScanResultOperations", + "SqlVulnerabilityAssessmentScanResultOperations", + "SqlVulnerabilityAssessmentScansOperations", "DatabaseVulnerabilityAssessmentRuleBaselinesOperations", + "ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations", "DatabaseVulnerabilityAssessmentsOperations", - "DatabaseVulnerabilityAssessmentScansOperations", - "DataWarehouseUserActivitiesOperations", + "ManagedDatabaseVulnerabilityAssessmentsOperations", + "ManagedDatabaseVulnerabilityAssessmentScansOperations", + "DataMaskingPoliciesOperations", "DeletedServersOperations", - "ElasticPoolOperationsOperations", + "DistributedAvailabilityGroupsOperations", + "ManagedDatabasesOperations", + "ServerTrustGroupsOperations", + "ManagedInstancesOperations", + "ElasticPoolsOperations", "EncryptionProtectorsOperations", - "FirewallRulesOperations", + "EndpointCertificatesOperations", + "FailoverGroupsOperations", + "GeoBackupPoliciesOperations", + "InstanceFailoverGroupsOperations", + "InstancePoolOperationsOperations", + "InstancePoolsOperations", + "IPv6FirewallRulesOperations", + "JobExecutionsOperations", "JobAgentsOperations", "JobCredentialsOperations", - "JobExecutionsOperations", - "JobPrivateEndpointsOperations", - "JobsOperations", "JobStepExecutionsOperations", - "JobStepsOperations", "JobTargetExecutionsOperations", + "JobsOperations", + "JobPrivateEndpointsOperations", + "JobStepsOperations", "JobTargetGroupsOperations", "JobVersionsOperations", - "CapabilitiesOperations", - "MaintenanceWindowOptionsOperations", - "MaintenanceWindowsOperations", + "LongTermRetentionBackupsOperations", + "LongTermRetentionManagedInstanceBackupsOperations", + "LongTermRetentionPoliciesOperations", "ManagedBackupShortTermRetentionPoliciesOperations", - "ManagedDatabaseColumnsOperations", - "ManagedDatabaseQueriesOperations", - "ManagedDatabaseSchemasOperations", + "ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations", "ManagedDatabaseSecurityAlertPoliciesOperations", - "ManagedDatabaseSecurityEventsOperations", - "ManagedDatabaseTablesOperations", - "ManagedDatabaseTransparentDataEncryptionOperations", - "ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations", - "ManagedDatabaseVulnerabilityAssessmentsOperations", - "ManagedDatabaseVulnerabilityAssessmentScansOperations", "ManagedInstanceAdministratorsOperations", "ManagedInstanceAzureADOnlyAuthenticationsOperations", + "ManagedInstanceDtcsOperations", "ManagedInstanceEncryptionProtectorsOperations", "ManagedInstanceKeysOperations", "ManagedInstanceLongTermRetentionPoliciesOperations", "ManagedInstanceOperationsOperations", "ManagedInstancePrivateEndpointConnectionsOperations", - "ManagedInstancePrivateLinkResourcesOperations", - "ManagedInstanceTdeCertificatesOperations", "ManagedInstanceVulnerabilityAssessmentsOperations", - "ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations", + "ManagedServerDnsAliasesOperations", "ManagedServerSecurityAlertPoliciesOperations", - "Operations", + "NetworkSecurityPerimeterConfigurationsOperations", + "OutboundFirewallRulesOperations", "PrivateEndpointConnectionsOperations", "PrivateLinkResourcesOperations", + "RecoverableDatabasesOperations", "RecoverableManagedDatabasesOperations", - "RestorePointsOperations", - "ServerAdvisorsOperations", - "ServerAutomaticTuningOperations", + "RestorableDroppedDatabasesOperations", + "RestorableDroppedManagedDatabasesOperations", "ServerAzureADAdministratorsOperations", "ServerAzureADOnlyAuthenticationsOperations", + "ServerConfigurationOptionsOperations", + "ServerConnectionPoliciesOperations", "ServerDevOpsAuditSettingsOperations", "ServerDnsAliasesOperations", "ServerKeysOperations", - "ServerOperationsOperations", "ServerSecurityAlertPoliciesOperations", - "ServerTrustGroupsOperations", + "ServerTrustCertificatesOperations", "ServerVulnerabilityAssessmentsOperations", - "SqlAgentOperations", + "StartStopManagedInstanceSchedulesOperations", "SubscriptionUsagesOperations", "SyncAgentsOperations", "SyncGroupsOperations", "SyncMembersOperations", - "TdeCertificatesOperations", "TimeZonesOperations", + "VirtualClustersOperations", "VirtualNetworkRulesOperations", "WorkloadClassifiersOperations", "WorkloadGroupsOperations", - "BackupShortTermRetentionPoliciesOperations", - "DatabaseExtensionsOperations", - "DatabaseUsagesOperations", - "LedgerDigestUploadsOperations", - "OutboundFirewallRulesOperations", - "UsagesOperations", - "LongTermRetentionManagedInstanceBackupsOperations", - "RestorableDroppedManagedDatabasesOperations", - "ServerConnectionPoliciesOperations", - "ServerTrustCertificatesOperations", - "EndpointCertificatesOperations", "ManagedDatabaseSensitivityLabelsOperations", - "ManagedDatabaseRecommendedSensitivityLabelsOperations", - "SensitivityLabelsOperations", + "DatabaseEncryptionProtectorsOperations", + "DatabaseOperationsOperations", + "DatabaseUsagesOperations", "RecommendedSensitivityLabelsOperations", - "ServerBlobAuditingPoliciesOperations", - "DatabaseBlobAuditingPoliciesOperations", - "ExtendedDatabaseBlobAuditingPoliciesOperations", - "ExtendedServerBlobAuditingPoliciesOperations", + "SynapseLinkWorkspacesOperations", + "ServerOperationsOperations", + "ServerUsagesOperations", + "TdeCertificatesOperations", "DatabaseAdvancedThreatProtectionSettingsOperations", - "ServerAdvancedThreatProtectionSettingsOperations", - "ManagedServerDnsAliasesOperations", + "DatabaseAdvisorsOperations", + "DatabaseAutomaticTuningOperations", + "DatabaseExtensionsOperations", + "DatabaseRecommendedActionsOperations", + "DatabaseSqlVulnerabilityAssessmentBaselinesOperations", + "SqlVulnerabilityAssessmentBaselinesOperations", + "DatabaseSqlVulnerabilityAssessmentsSettingsOperations", + "DatabaseSqlVulnerabilityAssessmentExecuteScanOperations", + "SqlVulnerabilityAssessmentExecuteScanOperations", + "SqlVulnerabilityAssessmentRuleBaselinesOperations", + "DatabaseSqlVulnerabilityAssessmentScansOperations", + "DatabaseVulnerabilityAssessmentScansOperations", + "DataMaskingRulesOperations", + "DataWarehouseUserActivitiesOperations", + "ManagedDatabaseSecurityEventsOperations", + "ManagedDatabaseRecommendedSensitivityLabelsOperations", + "ManagedInstanceTdeCertificatesOperations", + "ElasticPoolOperationsOperations", + "UsagesOperations", + "LedgerDigestUploadsOperations", + "MaintenanceWindowOptionsOperations", + "MaintenanceWindowsOperations", "ManagedDatabaseAdvancedThreatProtectionSettingsOperations", - "ManagedInstanceAdvancedThreatProtectionSettingsOperations", "ManagedDatabaseMoveOperationsOperations", - "ManagedInstanceDtcsOperations", - "SynapseLinkWorkspacesOperations", - "VirtualClustersOperations", - "InstanceFailoverGroupsOperations", + "ManagedDatabaseQueriesOperations", "ManagedDatabaseRestoreDetailsOperations", - "DatabaseEncryptionProtectorsOperations", - "ManagedDatabasesOperations", + "ManagedDatabaseTransparentDataEncryptionOperations", + "ManagedInstanceAdvancedThreatProtectionSettingsOperations", + "ManagedInstancePrivateLinkResourcesOperations", "ManagedLedgerDigestUploadsOperations", - "RecoverableDatabasesOperations", - "RestorableDroppedDatabasesOperations", - "ServerConfigurationOptionsOperations", - "StartStopManagedInstanceSchedulesOperations", + "ServerAdvancedThreatProtectionSettingsOperations", + "ServerAutomaticTuningOperations", + "SqlAgentOperations", "TransparentDataEncryptionsOperations", - "IPv6FirewallRulesOperations", - "SqlVulnerabilityAssessmentBaselineOperations", - "SqlVulnerabilityAssessmentBaselinesOperations", - "SqlVulnerabilityAssessmentExecuteScanOperations", - "SqlVulnerabilityAssessmentRuleBaselineOperations", - "SqlVulnerabilityAssessmentRuleBaselinesOperations", - "SqlVulnerabilityAssessmentScanResultOperations", - "SqlVulnerabilityAssessmentScansOperations", - "SqlVulnerabilityAssessmentsSettingsOperations", - "SqlVulnerabilityAssessmentsOperations", - "DatabaseSqlVulnerabilityAssessmentBaselinesOperations", - "DatabaseSqlVulnerabilityAssessmentExecuteScanOperations", - "DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations", - "DatabaseSqlVulnerabilityAssessmentScanResultOperations", - "DatabaseSqlVulnerabilityAssessmentScansOperations", - "DatabaseSqlVulnerabilityAssessmentsSettingsOperations", - "FailoverGroupsOperations", - "InstancePoolsOperations", - "ManagedInstancesOperations", - "ReplicationLinksOperations", - "DistributedAvailabilityGroupsOperations", - "ServersOperations", - "LongTermRetentionBackupsOperations", - "LongTermRetentionPoliciesOperations", - "DatabaseOperationsOperations", + "CapabilitiesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _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 deleted file mode 100644 index 7da3e128fb5c..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_backup_short_term_retention_policies_operations.py +++ /dev/null @@ -1,648 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._backup_short_term_retention_policies_operations import ( - build_create_or_update_request, - build_get_request, - build_list_by_database_request, - build_update_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class BackupShortTermRetentionPoliciesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`backup_short_term_retention_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - policy_name: Union[str, _models.ShortTermRetentionPolicyName], - **kwargs: Any - ) -> _models.BackupShortTermRetentionPolicy: - """Gets a database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ShortTermRetentionPolicyName - :return: BackupShortTermRetentionPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.BackupShortTermRetentionPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[_models.BackupShortTermRetentionPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - policy_name=policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("BackupShortTermRetentionPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - policy_name: Union[str, _models.ShortTermRetentionPolicyName], - parameters: Union[_models.BackupShortTermRetentionPolicy, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2021-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "BackupShortTermRetentionPolicy") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - policy_name=policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - policy_name: Union[str, _models.ShortTermRetentionPolicyName], - parameters: _models.BackupShortTermRetentionPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.BackupShortTermRetentionPolicy]: - """Updates a database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Required. - :type parameters: ~azure.mgmt.sql.models.BackupShortTermRetentionPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either BackupShortTermRetentionPolicy or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - policy_name: Union[str, _models.ShortTermRetentionPolicyName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.BackupShortTermRetentionPolicy]: - """Updates a database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either BackupShortTermRetentionPolicy or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - policy_name: Union[str, _models.ShortTermRetentionPolicyName], - parameters: Union[_models.BackupShortTermRetentionPolicy, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.BackupShortTermRetentionPolicy]: - """Updates a database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Is either a - BackupShortTermRetentionPolicy type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.BackupShortTermRetentionPolicy or IO[bytes] - :return: An instance of AsyncLROPoller that returns either BackupShortTermRetentionPolicy or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.BackupShortTermRetentionPolicy] = 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, - policy_name=policy_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("BackupShortTermRetentionPolicy", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.BackupShortTermRetentionPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.BackupShortTermRetentionPolicy]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - policy_name: Union[str, _models.ShortTermRetentionPolicyName], - parameters: Union[_models.BackupShortTermRetentionPolicy, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2021-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "BackupShortTermRetentionPolicy") - - _request = build_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - policy_name=policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - policy_name: Union[str, _models.ShortTermRetentionPolicyName], - parameters: _models.BackupShortTermRetentionPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.BackupShortTermRetentionPolicy]: - """Updates a database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Required. - :type parameters: ~azure.mgmt.sql.models.BackupShortTermRetentionPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either BackupShortTermRetentionPolicy or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - policy_name: Union[str, _models.ShortTermRetentionPolicyName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.BackupShortTermRetentionPolicy]: - """Updates a database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either BackupShortTermRetentionPolicy or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - policy_name: Union[str, _models.ShortTermRetentionPolicyName], - parameters: Union[_models.BackupShortTermRetentionPolicy, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.BackupShortTermRetentionPolicy]: - """Updates a database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Is either a - BackupShortTermRetentionPolicy type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.BackupShortTermRetentionPolicy or IO[bytes] - :return: An instance of AsyncLROPoller that returns either BackupShortTermRetentionPolicy or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.BackupShortTermRetentionPolicy] = 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( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - policy_name=policy_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("BackupShortTermRetentionPolicy", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.BackupShortTermRetentionPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.BackupShortTermRetentionPolicy]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either BackupShortTermRetentionPolicy or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[_models.BackupShortTermRetentionPolicyListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index d94594af61a8..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_capabilities_operations.py +++ /dev/null @@ -1,112 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar, Union - -from azure.core import AsyncPipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -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 ..._utils.serialization import Deserializer, Serializer -from ...operations._capabilities_operations import build_list_by_location_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class CapabilitiesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`capabilities` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def list_by_location( - self, location_name: str, include: Optional[Union[str, _models.CapabilityGroup]] = None, **kwargs: Any - ) -> _models.LocationCapabilities: - """Gets the subscription capabilities available for the specified location. - - :param location_name: The location name whose capabilities are retrieved. Required. - :type location_name: str - :param include: If specified, restricts the response to only include the selected item. Known - values are: "supportedEditions", "supportedElasticPoolEditions", - "supportedManagedInstanceVersions", "supportedInstancePoolEditions", and - "supportedManagedInstanceEditions". Default value is None. - :type include: str or ~azure.mgmt.sql.models.CapabilityGroup - :return: LocationCapabilities or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.LocationCapabilities - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.LocationCapabilities] = kwargs.pop("cls", None) - - _request = build_list_by_location_request( - location_name=location_name, - subscription_id=self._config.subscription_id, - include=include, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("LocationCapabilities", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_data_masking_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_data_masking_policies_operations.py deleted file mode 100644 index 2cff1329da80..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_data_masking_policies_operations.py +++ /dev/null @@ -1,258 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Literal, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -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 ..._utils.serialization import Deserializer, Serializer -from ...operations._data_masking_policies_operations import build_create_or_update_request, build_get_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class DataMaskingPoliciesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`data_masking_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: _models.DataMaskingPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataMaskingPolicy: - """Creates or updates a database data masking policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 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 - :return: DataMaskingPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DataMaskingPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataMaskingPolicy: - """Creates or updates a database data masking policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: Parameters for creating or updating a data masking policy. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DataMaskingPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DataMaskingPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.DataMaskingPolicy, IO[bytes]], - **kwargs: Any - ) -> _models.DataMaskingPolicy: - """Creates or updates a database data masking policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: Parameters for creating or updating a data masking policy. Is either a - DataMaskingPolicy type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DataMaskingPolicy or IO[bytes] - :return: DataMaskingPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DataMaskingPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - 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)) - cls: ClsType[_models.DataMaskingPolicy] = 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, "DataMaskingPolicy") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - data_masking_policy_name=data_masking_policy_name, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: DataMaskingPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DataMaskingPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") - cls: ClsType[_models.DataMaskingPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - data_masking_policy_name=data_masking_policy_name, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_data_masking_rules_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_data_masking_rules_operations.py deleted file mode 100644 index f4ca43fa3c06..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_data_masking_rules_operations.py +++ /dev/null @@ -1,287 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Literal, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._data_masking_rules_operations import build_create_or_update_request, build_list_by_database_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class DataMaskingRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`data_masking_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - data_masking_rule_name: str, - parameters: _models.DataMaskingRule, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataMaskingRule: - """Creates or updates a database data masking rule. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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_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. - Required. - :type parameters: ~azure.mgmt.sql.models.DataMaskingRule - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DataMaskingRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DataMaskingRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - data_masking_rule_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataMaskingRule: - """Creates or updates a database data masking rule. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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_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. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DataMaskingRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DataMaskingRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - data_masking_rule_name: str, - parameters: Union[_models.DataMaskingRule, IO[bytes]], - **kwargs: Any - ) -> _models.DataMaskingRule: - """Creates or updates a database data masking rule. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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_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[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DataMaskingRule or IO[bytes] - :return: DataMaskingRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DataMaskingRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - 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)) - cls: ClsType[_models.DataMaskingRule] = 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, "DataMaskingRule") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_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, - headers=_headers, - params=_params, - ) - _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, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DataMaskingRule", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either DataMaskingRule or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DataMaskingRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") - cls: ClsType[_models.DataMaskingRuleListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index d90624e4ad46..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_data_warehouse_user_activities_operations.py +++ /dev/null @@ -1,202 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar, Union - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._data_warehouse_user_activities_operations import build_get_request, build_list_by_database_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class DataWarehouseUserActivitiesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`data_warehouse_user_activities` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - :return: DataWarehouseUserActivities or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DataWarehouseUserActivities - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DataWarehouseUserActivities] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - data_warehouse_user_activity_name=data_warehouse_user_activity_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.DataWarehouseUserActivities"]: - """List the user activities of a data warehouse which includes running and suspended queries. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :return: An iterator like instance of either DataWarehouseUserActivities or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DataWarehouseUserActivities] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DataWarehouseUserActivitiesListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DataWarehouseUserActivitiesListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) 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 deleted file mode 100644 index 2b071f58ae50..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_advanced_threat_protection_settings_operations.py +++ /dev/null @@ -1,363 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._database_advanced_threat_protection_settings_operations import ( - build_create_or_update_request, - build_get_request, - build_list_by_database_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class DatabaseAdvancedThreatProtectionSettingsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`database_advanced_threat_protection_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.DatabaseAdvancedThreatProtection"]: - """Gets a list of database's Advanced Threat Protection states. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :return: An iterator like instance of either DatabaseAdvancedThreatProtection or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseAdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.DatabaseAdvancedThreatProtectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseAdvancedThreatProtectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - server_name: str, - database_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - **kwargs: Any - ) -> _models.DatabaseAdvancedThreatProtection: - """Gets a database's Advanced Threat Protection state. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. - "Default" Required. - :type advanced_threat_protection_name: str or - ~azure.mgmt.sql.models.AdvancedThreatProtectionName - :return: DatabaseAdvancedThreatProtection or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseAdvancedThreatProtection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.DatabaseAdvancedThreatProtection] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - advanced_threat_protection_name=advanced_threat_protection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("DatabaseAdvancedThreatProtection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: _models.DatabaseAdvancedThreatProtection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseAdvancedThreatProtection: - """Creates or updates a database's Advanced Threat Protection state. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. - "Default" Required. - :type advanced_threat_protection_name: str or - ~azure.mgmt.sql.models.AdvancedThreatProtectionName - :param parameters: The database Advanced Threat Protection state. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseAdvancedThreatProtection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseAdvancedThreatProtection or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseAdvancedThreatProtection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseAdvancedThreatProtection: - """Creates or updates a database's Advanced Threat Protection state. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. - "Default" Required. - :type advanced_threat_protection_name: str or - ~azure.mgmt.sql.models.AdvancedThreatProtectionName - :param parameters: The database Advanced Threat Protection state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseAdvancedThreatProtection or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseAdvancedThreatProtection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: Union[_models.DatabaseAdvancedThreatProtection, IO[bytes]], - **kwargs: Any - ) -> _models.DatabaseAdvancedThreatProtection: - """Creates or updates a database's Advanced Threat Protection state. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. - "Default" Required. - :type advanced_threat_protection_name: str or - ~azure.mgmt.sql.models.AdvancedThreatProtectionName - :param parameters: The database Advanced Threat Protection state. Is either a - DatabaseAdvancedThreatProtection type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseAdvancedThreatProtection or IO[bytes] - :return: DatabaseAdvancedThreatProtection or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseAdvancedThreatProtection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2021-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DatabaseAdvancedThreatProtection") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - advanced_threat_protection_name=advanced_threat_protection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DatabaseAdvancedThreatProtection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 3a2746863940..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_advisors_operations.py +++ /dev/null @@ -1,339 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -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 ..._utils.serialization import Deserializer, Serializer -from ...operations._database_advisors_operations import ( - build_get_request, - build_list_by_database_request, - build_update_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class DatabaseAdvisorsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`database_advisors` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def list_by_database( - self, - resource_group_name: str, - server_name: str, - database_name: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> List[_models.Advisor]: - """Gets a list of database advisors. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 expand: The child resources to include in the response. Default value is None. - :type expand: str - :return: list of Advisor or the result of cls(response) - :rtype: list[~azure.mgmt.sql.models.Advisor] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[List[_models.Advisor]] = 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, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("[Advisor]", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get( - self, resource_group_name: str, server_name: str, database_name: str, advisor_name: str, **kwargs: Any - ) -> _models.Advisor: - """Gets a database advisor. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 advisor_name: The name of the Database Advisor. Required. - :type advisor_name: str - :return: Advisor or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.Advisor - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.Advisor] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - advisor_name=advisor_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("Advisor", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - advisor_name: str, - parameters: _models.Advisor, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Advisor: - """Updates a database advisor. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 advisor_name: The name of the Database Advisor. Required. - :type advisor_name: str - :param parameters: The requested advisor resource state. Required. - :type parameters: ~azure.mgmt.sql.models.Advisor - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Advisor or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.Advisor - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - advisor_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Advisor: - """Updates a database advisor. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 advisor_name: The name of the Database Advisor. Required. - :type advisor_name: str - :param parameters: The requested advisor resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: Advisor or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.Advisor - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - advisor_name: str, - parameters: Union[_models.Advisor, IO[bytes]], - **kwargs: Any - ) -> _models.Advisor: - """Updates a database advisor. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 advisor_name: The name of the Database Advisor. Required. - :type advisor_name: str - :param parameters: The requested advisor resource state. Is either a Advisor type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.Advisor or IO[bytes] - :return: Advisor or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.Advisor - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "Advisor") - - _request = build_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - advisor_name=advisor_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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("Advisor", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_automatic_tuning_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_automatic_tuning_operations.py deleted file mode 100644 index 79f973c4f9e9..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_automatic_tuning_operations.py +++ /dev/null @@ -1,254 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -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 ..._utils.serialization import Deserializer, Serializer -from ...operations._database_automatic_tuning_operations import build_get_request, build_update_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class DatabaseAutomaticTuningOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`database_automatic_tuning` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, **kwargs: Any - ) -> _models.DatabaseAutomaticTuning: - """Gets a database's automatic tuning. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :return: DatabaseAutomaticTuning or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseAutomaticTuning - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseAutomaticTuning] = 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, - headers=_headers, - params=_params, - ) - _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("DatabaseAutomaticTuning", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: _models.DatabaseAutomaticTuning, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseAutomaticTuning: - """Update automatic tuning properties for target database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The requested automatic tuning resource state. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseAutomaticTuning - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseAutomaticTuning or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseAutomaticTuning - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseAutomaticTuning: - """Update automatic tuning properties for target database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The requested automatic tuning resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseAutomaticTuning or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseAutomaticTuning - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.DatabaseAutomaticTuning, IO[bytes]], - **kwargs: Any - ) -> _models.DatabaseAutomaticTuning: - """Update automatic tuning properties for target database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The requested automatic tuning resource state. Is either a - DatabaseAutomaticTuning type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseAutomaticTuning or IO[bytes] - :return: DatabaseAutomaticTuning or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseAutomaticTuning - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DatabaseAutomaticTuning") - - _request = build_update_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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("DatabaseAutomaticTuning", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_blob_auditing_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_blob_auditing_policies_operations.py deleted file mode 100644 index 2c3958e62ec2..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_blob_auditing_policies_operations.py +++ /dev/null @@ -1,341 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Literal, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._database_blob_auditing_policies_operations import ( - build_create_or_update_request, - build_get_request, - build_list_by_database_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class DatabaseBlobAuditingPoliciesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`database_blob_auditing_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.DatabaseBlobAuditingPolicy"]: - """Lists auditing settings 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 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 - :return: An iterator like instance of either DatabaseBlobAuditingPolicy or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseBlobAuditingPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.DatabaseBlobAuditingPolicyListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseBlobAuditingPolicyListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> _models.DatabaseBlobAuditingPolicy: - """Gets a database's blob auditing policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :return: DatabaseBlobAuditingPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseBlobAuditingPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 {}) - - blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.DatabaseBlobAuditingPolicy] = 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, - blob_auditing_policy_name=blob_auditing_policy_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("DatabaseBlobAuditingPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: _models.DatabaseBlobAuditingPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseBlobAuditingPolicy: - """Creates or updates a database's blob auditing policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The database blob auditing policy. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseBlobAuditingPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseBlobAuditingPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseBlobAuditingPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseBlobAuditingPolicy: - """Creates or updates a database's blob auditing policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The database blob auditing policy. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseBlobAuditingPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseBlobAuditingPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.DatabaseBlobAuditingPolicy, IO[bytes]], - **kwargs: Any - ) -> _models.DatabaseBlobAuditingPolicy: - """Creates or updates a database's blob auditing policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The database blob auditing policy. Is either a DatabaseBlobAuditingPolicy - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseBlobAuditingPolicy or IO[bytes] - :return: DatabaseBlobAuditingPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseBlobAuditingPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 {}) - - blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DatabaseBlobAuditingPolicy") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - blob_auditing_policy_name=blob_auditing_policy_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DatabaseBlobAuditingPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 75c0be68acb7..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_columns_operations.py +++ /dev/null @@ -1,327 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._database_columns_operations import ( - build_get_request, - build_list_by_database_request, - build_list_by_table_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class DatabaseColumnsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`database_columns` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - schema: Optional[List[str]] = None, - table: Optional[List[str]] = None, - column: Optional[List[str]] = None, - order_by: Optional[List[str]] = None, - skiptoken: Optional[str] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.DatabaseColumn"]: - """List database 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: Default value is None. - :type schema: list[str] - :param table: Default value is None. - :type table: list[str] - :param column: Default value is None. - :type column: list[str] - :param order_by: Default value is None. - :type order_by: list[str] - :param skiptoken: An opaque token that identifies a starting point in the collection. Default - value is None. - :type skiptoken: str - :return: An iterator like instance of either DatabaseColumn or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseColumn] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseColumnListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - schema=schema, - table=table, - column=column, - order_by=order_by, - skiptoken=skiptoken, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseColumnListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_table( - self, - resource_group_name: str, - server_name: str, - database_name: str, - schema_name: str, - table_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.DatabaseColumn"]: - """List database 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 filter: An OData filter expression that filters elements in the collection. Default - value is None. - :type filter: str - :return: An iterator like instance of either DatabaseColumn or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseColumn] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseColumnListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_table_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - schema_name=schema_name, - table_name=table_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseColumnListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - server_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - **kwargs: Any - ) -> _models.DatabaseColumn: - """Get database column. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :return: DatabaseColumn or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseColumn - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseColumn] = 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, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("DatabaseColumn", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 73d4007c24b6..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_encryption_protectors_operations.py +++ /dev/null @@ -1,309 +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 collections.abc import MutableMapping -from typing import Any, AsyncIterator, Callable, Optional, TypeVar, Union, cast - -from azure.core import AsyncPipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -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 ..._utils.serialization import Deserializer, Serializer -from ...operations._database_encryption_protectors_operations import build_revalidate_request, build_revert_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class DatabaseEncryptionProtectorsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`database_encryption_protectors` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - async def _revalidate_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_revalidate_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - encryption_protector_name=encryption_protector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_revalidate( - self, - resource_group_name: str, - server_name: str, - database_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Revalidates an existing encryption protector for a particular 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 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 - :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", "2022-08-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( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - encryption_protector_name=encryption_protector_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _revert_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_revert_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - encryption_protector_name=encryption_protector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_revert( - self, - resource_group_name: str, - server_name: str, - database_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Reverts an existing encryption protector for a particular 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 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 - :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", "2022-08-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._revert_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - encryption_protector_name=encryption_protector_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_extensions_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_extensions_operations.py deleted file mode 100644 index 6177f211e16c..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_extensions_operations.py +++ /dev/null @@ -1,419 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._database_extensions_operations import ( - build_create_or_update_request, - build_get_request, - build_list_by_database_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class DatabaseExtensionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`database_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, extension_name: str, **kwargs: Any - ) -> None: - """Gets a database extension. This will return resource not found as it is not supported. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 extension_name: Required. - :type extension_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - extension_name=extension_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - extension_name: str, - parameters: Union[_models.DatabaseExtensions, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2021-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "DatabaseExtensions") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - extension_name=extension_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - extension_name: str, - parameters: _models.DatabaseExtensions, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ImportExportExtensionsOperationResult]: - """Perform a database extension operation, like polybase import. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 extension_name: Required. - :type extension_name: str - :param parameters: The database import request parameters. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseExtensions - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either - ImportExportExtensionsOperationResult or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportExtensionsOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - extension_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ImportExportExtensionsOperationResult]: - """Perform a database extension operation, like polybase import. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 extension_name: Required. - :type extension_name: str - :param parameters: The database import request parameters. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either - ImportExportExtensionsOperationResult or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportExtensionsOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - extension_name: str, - parameters: Union[_models.DatabaseExtensions, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ImportExportExtensionsOperationResult]: - """Perform a database extension operation, like polybase import. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 extension_name: Required. - :type extension_name: str - :param parameters: The database import request parameters. Is either a DatabaseExtensions type - or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseExtensions or IO[bytes] - :return: An instance of AsyncLROPoller that returns either - ImportExportExtensionsOperationResult or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportExtensionsOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ImportExportExtensionsOperationResult] = 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, - extension_name=extension_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ImportExportExtensionsOperationResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ImportExportExtensionsOperationResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ImportExportExtensionsOperationResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either ImportExportExtensionsOperationResult or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ImportExportExtensionsOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[_models.ImportExportExtensionsOperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 8226f3b07eab..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_operations_operations.py +++ /dev/null @@ -1,191 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._database_operations_operations import build_cancel_request, build_list_by_database_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class DatabaseOperationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`database_operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.DatabaseOperation"]: - """Gets a list of operations performed on the database. - - :param resource_group_name: The name of the resource group that contains the resource. - Required. - :type resource_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 - :return: An iterator like instance of either DatabaseOperation or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseOperation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - cls: ClsType[_models.DatabaseOperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseOperationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def cancel( - 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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2024-11-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, - headers=_headers, - params=_params, - ) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore 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 deleted file mode 100644 index 748e0e6568ae..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_recommended_actions_operations.py +++ /dev/null @@ -1,353 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -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 ..._utils.serialization import Deserializer, Serializer -from ...operations._database_recommended_actions_operations import ( - build_get_request, - build_list_by_database_advisor_request, - build_update_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class DatabaseRecommendedActionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`database_recommended_actions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def list_by_database_advisor( - self, resource_group_name: str, server_name: str, database_name: str, advisor_name: str, **kwargs: Any - ) -> List[_models.RecommendedAction]: - """Gets list of Database Recommended Actions. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 advisor_name: The name of the Database Advisor. Required. - :type advisor_name: str - :return: list of RecommendedAction or the result of cls(response) - :rtype: list[~azure.mgmt.sql.models.RecommendedAction] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[List[_models.RecommendedAction]] = kwargs.pop("cls", None) - - _request = build_list_by_database_advisor_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - advisor_name=advisor_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("[RecommendedAction]", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - server_name: str, - database_name: str, - advisor_name: str, - recommended_action_name: str, - **kwargs: Any - ) -> _models.RecommendedAction: - """Gets a database recommended action. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 advisor_name: The name of the Database Advisor. Required. - :type advisor_name: str - :param recommended_action_name: The name of Database Recommended Action. Required. - :type recommended_action_name: str - :return: RecommendedAction or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.RecommendedAction - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.RecommendedAction] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - advisor_name=advisor_name, - recommended_action_name=recommended_action_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("RecommendedAction", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - advisor_name: str, - recommended_action_name: str, - parameters: _models.RecommendedAction, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RecommendedAction: - """Updates a database recommended action. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 advisor_name: The name of the Database Advisor. Required. - :type advisor_name: str - :param recommended_action_name: The name of Database Recommended Action. Required. - :type recommended_action_name: str - :param parameters: The requested recommended action resource state. Required. - :type parameters: ~azure.mgmt.sql.models.RecommendedAction - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: RecommendedAction or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.RecommendedAction - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - advisor_name: str, - recommended_action_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RecommendedAction: - """Updates a database recommended action. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 advisor_name: The name of the Database Advisor. Required. - :type advisor_name: str - :param recommended_action_name: The name of Database Recommended Action. Required. - :type recommended_action_name: str - :param parameters: The requested recommended action resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: RecommendedAction or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.RecommendedAction - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - advisor_name: str, - recommended_action_name: str, - parameters: Union[_models.RecommendedAction, IO[bytes]], - **kwargs: Any - ) -> _models.RecommendedAction: - """Updates a database recommended action. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 advisor_name: The name of the Database Advisor. Required. - :type advisor_name: str - :param recommended_action_name: The name of Database Recommended Action. Required. - :type recommended_action_name: str - :param parameters: The requested recommended action resource state. Is either a - RecommendedAction type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.RecommendedAction or IO[bytes] - :return: RecommendedAction or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.RecommendedAction - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RecommendedAction") - - _request = build_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - advisor_name=advisor_name, - recommended_action_name=recommended_action_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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("RecommendedAction", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_schemas_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_schemas_operations.py deleted file mode 100644 index 9bf87dda5676..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_schemas_operations.py +++ /dev/null @@ -1,202 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._database_schemas_operations import build_get_request, build_list_by_database_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class DatabaseSchemasOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`database_schemas` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.DatabaseSchema"]: - """List database schemas. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :type database_name: str - :param filter: An OData filter expression that filters elements in the collection. Default - value is None. - :type filter: str - :return: An iterator like instance of either DatabaseSchema or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseSchema] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseSchemaListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseSchemaListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, server_name: str, database_name: str, schema_name: str, **kwargs: Any - ) -> _models.DatabaseSchema: - """Get database schema. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :return: DatabaseSchema or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSchema - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseSchema] = 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, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("DatabaseSchema", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_security_alert_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_security_alert_policies_operations.py deleted file mode 100644 index 175d4ae723b0..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_security_alert_policies_operations.py +++ /dev/null @@ -1,360 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._database_security_alert_policies_operations import ( - build_create_or_update_request, - build_get_request, - build_list_by_database_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class DatabaseSecurityAlertPoliciesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`database_security_alert_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - **kwargs: Any - ) -> _models.DatabaseSecurityAlertPolicy: - """Gets a database's security alert policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :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 - :return: DatabaseSecurityAlertPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSecurityAlertPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseSecurityAlertPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - security_alert_policy_name=security_alert_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("DatabaseSecurityAlertPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - parameters: _models.DatabaseSecurityAlertPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseSecurityAlertPolicy: - """Creates or updates a database's security alert policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :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 - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseSecurityAlertPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSecurityAlertPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseSecurityAlertPolicy: - """Creates or updates a database's security alert policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseSecurityAlertPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSecurityAlertPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - parameters: Union[_models.DatabaseSecurityAlertPolicy, IO[bytes]], - **kwargs: Any - ) -> _models.DatabaseSecurityAlertPolicy: - """Creates or updates a database's security alert policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :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[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseSecurityAlertPolicy or IO[bytes] - :return: DatabaseSecurityAlertPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSecurityAlertPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DatabaseSecurityAlertPolicy") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - security_alert_policy_name=security_alert_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DatabaseSecurityAlertPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either DatabaseSecurityAlertPolicy or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseSecurityAlertPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseSecurityAlertListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 0e95a3c18e30..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessment_baselines_operations.py +++ /dev/null @@ -1,390 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._database_sql_vulnerability_assessment_baselines_operations import ( - build_create_or_update_request, - build_get_request, - build_list_by_sql_vulnerability_assessment_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class DatabaseSqlVulnerabilityAssessmentBaselinesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`database_sql_vulnerability_assessment_baselines` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_sql_vulnerability_assessment( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **kwargs: Any - ) -> AsyncItemPaged["_models.DatabaseSqlVulnerabilityAssessmentBaselineSet"]: - """Gets a list of database's sql vulnerability assessment rule baselines. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :return: An iterator like instance of either DatabaseSqlVulnerabilityAssessmentBaselineSet or - the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentBaselineSetListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_sql_vulnerability_assessment_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize( - "DatabaseSqlVulnerabilityAssessmentBaselineSetListResult", pipeline_response - ) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - **kwargs: Any - ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: - """Gets a list of database's sql vulnerability assessment rule baselines. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :return: DatabaseSqlVulnerabilityAssessmentBaselineSet or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-11-01-preview")) - cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentBaselineSet] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - baseline_name=baseline_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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( - "DatabaseSqlVulnerabilityAssessmentBaselineSet", pipeline_response.http_response - ) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - parameters: _models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: - """Add a database's vulnerability assessment rule baseline 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 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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :param parameters: The requested rule baseline resource. Required. - :type parameters: - ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseSqlVulnerabilityAssessmentBaselineSet or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: - """Add a database's vulnerability assessment rule baseline 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 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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :param parameters: The requested rule baseline resource. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseSqlVulnerabilityAssessmentBaselineSet or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - parameters: Union[_models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput, IO[bytes]], - **kwargs: Any - ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: - """Add a database's vulnerability assessment rule baseline 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 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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :param parameters: The requested rule baseline resource. Is either a - DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput type or a IO[bytes] type. Required. - :type parameters: - ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput or IO[bytes] - :return: DatabaseSqlVulnerabilityAssessmentBaselineSet or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - baseline_name=baseline_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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( - "DatabaseSqlVulnerabilityAssessmentBaselineSet", pipeline_response.http_response - ) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 39234b2649ba..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessment_execute_scan_operations.py +++ /dev/null @@ -1,181 +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 collections.abc import MutableMapping -from typing import Any, AsyncIterator, Callable, Optional, TypeVar, Union, cast - -from azure.core import AsyncPipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -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 ..._utils.serialization import Deserializer, Serializer -from ...operations._database_sql_vulnerability_assessment_execute_scan_operations import build_execute_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class DatabaseSqlVulnerabilityAssessmentExecuteScanOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`database_sql_vulnerability_assessment_execute_scan` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - async def _execute_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2022-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_execute_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_execute( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **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 - :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", "2022-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._execute_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index fec0ff93510a..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessment_rule_baselines_operations.py +++ /dev/null @@ -1,481 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._database_sql_vulnerability_assessment_rule_baselines_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_baseline_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`database_sql_vulnerability_assessment_rule_baselines` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_baseline( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - **kwargs: Any - ) -> AsyncItemPaged["_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline"]: - """Gets a list of database's sql vulnerability assessment rule baselines. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :return: An iterator like instance of either DatabaseSqlVulnerabilityAssessmentRuleBaseline or - the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_baseline_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - baseline_name=baseline_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize( - "DatabaseSqlVulnerabilityAssessmentRuleBaselineListResult", pipeline_response - ) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - rule_id: str, - **kwargs: Any - ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: - """Gets a database's sql vulnerability assessment rule baseline. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :param rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-11-01-preview")) - cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - baseline_name=baseline_name, - rule_id=rule_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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( - "DatabaseSqlVulnerabilityAssessmentRuleBaseline", pipeline_response.http_response - ) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - rule_id: str, - parameters: _models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :param rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :param parameters: The requested rule baseline resource. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - rule_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :param rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :param parameters: The requested rule baseline resource. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - rule_id: str, - parameters: Union[_models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput, IO[bytes]], - **kwargs: Any - ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :param rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :param parameters: The requested rule baseline resource. Is either a - DatabaseSqlVulnerabilityAssessmentRuleBaselineInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput or - IO[bytes] - :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DatabaseSqlVulnerabilityAssessmentRuleBaselineInput") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - baseline_name=baseline_name, - rule_id=rule_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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( - "DatabaseSqlVulnerabilityAssessmentRuleBaseline", pipeline_response.http_response - ) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - rule_id: str, - **kwargs: Any - ) -> None: - """Removes the database's vulnerability assessment rule baseline. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :param rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-11-01-preview")) - 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, - vulnerability_assessment_name=vulnerability_assessment_name, - baseline_name=baseline_name, - rule_id=rule_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore 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 deleted file mode 100644 index f9297d7c6296..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessment_scan_result_operations.py +++ /dev/null @@ -1,229 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar, Union - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._database_sql_vulnerability_assessment_scan_result_operations import ( - build_get_request, - build_list_by_scan_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class DatabaseSqlVulnerabilityAssessmentScanResultOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`database_sql_vulnerability_assessment_scan_result` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_scan( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], - scan_id: str, - **kwargs: Any - ) -> AsyncItemPaged["_models.SqlVulnerabilityAssessmentScanResults"]: - """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. - :type resource_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 SQL Vulnerability Assessment. "default" - Required. - :type vulnerability_assessment_name: str or - ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentName - :param scan_id: The scan id of the SQL Vulnerability Assessment scan to retrieve result from. - Required. - :type scan_id: str - :return: An iterator like instance of either SqlVulnerabilityAssessmentScanResults or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanResults] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[_models.SQLVulnerabilityAssessmentScanListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SQLVulnerabilityAssessmentScanListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], - scan_id: str, - scan_result_id: str, - **kwargs: Any - ) -> _models.SqlVulnerabilityAssessmentScanResults: - """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. - :type resource_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 SQL Vulnerability Assessment. "default" - Required. - :type vulnerability_assessment_name: str or - ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentName - :param scan_id: The scan id of the SQL Vulnerability Assessment scan to retrieve result from. - Required. - :type scan_id: str - :param scan_result_id: The scan result id of the specific result to retrieve. Required. - :type scan_result_id: str - :return: SqlVulnerabilityAssessmentScanResults or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-11-01-preview")) - cls: ClsType[_models.SqlVulnerabilityAssessmentScanResults] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - scan_id=scan_id, - scan_result_id=scan_result_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("SqlVulnerabilityAssessmentScanResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 9b2c79f4b4aa..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessment_scans_operations.py +++ /dev/null @@ -1,217 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar, Union - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._database_sql_vulnerability_assessment_scans_operations import ( - build_get_request, - build_list_by_sql_vulnerability_assessments_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class DatabaseSqlVulnerabilityAssessmentScansOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`database_sql_vulnerability_assessment_scans` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_sql_vulnerability_assessments( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **kwargs: Any - ) -> AsyncItemPaged["_models.SqlVulnerabilityAssessmentScanRecord"]: - """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 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 - :return: An iterator like instance of either SqlVulnerabilityAssessmentScanRecord or the result - of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanRecord] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[_models.SqlVulnerabilityAssessmentScanRecordListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_sql_vulnerability_assessments_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SqlVulnerabilityAssessmentScanRecordListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - scan_id: str, - **kwargs: Any - ) -> _models.SqlVulnerabilityAssessmentScanRecord: - """Get a database vulnerability assessment scan result. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :return: SqlVulnerabilityAssessmentScanRecord or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanRecord - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-11-01-preview")) - cls: ClsType[_models.SqlVulnerabilityAssessmentScanRecord] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - scan_id=scan_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("SqlVulnerabilityAssessmentScanRecord", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index b887f73260ad..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessments_settings_operations.py +++ /dev/null @@ -1,205 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar, Union - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._database_sql_vulnerability_assessments_settings_operations import ( - build_get_request, - build_list_by_database_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class DatabaseSqlVulnerabilityAssessmentsSettingsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`database_sql_vulnerability_assessments_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.SqlVulnerabilityAssessment"]: - """Lists SQL 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. Required. - :type database_name: str - :return: An iterator like instance of either SqlVulnerabilityAssessment or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SqlVulnerabilityAssessment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[_models.SqlVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SqlVulnerabilityAssessmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], - **kwargs: Any - ) -> _models.SqlVulnerabilityAssessment: - """Gets SQL Vulnerability Assessment policy for 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 vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" - Required. - :type vulnerability_assessment_name: str or - ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentName - :return: SqlVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-11-01-preview")) - cls: ClsType[_models.SqlVulnerabilityAssessment] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("SqlVulnerabilityAssessment", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 7db2758b5402..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_tables_operations.py +++ /dev/null @@ -1,215 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._database_tables_operations import build_get_request, build_list_by_schema_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class DatabaseTablesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`database_tables` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_schema( - self, - resource_group_name: str, - server_name: str, - database_name: str, - schema_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.DatabaseTable"]: - """List database tables. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 filter: An OData filter expression that filters elements in the collection. Default - value is None. - :type filter: str - :return: An iterator like instance of either DatabaseTable or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseTable] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseTableListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_schema_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - schema_name=schema_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseTableListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - server_name: str, - database_name: str, - schema_name: str, - table_name: str, - **kwargs: Any - ) -> _models.DatabaseTable: - """Get database table. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :return: DatabaseTable or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseTable - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseTable] = 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, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("DatabaseTable", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_usages_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_usages_operations.py deleted file mode 100644 index c24cf171614f..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_usages_operations.py +++ /dev/null @@ -1,129 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._database_usages_operations import build_list_by_database_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class DatabaseUsagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`database_usages` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.DatabaseUsage"]: - """Gets database 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. - :type resource_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 - :return: An iterator like instance of either DatabaseUsage or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseUsage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[_models.DatabaseUsageListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseUsageListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_vulnerability_assessment_rule_baselines_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_vulnerability_assessment_rule_baselines_operations.py deleted file mode 100644 index 24754c79a635..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_vulnerability_assessment_rule_baselines_operations.py +++ /dev/null @@ -1,397 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -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 ..._utils.serialization import Deserializer, Serializer -from ...operations._database_vulnerability_assessment_rule_baselines_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class DatabaseVulnerabilityAssessmentRuleBaselinesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`database_vulnerability_assessment_rule_baselines` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - rule_id: str, - baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: - """Gets a database's vulnerability assessment rule baseline. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 rule - baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a - baseline on a database level rule and master for server level rule). Known values are: "master" - and "default". Required. - :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName - :return: DatabaseVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - rule_id=rule_id, - baseline_name=baseline_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("DatabaseVulnerabilityAssessmentRuleBaseline", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - rule_id: str, - baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - parameters: _models.DatabaseVulnerabilityAssessmentRuleBaseline, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: - """Creates or updates a database's vulnerability assessment rule baseline. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 rule - baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a - baseline on a database level rule and master for server level rule). Known values are: "master" - 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 - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - rule_id: str, - baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: - """Creates or updates a database's vulnerability assessment rule baseline. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 rule - baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a - baseline on a database level rule and master for server level rule). Known values are: "master" - and "default". Required. - :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName - :param parameters: The requested rule baseline resource. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - rule_id: str, - baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - parameters: Union[_models.DatabaseVulnerabilityAssessmentRuleBaseline, IO[bytes]], - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: - """Creates or updates a database's vulnerability assessment rule baseline. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 rule - baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a - baseline on a database level rule and master for server level rule). Known values are: "master" - 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[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline or - IO[bytes] - :return: DatabaseVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DatabaseVulnerabilityAssessmentRuleBaseline") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - rule_id=rule_id, - baseline_name=baseline_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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("DatabaseVulnerabilityAssessmentRuleBaseline", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - rule_id: str, - baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - **kwargs: Any - ) -> None: - """Removes the database's vulnerability assessment rule baseline. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 rule - baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a - baseline on a database level rule and master for server level rule). Known values are: "master" - and "default". Required. - :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - rule_id=rule_id, - baseline_name=baseline_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_vulnerability_assessment_scans_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_vulnerability_assessment_scans_operations.py deleted file mode 100644 index 9e97374ac2c2..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_vulnerability_assessment_scans_operations.py +++ /dev/null @@ -1,426 +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 collections.abc import MutableMapping -from typing import Any, AsyncIterator, Callable, Optional, TypeVar, Union, cast - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._database_vulnerability_assessment_scans_operations import ( - build_export_request, - build_get_request, - build_initiate_scan_request, - build_list_by_database_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class DatabaseVulnerabilityAssessmentScansOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`database_vulnerability_assessment_scans` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - async def _initiate_scan_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - scan_id: str, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._initiate_scan_initial( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_by_database( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **kwargs: Any - ) -> AsyncItemPaged["_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 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 - :return: An iterator like instance of either VulnerabilityAssessmentScanRecord or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecord] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.VulnerabilityAssessmentScanRecordListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("VulnerabilityAssessmentScanRecordListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - scan_id: str, - **kwargs: Any - ) -> _models.VulnerabilityAssessmentScanRecord: - """Gets a vulnerability assessment scan record of a database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :return: VulnerabilityAssessmentScanRecord or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecord - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.VulnerabilityAssessmentScanRecord] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def export( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - scan_id: str, - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessmentScansExport: - """Convert an existing scan result to a human readable format. If already exists nothing happens. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the scanned 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. Required. - :type scan_id: str - :return: DatabaseVulnerabilityAssessmentScansExport or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentScansExport - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseVulnerabilityAssessmentScansExport] = kwargs.pop("cls", None) - - _request = build_export_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - scan_id=scan_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DatabaseVulnerabilityAssessmentScansExport", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_vulnerability_assessments_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_vulnerability_assessments_operations.py deleted file mode 100644 index bcc68ab9991a..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_vulnerability_assessments_operations.py +++ /dev/null @@ -1,431 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._database_vulnerability_assessments_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_database_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class DatabaseVulnerabilityAssessmentsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`database_vulnerability_assessments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessment: - """Gets the database's vulnerability assessment. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 is - defined. 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 - :return: DatabaseVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseVulnerabilityAssessment] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("DatabaseVulnerabilityAssessment", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: _models.DatabaseVulnerabilityAssessment, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessment: - """Creates or updates the database's vulnerability assessment. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 is - defined. 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 parameters: The requested resource. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessment: - """Creates or updates the database's vulnerability assessment. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 is - defined. 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 parameters: The requested resource. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: Union[_models.DatabaseVulnerabilityAssessment, IO[bytes]], - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessment: - """Creates or updates the database's vulnerability assessment. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 is - defined. 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 parameters: The requested resource. Is either a DatabaseVulnerabilityAssessment type or - a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment or IO[bytes] - :return: DatabaseVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DatabaseVulnerabilityAssessment") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DatabaseVulnerabilityAssessment", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **kwargs: Any - ) -> None: - """Removes the database's vulnerability assessment. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 is - defined. 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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either DatabaseVulnerabilityAssessment or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index ddfb0d2723ef..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_databases_operations.py +++ /dev/null @@ -1,2056 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._databases_operations import ( - build_create_or_update_request, - build_delete_request, - build_export_request, - build_failover_request, - build_get_request, - build_import_method_request, - 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, - build_update_request, - build_upgrade_data_warehouse_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class DatabasesOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`databases` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either Metric or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.Metric] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.MetricListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace - def list_metric_definitions( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either MetricDefinition or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.MetricDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.MetricDefinitionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, skip_token: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.Database"]: - """Gets a list of databases. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param skip_token: Default value is None. - :type skip_token: str - :return: An iterator like instance of either Database or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) - cls: ClsType[_models.DatabaseListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - skip_token=skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - server_name: str, - database_name: str, - expand: Optional[str] = None, - filter: Optional[str] = None, - **kwargs: Any - ) -> _models.Database: - """Gets 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 - :param expand: The child resources to include in the response. Default value is None. - :type expand: str - :param filter: An OData filter expression that filters elements in the collection. Default - value is None. - :type filter: str - :return: Database or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.Database - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2023-02-01-preview")) - cls: ClsType[_models.Database] = 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, - expand=expand, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("Database", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.Database, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "Database") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: _models.Database, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Database]: - """Creates a new database or updates an existing database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The requested database resource state. Required. - :type parameters: ~azure.mgmt.sql.models.Database - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Database or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Database]: - """Creates a new database or updates an existing database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The requested database resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Database or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.Database, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Database]: - """Creates a new database or updates an existing database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The requested database resource state. Is either a Database type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.Database or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Database or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_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)) - 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) - 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, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Database", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Database].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Database]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-02-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes 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 - :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", "2023-02-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( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.DatabaseUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "DatabaseUpdate") - - _request = build_update_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: _models.DatabaseUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Database]: - """Updates an existing 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 parameters: The requested database resource state. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Database or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Database]: - """Updates an existing 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 parameters: The requested database resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Database or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.DatabaseUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Database]: - """Updates an existing 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 parameters: The requested database resource state. Is either a DatabaseUpdate type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Database or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_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)) - 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) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Database", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Database].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Database]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _export_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.ExportDatabaseDefinition, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ExportDatabaseDefinition") - - _request = build_export_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_export( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: _models.ExportDatabaseDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ImportExportOperationResult]: - """Exports 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 - :param parameters: The database export request parameters. Required. - :type parameters: ~azure.mgmt.sql.models.ExportDatabaseDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ImportExportOperationResult or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_export( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ImportExportOperationResult]: - """Exports 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 - :param parameters: The database export request parameters. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ImportExportOperationResult or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_export( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.ExportDatabaseDefinition, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ImportExportOperationResult]: - """Exports 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 - :param parameters: The database export request parameters. Is either a ExportDatabaseDefinition - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ExportDatabaseDefinition or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ImportExportOperationResult or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_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)) - cls: ClsType[_models.ImportExportOperationResult] = 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._export_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ImportExportOperationResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ImportExportOperationResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ImportExportOperationResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _failover_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - replica_type: Optional[Union[str, _models.ReplicaType]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-02-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_failover_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - replica_type=replica_type, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_failover( - self, - resource_group_name: str, - server_name: str, - database_name: str, - replica_type: Optional[Union[str, _models.ReplicaType]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Failovers 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 to failover. Required. - :type database_name: str - :param replica_type: The type of replica to be failed over. Known values are: "Primary" and - "ReadableSecondary". Default value is None. - :type replica_type: str or ~azure.mgmt.sql.models.ReplicaType - :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", "2023-02-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._failover_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - replica_type=replica_type, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _import_method_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.ImportExistingDatabaseDefinition, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ImportExistingDatabaseDefinition") - - _request = build_import_method_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_import_method( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: _models.ImportExistingDatabaseDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ImportExportOperationResult]: - """Imports a bacpac into a new database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The database import request parameters. Required. - :type parameters: ~azure.mgmt.sql.models.ImportExistingDatabaseDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ImportExportOperationResult or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_import_method( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ImportExportOperationResult]: - """Imports a bacpac into a new database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The database import request parameters. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ImportExportOperationResult or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_import_method( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.ImportExistingDatabaseDefinition, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ImportExportOperationResult]: - """Imports a bacpac into a new database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The database import request parameters. Is either a - ImportExistingDatabaseDefinition type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ImportExistingDatabaseDefinition or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ImportExportOperationResult or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_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)) - cls: ClsType[_models.ImportExportOperationResult] = 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._import_method_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ImportExportOperationResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ImportExportOperationResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ImportExportOperationResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @overload - async def rename( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: _models.ResourceMoveDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Renames 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 to rename. Required. - :type database_name: str - :param parameters: The resource move definition for renaming this database. Required. - :type parameters: ~azure.mgmt.sql.models.ResourceMoveDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def rename( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Renames 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 to rename. Required. - :type database_name: str - :param parameters: The resource move definition for renaming this database. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def rename( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.ResourceMoveDefinition, IO[bytes]], - **kwargs: Any - ) -> None: - """Renames 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 to rename. Required. - :type database_name: str - :param parameters: The resource move definition for renaming this database. Is either a - ResourceMoveDefinition type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ResourceMoveDefinition or IO[bytes] - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2023-02-01-preview")) - 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, "ResourceMoveDefinition") - - _request = build_rename_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - async def _pause_initial( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-02-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_pause_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_pause( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.Database]: - """Pauses 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 to be paused. Required. - :type database_name: str - :return: An instance of AsyncLROPoller that returns either Database or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) - 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) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._pause_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Database", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Database].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Database]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _resume_initial( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-02-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_resume_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_resume( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.Database]: - """Resumes 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 to be resumed. Required. - :type database_name: str - :return: An instance of AsyncLROPoller that returns either Database or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) - 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) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._resume_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Database", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Database].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Database]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _upgrade_data_warehouse_initial( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-02-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_upgrade_data_warehouse_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_upgrade_data_warehouse( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Upgrades a data warehouse. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database to be upgraded. Required. - :type database_name: str - :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", "2023-02-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._upgrade_data_warehouse_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_by_elastic_pool( - self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.Database"]: - """Gets a list of databases in an elastic pool. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 - :return: An iterator like instance of either Database or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) - cls: ClsType[_models.DatabaseListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_inaccessible_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.Database"]: - """Gets a list of inaccessible databases in a logical server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either Database or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) - cls: ClsType[_models.DatabaseListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_inaccessible_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) 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 deleted file mode 100644 index fce2f3c22f6d..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_deleted_servers_operations.py +++ /dev/null @@ -1,356 +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 collections.abc import MutableMapping -from typing import Any, AsyncIterator, Callable, Optional, TypeVar, Union, cast - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._deleted_servers_operations import ( - build_get_request, - build_list_by_location_request, - build_list_request, - build_recover_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class DeletedServersOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`deleted_servers` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_models.DeletedServer"]: - """Gets a list of all deleted servers in a subscription. - - :return: An iterator like instance of either DeletedServer or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DeletedServer] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DeletedServerListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DeletedServerListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @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 - :return: DeletedServer or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DeletedServer - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DeletedServer] = kwargs.pop("cls", None) - - _request = build_get_request( - location_name=location_name, - deleted_server_name=deleted_server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_location(self, location_name: str, **kwargs: Any) -> AsyncItemPaged["_models.DeletedServer"]: - """Gets a list of deleted servers for a location. - - :param location_name: The name of the region where the resource is located. Required. - :type location_name: str - :return: An iterator like instance of either DeletedServer or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DeletedServer] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DeletedServerListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DeletedServerListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - async def _recover_initial( - self, location_name: str, deleted_server_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_recover_request( - location_name=location_name, - deleted_server_name=deleted_server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_recover( - self, location_name: str, deleted_server_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.DeletedServer]: - """Recovers 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 - :return: An instance of AsyncLROPoller that returns either DeletedServer or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.DeletedServer] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DeletedServer] = kwargs.pop("cls", None) - 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._recover_initial( - location_name=location_name, - deleted_server_name=deleted_server_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DeletedServer", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.DeletedServer].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.DeletedServer]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 37835feff73d..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_distributed_availability_groups_operations.py +++ /dev/null @@ -1,1156 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._distributed_availability_groups_operations import ( - build_create_or_update_request, - build_delete_request, - build_failover_request, - build_get_request, - build_list_by_instance_request, - build_set_role_request, - build_update_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class DistributedAvailabilityGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`distributed_availability_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.DistributedAvailabilityGroup"]: - """Gets a list of a distributed availability groups in instance. - - :param resource_group_name: The name of the resource group that 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 - :return: An iterator like instance of either DistributedAvailabilityGroup or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DistributedAvailabilityGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) - cls: ClsType[_models.DistributedAvailabilityGroupsListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DistributedAvailabilityGroupsListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - managed_instance_name: str, - distributed_availability_group_name: str, - **kwargs: Any - ) -> _models.DistributedAvailabilityGroup: - """Gets a distributed availability group info. - - :param resource_group_name: The name of the resource group that 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 - :return: DistributedAvailabilityGroup or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DistributedAvailabilityGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2023-08-01-preview")) - cls: ClsType[_models.DistributedAvailabilityGroup] = kwargs.pop("cls", None) - - _request = build_get_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, - headers=_headers, - params=_params, - ) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DistributedAvailabilityGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - distributed_availability_group_name: str, - parameters: Union[_models.DistributedAvailabilityGroup, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "DistributedAvailabilityGroup") - - _request = build_create_or_update_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - distributed_availability_group_name: str, - parameters: _models.DistributedAvailabilityGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DistributedAvailabilityGroup]: - """Creates a distributed availability group between Sql On-Prem and Sql Managed Instance. - - :param resource_group_name: The name of the resource group that 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 info. Required. - :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :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_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - distributed_availability_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DistributedAvailabilityGroup]: - """Creates a distributed availability group between Sql On-Prem and Sql Managed Instance. - - :param resource_group_name: The name of the resource group that 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 info. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - distributed_availability_group_name: str, - parameters: Union[_models.DistributedAvailabilityGroup, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.DistributedAvailabilityGroup]: - """Creates a distributed availability group between Sql On-Prem and Sql Managed Instance. - - :param resource_group_name: The name of the resource group that 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 info. Is either a - DistributedAvailabilityGroup type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroup or IO[bytes] - :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", "2023-08-01-preview")) - 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._create_or_update_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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DistributedAvailabilityGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.DistributedAvailabilityGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.DistributedAvailabilityGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, - resource_group_name: str, - managed_instance_name: str, - distributed_availability_group_name: str, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-08-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, - resource_group_name: str, - managed_instance_name: str, - distributed_availability_group_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Drops a distributed availability group between Sql On-Prem and Sql Managed Instance. - - :param resource_group_name: The name of the resource group that 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 - :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", "2023-08-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( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - distributed_availability_group_name=distributed_availability_group_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - distributed_availability_group_name: str, - parameters: Union[_models.DistributedAvailabilityGroup, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "DistributedAvailabilityGroup") - - _request = build_update_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - managed_instance_name: str, - distributed_availability_group_name: str, - parameters: _models.DistributedAvailabilityGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DistributedAvailabilityGroup]: - """Updates a distributed availability group replication mode. - - :param resource_group_name: The name of the resource group that 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 info. Required. - :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :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_update( - self, - resource_group_name: str, - managed_instance_name: str, - distributed_availability_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DistributedAvailabilityGroup]: - """Updates a distributed availability group replication mode. - - :param resource_group_name: The name of the resource group that 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 info. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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_update( - self, - resource_group_name: str, - managed_instance_name: str, - distributed_availability_group_name: str, - parameters: Union[_models.DistributedAvailabilityGroup, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.DistributedAvailabilityGroup]: - """Updates a distributed availability group replication mode. - - :param resource_group_name: The name of the resource group that 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 info. Is either a - DistributedAvailabilityGroup type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroup or IO[bytes] - :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", "2023-08-01-preview")) - 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._update_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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DistributedAvailabilityGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.DistributedAvailabilityGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.DistributedAvailabilityGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _failover_initial( - self, - resource_group_name: str, - managed_instance_name: str, - distributed_availability_group_name: str, - parameters: Union[_models.DistributedAvailabilityGroupsFailoverRequest, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "DistributedAvailabilityGroupsFailoverRequest") - - _request = build_failover_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_failover( - self, - resource_group_name: str, - managed_instance_name: str, - distributed_availability_group_name: str, - parameters: _models.DistributedAvailabilityGroupsFailoverRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DistributedAvailabilityGroup]: - """Performs requested failover type in this 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 failover request parameters. Required. - :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroupsFailoverRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :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_failover( - self, - resource_group_name: str, - managed_instance_name: str, - distributed_availability_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.DistributedAvailabilityGroup]: - """Performs requested failover type in this 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 failover request parameters. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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_failover( - self, - resource_group_name: str, - managed_instance_name: str, - distributed_availability_group_name: str, - parameters: Union[_models.DistributedAvailabilityGroupsFailoverRequest, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.DistributedAvailabilityGroup]: - """Performs requested failover type in this 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 failover request parameters. Is either a - DistributedAvailabilityGroupsFailoverRequest type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroupsFailoverRequest or - IO[bytes] - :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", "2023-08-01-preview")) - 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._failover_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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DistributedAvailabilityGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.DistributedAvailabilityGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.DistributedAvailabilityGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _set_role_initial( - self, - resource_group_name: str, - managed_instance_name: str, - distributed_availability_group_name: str, - parameters: Union[_models.DistributedAvailabilityGroupSetRole, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroupSetRole or IO[bytes] - :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", "2023-08-01-preview")) - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DistributedAvailabilityGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.DistributedAvailabilityGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.DistributedAvailabilityGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_elastic_pool_activities_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_elastic_pool_activities_operations.py deleted file mode 100644 index 8ceb1132e19f..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_elastic_pool_activities_operations.py +++ /dev/null @@ -1,130 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._elastic_pool_activities_operations import build_list_by_elastic_pool_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -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: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either ElasticPoolActivity or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ElasticPoolActivity] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.ElasticPoolActivityListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 c85af3f82b82..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_elastic_pool_database_activities_operations.py +++ /dev/null @@ -1,131 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._elastic_pool_database_activities_operations import build_list_by_elastic_pool_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -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: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either ElasticPoolDatabaseActivity or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ElasticPoolDatabaseActivity] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.ElasticPoolDatabaseActivityListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index b77d11dd1fb0..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_elastic_pool_operations_operations.py +++ /dev/null @@ -1,190 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._elastic_pool_operations_operations import build_cancel_request, build_list_by_elastic_pool_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ElasticPoolOperationsOperations: - """ - .. 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_operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def cancel( - 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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_cancel_request( - resource_group_name=resource_group_name, - server_name=server_name, - elastic_pool_name=elastic_pool_name, - operation_id=operation_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @distributed_trace - def list_by_elastic_pool( - self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.ElasticPoolOperation"]: - """Gets a list of operations performed on the elastic pool. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 - :return: An iterator like instance of either ElasticPoolOperation or the result of - cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ElasticPoolOperation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ElasticPoolOperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ElasticPoolOperationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_elastic_pools_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_elastic_pools_operations.py deleted file mode 100644 index fad98e159dbf..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_elastic_pools_operations.py +++ /dev/null @@ -1,991 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._elastic_pools_operations import ( - build_create_or_update_request, - build_delete_request, - build_failover_request, - build_get_request, - build_list_by_server_request, - build_list_metric_definitions_request, - build_list_metrics_request, - build_update_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ElasticPoolsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`elastic_pools` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either Metric or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.Metric] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.MetricListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace - def list_metric_definitions( - self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either MetricDefinition or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.MetricDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.MetricDefinitionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.ElasticPool"]: - """Gets all elastic pools 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 - :param skip: The number of elements in the collection to skip. Default value is None. - :type skip: int - :return: An iterator like instance of either ElasticPool or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ElasticPool] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.ElasticPoolListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - skip=skip, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ElasticPoolListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any - ) -> _models.ElasticPool: - """Gets an elastic pool. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 - :return: ElasticPool or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ElasticPool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - cls: ClsType[_models.ElasticPool] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - elastic_pool_name=elastic_pool_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ElasticPool", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - elastic_pool_name: str, - parameters: Union[_models.ElasticPool, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ElasticPool") - - _request = build_create_or_update_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - elastic_pool_name: str, - parameters: _models.ElasticPool, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ElasticPool]: - """Creates or updates 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 - :param parameters: The elastic pool parameters. Required. - :type parameters: ~azure.mgmt.sql.models.ElasticPool - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ElasticPool or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ElasticPool] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - elastic_pool_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ElasticPool]: - """Creates or updates 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 - :param parameters: The elastic pool parameters. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ElasticPool or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ElasticPool] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - elastic_pool_name: str, - parameters: Union[_models.ElasticPool, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ElasticPool]: - """Creates or updates 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 - :param parameters: The elastic pool parameters. Is either a ElasticPool type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.sql.models.ElasticPool or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ElasticPool or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ElasticPool] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - 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) - 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, - elastic_pool_name=elastic_pool_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ElasticPool", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.ElasticPool].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ElasticPool]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes 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 - :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", "2022-08-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( - resource_group_name=resource_group_name, - server_name=server_name, - elastic_pool_name=elastic_pool_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - server_name: str, - elastic_pool_name: str, - parameters: Union[_models.ElasticPoolUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ElasticPoolUpdate") - - _request = build_update_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - server_name: str, - elastic_pool_name: str, - parameters: _models.ElasticPoolUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ElasticPool]: - """Updates 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 - :param parameters: The elastic pool update parameters. Required. - :type parameters: ~azure.mgmt.sql.models.ElasticPoolUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ElasticPool or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ElasticPool] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - server_name: str, - elastic_pool_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ElasticPool]: - """Updates 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 - :param parameters: The elastic pool update parameters. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ElasticPool or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ElasticPool] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - server_name: str, - elastic_pool_name: str, - parameters: Union[_models.ElasticPoolUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ElasticPool]: - """Updates 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 - :param parameters: The elastic pool update parameters. Is either a ElasticPoolUpdate type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ElasticPoolUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ElasticPool or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ElasticPool] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - 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) - 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( - resource_group_name=resource_group_name, - server_name=server_name, - elastic_pool_name=elastic_pool_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ElasticPool", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ElasticPool].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ElasticPool]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _failover_initial( - self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_failover_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_failover( - self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Failovers 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 to failover. Required. - :type elastic_pool_name: str - :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", "2022-08-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._failover_initial( - resource_group_name=resource_group_name, - server_name=server_name, - elastic_pool_name=elastic_pool_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_encryption_protectors_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_encryption_protectors_operations.py deleted file mode 100644 index c95d9ba6372a..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_encryption_protectors_operations.py +++ /dev/null @@ -1,527 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._encryption_protectors_operations import ( - build_create_or_update_request, - build_get_request, - build_list_by_server_request, - build_revalidate_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class EncryptionProtectorsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`encryption_protectors` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.EncryptionProtector"]: - """Gets a list of server encryption protectors. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either EncryptionProtector or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.EncryptionProtector] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.EncryptionProtectorListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("EncryptionProtectorListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - server_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - **kwargs: Any - ) -> _models.EncryptionProtector: - """Gets a server encryption protector. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param encryption_protector_name: The name of the encryption protector to be retrieved. - "current" Required. - :type encryption_protector_name: str or ~azure.mgmt.sql.models.EncryptionProtectorName - :return: EncryptionProtector or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.EncryptionProtector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.EncryptionProtector] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - encryption_protector_name=encryption_protector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("EncryptionProtector", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - parameters: Union[_models.EncryptionProtector, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "EncryptionProtector") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - encryption_protector_name=encryption_protector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - parameters: _models.EncryptionProtector, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.EncryptionProtector]: - """Updates 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 server_name: The name of the server. Required. - :type server_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 - :param parameters: The requested encryption protector resource state. Required. - :type parameters: ~azure.mgmt.sql.models.EncryptionProtector - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either EncryptionProtector or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.EncryptionProtector] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.EncryptionProtector]: - """Updates 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 server_name: The name of the server. Required. - :type server_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 - :param parameters: The requested encryption protector resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either EncryptionProtector or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.EncryptionProtector] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - parameters: Union[_models.EncryptionProtector, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.EncryptionProtector]: - """Updates 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 server_name: The name of the server. Required. - :type server_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 - :param parameters: The requested encryption protector resource state. Is either a - EncryptionProtector type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.EncryptionProtector or IO[bytes] - :return: An instance of AsyncLROPoller that returns either EncryptionProtector or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.EncryptionProtector] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.EncryptionProtector] = 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, - encryption_protector_name=encryption_protector_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("EncryptionProtector", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.EncryptionProtector].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.EncryptionProtector]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _revalidate_initial( - self, - resource_group_name: str, - server_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_revalidate_request( - resource_group_name=resource_group_name, - server_name=server_name, - encryption_protector_name=encryption_protector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_revalidate( - self, - resource_group_name: str, - server_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 server_name: The name of the server. Required. - :type server_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 - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._revalidate_initial( - resource_group_name=resource_group_name, - server_name=server_name, - encryption_protector_name=encryption_protector_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index b5fd7f3432f6..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_endpoint_certificates_operations.py +++ /dev/null @@ -1,188 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._endpoint_certificates_operations import build_get_request, build_list_by_instance_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class EndpointCertificatesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`endpoint_certificates` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.EndpointCertificate"]: - """List certificates used on endpoints on the target instance. - - :param resource_group_name: The name of the resource group that 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 - :return: An iterator like instance of either EndpointCertificate or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.EndpointCertificate] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.EndpointCertificateListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("EndpointCertificateListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, managed_instance_name: str, endpoint_type: str, **kwargs: Any - ) -> _models.EndpointCertificate: - """Gets a certificate used on the endpoint with the given id. - - :param resource_group_name: The name of the resource group that 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 endpoint_type: Type of the endpoint whose certificate the customer is looking for. - Required. - :type endpoint_type: str - :return: EndpointCertificate or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.EndpointCertificate - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.EndpointCertificate] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - endpoint_type=endpoint_type, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("EndpointCertificate", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_extended_database_blob_auditing_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_extended_database_blob_auditing_policies_operations.py deleted file mode 100644 index 2d3b9f20e5f8..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_extended_database_blob_auditing_policies_operations.py +++ /dev/null @@ -1,341 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Literal, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._extended_database_blob_auditing_policies_operations import ( - build_create_or_update_request, - build_get_request, - build_list_by_database_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ExtendedDatabaseBlobAuditingPoliciesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`extended_database_blob_auditing_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.ExtendedDatabaseBlobAuditingPolicy"]: - """Lists extended auditing settings 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 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 - :return: An iterator like instance of either ExtendedDatabaseBlobAuditingPolicy or the result - of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.ExtendedDatabaseBlobAuditingPolicyListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ExtendedDatabaseBlobAuditingPolicyListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> _models.ExtendedDatabaseBlobAuditingPolicy: - """Gets an extended database's blob auditing policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :return: ExtendedDatabaseBlobAuditingPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 {}) - - blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.ExtendedDatabaseBlobAuditingPolicy] = 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, - blob_auditing_policy_name=blob_auditing_policy_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ExtendedDatabaseBlobAuditingPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: _models.ExtendedDatabaseBlobAuditingPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ExtendedDatabaseBlobAuditingPolicy: - """Creates or updates an extended database's blob auditing policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The extended database blob auditing policy. Required. - :type parameters: ~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ExtendedDatabaseBlobAuditingPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ExtendedDatabaseBlobAuditingPolicy: - """Creates or updates an extended database's blob auditing policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The extended database blob auditing policy. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ExtendedDatabaseBlobAuditingPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.ExtendedDatabaseBlobAuditingPolicy, IO[bytes]], - **kwargs: Any - ) -> _models.ExtendedDatabaseBlobAuditingPolicy: - """Creates or updates an extended database's blob auditing policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The extended database blob auditing policy. Is either a - ExtendedDatabaseBlobAuditingPolicy type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicy or IO[bytes] - :return: ExtendedDatabaseBlobAuditingPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 {}) - - blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ExtendedDatabaseBlobAuditingPolicy") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - blob_auditing_policy_name=blob_auditing_policy_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ExtendedDatabaseBlobAuditingPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 5f5b5b9b9ac9..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_extended_server_blob_auditing_policies_operations.py +++ /dev/null @@ -1,396 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Literal, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._extended_server_blob_auditing_policies_operations import ( - build_create_or_update_request, - build_get_request, - build_list_by_server_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ExtendedServerBlobAuditingPoliciesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`extended_server_blob_auditing_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.ExtendedServerBlobAuditingPolicy"]: - """Lists extended auditing settings of 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 - :return: An iterator like instance of either ExtendedServerBlobAuditingPolicy or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.ExtendedServerBlobAuditingPolicyListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ExtendedServerBlobAuditingPolicyListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> _models.ExtendedServerBlobAuditingPolicy: - """Gets an extended server's blob auditing policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: ExtendedServerBlobAuditingPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 {}) - - blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.ExtendedServerBlobAuditingPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - blob_auditing_policy_name=blob_auditing_policy_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ExtendedServerBlobAuditingPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ExtendedServerBlobAuditingPolicy, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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 {}) - - blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ExtendedServerBlobAuditingPolicy") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - blob_auditing_policy_name=blob_auditing_policy_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - parameters: _models.ExtendedServerBlobAuditingPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ExtendedServerBlobAuditingPolicy]: - """Creates or updates an extended server's blob auditing policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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: Properties of extended blob auditing policy. Required. - :type parameters: ~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ExtendedServerBlobAuditingPolicy or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ExtendedServerBlobAuditingPolicy]: - """Creates or updates an extended server's blob auditing policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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: Properties of extended blob auditing policy. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ExtendedServerBlobAuditingPolicy or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ExtendedServerBlobAuditingPolicy, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ExtendedServerBlobAuditingPolicy]: - """Creates or updates an extended server's blob auditing policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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: Properties of extended blob auditing policy. Is either a - ExtendedServerBlobAuditingPolicy type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ExtendedServerBlobAuditingPolicy or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - 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) - 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, - parameters=parameters, - blob_auditing_policy_name=blob_auditing_policy_name, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ExtendedServerBlobAuditingPolicy", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ExtendedServerBlobAuditingPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ExtendedServerBlobAuditingPolicy]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 9ad66a34a332..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_failover_groups_operations.py +++ /dev/null @@ -1,1069 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._failover_groups_operations import ( - build_create_or_update_request, - build_delete_request, - build_failover_request, - 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, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class FailoverGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`failover_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_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 - :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", "2023-05-01-preview")) - cls: ClsType[_models.FailoverGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace_async - async def get( - self, resource_group_name: str, server_name: str, failover_group_name: str, **kwargs: Any - ) -> _models.FailoverGroup: - """Gets a failover group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :return: FailoverGroup or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.FailoverGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[_models.FailoverGroup] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - failover_group_name=failover_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("FailoverGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - failover_group_name: str, - parameters: Union[_models.FailoverGroup, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "FailoverGroup") - - _request = build_create_or_update_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - failover_group_name: str, - parameters: _models.FailoverGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.FailoverGroup]: - """Creates or updates a failover 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 containing the failover group. Required. - :type server_name: str - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :param parameters: The failover group parameters. Required. - :type parameters: ~azure.mgmt.sql.models.FailoverGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - failover_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.FailoverGroup]: - """Creates or updates a failover 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 containing the failover group. Required. - :type server_name: str - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :param parameters: The failover group parameters. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - failover_group_name: str, - parameters: Union[_models.FailoverGroup, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.FailoverGroup]: - """Creates or updates a failover 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 containing the failover group. Required. - :type server_name: str - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :param parameters: The failover group parameters. Is either a FailoverGroup type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.sql.models.FailoverGroup or IO[bytes] - :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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - 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._create_or_update_initial( - resource_group_name=resource_group_name, - server_name=server_name, - failover_group_name=failover_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("FailoverGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.FailoverGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.FailoverGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, server_name: str, failover_group_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, server_name: str, failover_group_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a failover 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 containing the failover group. Required. - :type server_name: str - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :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", "2023-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_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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - server_name: str, - failover_group_name: str, - parameters: Union[_models.FailoverGroupUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "FailoverGroupUpdate") - - _request = build_update_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - server_name: str, - failover_group_name: str, - parameters: _models.FailoverGroupUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.FailoverGroup]: - """Updates a failover 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 containing the failover group. Required. - :type server_name: str - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :param parameters: The failover group parameters. Required. - :type parameters: ~azure.mgmt.sql.models.FailoverGroupUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - server_name: str, - failover_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.FailoverGroup]: - """Updates a failover 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 containing the failover group. Required. - :type server_name: str - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :param parameters: The failover group parameters. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - server_name: str, - failover_group_name: str, - parameters: Union[_models.FailoverGroupUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.FailoverGroup]: - """Updates a failover 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 containing the failover group. Required. - :type server_name: str - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :param parameters: The failover group parameters. Is either a FailoverGroupUpdate type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.FailoverGroupUpdate or IO[bytes] - :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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - 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._update_initial( - resource_group_name=resource_group_name, - server_name=server_name, - failover_group_name=failover_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("FailoverGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.FailoverGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.FailoverGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _failover_initial( - self, resource_group_name: str, server_name: str, failover_group_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_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. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :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", "2023-05-01-preview")) - 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._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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("FailoverGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.FailoverGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.FailoverGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _force_failover_allow_data_loss_initial( - self, resource_group_name: str, server_name: str, failover_group_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_force_failover_allow_data_loss_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_force_failover_allow_data_loss( - 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 might 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 containing the failover group. Required. - :type server_name: str - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :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", "2023-05-01-preview")) - 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._force_failover_allow_data_loss_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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("FailoverGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.FailoverGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.FailoverGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _try_planned_before_forced_failover_initial( # pylint: disable=name-too-long - self, resource_group_name: str, server_name: str, failover_group_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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", "2023-05-01-preview")) - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("FailoverGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.FailoverGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.FailoverGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_firewall_rules_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_firewall_rules_operations.py deleted file mode 100644 index 80dc30107e31..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_firewall_rules_operations.py +++ /dev/null @@ -1,519 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._firewall_rules_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_server_request, - build_replace_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class FirewallRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`firewall_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 - :return: FirewallRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.FirewallRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.FirewallRule] = kwargs.pop("cls", None) - - _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, - headers=_headers, - params=_params, - ) - _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("FirewallRule", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - firewall_rule_name: str, - parameters: _models.FirewallRule, - *, - content_type: str = "application/json", - **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 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 - :return: FirewallRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.FirewallRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - firewall_rule_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **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 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: FirewallRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.FirewallRule - :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[bytes]], - **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 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[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.FirewallRule or IO[bytes] - :return: FirewallRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.FirewallRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.FirewallRule] = 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, "FirewallRule") - - _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, - headers=_headers, - params=_params, - ) - _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, 201]: - 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete(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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_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, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either FirewallRule or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.FirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.FirewallRuleListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @overload - async def replace( - self, - resource_group_name: str, - server_name: str, - parameters: _models.FirewallRuleList, - *, - content_type: str = "application/json", - **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 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 - :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 replace( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **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 parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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 replace( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.FirewallRuleList, IO[bytes]], - **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 parameters: Is either a FirewallRuleList type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.FirewallRuleList or IO[bytes] - :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: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.FirewallRule]] = 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, "FirewallRuleList") - - _request = build_replace_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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("FirewallRule", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_geo_backup_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_geo_backup_policies_operations.py deleted file mode 100644 index aa853962fe5e..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_geo_backup_policies_operations.py +++ /dev/null @@ -1,355 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._geo_backup_policies_operations import ( - build_create_or_update_request, - build_get_request, - build_list_by_database_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class GeoBackupPoliciesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`geo_backup_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - geo_backup_policy_name: Union[str, _models.GeoBackupPolicyName], - parameters: _models.GeoBackupPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GeoBackupPolicy: - """Updates a database geo backup policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :param parameters: The required parameters for creating or updating the geo backup policy. - Required. - :type parameters: ~azure.mgmt.sql.models.GeoBackupPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: GeoBackupPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.GeoBackupPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - geo_backup_policy_name: Union[str, _models.GeoBackupPolicyName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GeoBackupPolicy: - """Updates a database geo backup policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :param parameters: The required parameters for creating or updating the geo backup policy. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: GeoBackupPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.GeoBackupPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - geo_backup_policy_name: Union[str, _models.GeoBackupPolicyName], - parameters: Union[_models.GeoBackupPolicy, IO[bytes]], - **kwargs: Any - ) -> _models.GeoBackupPolicy: - """Updates a database geo backup policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :param parameters: The required parameters for creating or updating the geo backup policy. Is - either a GeoBackupPolicy type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.GeoBackupPolicy or IO[bytes] - :return: GeoBackupPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.GeoBackupPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GeoBackupPolicy] = 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, "GeoBackupPolicy") - - _request = build_create_or_update_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, 201]: - 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: GeoBackupPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.GeoBackupPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.GeoBackupPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - geo_backup_policy_name=geo_backup_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either GeoBackupPolicy or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.GeoBackupPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.GeoBackupPolicyListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 9c3df0ba0c8d..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_instance_failover_groups_operations.py +++ /dev/null @@ -1,742 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._instance_failover_groups_operations import ( - build_create_or_update_request, - build_delete_request, - build_failover_request, - build_force_failover_allow_data_loss_request, - build_get_request, - build_list_by_location_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class InstanceFailoverGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`instance_failover_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.InstanceFailoverGroup"]: - """Lists the failover groups in a 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 name of the region where the resource is located. Required. - :type location_name: str - :return: An iterator like instance of either InstanceFailoverGroup or the result of - cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.InstanceFailoverGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - cls: ClsType[_models.InstanceFailoverGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("InstanceFailoverGroupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, location_name: str, failover_group_name: str, **kwargs: Any - ) -> _models.InstanceFailoverGroup: - """Gets a failover group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :return: InstanceFailoverGroup or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.InstanceFailoverGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-05-01-preview")) - cls: ClsType[_models.InstanceFailoverGroup] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - location_name=location_name, - failover_group_name=failover_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("InstanceFailoverGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - location_name: str, - failover_group_name: str, - parameters: Union[_models.InstanceFailoverGroup, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2022-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "InstanceFailoverGroup") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - location_name=location_name, - failover_group_name=failover_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - location_name: str, - failover_group_name: str, - parameters: _models.InstanceFailoverGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.InstanceFailoverGroup]: - """Creates or updates a failover 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 - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :param parameters: The failover group parameters. Required. - :type parameters: ~azure.mgmt.sql.models.InstanceFailoverGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either InstanceFailoverGroup or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.InstanceFailoverGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - location_name: str, - failover_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.InstanceFailoverGroup]: - """Creates or updates a failover 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 - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :param parameters: The failover group parameters. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either InstanceFailoverGroup or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.InstanceFailoverGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - location_name: str, - failover_group_name: str, - parameters: Union[_models.InstanceFailoverGroup, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.InstanceFailoverGroup]: - """Creates or updates a failover 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 - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :param parameters: The failover group parameters. Is either a InstanceFailoverGroup type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.InstanceFailoverGroup or IO[bytes] - :return: An instance of AsyncLROPoller that returns either InstanceFailoverGroup or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.InstanceFailoverGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - 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) - 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, - location_name=location_name, - failover_group_name=failover_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("InstanceFailoverGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.InstanceFailoverGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.InstanceFailoverGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, location_name: str, failover_group_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2022-05-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - location_name=location_name, - failover_group_name=failover_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, location_name: str, failover_group_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a failover 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 - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :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", "2022-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_initial( - resource_group_name=resource_group_name, - location_name=location_name, - failover_group_name=failover_group_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _failover_initial( - self, resource_group_name: str, location_name: str, failover_group_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2022-05-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_failover_request( - resource_group_name=resource_group_name, - location_name=location_name, - failover_group_name=failover_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_failover( - self, resource_group_name: str, location_name: str, failover_group_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.InstanceFailoverGroup]: - """Fails over from the current primary managed instance to this managed instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :return: An instance of AsyncLROPoller that returns either InstanceFailoverGroup or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.InstanceFailoverGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - 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) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._failover_initial( - resource_group_name=resource_group_name, - location_name=location_name, - failover_group_name=failover_group_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("InstanceFailoverGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.InstanceFailoverGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.InstanceFailoverGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _force_failover_allow_data_loss_initial( - self, resource_group_name: str, location_name: str, failover_group_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2022-05-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_force_failover_allow_data_loss_request( - resource_group_name=resource_group_name, - location_name=location_name, - failover_group_name=failover_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_force_failover_allow_data_loss( - self, resource_group_name: str, location_name: str, failover_group_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.InstanceFailoverGroup]: - """Fails over from the current primary managed instance to this managed instance. This operation - might 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 location_name: The name of the region where the resource is located. Required. - :type location_name: str - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :return: An instance of AsyncLROPoller that returns either InstanceFailoverGroup or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.InstanceFailoverGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - 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) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._force_failover_allow_data_loss_initial( - resource_group_name=resource_group_name, - location_name=location_name, - failover_group_name=failover_group_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("InstanceFailoverGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.InstanceFailoverGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.InstanceFailoverGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_instance_pools_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_instance_pools_operations.py deleted file mode 100644 index 940301cc189c..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_instance_pools_operations.py +++ /dev/null @@ -1,741 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._instance_pools_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_request, - build_update_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class InstancePoolsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`instance_pools` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_models.InstancePool"]: - """Gets a list of all instance pools in the subscription. - - :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", "2023-05-01-preview")) - cls: ClsType[_models.InstancePoolListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncItemPaged["_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 - :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", "2023-05-01-preview")) - cls: ClsType[_models.InstancePoolListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace_async - async def get(self, resource_group_name: str, instance_pool_name: str, **kwargs: Any) -> _models.InstancePool: - """Gets an instance pool. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param instance_pool_name: The name of the instance pool to be retrieved. Required. - :type instance_pool_name: str - :return: InstancePool or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.InstancePool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[_models.InstancePool] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - instance_pool_name=instance_pool_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("InstancePool", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - instance_pool_name: str, - parameters: Union[_models.InstancePool, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "InstancePool") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - instance_pool_name=instance_pool_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - instance_pool_name: str, - parameters: _models.InstancePool, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.InstancePool]: - """Creates or updates an instance 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 instance_pool_name: The name of the instance pool to be created or updated. Required. - :type instance_pool_name: str - :param parameters: The requested instance pool resource state. Required. - :type parameters: ~azure.mgmt.sql.models.InstancePool - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either InstancePool or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.InstancePool] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - instance_pool_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.InstancePool]: - """Creates or updates an instance 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 instance_pool_name: The name of the instance pool to be created or updated. Required. - :type instance_pool_name: str - :param parameters: The requested instance pool resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either InstancePool or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.InstancePool] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - instance_pool_name: str, - parameters: Union[_models.InstancePool, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.InstancePool]: - """Creates or updates an instance 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 instance_pool_name: The name of the instance pool to be created or updated. Required. - :type instance_pool_name: str - :param parameters: The requested instance pool resource state. Is either a InstancePool type or - a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.InstancePool or IO[bytes] - :return: An instance of AsyncLROPoller that returns either InstancePool or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.InstancePool] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.InstancePool] = 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, - instance_pool_name=instance_pool_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("InstancePool", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.InstancePool].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.InstancePool]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, instance_pool_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - instance_pool_name=instance_pool_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, instance_pool_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an instance 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 instance_pool_name: The name of the instance pool to be deleted. Required. - :type instance_pool_name: str - :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", "2023-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_initial( - resource_group_name=resource_group_name, - instance_pool_name=instance_pool_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - instance_pool_name: str, - parameters: Union[_models.InstancePoolUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "InstancePoolUpdate") - - _request = build_update_request( - resource_group_name=resource_group_name, - instance_pool_name=instance_pool_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - instance_pool_name: str, - parameters: _models.InstancePoolUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.InstancePool]: - """Updates an instance 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 instance_pool_name: The name of the instance pool to be updated. Required. - :type instance_pool_name: str - :param parameters: The requested instance pool resource state. Required. - :type parameters: ~azure.mgmt.sql.models.InstancePoolUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either InstancePool or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.InstancePool] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - instance_pool_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.InstancePool]: - """Updates an instance 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 instance_pool_name: The name of the instance pool to be updated. Required. - :type instance_pool_name: str - :param parameters: The requested instance pool resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either InstancePool or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.InstancePool] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - instance_pool_name: str, - parameters: Union[_models.InstancePoolUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.InstancePool]: - """Updates an instance 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 instance_pool_name: The name of the instance pool to be updated. Required. - :type instance_pool_name: str - :param parameters: The requested instance pool resource state. Is either a InstancePoolUpdate - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.InstancePoolUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either InstancePool or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.InstancePool] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.InstancePool] = 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( - resource_group_name=resource_group_name, - instance_pool_name=instance_pool_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("InstancePool", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.InstancePool].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.InstancePool]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 4d0b2b4e7d85..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_ipv6_firewall_rules_operations.py +++ /dev/null @@ -1,389 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._ipv6_firewall_rules_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_server_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class IPv6FirewallRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`ipv6_firewall_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.IPv6FirewallRule"]: - """Gets a list of IPv6 firewall rules. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either IPv6FirewallRule or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.IPv6FirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[_models.IPv6FirewallRuleListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("IPv6FirewallRuleListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, server_name: str, firewall_rule_name: str, **kwargs: Any - ) -> _models.IPv6FirewallRule: - """Gets an IPv6 firewall rule. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. 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 - :return: IPv6FirewallRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.IPv6FirewallRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-11-01-preview")) - cls: ClsType[_models.IPv6FirewallRule] = kwargs.pop("cls", None) - - _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, - headers=_headers, - params=_params, - ) - _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("IPv6FirewallRule", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - firewall_rule_name: str, - parameters: _models.IPv6FirewallRule, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IPv6FirewallRule: - """Creates or updates an IPv6 firewall rule. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. 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 an IPv6 firewall rule. - Required. - :type parameters: ~azure.mgmt.sql.models.IPv6FirewallRule - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: IPv6FirewallRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.IPv6FirewallRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - firewall_rule_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IPv6FirewallRule: - """Creates or updates an IPv6 firewall rule. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. 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 an IPv6 firewall rule. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: IPv6FirewallRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.IPv6FirewallRule - :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.IPv6FirewallRule, IO[bytes]], - **kwargs: Any - ) -> _models.IPv6FirewallRule: - """Creates or updates an IPv6 firewall rule. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. 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 an IPv6 firewall rule. Is - either a IPv6FirewallRule type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.IPv6FirewallRule or IO[bytes] - :return: IPv6FirewallRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.IPv6FirewallRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "IPv6FirewallRule") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - firewall_rule_name=firewall_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("IPv6FirewallRule", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete(self, resource_group_name: str, server_name: str, firewall_rule_name: str, **kwargs: Any) -> None: - """Deletes an IPv6 firewall rule. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. 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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-11-01-preview")) - 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, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_agents_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_agents_operations.py deleted file mode 100644 index 4f57a0298086..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_agents_operations.py +++ /dev/null @@ -1,715 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._job_agents_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_server_request, - build_update_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class JobAgentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`job_agents` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.JobAgent"]: - """Gets a list of job agents in a server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either JobAgent or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobAgent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobAgentListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("JobAgentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, server_name: str, job_agent_name: str, **kwargs: Any - ) -> _models.JobAgent: - """Gets a job agent. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 to be retrieved. Required. - :type job_agent_name: str - :return: JobAgent or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobAgent - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobAgent] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("JobAgent", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - parameters: Union[_models.JobAgent, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "JobAgent") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - parameters: _models.JobAgent, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.JobAgent]: - """Creates or updates a job agent. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 to be created or updated. Required. - :type job_agent_name: str - :param parameters: The requested job agent resource state. Required. - :type parameters: ~azure.mgmt.sql.models.JobAgent - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either JobAgent or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.JobAgent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.JobAgent]: - """Creates or updates a job agent. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 to be created or updated. Required. - :type job_agent_name: str - :param parameters: The requested job agent resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either JobAgent or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.JobAgent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - parameters: Union[_models.JobAgent, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.JobAgent]: - """Creates or updates a job agent. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 to be created or updated. Required. - :type job_agent_name: str - :param parameters: The requested job agent resource state. Is either a JobAgent type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.JobAgent or IO[bytes] - :return: An instance of AsyncLROPoller that returns either JobAgent or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.JobAgent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.JobAgent] = 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, - job_agent_name=job_agent_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("JobAgent", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.JobAgent].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.JobAgent]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, server_name: str, job_agent_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, server_name: str, job_agent_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a job agent. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 to be deleted. Required. - :type job_agent_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - parameters: Union[_models.JobAgentUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "JobAgentUpdate") - - _request = build_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - parameters: _models.JobAgentUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.JobAgent]: - """Updates a job agent. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 to be updated. Required. - :type job_agent_name: str - :param parameters: The update to the job agent. Required. - :type parameters: ~azure.mgmt.sql.models.JobAgentUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either JobAgent or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.JobAgent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.JobAgent]: - """Updates a job agent. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 to be updated. Required. - :type job_agent_name: str - :param parameters: The update to the job agent. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either JobAgent or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.JobAgent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - parameters: Union[_models.JobAgentUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.JobAgent]: - """Updates a job agent. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 to be updated. Required. - :type job_agent_name: str - :param parameters: The update to the job agent. Is either a JobAgentUpdate type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.sql.models.JobAgentUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either JobAgent or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.JobAgent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.JobAgent] = 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( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("JobAgent", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.JobAgent].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.JobAgent]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_credentials_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_credentials_operations.py deleted file mode 100644 index e5fe8d92e46d..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_credentials_operations.py +++ /dev/null @@ -1,408 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._job_credentials_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_agent_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class JobCredentialsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`job_credentials` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_agent( - self, resource_group_name: str, server_name: str, job_agent_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.JobCredential"]: - """Gets a list of jobs credentials. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 - :return: An iterator like instance of either JobCredential or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobCredential] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobCredentialListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_agent_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("JobCredentialListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, server_name: str, job_agent_name: str, credential_name: str, **kwargs: Any - ) -> _models.JobCredential: - """Gets a jobs credential. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 credential_name: The name of the credential. Required. - :type credential_name: str - :return: JobCredential or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobCredential - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobCredential] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - credential_name=credential_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("JobCredential", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - credential_name: str, - parameters: _models.JobCredential, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.JobCredential: - """Creates or updates a job credential. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 credential_name: The name of the credential. Required. - :type credential_name: str - :param parameters: The requested job credential state. Required. - :type parameters: ~azure.mgmt.sql.models.JobCredential - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: JobCredential or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobCredential - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - credential_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.JobCredential: - """Creates or updates a job credential. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 credential_name: The name of the credential. Required. - :type credential_name: str - :param parameters: The requested job credential state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: JobCredential or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobCredential - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - credential_name: str, - parameters: Union[_models.JobCredential, IO[bytes]], - **kwargs: Any - ) -> _models.JobCredential: - """Creates or updates a job credential. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 credential_name: The name of the credential. Required. - :type credential_name: str - :param parameters: The requested job credential state. Is either a JobCredential type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.JobCredential or IO[bytes] - :return: JobCredential or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobCredential - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "JobCredential") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - credential_name=credential_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("JobCredential", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( - self, resource_group_name: str, server_name: str, job_agent_name: str, credential_name: str, **kwargs: Any - ) -> None: - """Deletes a job credential. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 credential_name: The name of the credential. Required. - :type credential_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - credential_name=credential_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_executions_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_executions_operations.py deleted file mode 100644 index 9b3be94cf29d..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_executions_operations.py +++ /dev/null @@ -1,687 +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 collections.abc import MutableMapping -import datetime -from typing import Any, AsyncIterator, Callable, Optional, TypeVar, Union, cast - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._job_executions_operations import ( - build_cancel_request, - build_create_or_update_request, - build_create_request, - build_get_request, - build_list_by_agent_request, - build_list_by_job_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class JobExecutionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`job_executions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_agent( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - create_time_min: Optional[datetime.datetime] = None, - create_time_max: Optional[datetime.datetime] = None, - end_time_min: Optional[datetime.datetime] = None, - end_time_max: Optional[datetime.datetime] = None, - is_active: Optional[bool] = None, - skip: Optional[int] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.JobExecution"]: - """Lists all executions in a job agent. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 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 - :return: An iterator like instance of either JobExecution or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobExecution] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobExecutionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_agent_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - subscription_id=self._config.subscription_id, - create_time_min=create_time_min, - create_time_max=create_time_max, - end_time_min=end_time_min, - end_time_max=end_time_max, - is_active=is_active, - skip=skip, - top=top, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace_async - async def cancel( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - job_execution_id: str, - **kwargs: Any - ) -> None: - """Requests cancellation of a job execution. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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_execution_id: The id of the job execution to cancel. Required. - :type job_execution_id: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_cancel_request( - resource_group_name=resource_group_name, - server_name=server_name, - 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, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - async def _create_initial( - self, resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_create_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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_create( - self, resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.JobExecution]: - """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. - :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 - :return: An instance of AsyncLROPoller that returns either JobExecution or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.JobExecution] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobExecution] = kwargs.pop("cls", None) - 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( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - job_name=job_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("JobExecution", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.JobExecution].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.JobExecution]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either JobExecution or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobExecution] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobExecutionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @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, - **kwargs: Any - ) -> _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. - :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_execution_id: The id of the job execution. Required. - :type job_execution_id: str - :return: JobExecution or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobExecution - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobExecution] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - job_name=job_name, - job_execution_id=job_execution_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - 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 - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - ) -> AsyncLROPoller[_models.JobExecution]: - """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. - :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 job execution id to create the job execution under. Required. - :type job_execution_id: str - :return: An instance of AsyncLROPoller that returns either JobExecution or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.JobExecution] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobExecution] = kwargs.pop("cls", None) - 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, - 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, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("JobExecution", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.JobExecution].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.JobExecution]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_private_endpoints_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_private_endpoints_operations.py deleted file mode 100644 index 4650712ca66a..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_private_endpoints_operations.py +++ /dev/null @@ -1,536 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._job_private_endpoints_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_agent_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class JobPrivateEndpointsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`job_private_endpoints` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_agent( - self, resource_group_name: str, server_name: str, job_agent_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.JobPrivateEndpoint"]: - """Gets a list of job agent private endpoints. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param job_agent_name: The name of the job agent. Required. - :type job_agent_name: str - :return: An iterator like instance of either JobPrivateEndpoint or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobPrivateEndpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - cls: ClsType[_models.JobPrivateEndpointListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_agent_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("JobPrivateEndpointListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, server_name: str, job_agent_name: str, private_endpoint_name: str, **kwargs: Any - ) -> _models.JobPrivateEndpoint: - """Gets a private endpoint. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param job_agent_name: The name of the job agent. Required. - :type job_agent_name: str - :param private_endpoint_name: The name of the private endpoint to get. Required. - :type private_endpoint_name: str - :return: JobPrivateEndpoint or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobPrivateEndpoint - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[_models.JobPrivateEndpoint] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - private_endpoint_name=private_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("JobPrivateEndpoint", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - private_endpoint_name: str, - parameters: Union[_models.JobPrivateEndpoint, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "JobPrivateEndpoint") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - private_endpoint_name=private_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - private_endpoint_name: str, - parameters: _models.JobPrivateEndpoint, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.JobPrivateEndpoint]: - """Creates or updates a private endpoint. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param job_agent_name: The name of the job agent. Required. - :type job_agent_name: str - :param private_endpoint_name: The name of the private endpoint. Required. - :type private_endpoint_name: str - :param parameters: The requested private endpoint state. Required. - :type parameters: ~azure.mgmt.sql.models.JobPrivateEndpoint - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either JobPrivateEndpoint or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.JobPrivateEndpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - private_endpoint_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.JobPrivateEndpoint]: - """Creates or updates a private endpoint. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param job_agent_name: The name of the job agent. Required. - :type job_agent_name: str - :param private_endpoint_name: The name of the private endpoint. Required. - :type private_endpoint_name: str - :param parameters: The requested private endpoint state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either JobPrivateEndpoint or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.JobPrivateEndpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - private_endpoint_name: str, - parameters: Union[_models.JobPrivateEndpoint, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.JobPrivateEndpoint]: - """Creates or updates a private endpoint. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param job_agent_name: The name of the job agent. Required. - :type job_agent_name: str - :param private_endpoint_name: The name of the private endpoint. Required. - :type private_endpoint_name: str - :param parameters: The requested private endpoint state. Is either a JobPrivateEndpoint type or - a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.JobPrivateEndpoint or IO[bytes] - :return: An instance of AsyncLROPoller that returns either JobPrivateEndpoint or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.JobPrivateEndpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.JobPrivateEndpoint] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - private_endpoint_name=private_endpoint_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("JobPrivateEndpoint", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.JobPrivateEndpoint].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.JobPrivateEndpoint]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, server_name: str, job_agent_name: str, private_endpoint_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - private_endpoint_name=private_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, server_name: str, job_agent_name: str, private_endpoint_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a private endpoint. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param job_agent_name: The name of the job agent. Required. - :type job_agent_name: str - :param private_endpoint_name: The name of the private endpoint to delete. Required. - :type private_endpoint_name: str - :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", "2023-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_initial( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - private_endpoint_name=private_endpoint_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_step_executions_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_step_executions_operations.py deleted file mode 100644 index bb8bff32d245..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_step_executions_operations.py +++ /dev/null @@ -1,252 +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 collections.abc import MutableMapping -import datetime -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._job_step_executions_operations import build_get_request, build_list_by_job_execution_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class JobStepExecutionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`job_step_executions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @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, - end_time_max: Optional[datetime.datetime] = None, - is_active: Optional[bool] = None, - skip: Optional[int] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.JobExecution"]: - """Lists the step executions 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. - :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 id of the job execution. Required. - :type job_execution_id: 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 - :return: An iterator like instance of either JobExecution or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobExecution] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobExecutionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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_execution_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - job_name=job_name, - job_execution_id=job_execution_id, - subscription_id=self._config.subscription_id, - create_time_min=create_time_min, - create_time_max=create_time_max, - end_time_min=end_time_min, - end_time_max=end_time_max, - is_active=is_active, - skip=skip, - top=top, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @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, - **kwargs: Any - ) -> _models.JobExecution: - """Gets a step execution of a job execution. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 - :return: JobExecution or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobExecution - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobExecution] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - job_name=job_name, - job_execution_id=job_execution_id, - step_name=step_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_steps_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_steps_operations.py deleted file mode 100644 index 3b6f6be8cfa2..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_steps_operations.py +++ /dev/null @@ -1,604 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._job_steps_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_by_version_request, - build_get_request, - build_list_by_job_request, - build_list_by_version_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class JobStepsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`job_steps` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either JobStep or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobStep] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobStepListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @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 - :return: JobStep or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobStep] = kwargs.pop("cls", None) - - _request = build_get_by_version_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - job_name=job_name, - job_version=job_version, - step_name=step_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_job( - self, resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.JobStep"]: - """Gets all job steps for a job's current version. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 - :return: An iterator like instance of either JobStep or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobStep] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobStepListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - step_name: str, - **kwargs: Any - ) -> _models.JobStep: - """Gets a job step in a job's current version. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 step_name: The name of the job step. Required. - :type step_name: str - :return: JobStep or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobStep] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - job_name=job_name, - step_name=step_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - step_name: str, - parameters: _models.JobStep, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.JobStep: - """Creates or updates a job step. This will implicitly create a new job version. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 step_name: The name of the job step. Required. - :type step_name: str - :param parameters: The requested state of the job step. Required. - :type parameters: ~azure.mgmt.sql.models.JobStep - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: JobStep or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - step_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.JobStep: - """Creates or updates a job step. This will implicitly create a new job version. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 step_name: The name of the job step. Required. - :type step_name: str - :param parameters: The requested state of the job step. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: JobStep or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - step_name: str, - parameters: Union[_models.JobStep, IO[bytes]], - **kwargs: Any - ) -> _models.JobStep: - """Creates or updates a job step. This will implicitly create a new job version. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 step_name: The name of the job step. Required. - :type step_name: str - :param parameters: The requested state of the job step. Is either a JobStep type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.sql.models.JobStep or IO[bytes] - :return: JobStep or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "JobStep") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - job_name=job_name, - step_name=step_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, 201]: - 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - step_name: str, - **kwargs: Any - ) -> None: - """Deletes a job step. This will implicitly create a new job version. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 step_name: The name of the job step to delete. Required. - :type step_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - job_name=job_name, - step_name=step_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_target_executions_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_target_executions_operations.py deleted file mode 100644 index a0401ac966e5..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_target_executions_operations.py +++ /dev/null @@ -1,384 +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 collections.abc import MutableMapping -import datetime -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._job_target_executions_operations import ( - build_get_request, - build_list_by_job_execution_request, - build_list_by_step_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class JobTargetExecutionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`job_target_executions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @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, - end_time_max: Optional[datetime.datetime] = None, - is_active: Optional[bool] = None, - skip: Optional[int] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.JobExecution"]: - """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. - :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 id of the job execution. Required. - :type job_execution_id: 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 - :return: An iterator like instance of either JobExecution or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobExecution] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobExecutionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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_execution_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - job_name=job_name, - job_execution_id=job_execution_id, - subscription_id=self._config.subscription_id, - create_time_min=create_time_min, - create_time_max=create_time_max, - end_time_min=end_time_min, - end_time_max=end_time_max, - is_active=is_active, - skip=skip, - top=top, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace - 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, - end_time_max: Optional[datetime.datetime] = None, - is_active: Optional[bool] = None, - skip: Optional[int] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.JobExecution"]: - """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. - :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 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 - :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 - :return: An iterator like instance of either JobExecution or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobExecution] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobExecutionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_step_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - job_name=job_name, - job_execution_id=job_execution_id, - step_name=step_name, - subscription_id=self._config.subscription_id, - create_time_min=create_time_min, - create_time_max=create_time_max, - end_time_min=end_time_min, - end_time_max=end_time_max, - is_active=is_active, - skip=skip, - top=top, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @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 - :return: JobExecution or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobExecution - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobExecution] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - job_name=job_name, - job_execution_id=job_execution_id, - step_name=step_name, - target_id=target_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_target_groups_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_target_groups_operations.py deleted file mode 100644 index 822928e4b117..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_target_groups_operations.py +++ /dev/null @@ -1,408 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._job_target_groups_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_agent_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class JobTargetGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`job_target_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_agent( - self, resource_group_name: str, server_name: str, job_agent_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.JobTargetGroup"]: - """Gets all target groups in an agent. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 - :return: An iterator like instance of either JobTargetGroup or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobTargetGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobTargetGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_agent_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("JobTargetGroupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, server_name: str, job_agent_name: str, target_group_name: str, **kwargs: Any - ) -> _models.JobTargetGroup: - """Gets a target group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 target_group_name: The name of the target group. Required. - :type target_group_name: str - :return: JobTargetGroup or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobTargetGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobTargetGroup] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - target_group_name=target_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("JobTargetGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - target_group_name: str, - parameters: _models.JobTargetGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.JobTargetGroup: - """Creates or updates a target group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 target_group_name: The name of the target group. Required. - :type target_group_name: str - :param parameters: The requested state of the target group. Required. - :type parameters: ~azure.mgmt.sql.models.JobTargetGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: JobTargetGroup or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobTargetGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - target_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.JobTargetGroup: - """Creates or updates a target group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 target_group_name: The name of the target group. Required. - :type target_group_name: str - :param parameters: The requested state of the target group. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: JobTargetGroup or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobTargetGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - target_group_name: str, - parameters: Union[_models.JobTargetGroup, IO[bytes]], - **kwargs: Any - ) -> _models.JobTargetGroup: - """Creates or updates a target group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 target_group_name: The name of the target group. Required. - :type target_group_name: str - :param parameters: The requested state of the target group. Is either a JobTargetGroup type or - a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.JobTargetGroup or IO[bytes] - :return: JobTargetGroup or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobTargetGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "JobTargetGroup") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - target_group_name=target_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("JobTargetGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( - self, resource_group_name: str, server_name: str, job_agent_name: str, target_group_name: str, **kwargs: Any - ) -> None: - """Deletes a target group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 target_group_name: The name of the target group. Required. - :type target_group_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - target_group_name=target_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_versions_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_versions_operations.py deleted file mode 100644 index 865d9c9fcdc1..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_versions_operations.py +++ /dev/null @@ -1,205 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._job_versions_operations import build_get_request, build_list_by_job_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class JobVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`job_versions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_job( - self, resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.JobVersion"]: - """Gets all versions of a job. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 - :return: An iterator like instance of either JobVersion or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobVersionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("JobVersionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - job_version: int, - **kwargs: Any - ) -> _models.JobVersion: - """Gets a job version. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 - :return: JobVersion or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobVersion] = 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_version=job_version, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("JobVersion", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_jobs_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_jobs_operations.py deleted file mode 100644 index 7087ffc555a9..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_jobs_operations.py +++ /dev/null @@ -1,407 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._jobs_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_agent_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class JobsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`jobs` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_agent( - self, resource_group_name: str, server_name: str, job_agent_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.Job"]: - """Gets a list of jobs. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 - :return: An iterator like instance of either Job or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.Job] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_agent_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("JobListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, **kwargs: Any - ) -> _models.Job: - """Gets a job. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 - :return: Job or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.Job - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.Job] = 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, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("Job", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - parameters: _models.Job, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Job: - """Creates or updates a job. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 parameters: The requested job state. Required. - :type parameters: ~azure.mgmt.sql.models.Job - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Job or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.Job - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Job: - """Creates or updates a job. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 parameters: The requested job state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: Job or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.Job - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - parameters: Union[_models.Job, IO[bytes]], - **kwargs: Any - ) -> _models.Job: - """Creates or updates a job. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 parameters: The requested job state. Is either a Job type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.Job or IO[bytes] - :return: Job or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.Job - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "Job") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - job_name=job_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Job", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( - self, resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, **kwargs: Any - ) -> None: - """Deletes a job. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 delete. Required. - :type job_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - job_name=job_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_ledger_digest_uploads_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_ledger_digest_uploads_operations.py deleted file mode 100644 index 7b4dbe7d2214..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_ledger_digest_uploads_operations.py +++ /dev/null @@ -1,555 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._ledger_digest_uploads_operations import ( - build_create_or_update_request, - build_disable_request, - build_get_request, - build_list_by_database_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class LedgerDigestUploadsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`ledger_digest_uploads` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], - **kwargs: Any - ) -> _models.LedgerDigestUploads: - """Gets the current ledger digest upload configuration for a database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 ledger_digest_uploads: "current" Required. - :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName - :return: LedgerDigestUploads or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.LedgerDigestUploads - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[_models.LedgerDigestUploads] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - ledger_digest_uploads=ledger_digest_uploads, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("LedgerDigestUploads", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], - parameters: Union[_models.LedgerDigestUploads, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2021-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "LedgerDigestUploads") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - ledger_digest_uploads=ledger_digest_uploads, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], - parameters: _models.LedgerDigestUploads, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.LedgerDigestUploads]: - """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger - instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 ledger_digest_uploads: "current" Required. - :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName - :param parameters: Required. - :type parameters: ~azure.mgmt.sql.models.LedgerDigestUploads - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either LedgerDigestUploads or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LedgerDigestUploads] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.LedgerDigestUploads]: - """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger - instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 ledger_digest_uploads: "current" Required. - :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName - :param parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either LedgerDigestUploads or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LedgerDigestUploads] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], - parameters: Union[_models.LedgerDigestUploads, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.LedgerDigestUploads]: - """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger - instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 ledger_digest_uploads: "current" Required. - :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName - :param parameters: Is either a LedgerDigestUploads type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.LedgerDigestUploads or IO[bytes] - :return: An instance of AsyncLROPoller that returns either LedgerDigestUploads or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LedgerDigestUploads] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - 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) - 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, - ledger_digest_uploads=ledger_digest_uploads, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LedgerDigestUploads", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LedgerDigestUploads].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.LedgerDigestUploads]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either LedgerDigestUploads or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LedgerDigestUploads] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[_models.LedgerDigestUploadsListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - async def _disable_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disable_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - ledger_digest_uploads=ledger_digest_uploads, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_disable( - self, - resource_group_name: str, - server_name: str, - database_name: str, - ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], - **kwargs: Any - ) -> AsyncLROPoller[_models.LedgerDigestUploads]: - """Disables uploading ledger digests to an Azure Storage account or an Azure Confidential Ledger - instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 ledger_digest_uploads: "current" Required. - :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName - :return: An instance of AsyncLROPoller that returns either LedgerDigestUploads or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LedgerDigestUploads] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[_models.LedgerDigestUploads] = 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._disable_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - ledger_digest_uploads=ledger_digest_uploads, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LedgerDigestUploads", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LedgerDigestUploads].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.LedgerDigestUploads]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_long_term_retention_backups_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_long_term_retention_backups_operations.py deleted file mode 100644 index a13cb59efd48..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_long_term_retention_backups_operations.py +++ /dev/null @@ -1,3466 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._long_term_retention_backups_operations import ( - build_change_access_tier_by_resource_group_request, - build_change_access_tier_request, - build_copy_by_resource_group_request, - build_copy_request, - build_delete_by_resource_group_request, - build_delete_request, - build_get_by_resource_group_request, - build_get_request, - build_list_by_database_request, - build_list_by_location_request, - build_list_by_resource_group_database_request, - build_list_by_resource_group_location_request, - build_list_by_resource_group_server_request, - build_list_by_server_request, - build_lock_time_based_immutability_by_resource_group_request, - build_lock_time_based_immutability_request, - build_remove_legal_hold_immutability_by_resource_group_request, - build_remove_legal_hold_immutability_request, - build_remove_time_based_immutability_by_resource_group_request, - build_remove_time_based_immutability_request, - build_set_legal_hold_immutability_by_resource_group_request, - build_set_legal_hold_immutability_request, - build_update_by_resource_group_request, - build_update_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class LongTermRetentionBackupsOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`long_term_retention_backups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_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 - :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", "2024-11-01-preview")) - cls: ClsType[_models.LongTermRetentionBackupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_server( - self, - location_name: str, - long_term_retention_server_name: str, - only_latest_per_database: Optional[bool] = None, - database_state: Optional[Union[str, _models.DatabaseState]] = None, - **kwargs: Any - ) -> AsyncItemPaged["_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 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 - :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", "2024-11-01-preview")) - cls: ClsType[_models.LongTermRetentionBackupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_database( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - only_latest_per_database: Optional[bool] = None, - database_state: Optional[Union[str, _models.DatabaseState]] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.LongTermRetentionBackup"]: - """Lists all long term retention backups for a database. - - :param location_name: The location of the database. Required. - :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. - :type long_term_retention_database_name: str - :param only_latest_per_database: Whether or not to only get the latest backup for each - database. Default value is None. - :type only_latest_per_database: bool - :param database_state: Whether to query against just live databases, just deleted databases, or - all databases. Known values are: "All", "Live", and "Deleted". Default value is None. - :type database_state: str or ~azure.mgmt.sql.models.DatabaseState - :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", "2024-11-01-preview")) - cls: ClsType[_models.LongTermRetentionBackupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - **kwargs: Any - ) -> _models.LongTermRetentionBackup: - """Gets a long term retention backup. - - :param location_name: The location of the database. 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 - :return: LongTermRetentionBackup or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.LongTermRetentionBackup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - 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, - headers=_headers, - params=_params, - ) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _delete_initial( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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 - :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", "2024-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _change_access_tier_initial( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: Union[_models.ChangeLongTermRetentionBackupAccessTierParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ChangeLongTermRetentionBackupAccessTierParameters") - - _request = build_change_access_tier_request( - location_name=location_name, - long_term_retention_server_name=long_term_retention_server_name, - long_term_retention_database_name=long_term_retention_database_name, - backup_name=backup_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_change_access_tier( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: _models.ChangeLongTermRetentionBackupAccessTierParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: - """Change a long term retention backup access tier. - - :param location_name: Required. - :type location_name: str - :param long_term_retention_server_name: Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: Required. - :type long_term_retention_database_name: str - :param backup_name: Required. - :type backup_name: str - :param parameters: Required. - :type parameters: ~azure.mgmt.sql.models.ChangeLongTermRetentionBackupAccessTierParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either LongTermRetentionBackup or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_change_access_tier( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: - """Change a long term retention backup access tier. - - :param location_name: Required. - :type location_name: str - :param long_term_retention_server_name: Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: Required. - :type long_term_retention_database_name: str - :param backup_name: Required. - :type backup_name: str - :param parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either LongTermRetentionBackup or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_change_access_tier( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: Union[_models.ChangeLongTermRetentionBackupAccessTierParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: - """Change a long term retention backup access tier. - - :param location_name: Required. - :type location_name: str - :param long_term_retention_server_name: Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: Required. - :type long_term_retention_database_name: str - :param backup_name: Required. - :type backup_name: str - :param parameters: Is either a ChangeLongTermRetentionBackupAccessTierParameters type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ChangeLongTermRetentionBackupAccessTierParameters or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either LongTermRetentionBackup or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._change_access_tier_initial( - location_name=location_name, - long_term_retention_server_name=long_term_retention_server_name, - long_term_retention_database_name=long_term_retention_database_name, - backup_name=backup_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LongTermRetentionBackup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.LongTermRetentionBackup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _copy_initial( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: Union[_models.CopyLongTermRetentionBackupParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_copy( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: _models.CopyLongTermRetentionBackupParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_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 - :return: An instance of AsyncLROPoller that returns either - LongTermRetentionBackupOperationResult or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_copy( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_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: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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_copy( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: Union[_models.CopyLongTermRetentionBackupParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_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. Is either a - CopyLongTermRetentionBackupParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.CopyLongTermRetentionBackupParameters or IO[bytes] - :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", "2024-11-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, 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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LongTermRetentionBackupOperationResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _lock_time_based_immutability_initial( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_lock_time_based_immutability_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_lock_time_based_immutability( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - **kwargs: Any - ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: - """Lock time based immutability of an existing long term retention backup. - - :param location_name: 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 - :return: An instance of AsyncLROPoller that returns either LongTermRetentionBackup or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._lock_time_based_immutability_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, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LongTermRetentionBackup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.LongTermRetentionBackup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _remove_legal_hold_immutability_initial( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_remove_legal_hold_immutability_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_remove_legal_hold_immutability( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - **kwargs: Any - ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: - """Remove legal hold immutability of an existing long term retention backup. - - :param location_name: 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 - :return: An instance of AsyncLROPoller that returns either LongTermRetentionBackup or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._remove_legal_hold_immutability_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, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LongTermRetentionBackup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.LongTermRetentionBackup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _remove_time_based_immutability_initial( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_remove_time_based_immutability_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_remove_time_based_immutability( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - **kwargs: Any - ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: - """Remove time based immutability of an existing long term retention backup. - - :param location_name: 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 - :return: An instance of AsyncLROPoller that returns either LongTermRetentionBackup or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._remove_time_based_immutability_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, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LongTermRetentionBackup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.LongTermRetentionBackup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _set_legal_hold_immutability_initial( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_set_legal_hold_immutability_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_set_legal_hold_immutability( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - **kwargs: Any - ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: - """Set legal hold immutability of an existing long term retention backup. - - :param location_name: 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 - :return: An instance of AsyncLROPoller that returns either LongTermRetentionBackup or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._set_legal_hold_immutability_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, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LongTermRetentionBackup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.LongTermRetentionBackup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - 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[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "UpdateLongTermRetentionBackupParameters") - - _request = build_update_request( - location_name=location_name, - long_term_retention_server_name=long_term_retention_server_name, - long_term_retention_database_name=long_term_retention_database_name, - backup_name=backup_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: _models.UpdateLongTermRetentionBackupParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: - """Updates an existing long term retention backup. - - :param location_name: The location of the database. Required. - :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. - :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. - :type backup_name: str - :param parameters: The requested backup resource state. Required. - :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either - LongTermRetentionBackupOperationResult or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: - """Updates an existing long term retention backup. - - :param location_name: The location of the database. Required. - :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. - :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. - :type backup_name: str - :param parameters: The requested backup resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either - LongTermRetentionBackupOperationResult or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: Union[_models.UpdateLongTermRetentionBackupParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: - """Updates an existing long term retention backup. - - :param location_name: The location of the database. Required. - :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. - :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. - :type backup_name: str - :param parameters: The requested backup resource state. Is either a - UpdateLongTermRetentionBackupParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters or IO[bytes] - :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", "2024-11-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, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - location_name=location_name, - long_term_retention_server_name=long_term_retention_server_name, - long_term_retention_database_name=long_term_retention_database_name, - backup_name=backup_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LongTermRetentionBackupOperationResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 - ) -> AsyncItemPaged["_models.LongTermRetentionBackup"]: - """Lists the long term retention backups for a given location based on resource group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param location_name: The location of the database. Required. - :type location_name: str - :param only_latest_per_database: Whether or not to only get the latest backup for each - database. Default value is None. - :type only_latest_per_database: bool - :param database_state: Whether to query against just live databases, just deleted databases, or - all databases. Known values are: "All", "Live", and "Deleted". Default value is None. - :type database_state: str or ~azure.mgmt.sql.models.DatabaseState - :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", "2024-11-01-preview")) - cls: ClsType[_models.LongTermRetentionBackupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @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 - ) -> AsyncItemPaged["_models.LongTermRetentionBackup"]: - """Lists the long term retention backups for a given server based on resource groups. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :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 - :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", "2024-11-01-preview")) - cls: ClsType[_models.LongTermRetentionBackupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @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 - ) -> AsyncItemPaged["_models.LongTermRetentionBackup"]: - """Lists all long term retention backups for a database based on a particular resource group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :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 - :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", "2024-11-01-preview")) - cls: ClsType[_models.LongTermRetentionBackupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @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, - **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 - :return: LongTermRetentionBackup or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.LongTermRetentionBackup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2024-11-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, - headers=_headers, - params=_params, - ) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _delete_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, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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, - **kwargs: Any - ) -> 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. - :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 - :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", "2024-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_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, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _change_access_tier_by_resource_group_initial( # pylint: disable=name-too-long - 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.ChangeLongTermRetentionBackupAccessTierParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ChangeLongTermRetentionBackupAccessTierParameters") - - _request = build_change_access_tier_by_resource_group_request( - resource_group_name=resource_group_name, - location_name=location_name, - long_term_retention_server_name=long_term_retention_server_name, - long_term_retention_database_name=long_term_retention_database_name, - backup_name=backup_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_change_access_tier_by_resource_group( # pylint: disable=name-too-long - 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.ChangeLongTermRetentionBackupAccessTierParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: - """Change a long term retention backup access tier. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param location_name: Required. - :type location_name: str - :param long_term_retention_server_name: Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: Required. - :type long_term_retention_database_name: str - :param backup_name: Required. - :type backup_name: str - :param parameters: Required. - :type parameters: ~azure.mgmt.sql.models.ChangeLongTermRetentionBackupAccessTierParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either LongTermRetentionBackup or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_change_access_tier_by_resource_group( # pylint: disable=name-too-long - 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[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: - """Change a long term retention backup access tier. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param location_name: Required. - :type location_name: str - :param long_term_retention_server_name: Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: Required. - :type long_term_retention_database_name: str - :param backup_name: Required. - :type backup_name: str - :param parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either LongTermRetentionBackup or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_change_access_tier_by_resource_group( # pylint: disable=name-too-long - 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.ChangeLongTermRetentionBackupAccessTierParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: - """Change a long term retention backup access tier. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param location_name: Required. - :type location_name: str - :param long_term_retention_server_name: Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: Required. - :type long_term_retention_database_name: str - :param backup_name: Required. - :type backup_name: str - :param parameters: Is either a ChangeLongTermRetentionBackupAccessTierParameters type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ChangeLongTermRetentionBackupAccessTierParameters or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either LongTermRetentionBackup or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._change_access_tier_by_resource_group_initial( - resource_group_name=resource_group_name, - location_name=location_name, - long_term_retention_server_name=long_term_retention_server_name, - long_term_retention_database_name=long_term_retention_database_name, - backup_name=backup_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LongTermRetentionBackup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.LongTermRetentionBackup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _copy_by_resource_group_initial( - self, - resource_group_name: str, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: Union[_models.CopyLongTermRetentionBackupParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "CopyLongTermRetentionBackupParameters") - - _request = build_copy_by_resource_group_request( - resource_group_name=resource_group_name, - location_name=location_name, - long_term_retention_server_name=long_term_retention_server_name, - long_term_retention_database_name=long_term_retention_database_name, - backup_name=backup_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_copy_by_resource_group( - self, - resource_group_name: str, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: _models.CopyLongTermRetentionBackupParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: - """Copy an existing long term retention backup to a different server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param location_name: The location of the database. Required. - :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. - :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. - :type backup_name: str - :param parameters: The parameters needed for long term retention copy request. Required. - :type parameters: ~azure.mgmt.sql.models.CopyLongTermRetentionBackupParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either - LongTermRetentionBackupOperationResult or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_copy_by_resource_group( - self, - resource_group_name: str, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **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. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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_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[bytes]], - **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[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.CopyLongTermRetentionBackupParameters or IO[bytes] - :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", "2024-11-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, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._copy_by_resource_group_initial( - resource_group_name=resource_group_name, - location_name=location_name, - long_term_retention_server_name=long_term_retention_server_name, - long_term_retention_database_name=long_term_retention_database_name, - backup_name=backup_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LongTermRetentionBackupOperationResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _lock_time_based_immutability_by_resource_group_initial( # pylint: disable=name-too-long - 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 - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_lock_time_based_immutability_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_lock_time_based_immutability_by_resource_group( # pylint: disable=name-too-long - 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 - ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: - """Lock time based immutability of an existing long term retention backup. - - :param resource_group_name: The resource group name of the database. Required. - :type resource_group_name: str - :param location_name: 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 - :return: An instance of AsyncLROPoller that returns either LongTermRetentionBackup or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._lock_time_based_immutability_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, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LongTermRetentionBackup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.LongTermRetentionBackup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _remove_legal_hold_immutability_by_resource_group_initial( # pylint: disable=name-too-long - 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 - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_remove_legal_hold_immutability_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_remove_legal_hold_immutability_by_resource_group( # pylint: disable=name-too-long - 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 - ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: - """Remove legal hold immutability of an existing long term retention backup. - - :param resource_group_name: The resource group name of the database. Required. - :type resource_group_name: str - :param location_name: 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 - :return: An instance of AsyncLROPoller that returns either LongTermRetentionBackup or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._remove_legal_hold_immutability_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, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LongTermRetentionBackup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.LongTermRetentionBackup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _remove_time_based_immutability_by_resource_group_initial( # pylint: disable=name-too-long - 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 - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_remove_time_based_immutability_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_remove_time_based_immutability_by_resource_group( # pylint: disable=name-too-long - 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 - ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: - """Remove time based immutability of an existing long term retention backup. - - :param resource_group_name: The resource group name of the database. Required. - :type resource_group_name: str - :param location_name: 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 - :return: An instance of AsyncLROPoller that returns either LongTermRetentionBackup or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._remove_time_based_immutability_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, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LongTermRetentionBackup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.LongTermRetentionBackup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _set_legal_hold_immutability_by_resource_group_initial( # pylint: disable=name-too-long - 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 - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_set_legal_hold_immutability_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_set_legal_hold_immutability_by_resource_group( # pylint: disable=name-too-long - 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 - ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: - """Set legal hold immutability of an existing long term retention backup. - - :param resource_group_name: The resource group name of the database. Required. - :type resource_group_name: str - :param location_name: 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 - :return: An instance of AsyncLROPoller that returns either LongTermRetentionBackup or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._set_legal_hold_immutability_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, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LongTermRetentionBackup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.LongTermRetentionBackup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - 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[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "UpdateLongTermRetentionBackupParameters") - - _request = build_update_by_resource_group_request( - resource_group_name=resource_group_name, - location_name=location_name, - long_term_retention_server_name=long_term_retention_server_name, - long_term_retention_database_name=long_term_retention_database_name, - backup_name=backup_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update_by_resource_group( - self, - resource_group_name: str, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: _models.UpdateLongTermRetentionBackupParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: - """Updates an existing long term retention backup. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param location_name: The location of the database. Required. - :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. - :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. - :type backup_name: str - :param parameters: The requested backup resource state. Required. - :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either - LongTermRetentionBackupOperationResult or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update_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[bytes], - *, - content_type: str = "application/json", - **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. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either - LongTermRetentionBackupOperationResult or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update_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[bytes]], - **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[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters or IO[bytes] - :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", "2024-11-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, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_by_resource_group_initial( - resource_group_name=resource_group_name, - location_name=location_name, - long_term_retention_server_name=long_term_retention_server_name, - long_term_retention_database_name=long_term_retention_database_name, - backup_name=backup_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LongTermRetentionBackupOperationResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 2272ced240dc..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_long_term_retention_managed_instance_backups_operations.py +++ /dev/null @@ -1,976 +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 collections.abc import MutableMapping -from typing import Any, AsyncIterator, Callable, Optional, TypeVar, Union, cast - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._long_term_retention_managed_instance_backups_operations import ( - build_delete_by_resource_group_request, - build_delete_request, - build_get_by_resource_group_request, - build_get_request, - build_list_by_database_request, - build_list_by_instance_request, - build_list_by_location_request, - build_list_by_resource_group_database_request, - build_list_by_resource_group_instance_request, - build_list_by_resource_group_location_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class LongTermRetentionManagedInstanceBackupsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`long_term_retention_managed_instance_backups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get( - self, location_name: str, managed_instance_name: str, database_name: str, backup_name: str, **kwargs: Any - ) -> _models.ManagedInstanceLongTermRetentionBackup: - """Gets a long term retention backup for a managed database. - - :param location_name: The location of the database. 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 backup_name: The backup name. Required. - :type backup_name: str - :return: ManagedInstanceLongTermRetentionBackup or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.ManagedInstanceLongTermRetentionBackup] = kwargs.pop("cls", None) - - _request = build_get_request( - location_name=location_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - backup_name=backup_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedInstanceLongTermRetentionBackup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _delete_initial( - self, location_name: str, managed_instance_name: str, database_name: str, backup_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - location_name=location_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - backup_name=backup_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, location_name: str, managed_instance_name: str, 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 - :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 backup_name: The backup name. Required. - :type backup_name: str - :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", "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_initial( - location_name=location_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - backup_name=backup_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @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 - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackup or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.ManagedInstanceLongTermRetentionBackupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace - def list_by_instance( - self, - location_name: str, - managed_instance_name: str, - only_latest_per_database: Optional[bool] = None, - database_state: Optional[Union[str, _models.DatabaseState]] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.ManagedInstanceLongTermRetentionBackup"]: - """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 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 - :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackup or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.ManagedInstanceLongTermRetentionBackupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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( - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @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 - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackup or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.ManagedInstanceLongTermRetentionBackupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace_async - async def get_by_resource_group( - self, - resource_group_name: str, - location_name: str, - managed_instance_name: str, - database_name: str, - backup_name: str, - **kwargs: Any - ) -> _models.ManagedInstanceLongTermRetentionBackup: - """Gets a long term retention backup for a managed database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 backup_name: The backup name. Required. - :type backup_name: str - :return: ManagedInstanceLongTermRetentionBackup or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.ManagedInstanceLongTermRetentionBackup] = kwargs.pop("cls", None) - - _request = build_get_by_resource_group_request( - resource_group_name=resource_group_name, - location_name=location_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - backup_name=backup_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedInstanceLongTermRetentionBackup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _delete_by_resource_group_initial( - self, - resource_group_name: str, - location_name: str, - managed_instance_name: str, - database_name: str, - backup_name: str, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_by_resource_group_request( - resource_group_name=resource_group_name, - location_name=location_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - backup_name=backup_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete_by_resource_group( - self, - resource_group_name: str, - location_name: str, - managed_instance_name: str, - database_name: str, - backup_name: str, - **kwargs: Any - ) -> 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. - :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 backup_name: The backup name. Required. - :type backup_name: str - :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", "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( - resource_group_name=resource_group_name, - location_name=location_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - backup_name=backup_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @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 - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackup or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.ManagedInstanceLongTermRetentionBackupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace - def list_by_resource_group_instance( - 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 - ) -> AsyncItemPaged["_models.ManagedInstanceLongTermRetentionBackup"]: - """Lists the long term retention backups for a given managed instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param location_name: The location of the database. Required. - :type location_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param only_latest_per_database: Whether or not to only get the latest backup for each - database. Default value is None. - :type only_latest_per_database: bool - :param database_state: Whether to query against just live databases, just deleted databases, or - all databases. Known values are: "All", "Live", and "Deleted". Default value is None. - :type database_state: str or ~azure.mgmt.sql.models.DatabaseState - :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackup or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.ManagedInstanceLongTermRetentionBackupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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_instance_request( - resource_group_name=resource_group_name, - location_name=location_name, - managed_instance_name=managed_instance_name, - subscription_id=self._config.subscription_id, - only_latest_per_database=only_latest_per_database, - database_state=database_state, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @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 - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackup or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.ManagedInstanceLongTermRetentionBackupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index c87e9fa88aed..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_long_term_retention_policies_operations.py +++ /dev/null @@ -1,431 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._long_term_retention_policies_operations import ( - build_create_or_update_request, - build_get_request, - build_list_by_database_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class LongTermRetentionPoliciesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`long_term_retention_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_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 - :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", "2024-11-01-preview")) - cls: ClsType[_models.LongTermRetentionPolicyListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - server_name: str, - database_name: str, - policy_name: Union[str, _models.LongTermRetentionPolicyName], - **kwargs: Any - ) -> _models.LongTermRetentionPolicy: - """Gets a database's long term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 policy_name: The policy name. Should always be Default. "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.LongTermRetentionPolicyName - :return: LongTermRetentionPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.LongTermRetentionPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - cls: ClsType[_models.LongTermRetentionPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - policy_name=policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("LongTermRetentionPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - policy_name: Union[str, _models.LongTermRetentionPolicyName], - parameters: Union[_models.LongTermRetentionPolicy, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "LongTermRetentionPolicy") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - policy_name=policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - policy_name: Union[str, _models.LongTermRetentionPolicyName], - parameters: _models.LongTermRetentionPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.LongTermRetentionPolicy]: - """Set or update a database's long term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 policy_name: The policy name. Should always be Default. "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.LongTermRetentionPolicyName - :param parameters: The long term retention policy info. Required. - :type parameters: ~azure.mgmt.sql.models.LongTermRetentionPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either LongTermRetentionPolicy or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - policy_name: Union[str, _models.LongTermRetentionPolicyName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.LongTermRetentionPolicy]: - """Set or update a database's long term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 policy_name: The policy name. Should always be Default. "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.LongTermRetentionPolicyName - :param parameters: The long term retention policy info. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either LongTermRetentionPolicy or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - policy_name: Union[str, _models.LongTermRetentionPolicyName], - parameters: Union[_models.LongTermRetentionPolicy, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.LongTermRetentionPolicy]: - """Set or update a database's long term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 policy_name: The policy name. Should always be Default. "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.LongTermRetentionPolicyName - :param parameters: The long term retention policy info. Is either a LongTermRetentionPolicy - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.LongTermRetentionPolicy or IO[bytes] - :return: An instance of AsyncLROPoller that returns either LongTermRetentionPolicy or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - 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) - 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, - policy_name=policy_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionPolicy", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LongTermRetentionPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.LongTermRetentionPolicy]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 3eaf3718a0d2..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_maintenance_window_options_operations.py +++ /dev/null @@ -1,122 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -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 ..._utils.serialization import Deserializer, Serializer -from ...operations._maintenance_window_options_operations import build_get_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class MaintenanceWindowOptionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`maintenance_window_options` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - maintenance_window_options_name: str, - **kwargs: Any - ) -> _models.MaintenanceWindowOptions: - """Gets a list of available maintenance windows. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database to get maintenance windows options for. - Required. - :type database_name: str - :param maintenance_window_options_name: Maintenance window options name. Required. - :type maintenance_window_options_name: str - :return: MaintenanceWindowOptions or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.MaintenanceWindowOptions - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.MaintenanceWindowOptions] = 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, - maintenance_window_options_name=maintenance_window_options_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("MaintenanceWindowOptions", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_maintenance_windows_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_maintenance_windows_operations.py deleted file mode 100644 index 1089b4be605c..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_maintenance_windows_operations.py +++ /dev/null @@ -1,267 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -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 ..._utils.serialization import Deserializer, Serializer -from ...operations._maintenance_windows_operations import build_create_or_update_request, build_get_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class MaintenanceWindowsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`maintenance_windows` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - maintenance_window_name: str, - **kwargs: Any - ) -> _models.MaintenanceWindows: - """Gets maintenance windows settings for a database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database to get maintenance windows for. Required. - :type database_name: str - :param maintenance_window_name: Maintenance window name. Required. - :type maintenance_window_name: str - :return: MaintenanceWindows or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.MaintenanceWindows - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.MaintenanceWindows] = 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, - maintenance_window_name=maintenance_window_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("MaintenanceWindows", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - maintenance_window_name: str, - parameters: _models.MaintenanceWindows, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Sets maintenance windows settings for a database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database to set maintenance windows for. Required. - :type database_name: str - :param maintenance_window_name: Maintenance window name. Required. - :type maintenance_window_name: str - :param parameters: Required. - :type parameters: ~azure.mgmt.sql.models.MaintenanceWindows - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - maintenance_window_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Sets maintenance windows settings for a database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database to set maintenance windows for. Required. - :type database_name: str - :param maintenance_window_name: Maintenance window name. Required. - :type maintenance_window_name: str - :param parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - maintenance_window_name: str, - parameters: Union[_models.MaintenanceWindows, IO[bytes]], - **kwargs: Any - ) -> None: - """Sets maintenance windows settings for a database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database to set maintenance windows for. Required. - :type database_name: str - :param maintenance_window_name: Maintenance window name. Required. - :type maintenance_window_name: str - :param parameters: Is either a MaintenanceWindows type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.MaintenanceWindows or IO[bytes] - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, "MaintenanceWindows") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - maintenance_window_name=maintenance_window_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_backup_short_term_retention_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_backup_short_term_retention_policies_operations.py deleted file mode 100644 index 092481f58476..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_backup_short_term_retention_policies_operations.py +++ /dev/null @@ -1,648 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_backup_short_term_retention_policies_operations import ( - build_create_or_update_request, - build_get_request, - build_list_by_database_request, - build_update_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedBackupShortTermRetentionPoliciesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_backup_short_term_retention_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - **kwargs: Any - ) -> _models.ManagedBackupShortTermRetentionPolicy: - """Gets a managed database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy_name: The policy name. "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName - :return: ManagedBackupShortTermRetentionPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedBackupShortTermRetentionPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - policy_name=policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedBackupShortTermRetentionPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - parameters: Union[_models.ManagedBackupShortTermRetentionPolicy, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ManagedBackupShortTermRetentionPolicy") - - _request = build_create_or_update_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - parameters: _models.ManagedBackupShortTermRetentionPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]: - """Updates a managed database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either - ManagedBackupShortTermRetentionPolicy or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]: - """Updates a managed database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either - ManagedBackupShortTermRetentionPolicy or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - parameters: Union[_models.ManagedBackupShortTermRetentionPolicy, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]: - """Updates a managed database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Is either a - ManagedBackupShortTermRetentionPolicy type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy or IO[bytes] - :return: An instance of AsyncLROPoller that returns either - ManagedBackupShortTermRetentionPolicy or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagedBackupShortTermRetentionPolicy] = 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, - managed_instance_name=managed_instance_name, - database_name=database_name, - policy_name=policy_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedBackupShortTermRetentionPolicy", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedBackupShortTermRetentionPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - parameters: Union[_models.ManagedBackupShortTermRetentionPolicy, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ManagedBackupShortTermRetentionPolicy") - - _request = build_update_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - parameters: _models.ManagedBackupShortTermRetentionPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]: - """Updates a managed database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either - ManagedBackupShortTermRetentionPolicy or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]: - """Updates a managed database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either - ManagedBackupShortTermRetentionPolicy or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - parameters: Union[_models.ManagedBackupShortTermRetentionPolicy, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]: - """Updates a managed database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Is either a - ManagedBackupShortTermRetentionPolicy type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy or IO[bytes] - :return: An instance of AsyncLROPoller that returns either - ManagedBackupShortTermRetentionPolicy or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagedBackupShortTermRetentionPolicy] = 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( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - policy_name=policy_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedBackupShortTermRetentionPolicy", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedBackupShortTermRetentionPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_by_database( - self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either ManagedBackupShortTermRetentionPolicy or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedBackupShortTermRetentionPolicyListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 2ec2020893f2..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_advanced_threat_protection_settings_operations.py +++ /dev/null @@ -1,363 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_database_advanced_threat_protection_settings_operations import ( - build_create_or_update_request, - build_get_request, - build_list_by_database_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedDatabaseAdvancedThreatProtectionSettingsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_database_advanced_threat_protection_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.ManagedDatabaseAdvancedThreatProtection"]: - """Gets a list of managed database's Advanced Threat Protection states. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. 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 - :return: An iterator like instance of either ManagedDatabaseAdvancedThreatProtection or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) - cls: ClsType[_models.ManagedDatabaseAdvancedThreatProtectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedDatabaseAdvancedThreatProtectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - **kwargs: Any - ) -> _models.ManagedDatabaseAdvancedThreatProtection: - """Gets a managed database's Advanced Threat Protection state. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. 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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. - "Default" Required. - :type advanced_threat_protection_name: str or - ~azure.mgmt.sql.models.AdvancedThreatProtectionName - :return: ManagedDatabaseAdvancedThreatProtection or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-02-01-preview")) - cls: ClsType[_models.ManagedDatabaseAdvancedThreatProtection] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - advanced_threat_protection_name=advanced_threat_protection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedDatabaseAdvancedThreatProtection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: _models.ManagedDatabaseAdvancedThreatProtection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ManagedDatabaseAdvancedThreatProtection: - """Creates or updates a managed database's Advanced Threat Protection state. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. 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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. - "Default" Required. - :type advanced_threat_protection_name: str or - ~azure.mgmt.sql.models.AdvancedThreatProtectionName - :param parameters: The managed database Advanced Threat Protection state. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ManagedDatabaseAdvancedThreatProtection or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ManagedDatabaseAdvancedThreatProtection: - """Creates or updates a managed database's Advanced Threat Protection state. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. 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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. - "Default" Required. - :type advanced_threat_protection_name: str or - ~azure.mgmt.sql.models.AdvancedThreatProtectionName - :param parameters: The managed database Advanced Threat Protection state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ManagedDatabaseAdvancedThreatProtection or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: Union[_models.ManagedDatabaseAdvancedThreatProtection, IO[bytes]], - **kwargs: Any - ) -> _models.ManagedDatabaseAdvancedThreatProtection: - """Creates or updates a managed database's Advanced Threat Protection state. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. 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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. - "Default" Required. - :type advanced_threat_protection_name: str or - ~azure.mgmt.sql.models.AdvancedThreatProtectionName - :param parameters: The managed database Advanced Threat Protection state. Is either a - ManagedDatabaseAdvancedThreatProtection type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection or IO[bytes] - :return: ManagedDatabaseAdvancedThreatProtection or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-02-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ManagedDatabaseAdvancedThreatProtection") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - advanced_threat_protection_name=advanced_threat_protection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ManagedDatabaseAdvancedThreatProtection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 160954b49430..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_columns_operations.py +++ /dev/null @@ -1,327 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_database_columns_operations import ( - build_get_request, - build_list_by_database_request, - build_list_by_table_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedDatabaseColumnsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_database_columns` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - schema: Optional[List[str]] = None, - table: Optional[List[str]] = None, - column: Optional[List[str]] = None, - order_by: Optional[List[str]] = None, - skiptoken: Optional[str] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.DatabaseColumn"]: - """List managed database 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 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: Default value is None. - :type schema: list[str] - :param table: Default value is None. - :type table: list[str] - :param column: Default value is None. - :type column: list[str] - :param order_by: Default value is None. - :type order_by: list[str] - :param skiptoken: An opaque token that identifies a starting point in the collection. Default - value is None. - :type skiptoken: str - :return: An iterator like instance of either DatabaseColumn or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseColumn] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseColumnListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - schema=schema, - table=table, - column=column, - order_by=order_by, - skiptoken=skiptoken, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseColumnListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_table( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - schema_name: str, - table_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.DatabaseColumn"]: - """List managed database 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 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 filter: An OData filter expression that filters elements in the collection. Default - value is None. - :type filter: str - :return: An iterator like instance of either DatabaseColumn or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseColumn] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseColumnListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_table_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - schema_name=schema_name, - table_name=table_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseColumnListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - **kwargs: Any - ) -> _models.DatabaseColumn: - """Get managed database column. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :return: DatabaseColumn or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseColumn - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseColumn] = 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, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("DatabaseColumn", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index acd45e3d4eeb..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_move_operations_operations.py +++ /dev/null @@ -1,202 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_database_move_operations_operations import build_get_request, build_list_by_location_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedDatabaseMoveOperationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_database_move_operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - only_latest_per_database: Optional[bool] = None, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.ManagedDatabaseMoveOperationResult"]: - """Lists managed database move operations. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param location_name: Required. - :type location_name: str - :param only_latest_per_database: Whether or not to only get the latest operation for each - database. Has higher priority than $filter. Default value is None. - :type only_latest_per_database: bool - :param filter: An OData filter expression that filters elements in the collection. Default - value is None. - :type filter: str - :return: An iterator like instance of either ManagedDatabaseMoveOperationResult or the result - of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedDatabaseMoveOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - cls: ClsType[_models.ManagedDatabaseMoveOperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - only_latest_per_database=only_latest_per_database, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedDatabaseMoveOperationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, location_name: str, operation_id: str, **kwargs: Any - ) -> _models.ManagedDatabaseMoveOperationResult: - """Gets a managed database move operation. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param location_name: Required. - :type location_name: str - :param operation_id: Required. - :type operation_id: str - :return: ManagedDatabaseMoveOperationResult or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedDatabaseMoveOperationResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-05-01-preview")) - cls: ClsType[_models.ManagedDatabaseMoveOperationResult] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - location_name=location_name, - operation_id=operation_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedDatabaseMoveOperationResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_queries_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_queries_operations.py deleted file mode 100644 index fdbb4a41113f..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_queries_operations.py +++ /dev/null @@ -1,214 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar, Union - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_database_queries_operations import build_get_request, build_list_by_query_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedDatabaseQueriesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_database_queries` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get( - self, resource_group_name: str, managed_instance_name: str, database_name: str, query_id: str, **kwargs: Any - ) -> _models.ManagedInstanceQuery: - """Get query by query id. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 query_id: Required. - :type query_id: str - :return: ManagedInstanceQuery or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstanceQuery - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceQuery] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - query_id=query_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedInstanceQuery", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_query( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - query_id: str, - start_time: Optional[str] = None, - end_time: Optional[str] = None, - interval: Optional[Union[str, _models.QueryTimeGrainType]] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.QueryStatistics"]: - """Get query execution statistics by query id. - - :param resource_group_name: The name of the resource group that 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 query_id: Required. - :type query_id: str - :param start_time: Start time for observed period. Default value is None. - :type start_time: str - :param end_time: End time for observed period. Default value is None. - :type end_time: str - :param interval: The time step to be used to summarize the metric values. Known values are: - "PT1H" and "P1D". Default value is None. - :type interval: str or ~azure.mgmt.sql.models.QueryTimeGrainType - :return: An iterator like instance of either QueryStatistics or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.QueryStatistics] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceQueryStatistics] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_query_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - query_id=query_id, - subscription_id=self._config.subscription_id, - start_time=start_time, - end_time=end_time, - interval=interval, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedInstanceQueryStatistics", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_recommended_sensitivity_labels_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_recommended_sensitivity_labels_operations.py deleted file mode 100644 index bb2e7f61ea41..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_recommended_sensitivity_labels_operations.py +++ /dev/null @@ -1,190 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_database_recommended_sensitivity_labels_operations import build_update_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedDatabaseRecommendedSensitivityLabelsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_database_recommended_sensitivity_labels` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: _models.RecommendedSensitivityLabelUpdateList, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Update recommended sensitivity labels states of a given database using an operations batch. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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.RecommendedSensitivityLabelUpdateList - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Update recommended sensitivity labels states of a given database using an operations batch. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: Union[_models.RecommendedSensitivityLabelUpdateList, IO[bytes]], - **kwargs: Any - ) -> None: - """Update recommended sensitivity labels states of a given database using an operations batch. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 RecommendedSensitivityLabelUpdateList type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.sql.models.RecommendedSensitivityLabelUpdateList or IO[bytes] - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, "RecommendedSensitivityLabelUpdateList") - - _request = build_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_restore_details_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_restore_details_operations.py deleted file mode 100644 index 8dd92f59b30e..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_restore_details_operations.py +++ /dev/null @@ -1,121 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar, Union - -from azure.core import AsyncPipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_database_restore_details_operations import build_get_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedDatabaseRestoreDetailsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_database_restore_details` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - restore_details_name: Union[str, _models.RestoreDetailsName], - **kwargs: Any - ) -> _models.ManagedDatabaseRestoreDetailsResult: - """Gets managed database restore details. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 restore_details_name: The name of the restore details to retrieve. "Default" Required. - :type restore_details_name: str or ~azure.mgmt.sql.models.RestoreDetailsName - :return: ManagedDatabaseRestoreDetailsResult or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedDatabaseRestoreDetailsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-05-01-preview")) - cls: ClsType[_models.ManagedDatabaseRestoreDetailsResult] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - restore_details_name=restore_details_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedDatabaseRestoreDetailsResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_schemas_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_schemas_operations.py deleted file mode 100644 index 2c0da0246f47..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_schemas_operations.py +++ /dev/null @@ -1,202 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_database_schemas_operations import build_get_request, build_list_by_database_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedDatabaseSchemasOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_database_schemas` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.DatabaseSchema"]: - """List managed database schemas. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param 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 filter: An OData filter expression that filters elements in the collection. Default - value is None. - :type filter: str - :return: An iterator like instance of either DatabaseSchema or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseSchema] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseSchemaListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseSchemaListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, managed_instance_name: str, database_name: str, schema_name: str, **kwargs: Any - ) -> _models.DatabaseSchema: - """Get managed database schema. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :return: DatabaseSchema or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSchema - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseSchema] = 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, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("DatabaseSchema", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_security_alert_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_security_alert_policies_operations.py deleted file mode 100644 index 27ce6965eda6..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_security_alert_policies_operations.py +++ /dev/null @@ -1,360 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_database_security_alert_policies_operations import ( - build_create_or_update_request, - build_get_request, - build_list_by_database_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedDatabaseSecurityAlertPoliciesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_database_security_alert_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - **kwargs: Any - ) -> _models.ManagedDatabaseSecurityAlertPolicy: - """Gets a managed database's security alert policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy is - defined. Required. - :type database_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 - :return: ManagedDatabaseSecurityAlertPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedDatabaseSecurityAlertPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - security_alert_policy_name=security_alert_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedDatabaseSecurityAlertPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - parameters: _models.ManagedDatabaseSecurityAlertPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ManagedDatabaseSecurityAlertPolicy: - """Creates or updates a database's security alert policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy is - defined. Required. - :type database_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 - :param parameters: The database security alert policy. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ManagedDatabaseSecurityAlertPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ManagedDatabaseSecurityAlertPolicy: - """Creates or updates a database's security alert policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy is - defined. Required. - :type database_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 - :param parameters: The database security alert policy. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ManagedDatabaseSecurityAlertPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - parameters: Union[_models.ManagedDatabaseSecurityAlertPolicy, IO[bytes]], - **kwargs: Any - ) -> _models.ManagedDatabaseSecurityAlertPolicy: - """Creates or updates a database's security alert policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy is - defined. Required. - :type database_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 - :param parameters: The database security alert policy. Is either a - ManagedDatabaseSecurityAlertPolicy type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy or IO[bytes] - :return: ManagedDatabaseSecurityAlertPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ManagedDatabaseSecurityAlertPolicy") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - security_alert_policy_name=security_alert_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ManagedDatabaseSecurityAlertPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_database( - self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either ManagedDatabaseSecurityAlertPolicy or the result - of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedDatabaseSecurityAlertPolicyListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index fe8699556efd..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_security_events_operations.py +++ /dev/null @@ -1,152 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_database_security_events_operations import build_list_by_database_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedDatabaseSecurityEventsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_database_security_events` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - filter: Optional[str] = None, - skip: Optional[int] = None, - top: Optional[int] = None, - skiptoken: Optional[str] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.SecurityEvent"]: - """Gets a list of security events. - - :param resource_group_name: The name of the resource group that 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 events are - retrieved. Required. - :type database_name: str - :param filter: An OData filter expression that filters elements in the collection. Default - value is None. - :type filter: str - :param skip: The number of elements in the collection to skip. Default value is None. - :type skip: int - :param top: The number of elements to return from the collection. Default value is None. - :type top: int - :param skiptoken: An opaque token that identifies a starting point in the collection. Default - value is None. - :type skiptoken: str - :return: An iterator like instance of either SecurityEvent or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SecurityEvent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SecurityEventCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - filter=filter, - skip=skip, - top=top, - skiptoken=skiptoken, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityEventCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_sensitivity_labels_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_sensitivity_labels_operations.py deleted file mode 100644 index 4aededf54396..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_sensitivity_labels_operations.py +++ /dev/null @@ -1,861 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Literal, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_database_sensitivity_labels_operations import ( - build_create_or_update_request, - build_delete_request, - build_disable_recommendation_request, - build_enable_recommendation_request, - build_get_request, - build_list_current_by_database_request, - build_list_recommended_by_database_request, - build_update_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedDatabaseSensitivityLabelsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_database_sensitivity_labels` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async 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 - :return: SensitivityLabel or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SensitivityLabel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SensitivityLabel] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - 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, - headers=_headers, - params=_params, - ) - _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("SensitivityLabel", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - parameters: _models.SensitivityLabel, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SensitivityLabel: - """Creates or updates the sensitivity label of a given column. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 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 - :return: SensitivityLabel or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SensitivityLabel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SensitivityLabel: - """Creates or updates the sensitivity label of a given column. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 parameters: The column sensitivity label resource. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: SensitivityLabel or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SensitivityLabel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - parameters: Union[_models.SensitivityLabel, IO[bytes]], - **kwargs: Any - ) -> _models.SensitivityLabel: - """Creates or updates the sensitivity label of a given column. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 parameters: The column sensitivity label resource. Is either a SensitivityLabel type or - a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.SensitivityLabel or IO[bytes] - :return: SensitivityLabel or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SensitivityLabel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 {}) - - sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SensitivityLabel] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SensitivityLabel") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - schema_name=schema_name, - table_name=table_name, - column_name=column_name, - subscription_id=self._config.subscription_id, - sensitivity_label_source=sensitivity_label_source, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, 201]: - 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - **kwargs: Any - ) -> None: - """Deletes the sensitivity label of a given column. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param database_name: The name of the database. Required. - :type database_name: str - :param schema_name: The name of the schema. Required. - :type schema_name: str - :param table_name: The name of the table. Required. - :type table_name: str - :param column_name: The name of the column. Required. - :type column_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - schema_name=schema_name, - table_name=table_name, - column_name=column_name, - subscription_id=self._config.subscription_id, - sensitivity_label_source=sensitivity_label_source, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @distributed_trace_async - async def disable_recommendation( - 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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_disable_recommendation_request( - resource_group_name=resource_group_name, - 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, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @distributed_trace_async - async def enable_recommendation( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - **kwargs: Any - ) -> None: - """Enables sensitivity recommendations on a given column (recommendations are enabled by default - on all columns). - - :param resource_group_name: The name of the resource group that 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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_enable_recommendation_request( - resource_group_name=resource_group_name, - 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, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @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 - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either SensitivityLabel or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SensitivityLabel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SensitivityLabelListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @overload - async def update( - 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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: Union[_models.SensitivityLabelUpdateList, IO[bytes]], - **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[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.SensitivityLabelUpdateList or IO[bytes] - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @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 - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either SensitivityLabel or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SensitivityLabel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SensitivityLabelListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index f43933da4f0b..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_tables_operations.py +++ /dev/null @@ -1,215 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_database_tables_operations import build_get_request, build_list_by_schema_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedDatabaseTablesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_database_tables` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_schema( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - schema_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.DatabaseTable"]: - """List managed database tables. - - :param resource_group_name: The name of the resource group that 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 filter: An OData filter expression that filters elements in the collection. Default - value is None. - :type filter: str - :return: An iterator like instance of either DatabaseTable or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseTable] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseTableListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_schema_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - schema_name=schema_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseTableListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - schema_name: str, - table_name: str, - **kwargs: Any - ) -> _models.DatabaseTable: - """Get managed database table. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :return: DatabaseTable or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseTable - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseTable] = 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, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("DatabaseTable", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_transparent_data_encryption_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_transparent_data_encryption_operations.py deleted file mode 100644 index 1d39e4640d0d..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_transparent_data_encryption_operations.py +++ /dev/null @@ -1,360 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_database_transparent_data_encryption_operations import ( - build_create_or_update_request, - build_get_request, - build_list_by_database_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedDatabaseTransparentDataEncryptionOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_database_transparent_data_encryption` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - tde_name: Union[str, _models.TransparentDataEncryptionName], - **kwargs: Any - ) -> _models.ManagedTransparentDataEncryption: - """Gets a managed database's transparent data encryption. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param tde_name: The name of the transparent data encryption configuration. "current" Required. - :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName - :return: ManagedTransparentDataEncryption or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedTransparentDataEncryption - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedTransparentDataEncryption] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - tde_name=tde_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedTransparentDataEncryption", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - tde_name: Union[str, _models.TransparentDataEncryptionName], - parameters: _models.ManagedTransparentDataEncryption, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ManagedTransparentDataEncryption: - """Updates a database's transparent data encryption configuration. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy is - defined. Required. - :type database_name: str - :param tde_name: The name of the transparent data encryption configuration. "current" Required. - :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName - :param parameters: The database transparent data encryption. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedTransparentDataEncryption - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ManagedTransparentDataEncryption or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedTransparentDataEncryption - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - tde_name: Union[str, _models.TransparentDataEncryptionName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ManagedTransparentDataEncryption: - """Updates a database's transparent data encryption configuration. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy is - defined. Required. - :type database_name: str - :param tde_name: The name of the transparent data encryption configuration. "current" Required. - :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName - :param parameters: The database transparent data encryption. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ManagedTransparentDataEncryption or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedTransparentDataEncryption - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - tde_name: Union[str, _models.TransparentDataEncryptionName], - parameters: Union[_models.ManagedTransparentDataEncryption, IO[bytes]], - **kwargs: Any - ) -> _models.ManagedTransparentDataEncryption: - """Updates a database's transparent data encryption configuration. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy is - defined. Required. - :type database_name: str - :param tde_name: The name of the transparent data encryption configuration. "current" Required. - :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName - :param parameters: The database transparent data encryption. Is either a - ManagedTransparentDataEncryption type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedTransparentDataEncryption or IO[bytes] - :return: ManagedTransparentDataEncryption or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedTransparentDataEncryption - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ManagedTransparentDataEncryption") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - tde_name=tde_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ManagedTransparentDataEncryption", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_database( - self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either ManagedTransparentDataEncryption or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedTransparentDataEncryption] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedTransparentDataEncryptionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 849bd75e061e..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_vulnerability_assessment_rule_baselines_operations.py +++ /dev/null @@ -1,397 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_database_vulnerability_assessment_rule_baselines_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_database_vulnerability_assessment_rule_baselines` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - rule_id: str, - baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: - """Gets a database's vulnerability assessment rule baseline. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 rule - baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a - baseline on a database level rule and master for server level rule). Known values are: "master" - and "default". Required. - :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName - :return: DatabaseVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseVulnerabilityAssessmentRuleBaseline] = 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, - rule_id=rule_id, - baseline_name=baseline_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("DatabaseVulnerabilityAssessmentRuleBaseline", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - rule_id: str, - baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - parameters: _models.DatabaseVulnerabilityAssessmentRuleBaseline, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: - """Creates or updates a database's vulnerability assessment rule baseline. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 rule - baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a - baseline on a database level rule and master for server level rule). Known values are: "master" - 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 - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - rule_id: str, - baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: - """Creates or updates a database's vulnerability assessment rule baseline. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 rule - baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a - baseline on a database level rule and master for server level rule). Known values are: "master" - and "default". Required. - :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName - :param parameters: The requested rule baseline resource. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - rule_id: str, - baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - parameters: Union[_models.DatabaseVulnerabilityAssessmentRuleBaseline, IO[bytes]], - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: - """Creates or updates a database's vulnerability assessment rule baseline. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 rule - baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a - baseline on a database level rule and master for server level rule). Known values are: "master" - 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[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline or - IO[bytes] - :return: DatabaseVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DatabaseVulnerabilityAssessmentRuleBaseline") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - rule_id=rule_id, - baseline_name=baseline_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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("DatabaseVulnerabilityAssessmentRuleBaseline", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - rule_id: str, - baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - **kwargs: Any - ) -> None: - """Removes the database's vulnerability assessment rule baseline. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 rule - baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a - baseline on a database level rule and master for server level rule). Known values are: "master" - and "default". Required. - :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - rule_id=rule_id, - baseline_name=baseline_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_vulnerability_assessment_scans_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_vulnerability_assessment_scans_operations.py deleted file mode 100644 index eb79a7054167..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_vulnerability_assessment_scans_operations.py +++ /dev/null @@ -1,426 +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 collections.abc import MutableMapping -from typing import Any, AsyncIterator, Callable, Optional, TypeVar, Union, cast - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_database_vulnerability_assessment_scans_operations import ( - build_export_request, - build_get_request, - build_initiate_scan_request, - build_list_by_database_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedDatabaseVulnerabilityAssessmentScansOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_database_vulnerability_assessment_scans` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - async def _initiate_scan_initial( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - scan_id: str, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_initiate_scan( - self, - resource_group_name: str, - managed_instance_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 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 - :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. Required. - :type scan_id: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._initiate_scan_initial( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def export( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - scan_id: str, - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessmentScansExport: - """Convert an existing scan result to a human readable format. If already exists nothing happens. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 scanned 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. Required. - :type scan_id: str - :return: DatabaseVulnerabilityAssessmentScansExport or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentScansExport - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseVulnerabilityAssessmentScansExport] = kwargs.pop("cls", None) - - _request = build_export_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - scan_id=scan_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DatabaseVulnerabilityAssessmentScansExport", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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], - **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either VulnerabilityAssessmentScanRecord or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecord] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.VulnerabilityAssessmentScanRecordListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("VulnerabilityAssessmentScanRecordListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - scan_id: str, - **kwargs: Any - ) -> _models.VulnerabilityAssessmentScanRecord: - """Gets a vulnerability assessment scan record of a database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. Required. - :type scan_id: str - :return: VulnerabilityAssessmentScanRecord or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecord - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.VulnerabilityAssessmentScanRecord] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - scan_id=scan_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_vulnerability_assessments_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_vulnerability_assessments_operations.py deleted file mode 100644 index 445452a0f57d..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_vulnerability_assessments_operations.py +++ /dev/null @@ -1,431 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_database_vulnerability_assessments_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_database_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedDatabaseVulnerabilityAssessmentsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_database_vulnerability_assessments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessment: - """Gets the database's vulnerability assessment. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" - Required. - :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName - :return: DatabaseVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseVulnerabilityAssessment] = 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, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("DatabaseVulnerabilityAssessment", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: _models.DatabaseVulnerabilityAssessment, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessment: - """Creates or updates the database's vulnerability assessment. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" - Required. - :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName - :param parameters: The requested resource. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessment: - """Creates or updates the database's vulnerability assessment. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" - Required. - :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName - :param parameters: The requested resource. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: Union[_models.DatabaseVulnerabilityAssessment, IO[bytes]], - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessment: - """Creates or updates the database's vulnerability assessment. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" - Required. - :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName - :param parameters: The requested resource. Is either a DatabaseVulnerabilityAssessment type or - a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment or IO[bytes] - :return: DatabaseVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DatabaseVulnerabilityAssessment") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DatabaseVulnerabilityAssessment", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **kwargs: Any - ) -> None: - """Removes the database's vulnerability assessment. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" - Required. - :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @distributed_trace - def list_by_database( - self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either DatabaseVulnerabilityAssessment or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 6c6969a11535..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_databases_operations.py +++ /dev/null @@ -1,1583 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_databases_operations import ( - build_cancel_move_request, - build_complete_move_request, - build_complete_restore_request, - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_instance_request, - build_list_inaccessible_by_instance_request, - build_start_move_request, - build_update_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedDatabasesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_databases` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.ManagedDatabase"]: - """Gets a list of managed databases. - - :param resource_group_name: The name of the resource group that 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 - :return: An iterator like instance of either ManagedDatabase or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.ManagedDatabaseListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedDatabaseListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any - ) -> _models.ManagedDatabase: - """Gets a managed database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :return: ManagedDatabase or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedDatabase - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - cls: ClsType[_models.ManagedDatabase] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedDatabase", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: Union[_models.ManagedDatabase, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ManagedDatabase") - - _request = build_create_or_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: _models.ManagedDatabase, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedDatabase]: - """Creates a new database or updates an existing database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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: The requested database resource state. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedDatabase - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ManagedDatabase or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedDatabase]: - """Creates a new database or updates an existing database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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: The requested database resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ManagedDatabase or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: Union[_models.ManagedDatabase, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedDatabase]: - """Creates a new database or updates an existing database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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: The requested database resource state. Is either a ManagedDatabase type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedDatabase or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ManagedDatabase or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - 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) - 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, - managed_instance_name=managed_instance_name, - database_name=database_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedDatabase", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedDatabase].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ManagedDatabase]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes 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. Required. - :type database_name: str - :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", "2022-08-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( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: Union[_models.ManagedDatabaseUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ManagedDatabaseUpdate") - - _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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: _models.ManagedDatabaseUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedDatabase]: - """Updates an existing 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 parameters: The requested database resource state. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ManagedDatabase or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedDatabase]: - """Updates an existing 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 parameters: The requested database resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ManagedDatabase or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: Union[_models.ManagedDatabaseUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedDatabase]: - """Updates an existing 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 parameters: The requested database resource state. Is either a ManagedDatabaseUpdate - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ManagedDatabase or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - 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) - 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( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedDatabase", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedDatabase].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ManagedDatabase]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _cancel_move_initial( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: Union[_models.ManagedDatabaseMoveDefinition, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ManagedDatabaseMoveDefinition") - - _request = build_cancel_move_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_cancel_move( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: _models.ManagedDatabaseMoveDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Cancels a managed database move operation. - - :param resource_group_name: The name of the resource group that 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: Parameters of the cancel managed database move operation. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseMoveDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @overload - async def begin_cancel_move( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Cancels a managed database move operation. - - :param resource_group_name: The name of the resource group that 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: Parameters of the cancel managed database move operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @distributed_trace_async - async def begin_cancel_move( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: Union[_models.ManagedDatabaseMoveDefinition, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Cancels a managed database move operation. - - :param resource_group_name: The name of the resource group that 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: Parameters of the cancel managed database move operation. Is either a - ManagedDatabaseMoveDefinition type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseMoveDefinition or IO[bytes] - :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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - 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) - 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._cancel_move_initial( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _complete_move_initial( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: Union[_models.ManagedDatabaseMoveDefinition, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ManagedDatabaseMoveDefinition") - - _request = build_complete_move_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_complete_move( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: _models.ManagedDatabaseMoveDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Completes a managed database move operation. - - :param resource_group_name: The name of the resource group that 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: Parameters of the complete managed database move operation. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseMoveDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @overload - async def begin_complete_move( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Completes a managed database move operation. - - :param resource_group_name: The name of the resource group that 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: Parameters of the complete managed database move operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @distributed_trace_async - async def begin_complete_move( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: Union[_models.ManagedDatabaseMoveDefinition, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Completes a managed database move operation. - - :param resource_group_name: The name of the resource group that 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: Parameters of the complete managed database move operation. Is either a - ManagedDatabaseMoveDefinition type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseMoveDefinition or IO[bytes] - :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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - 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) - 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._complete_move_initial( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _complete_restore_initial( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: Union[_models.CompleteDatabaseRestoreDefinition, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "CompleteDatabaseRestoreDefinition") - - _request = build_complete_restore_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_complete_restore( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: _models.CompleteDatabaseRestoreDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Completes the restore operation on a managed database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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: The definition for completing the restore of this managed database. - Required. - :type parameters: ~azure.mgmt.sql.models.CompleteDatabaseRestoreDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @overload - async def begin_complete_restore( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Completes the restore operation on a managed database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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: The definition for completing the restore of this managed database. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @distributed_trace_async - async def begin_complete_restore( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: Union[_models.CompleteDatabaseRestoreDefinition, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Completes the restore operation on a managed database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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: The definition for completing the restore of this managed database. Is - either a CompleteDatabaseRestoreDefinition type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.CompleteDatabaseRestoreDefinition or IO[bytes] - :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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - 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) - 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._complete_restore_initial( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _start_move_initial( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: Union[_models.ManagedDatabaseStartMoveDefinition, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ManagedDatabaseStartMoveDefinition") - - _request = build_start_move_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_start_move( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: _models.ManagedDatabaseStartMoveDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Starts a managed database move operation. - - :param resource_group_name: The name of the resource group that 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: Parameters of the start managed database move operation. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseStartMoveDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @overload - async def begin_start_move( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Starts a managed database move operation. - - :param resource_group_name: The name of the resource group that 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: Parameters of the start managed database move operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @distributed_trace_async - async def begin_start_move( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: Union[_models.ManagedDatabaseStartMoveDefinition, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Starts a managed database move operation. - - :param resource_group_name: The name of the resource group that 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: Parameters of the start managed database move operation. Is either a - ManagedDatabaseStartMoveDefinition type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseStartMoveDefinition or IO[bytes] - :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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - 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) - 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_move_initial( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_inaccessible_by_instance( - self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.ManagedDatabase"]: - """Gets a list of inaccessible managed databases in a managed instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :return: An iterator like instance of either ManagedDatabase or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.ManagedDatabaseListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_inaccessible_by_instance_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedDatabaseListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_administrators_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_administrators_operations.py deleted file mode 100644 index 6148bb1709c2..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_administrators_operations.py +++ /dev/null @@ -1,524 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_instance_administrators_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_instance_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedInstanceAdministratorsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_instance_administrators` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.ManagedInstanceAdministrator"]: - """Gets a list of managed instance administrators. - - :param resource_group_name: The name of the resource group that 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 - :return: An iterator like instance of either ManagedInstanceAdministrator or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceAdministrator] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceAdministratorListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedInstanceAdministratorListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - managed_instance_name: str, - administrator_name: Union[str, _models.AdministratorName], - **kwargs: Any - ) -> _models.ManagedInstanceAdministrator: - """Gets a managed instance administrator. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 administrator_name: "ActiveDirectory" Required. - :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName - :return: ManagedInstanceAdministrator or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstanceAdministrator - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceAdministrator] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - administrator_name=administrator_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedInstanceAdministrator", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - administrator_name: Union[str, _models.AdministratorName], - parameters: Union[_models.ManagedInstanceAdministrator, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ManagedInstanceAdministrator") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - administrator_name=administrator_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - administrator_name: Union[str, _models.AdministratorName], - parameters: _models.ManagedInstanceAdministrator, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedInstanceAdministrator]: - """Creates or updates a managed instance administrator. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 administrator_name: "ActiveDirectory" Required. - :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName - :param parameters: The requested administrator parameters. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceAdministrator - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ManagedInstanceAdministrator or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceAdministrator] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - administrator_name: Union[str, _models.AdministratorName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedInstanceAdministrator]: - """Creates or updates a managed instance administrator. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 administrator_name: "ActiveDirectory" Required. - :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName - :param parameters: The requested administrator parameters. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ManagedInstanceAdministrator or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceAdministrator] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - administrator_name: Union[str, _models.AdministratorName], - parameters: Union[_models.ManagedInstanceAdministrator, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedInstanceAdministrator]: - """Creates or updates a managed instance administrator. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 administrator_name: "ActiveDirectory" Required. - :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName - :param parameters: The requested administrator parameters. Is either a - ManagedInstanceAdministrator type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceAdministrator or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ManagedInstanceAdministrator or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceAdministrator] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagedInstanceAdministrator] = 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, - managed_instance_name=managed_instance_name, - administrator_name=administrator_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedInstanceAdministrator", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedInstanceAdministrator].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ManagedInstanceAdministrator]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, - resource_group_name: str, - managed_instance_name: str, - administrator_name: Union[str, _models.AdministratorName], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - administrator_name=administrator_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, - resource_group_name: str, - managed_instance_name: str, - administrator_name: Union[str, _models.AdministratorName], - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a managed instance administrator. - - :param resource_group_name: The name of the resource group that 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 administrator_name: "ActiveDirectory" Required. - :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - administrator_name=administrator_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_advanced_threat_protection_settings_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_advanced_threat_protection_settings_operations.py deleted file mode 100644 index 2d6a1321aded..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_advanced_threat_protection_settings_operations.py +++ /dev/null @@ -1,417 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_instance_advanced_threat_protection_settings_operations import ( - build_create_or_update_request, - build_get_request, - build_list_by_instance_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedInstanceAdvancedThreatProtectionSettingsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_instance_advanced_threat_protection_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.ManagedInstanceAdvancedThreatProtection"]: - """Get the managed instance's Advanced Threat Protection settings. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :return: An iterator like instance of either ManagedInstanceAdvancedThreatProtection or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) - cls: ClsType[_models.ManagedInstanceAdvancedThreatProtectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedInstanceAdvancedThreatProtectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - managed_instance_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - **kwargs: Any - ) -> _models.ManagedInstanceAdvancedThreatProtection: - """Get a managed instance's Advanced Threat Protection state. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. - "Default" Required. - :type advanced_threat_protection_name: str or - ~azure.mgmt.sql.models.AdvancedThreatProtectionName - :return: ManagedInstanceAdvancedThreatProtection or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-02-01-preview")) - cls: ClsType[_models.ManagedInstanceAdvancedThreatProtection] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - advanced_threat_protection_name=advanced_threat_protection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedInstanceAdvancedThreatProtection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: Union[_models.ManagedInstanceAdvancedThreatProtection, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2022-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ManagedInstanceAdvancedThreatProtection") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - advanced_threat_protection_name=advanced_threat_protection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: _models.ManagedInstanceAdvancedThreatProtection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedInstanceAdvancedThreatProtection]: - """Creates or updates Advanced Threat Protection settings. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. - "Default" Required. - :type advanced_threat_protection_name: str or - ~azure.mgmt.sql.models.AdvancedThreatProtectionName - :param parameters: The managed instance Advanced Threat Protection state. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either - ManagedInstanceAdvancedThreatProtection or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedInstanceAdvancedThreatProtection]: - """Creates or updates Advanced Threat Protection settings. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. - "Default" Required. - :type advanced_threat_protection_name: str or - ~azure.mgmt.sql.models.AdvancedThreatProtectionName - :param parameters: The managed instance Advanced Threat Protection state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either - ManagedInstanceAdvancedThreatProtection or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: Union[_models.ManagedInstanceAdvancedThreatProtection, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedInstanceAdvancedThreatProtection]: - """Creates or updates Advanced Threat Protection settings. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. - "Default" Required. - :type advanced_threat_protection_name: str or - ~azure.mgmt.sql.models.AdvancedThreatProtectionName - :param parameters: The managed instance Advanced Threat Protection state. Is either a - ManagedInstanceAdvancedThreatProtection type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection or IO[bytes] - :return: An instance of AsyncLROPoller that returns either - ManagedInstanceAdvancedThreatProtection or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) - 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) - 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, - managed_instance_name=managed_instance_name, - advanced_threat_protection_name=advanced_threat_protection_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedInstanceAdvancedThreatProtection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedInstanceAdvancedThreatProtection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ManagedInstanceAdvancedThreatProtection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_azure_ad_only_authentications_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_azure_ad_only_authentications_operations.py deleted file mode 100644 index c4fc8eece271..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_azure_ad_only_authentications_operations.py +++ /dev/null @@ -1,540 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_instance_azure_ad_only_authentications_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_instance_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedInstanceAzureADOnlyAuthenticationsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_instance_azure_ad_only_authentications` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - managed_instance_name: str, - authentication_name: Union[str, _models.AuthenticationName], - **kwargs: Any - ) -> _models.ManagedInstanceAzureADOnlyAuthentication: - """Gets a specific Azure Active Directory only authentication property. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 authentication_name: The name of server azure active directory only authentication. - "Default" Required. - :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName - :return: ManagedInstanceAzureADOnlyAuthentication or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceAzureADOnlyAuthentication] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - authentication_name=authentication_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedInstanceAzureADOnlyAuthentication", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - authentication_name: Union[str, _models.AuthenticationName], - parameters: Union[_models.ManagedInstanceAzureADOnlyAuthentication, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ManagedInstanceAzureADOnlyAuthentication") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - authentication_name=authentication_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - authentication_name: Union[str, _models.AuthenticationName], - parameters: _models.ManagedInstanceAzureADOnlyAuthentication, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedInstanceAzureADOnlyAuthentication]: - """Sets Server Active Directory only authentication property or updates an existing server Active - Directory only authentication property. - - :param resource_group_name: The name of the resource group that 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 authentication_name: The name of server azure active directory only authentication. - "Default" Required. - :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName - :param parameters: The required parameters for creating or updating an Active Directory only - authentication property. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either - ManagedInstanceAzureADOnlyAuthentication or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - authentication_name: Union[str, _models.AuthenticationName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedInstanceAzureADOnlyAuthentication]: - """Sets Server Active Directory only authentication property or updates an existing server Active - Directory only authentication property. - - :param resource_group_name: The name of the resource group that 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 authentication_name: The name of server azure active directory only authentication. - "Default" Required. - :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName - :param parameters: The required parameters for creating or updating an Active Directory only - authentication property. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either - ManagedInstanceAzureADOnlyAuthentication or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - authentication_name: Union[str, _models.AuthenticationName], - parameters: Union[_models.ManagedInstanceAzureADOnlyAuthentication, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedInstanceAzureADOnlyAuthentication]: - """Sets Server Active Directory only authentication property or updates an existing server Active - Directory only authentication property. - - :param resource_group_name: The name of the resource group that 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 authentication_name: The name of server azure active directory only authentication. - "Default" Required. - :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName - :param parameters: The required parameters for creating or updating an Active Directory only - authentication property. Is either a ManagedInstanceAzureADOnlyAuthentication type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication or IO[bytes] - :return: An instance of AsyncLROPoller that returns either - ManagedInstanceAzureADOnlyAuthentication or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagedInstanceAzureADOnlyAuthentication] = 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, - managed_instance_name=managed_instance_name, - authentication_name=authentication_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize( - "ManagedInstanceAzureADOnlyAuthentication", pipeline_response.http_response - ) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedInstanceAzureADOnlyAuthentication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ManagedInstanceAzureADOnlyAuthentication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, - resource_group_name: str, - managed_instance_name: str, - authentication_name: Union[str, _models.AuthenticationName], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - authentication_name=authentication_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, - resource_group_name: str, - managed_instance_name: str, - authentication_name: Union[str, _models.AuthenticationName], - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an existing server Active Directory only authentication property. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 authentication_name: The name of server azure active directory only authentication. - "Default" Required. - :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - authentication_name=authentication_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_by_instance( - self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either ManagedInstanceAzureADOnlyAuthentication or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceAzureADOnlyAuthListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 23d23d9da1f8..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_dtcs_operations.py +++ /dev/null @@ -1,400 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_instance_dtcs_operations import ( - build_create_or_update_request, - build_get_request, - build_list_by_managed_instance_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedInstanceDtcsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_instance_dtcs` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.ManagedInstanceDtc"]: - """Gets a list of managed instance DTC settings. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :return: An iterator like instance of either ManagedInstanceDtc or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceDtc] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - cls: ClsType[_models.ManagedInstanceDtcListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedInstanceDtcListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, managed_instance_name: str, dtc_name: Union[str, _models.DtcName], **kwargs: Any - ) -> _models.ManagedInstanceDtc: - """Gets managed instance DTC settings. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param dtc_name: The name of the managed instance DTC. "current" Required. - :type dtc_name: str or ~azure.mgmt.sql.models.DtcName - :return: ManagedInstanceDtc or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstanceDtc - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-05-01-preview")) - cls: ClsType[_models.ManagedInstanceDtc] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - dtc_name=dtc_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedInstanceDtc", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - dtc_name: Union[str, _models.DtcName], - parameters: Union[_models.ManagedInstanceDtc, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2022-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ManagedInstanceDtc") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - dtc_name=dtc_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - dtc_name: Union[str, _models.DtcName], - parameters: _models.ManagedInstanceDtc, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedInstanceDtc]: - """Updates managed instance DTC settings. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param dtc_name: The name of the managed instance DTC. "current" Required. - :type dtc_name: str or ~azure.mgmt.sql.models.DtcName - :param parameters: Managed instance DTC settings. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceDtc - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ManagedInstanceDtc or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceDtc] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - dtc_name: Union[str, _models.DtcName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedInstanceDtc]: - """Updates managed instance DTC settings. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param dtc_name: The name of the managed instance DTC. "current" Required. - :type dtc_name: str or ~azure.mgmt.sql.models.DtcName - :param parameters: Managed instance DTC settings. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ManagedInstanceDtc or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceDtc] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - dtc_name: Union[str, _models.DtcName], - parameters: Union[_models.ManagedInstanceDtc, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedInstanceDtc]: - """Updates managed instance DTC settings. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param dtc_name: The name of the managed instance DTC. "current" Required. - :type dtc_name: str or ~azure.mgmt.sql.models.DtcName - :param parameters: Managed instance DTC settings. Is either a ManagedInstanceDtc type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceDtc or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ManagedInstanceDtc or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceDtc] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - 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) - 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, - managed_instance_name=managed_instance_name, - dtc_name=dtc_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedInstanceDtc", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedInstanceDtc].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ManagedInstanceDtc]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 256f0fe3a951..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_encryption_protectors_operations.py +++ /dev/null @@ -1,532 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_instance_encryption_protectors_operations import ( - build_create_or_update_request, - build_get_request, - build_list_by_instance_request, - build_revalidate_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedInstanceEncryptionProtectorsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_instance_encryption_protectors` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - async def _revalidate_initial( - self, - resource_group_name: str, - managed_instance_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._revalidate_initial( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_by_instance( - self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.ManagedInstanceEncryptionProtector"]: - """Gets a list of managed instance encryption protectors. - - :param resource_group_name: The name of the resource group that 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 - :return: An iterator like instance of either ManagedInstanceEncryptionProtector or the result - of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceEncryptionProtectorListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedInstanceEncryptionProtectorListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - managed_instance_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - **kwargs: Any - ) -> _models.ManagedInstanceEncryptionProtector: - """Gets a managed instance encryption protector. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 retrieved. - "current" Required. - :type encryption_protector_name: str or ~azure.mgmt.sql.models.EncryptionProtectorName - :return: ManagedInstanceEncryptionProtector or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceEncryptionProtector] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - encryption_protector_name=encryption_protector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedInstanceEncryptionProtector", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - parameters: Union[_models.ManagedInstanceEncryptionProtector, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ManagedInstanceEncryptionProtector") - - _request = build_create_or_update_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - parameters: _models.ManagedInstanceEncryptionProtector, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedInstanceEncryptionProtector]: - """Updates 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 - :param parameters: The requested encryption protector resource state. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ManagedInstanceEncryptionProtector - or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedInstanceEncryptionProtector]: - """Updates 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 - :param parameters: The requested encryption protector resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ManagedInstanceEncryptionProtector - or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - parameters: Union[_models.ManagedInstanceEncryptionProtector, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedInstanceEncryptionProtector]: - """Updates 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 - :param parameters: The requested encryption protector resource state. Is either a - ManagedInstanceEncryptionProtector type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ManagedInstanceEncryptionProtector - or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagedInstanceEncryptionProtector] = 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, - managed_instance_name=managed_instance_name, - encryption_protector_name=encryption_protector_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedInstanceEncryptionProtector", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedInstanceEncryptionProtector].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ManagedInstanceEncryptionProtector]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_keys_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_keys_operations.py deleted file mode 100644 index 809ec1da71c2..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_keys_operations.py +++ /dev/null @@ -1,517 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_instance_keys_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_instance_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedInstanceKeysOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_instance_keys` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.ManagedInstanceKey"]: - """Gets a list of managed instance keys. - - :param resource_group_name: The name of the resource group that 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 filter: An OData filter expression that filters elements in the collection. Default - value is None. - :type filter: str - :return: An iterator like instance of either ManagedInstanceKey or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceKey] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceKeyListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedInstanceKeyListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, managed_instance_name: str, key_name: str, **kwargs: Any - ) -> _models.ManagedInstanceKey: - """Gets a managed instance key. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 key_name: The name of the managed instance key to be retrieved. Required. - :type key_name: str - :return: ManagedInstanceKey or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstanceKey - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceKey] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - key_name=key_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedInstanceKey", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - key_name: str, - parameters: Union[_models.ManagedInstanceKey, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ManagedInstanceKey") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - key_name=key_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - key_name: str, - parameters: _models.ManagedInstanceKey, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedInstanceKey]: - """Creates or updates a managed instance key. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 key_name: The name of the managed instance key to be operated on (updated or created). - Required. - :type key_name: str - :param parameters: The requested managed instance key resource state. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceKey - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ManagedInstanceKey or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceKey] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - key_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedInstanceKey]: - """Creates or updates a managed instance key. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 key_name: The name of the managed instance key to be operated on (updated or created). - Required. - :type key_name: str - :param parameters: The requested managed instance key resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ManagedInstanceKey or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceKey] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - key_name: str, - parameters: Union[_models.ManagedInstanceKey, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedInstanceKey]: - """Creates or updates a managed instance key. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 key_name: The name of the managed instance key to be operated on (updated or created). - Required. - :type key_name: str - :param parameters: The requested managed instance key resource state. Is either a - ManagedInstanceKey type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceKey or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ManagedInstanceKey or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceKey] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagedInstanceKey] = 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, - managed_instance_name=managed_instance_name, - key_name=key_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedInstanceKey", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedInstanceKey].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ManagedInstanceKey]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, managed_instance_name: str, key_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - key_name=key_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, managed_instance_name: str, key_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes the managed instance key with the given name. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 key_name: The name of the managed instance key to be deleted. Required. - :type key_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - key_name=key_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_long_term_retention_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_long_term_retention_policies_operations.py deleted file mode 100644 index 58c66a66f477..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_long_term_retention_policies_operations.py +++ /dev/null @@ -1,428 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_instance_long_term_retention_policies_operations import ( - build_create_or_update_request, - build_get_request, - build_list_by_database_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedInstanceLongTermRetentionPoliciesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_instance_long_term_retention_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - policy_name: Union[str, _models.ManagedInstanceLongTermRetentionPolicyName], - **kwargs: Any - ) -> _models.ManagedInstanceLongTermRetentionPolicy: - """Gets a managed database's long term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy_name: The policy name. Should always be Default. "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicyName - :return: ManagedInstanceLongTermRetentionPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceLongTermRetentionPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - policy_name=policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedInstanceLongTermRetentionPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - policy_name: Union[str, _models.ManagedInstanceLongTermRetentionPolicyName], - parameters: Union[_models.ManagedInstanceLongTermRetentionPolicy, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ManagedInstanceLongTermRetentionPolicy") - - _request = build_create_or_update_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - policy_name: Union[str, _models.ManagedInstanceLongTermRetentionPolicyName], - parameters: _models.ManagedInstanceLongTermRetentionPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedInstanceLongTermRetentionPolicy]: - """Sets a managed database's long term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy_name: The policy name. Should always be Default. "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicyName - :param parameters: The long term retention policy info. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either - ManagedInstanceLongTermRetentionPolicy or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - policy_name: Union[str, _models.ManagedInstanceLongTermRetentionPolicyName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedInstanceLongTermRetentionPolicy]: - """Sets a managed database's long term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy_name: The policy name. Should always be Default. "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicyName - :param parameters: The long term retention policy info. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either - ManagedInstanceLongTermRetentionPolicy or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - policy_name: Union[str, _models.ManagedInstanceLongTermRetentionPolicyName], - parameters: Union[_models.ManagedInstanceLongTermRetentionPolicy, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedInstanceLongTermRetentionPolicy]: - """Sets a managed database's long term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy_name: The policy name. Should always be Default. "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicyName - :param parameters: The long term retention policy info. Is either a - ManagedInstanceLongTermRetentionPolicy type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy or IO[bytes] - :return: An instance of AsyncLROPoller that returns either - ManagedInstanceLongTermRetentionPolicy or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.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._create_or_update_initial( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - policy_name=policy_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedInstanceLongTermRetentionPolicy", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedInstanceLongTermRetentionPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ManagedInstanceLongTermRetentionPolicy]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_by_database( - self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :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", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceLongTermRetentionPolicyListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 673777bd9743..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_operations_operations.py +++ /dev/null @@ -1,249 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_instance_operations_operations import ( - build_cancel_request, - build_get_request, - build_list_by_managed_instance_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedInstanceOperationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_instance_operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.ManagedInstanceOperation"]: - """Gets a list of operations performed on the managed instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :return: An iterator like instance of either ManagedInstanceOperation or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceOperation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceOperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedInstanceOperationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, managed_instance_name: str, operation_id: str, **kwargs: Any - ) -> _models.ManagedInstanceOperation: - """Gets a management operation on a managed instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 operation_id: Required. - :type operation_id: str - :return: ManagedInstanceOperation or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstanceOperation - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceOperation] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - operation_id=operation_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedInstanceOperation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def cancel( - self, resource_group_name: str, managed_instance_name: str, operation_id: str, **kwargs: Any - ) -> None: - """Cancels the asynchronous operation on the managed instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 operation_id: Required. - :type operation_id: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_cancel_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - operation_id=operation_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_private_endpoint_connections_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_private_endpoint_connections_operations.py deleted file mode 100644 index f856a333e906..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_private_endpoint_connections_operations.py +++ /dev/null @@ -1,517 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_instance_private_endpoint_connections_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_managed_instance_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedInstancePrivateEndpointConnectionsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_instance_private_endpoint_connections` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get( - self, resource_group_name: str, managed_instance_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> _models.ManagedInstancePrivateEndpointConnection: - """Gets a private endpoint connection. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :return: ManagedInstancePrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstancePrivateEndpointConnection] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedInstancePrivateEndpointConnection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - private_endpoint_connection_name: str, - parameters: Union[_models.ManagedInstancePrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ManagedInstancePrivateEndpointConnection") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - private_endpoint_connection_name: str, - parameters: _models.ManagedInstancePrivateEndpointConnection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedInstancePrivateEndpointConnection]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 private_endpoint_connection_name: Required. - :type private_endpoint_connection_name: str - :param parameters: Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either - ManagedInstancePrivateEndpointConnection or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - private_endpoint_connection_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedInstancePrivateEndpointConnection]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 private_endpoint_connection_name: Required. - :type private_endpoint_connection_name: str - :param parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either - ManagedInstancePrivateEndpointConnection or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - private_endpoint_connection_name: str, - parameters: Union[_models.ManagedInstancePrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedInstancePrivateEndpointConnection]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 private_endpoint_connection_name: Required. - :type private_endpoint_connection_name: str - :param parameters: Is either a ManagedInstancePrivateEndpointConnection type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection or IO[bytes] - :return: An instance of AsyncLROPoller that returns either - ManagedInstancePrivateEndpointConnection or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagedInstancePrivateEndpointConnection] = 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, - managed_instance_name=managed_instance_name, - private_endpoint_connection_name=private_endpoint_connection_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize( - "ManagedInstancePrivateEndpointConnection", pipeline_response.http_response - ) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedInstancePrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ManagedInstancePrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, managed_instance_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, managed_instance_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 private_endpoint_connection_name: Required. - :type private_endpoint_connection_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - private_endpoint_connection_name=private_endpoint_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_by_managed_instance( - self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either ManagedInstancePrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstancePrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index fa19f3653b48..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_private_link_resources_operations.py +++ /dev/null @@ -1,192 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_instance_private_link_resources_operations import ( - build_get_request, - build_list_by_managed_instance_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedInstancePrivateLinkResourcesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_instance_private_link_resources` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.ManagedInstancePrivateLink"]: - """Gets the private link resources for SQL 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 - :return: An iterator like instance of either ManagedInstancePrivateLink or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstancePrivateLink] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstancePrivateLinkListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedInstancePrivateLinkListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, managed_instance_name: str, group_name: str, **kwargs: Any - ) -> _models.ManagedInstancePrivateLink: - """Gets a private link resource for SQL server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 group_name: The name of the private link resource. Required. - :type group_name: str - :return: ManagedInstancePrivateLink or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstancePrivateLink - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstancePrivateLink] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - group_name=group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedInstancePrivateLink", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_tde_certificates_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_tde_certificates_operations.py deleted file mode 100644 index f688f03f18fa..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_tde_certificates_operations.py +++ /dev/null @@ -1,243 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_instance_tde_certificates_operations import build_create_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedInstanceTdeCertificatesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_instance_tde_certificates` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - async def _create_initial( - self, - resource_group_name: str, - managed_instance_name: str, - parameters: Union[_models.TdeCertificate, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "TdeCertificate") - - _request = build_create_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create( - self, - resource_group_name: str, - managed_instance_name: str, - parameters: _models.TdeCertificate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Creates a TDE certificate for a given server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 parameters: The requested TDE certificate to be created or updated. Required. - :type parameters: ~azure.mgmt.sql.models.TdeCertificate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - managed_instance_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Creates a TDE certificate for a given server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 parameters: The requested TDE certificate to be created or updated. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - managed_instance_name: str, - parameters: Union[_models.TdeCertificate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Creates a TDE certificate for a given server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 parameters: The requested TDE certificate to be created or updated. Is either a - TdeCertificate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.TdeCertificate or IO[bytes] - :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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[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._create_initial( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_vulnerability_assessments_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_vulnerability_assessments_operations.py deleted file mode 100644 index 7ec847c2e061..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_vulnerability_assessments_operations.py +++ /dev/null @@ -1,416 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_instance_vulnerability_assessments_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_instance_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedInstanceVulnerabilityAssessmentsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_instance_vulnerability_assessments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - managed_instance_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **kwargs: Any - ) -> _models.ManagedInstanceVulnerabilityAssessment: - """Gets the managed instance's vulnerability assessment. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - assessment is defined. Required. - :type managed_instance_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 - :return: ManagedInstanceVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceVulnerabilityAssessment] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedInstanceVulnerabilityAssessment", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: _models.ManagedInstanceVulnerabilityAssessment, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ManagedInstanceVulnerabilityAssessment: - """Creates or updates the managed instance's vulnerability assessment. Learn more about setting - SQL vulnerability assessment with managed identity - - https://docs.microsoft.com/azure/azure-sql/database/sql-database-vulnerability-assessment-storage. - - :param resource_group_name: The name of the resource group that 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 - assessment is defined. Required. - :type managed_instance_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 parameters: The requested resource. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ManagedInstanceVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ManagedInstanceVulnerabilityAssessment: - """Creates or updates the managed instance's vulnerability assessment. Learn more about setting - SQL vulnerability assessment with managed identity - - https://docs.microsoft.com/azure/azure-sql/database/sql-database-vulnerability-assessment-storage. - - :param resource_group_name: The name of the resource group that 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 - assessment is defined. Required. - :type managed_instance_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 parameters: The requested resource. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ManagedInstanceVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: Union[_models.ManagedInstanceVulnerabilityAssessment, IO[bytes]], - **kwargs: Any - ) -> _models.ManagedInstanceVulnerabilityAssessment: - """Creates or updates the managed instance's vulnerability assessment. Learn more about setting - SQL vulnerability assessment with managed identity - - https://docs.microsoft.com/azure/azure-sql/database/sql-database-vulnerability-assessment-storage. - - :param resource_group_name: The name of the resource group that 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 - assessment is defined. Required. - :type managed_instance_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 parameters: The requested resource. Is either a ManagedInstanceVulnerabilityAssessment - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment or IO[bytes] - :return: ManagedInstanceVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ManagedInstanceVulnerabilityAssessment") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ManagedInstanceVulnerabilityAssessment", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( - self, - resource_group_name: str, - managed_instance_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **kwargs: Any - ) -> None: - """Removes the managed instance's vulnerability assessment. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - assessment is defined. Required. - :type managed_instance_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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @distributed_trace - def list_by_instance( - self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either ManagedInstanceVulnerabilityAssessment or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 20230ff9a013..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instances_operations.py +++ /dev/null @@ -1,1477 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_instances_operations import ( - build_create_or_update_request, - build_delete_request, - build_failover_request, - build_get_request, - build_list_by_instance_pool_request, - build_list_by_managed_instance_request, - 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, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedInstancesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_instances` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, expand: Optional[str] = None, **kwargs: Any) -> AsyncItemPaged["_models.ManagedInstance"]: - """Gets a list of all managed instances in the subscription. - - :param expand: The child resources to include in the response. Default value is None. - :type expand: str - :return: An iterator like instance of either ManagedInstance or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - cls: ClsType[_models.ManagedInstanceListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedInstanceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_instance_pool( - self, resource_group_name: str, instance_pool_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.ManagedInstance"]: - """Gets a list of all managed instances in an instance pool. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param instance_pool_name: The instance pool name. Required. - :type instance_pool_name: str - :param expand: The child resources to include in the response. Default value is None. - :type expand: str - :return: An iterator like instance of either ManagedInstance or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - cls: ClsType[_models.ManagedInstanceListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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_pool_request( - resource_group_name=resource_group_name, - instance_pool_name=instance_pool_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedInstanceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.ManagedInstance"]: - """Gets a list of managed instances in a resource group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param expand: The child resources to include in the response. Default value is None. - :type expand: str - :return: An iterator like instance of either ManagedInstance or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - cls: ClsType[_models.ManagedInstanceListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedInstanceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, managed_instance_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> _models.ManagedInstance: - """Gets a managed instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 expand: The child resources to include in the response. Default value is None. - :type expand: str - :return: ManagedInstance or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstance - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[_models.ManagedInstance] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedInstance", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - parameters: Union[_models.ManagedInstance, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ManagedInstance") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - parameters: _models.ManagedInstance, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedInstance]: - """Creates or updates a managed instance. - - :param resource_group_name: The name of the resource group that 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 parameters: The requested managed instance resource state. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstance - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedInstance]: - """Creates or updates a managed instance. - - :param resource_group_name: The name of the resource group that 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 parameters: The requested managed instance resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - parameters: Union[_models.ManagedInstance, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedInstance]: - """Creates or updates a managed instance. - - :param resource_group_name: The name of the resource group that 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 parameters: The requested managed instance resource state. Is either a ManagedInstance - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstance or IO[bytes] - :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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - 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._create_or_update_initial( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedInstance", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedInstance].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ManagedInstance]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a managed instance. - - :param resource_group_name: The name of the resource group that 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 - :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", "2023-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_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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - parameters: Union[_models.ManagedInstanceUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ManagedInstanceUpdate") - - _request = build_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - managed_instance_name: str, - parameters: _models.ManagedInstanceUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedInstance]: - """Updates a managed instance. - - :param resource_group_name: The name of the resource group that 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 parameters: The requested managed instance resource state. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - managed_instance_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedInstance]: - """Updates a managed instance. - - :param resource_group_name: The name of the resource group that 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 parameters: The requested managed instance resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - managed_instance_name: str, - parameters: Union[_models.ManagedInstanceUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedInstance]: - """Updates a managed instance. - - :param resource_group_name: The name of the resource group that 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 parameters: The requested managed instance resource state. Is either a - ManagedInstanceUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceUpdate or IO[bytes] - :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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - 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._update_initial( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedInstance", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedInstance].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ManagedInstance]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _failover_initial( - self, - resource_group_name: str, - managed_instance_name: str, - replica_type: Optional[Union[str, _models.ReplicaType]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_failover_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - subscription_id=self._config.subscription_id, - replica_type=replica_type, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_failover( - self, - resource_group_name: str, - managed_instance_name: str, - replica_type: Optional[Union[str, _models.ReplicaType]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Failovers a managed instance. - - :param resource_group_name: The name of the resource group that 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 to failover. Required. - :type managed_instance_name: str - :param replica_type: The type of replica to be failed over. Known values are: "Primary" and - "ReadableSecondary". Default value is None. - :type replica_type: str or ~azure.mgmt.sql.models.ReplicaType - :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", "2023-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._failover_initial( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - replica_type=replica_type, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_outbound_network_dependencies_by_managed_instance( # pylint: disable=name-too-long - self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.OutboundEnvironmentEndpoint"]: - """Gets the collection of outbound network dependencies for the given managed instance. - - :param resource_group_name: The name of the resource group that 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 - :return: An iterator like instance of either OutboundEnvironmentEndpoint or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.OutboundEnvironmentEndpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - cls: ClsType[_models.OutboundEnvironmentEndpointCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_outbound_network_dependencies_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("OutboundEnvironmentEndpointCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - async def _refresh_status_initial( - self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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", "2023-05-01-preview")) - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize( - "RefreshExternalGovernanceStatusOperationResultMI", pipeline_response.http_response - ) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.RefreshExternalGovernanceStatusOperationResultMI].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.RefreshExternalGovernanceStatusOperationResultMI]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _start_initial( - self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_start_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_start( - self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedInstance]: - """Starts the managed instance. - - :param resource_group_name: The name of the resource group that 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 - :return: An instance of AsyncLROPoller that returns either ManagedInstance or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - 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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedInstance", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedInstance].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ManagedInstance]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _stop_initial( - self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_stop_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_stop( - self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedInstance]: - """Stops the managed instance. - - :param resource_group_name: The name of the resource group that 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 - :return: An instance of AsyncLROPoller that returns either ManagedInstance or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - 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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedInstance", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedInstance].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ManagedInstance]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_by_managed_instance( - self, - resource_group_name: str, - managed_instance_name: str, - number_of_queries: Optional[int] = None, - databases: Optional[str] = None, - start_time: Optional[str] = None, - end_time: Optional[str] = None, - interval: Optional[Union[str, _models.QueryTimeGrainType]] = None, - aggregation_function: Optional[Union[str, _models.AggregationFunctionType]] = None, - observation_metric: Optional[Union[str, _models.MetricType]] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.TopQueries"]: - """Get top resource consuming queries of a managed instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 number_of_queries: How many 'top queries' to return. Default is 5. Default value is - None. - :type number_of_queries: int - :param databases: Comma separated list of databases to be included into search. All DB's are - included if this parameter is not specified. Default value is None. - :type databases: str - :param start_time: Start time for observed period. Default value is None. - :type start_time: str - :param end_time: End time for observed period. Default value is None. - :type end_time: str - :param interval: The time step to be used to summarize the metric values. Default value is - PT1H. Known values are: "PT1H" and "P1D". Default value is None. - :type interval: str or ~azure.mgmt.sql.models.QueryTimeGrainType - :param aggregation_function: Aggregation function to be used, default value is 'sum'. Known - values are: "avg", "min", "max", "stdev", and "sum". Default value is None. - :type aggregation_function: str or ~azure.mgmt.sql.models.AggregationFunctionType - :param observation_metric: Metric to be used for ranking top queries. Default is 'cpu'. Known - values are: "cpu", "io", "logIo", "duration", and "dtu". Default value is None. - :type observation_metric: str or ~azure.mgmt.sql.models.MetricType - :return: An iterator like instance of either TopQueries or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.TopQueries] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - cls: ClsType[_models.TopQueriesListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - number_of_queries=number_of_queries, - databases=databases, - start_time=start_time, - end_time=end_time, - interval=interval, - aggregation_function=aggregation_function, - observation_metric=observation_metric, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("TopQueriesListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) 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 deleted file mode 100644 index bfd876cac1f6..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_ledger_digest_uploads_operations.py +++ /dev/null @@ -1,561 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_ledger_digest_uploads_operations import ( - build_create_or_update_request, - build_disable_request, - build_get_request, - build_list_by_database_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedLedgerDigestUploadsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_ledger_digest_uploads` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.ManagedLedgerDigestUploads"]: - """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 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 - :return: An iterator like instance of either ManagedLedgerDigestUploads or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedLedgerDigestUploads] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.ManagedLedgerDigestUploadsListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedLedgerDigestUploadsListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], - **kwargs: Any - ) -> _models.ManagedLedgerDigestUploads: - """Gets the current ledger digest upload configuration for a database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 ledger_digest_uploads: "current" Required. - :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.ManagedLedgerDigestUploadsName - :return: ManagedLedgerDigestUploads or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedLedgerDigestUploads - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - cls: ClsType[_models.ManagedLedgerDigestUploads] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - ledger_digest_uploads=ledger_digest_uploads, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedLedgerDigestUploads", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], - parameters: Union[_models.ManagedLedgerDigestUploads, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ManagedLedgerDigestUploads") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - ledger_digest_uploads=ledger_digest_uploads, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], - parameters: _models.ManagedLedgerDigestUploads, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedLedgerDigestUploads]: - """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger - instance. - - :param resource_group_name: The name of the resource group that 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 ledger_digest_uploads: The name of the Ledger Digest Upload Configurations. "current" - Required. - :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.ManagedLedgerDigestUploadsName - :param parameters: The Ledger Digest Storage Endpoint. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedLedgerDigestUploads - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ManagedLedgerDigestUploads or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedLedgerDigestUploads] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedLedgerDigestUploads]: - """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger - instance. - - :param resource_group_name: The name of the resource group that 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 ledger_digest_uploads: The name of the Ledger Digest Upload Configurations. "current" - Required. - :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.ManagedLedgerDigestUploadsName - :param parameters: The Ledger Digest Storage Endpoint. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ManagedLedgerDigestUploads or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedLedgerDigestUploads] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], - parameters: Union[_models.ManagedLedgerDigestUploads, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedLedgerDigestUploads]: - """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger - instance. - - :param resource_group_name: The name of the resource group that 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 ledger_digest_uploads: The name of the Ledger Digest Upload Configurations. "current" - Required. - :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.ManagedLedgerDigestUploadsName - :param parameters: The Ledger Digest Storage Endpoint. Is either a ManagedLedgerDigestUploads - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedLedgerDigestUploads or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ManagedLedgerDigestUploads or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedLedgerDigestUploads] - :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", "2022-08-01-preview")) - 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) - 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, - managed_instance_name=managed_instance_name, - database_name=database_name, - ledger_digest_uploads=ledger_digest_uploads, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedLedgerDigestUploads", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedLedgerDigestUploads].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ManagedLedgerDigestUploads]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _disable_initial( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disable_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - ledger_digest_uploads=ledger_digest_uploads, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_disable( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedLedgerDigestUploads]: - """Disables uploading ledger digests to an Azure Storage account or an Azure Confidential Ledger - instance. - - :param resource_group_name: The name of the resource group that 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 ledger_digest_uploads: "current" Required. - :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.ManagedLedgerDigestUploadsName - :return: An instance of AsyncLROPoller that returns either ManagedLedgerDigestUploads or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedLedgerDigestUploads] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.ManagedLedgerDigestUploads] = 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._disable_initial( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - ledger_digest_uploads=ledger_digest_uploads, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedLedgerDigestUploads", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedLedgerDigestUploads].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ManagedLedgerDigestUploads]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_restorable_dropped_database_backup_short_term_retention_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_restorable_dropped_database_backup_short_term_retention_policies_operations.py deleted file mode 100644 index bfd1ae2b3476..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_restorable_dropped_database_backup_short_term_retention_policies_operations.py +++ /dev/null @@ -1,648 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_restorable_dropped_database_backup_short_term_retention_policies_operations import ( - build_create_or_update_request, - build_get_request, - build_list_by_restorable_dropped_database_request, - build_update_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_restorable_dropped_database_backup_short_term_retention_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - managed_instance_name: str, - restorable_dropped_database_id: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - **kwargs: Any - ) -> _models.ManagedBackupShortTermRetentionPolicy: - """Gets a dropped database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param policy_name: The policy name. "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName - :return: ManagedBackupShortTermRetentionPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedBackupShortTermRetentionPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - restorable_dropped_database_id=restorable_dropped_database_id, - policy_name=policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedBackupShortTermRetentionPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - restorable_dropped_database_id: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - parameters: Union[_models.ManagedBackupShortTermRetentionPolicy, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ManagedBackupShortTermRetentionPolicy") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - restorable_dropped_database_id=restorable_dropped_database_id, - policy_name=policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - restorable_dropped_database_id: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - parameters: _models.ManagedBackupShortTermRetentionPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]: - """Sets a database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either - ManagedBackupShortTermRetentionPolicy or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - restorable_dropped_database_id: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]: - """Sets a database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either - ManagedBackupShortTermRetentionPolicy or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - restorable_dropped_database_id: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - parameters: Union[_models.ManagedBackupShortTermRetentionPolicy, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]: - """Sets a database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Is either a - ManagedBackupShortTermRetentionPolicy type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy or IO[bytes] - :return: An instance of AsyncLROPoller that returns either - ManagedBackupShortTermRetentionPolicy or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagedBackupShortTermRetentionPolicy] = 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, - managed_instance_name=managed_instance_name, - restorable_dropped_database_id=restorable_dropped_database_id, - policy_name=policy_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedBackupShortTermRetentionPolicy", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedBackupShortTermRetentionPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - restorable_dropped_database_id: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - parameters: Union[_models.ManagedBackupShortTermRetentionPolicy, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ManagedBackupShortTermRetentionPolicy") - - _request = build_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - restorable_dropped_database_id=restorable_dropped_database_id, - policy_name=policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - managed_instance_name: str, - restorable_dropped_database_id: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - parameters: _models.ManagedBackupShortTermRetentionPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]: - """Sets a database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either - ManagedBackupShortTermRetentionPolicy or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - managed_instance_name: str, - restorable_dropped_database_id: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]: - """Sets a database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either - ManagedBackupShortTermRetentionPolicy or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - managed_instance_name: str, - restorable_dropped_database_id: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - parameters: Union[_models.ManagedBackupShortTermRetentionPolicy, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]: - """Sets a database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Is either a - ManagedBackupShortTermRetentionPolicy type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy or IO[bytes] - :return: An instance of AsyncLROPoller that returns either - ManagedBackupShortTermRetentionPolicy or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagedBackupShortTermRetentionPolicy] = 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( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - restorable_dropped_database_id=restorable_dropped_database_id, - policy_name=policy_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedBackupShortTermRetentionPolicy", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedBackupShortTermRetentionPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_by_restorable_dropped_database( - self, resource_group_name: str, managed_instance_name: str, restorable_dropped_database_id: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either ManagedBackupShortTermRetentionPolicy or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedBackupShortTermRetentionPolicyListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 5e14f9bd3fcc..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_server_dns_aliases_operations.py +++ /dev/null @@ -1,716 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_server_dns_aliases_operations import ( - build_acquire_request, - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_managed_instance_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedServerDnsAliasesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_server_dns_aliases` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.ManagedServerDnsAlias"]: - """Gets a list of managed server DNS aliases for a managed 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 - :return: An iterator like instance of either ManagedServerDnsAlias or the result of - cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedServerDnsAlias] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.ManagedServerDnsAliasListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedServerDnsAliasListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, managed_instance_name: str, dns_alias_name: str, **kwargs: Any - ) -> _models.ManagedServerDnsAlias: - """Gets a server DNS alias. - - :param resource_group_name: The name of the resource group that 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 dns_alias_name: Required. - :type dns_alias_name: str - :return: ManagedServerDnsAlias or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedServerDnsAlias - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.ManagedServerDnsAlias] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - dns_alias_name=dns_alias_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedServerDnsAlias", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - dns_alias_name: str, - parameters: Union[_models.ManagedServerDnsAliasCreation, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2021-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ManagedServerDnsAliasCreation") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - dns_alias_name=dns_alias_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - dns_alias_name: str, - parameters: _models.ManagedServerDnsAliasCreation, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedServerDnsAlias]: - """Creates a managed server DNS alias. - - :param resource_group_name: The name of the resource group that 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 dns_alias_name: Required. - :type dns_alias_name: str - :param parameters: Required. - :type parameters: ~azure.mgmt.sql.models.ManagedServerDnsAliasCreation - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ManagedServerDnsAlias or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedServerDnsAlias] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - dns_alias_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedServerDnsAlias]: - """Creates a managed server DNS alias. - - :param resource_group_name: The name of the resource group that 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 dns_alias_name: Required. - :type dns_alias_name: str - :param parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ManagedServerDnsAlias or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedServerDnsAlias] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - dns_alias_name: str, - parameters: Union[_models.ManagedServerDnsAliasCreation, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedServerDnsAlias]: - """Creates a managed server DNS alias. - - :param resource_group_name: The name of the resource group that 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 dns_alias_name: Required. - :type dns_alias_name: str - :param parameters: Is either a ManagedServerDnsAliasCreation type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.sql.models.ManagedServerDnsAliasCreation or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ManagedServerDnsAlias or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedServerDnsAlias] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - 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) - 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, - managed_instance_name=managed_instance_name, - dns_alias_name=dns_alias_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedServerDnsAlias", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedServerDnsAlias].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ManagedServerDnsAlias]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, managed_instance_name: str, dns_alias_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - dns_alias_name=dns_alias_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, managed_instance_name: str, dns_alias_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes the managed server DNS alias with the 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 managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param dns_alias_name: Required. - :type dns_alias_name: str - :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", "2021-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( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - dns_alias_name=dns_alias_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _acquire_initial( - self, - resource_group_name: str, - managed_instance_name: str, - dns_alias_name: str, - parameters: Union[_models.ManagedServerDnsAliasAcquisition, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2021-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ManagedServerDnsAliasAcquisition") - - _request = build_acquire_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - dns_alias_name=dns_alias_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_acquire( - self, - resource_group_name: str, - managed_instance_name: str, - dns_alias_name: str, - parameters: _models.ManagedServerDnsAliasAcquisition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedServerDnsAlias]: - """Acquires managed server DNS alias from another managed 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 - :param dns_alias_name: Required. - :type dns_alias_name: str - :param parameters: Required. - :type parameters: ~azure.mgmt.sql.models.ManagedServerDnsAliasAcquisition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ManagedServerDnsAlias or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedServerDnsAlias] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_acquire( - self, - resource_group_name: str, - managed_instance_name: str, - dns_alias_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedServerDnsAlias]: - """Acquires managed server DNS alias from another managed 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 - :param dns_alias_name: Required. - :type dns_alias_name: str - :param parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ManagedServerDnsAlias or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedServerDnsAlias] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_acquire( - self, - resource_group_name: str, - managed_instance_name: str, - dns_alias_name: str, - parameters: Union[_models.ManagedServerDnsAliasAcquisition, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedServerDnsAlias]: - """Acquires managed server DNS alias from another managed 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 - :param dns_alias_name: Required. - :type dns_alias_name: str - :param parameters: Is either a ManagedServerDnsAliasAcquisition type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.sql.models.ManagedServerDnsAliasAcquisition or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ManagedServerDnsAlias or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedServerDnsAlias] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - 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) - 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._acquire_initial( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - dns_alias_name=dns_alias_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedServerDnsAlias", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedServerDnsAlias].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ManagedServerDnsAlias]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index c00a2ad4a7e6..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_server_security_alert_policies_operations.py +++ /dev/null @@ -1,409 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._managed_server_security_alert_policies_operations import ( - build_create_or_update_request, - build_get_request, - build_list_by_instance_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ManagedServerSecurityAlertPoliciesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`managed_server_security_alert_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - managed_instance_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - **kwargs: Any - ) -> _models.ManagedServerSecurityAlertPolicy: - """Get a managed server's threat detection policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 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 - :return: ManagedServerSecurityAlertPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedServerSecurityAlertPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - security_alert_policy_name=security_alert_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedServerSecurityAlertPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - parameters: Union[_models.ManagedServerSecurityAlertPolicy, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ManagedServerSecurityAlertPolicy") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - security_alert_policy_name=security_alert_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - parameters: _models.ManagedServerSecurityAlertPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedServerSecurityAlertPolicy]: - """Creates or updates a threat detection policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 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 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. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ManagedServerSecurityAlertPolicy or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedServerSecurityAlertPolicy]: - """Creates or updates a threat detection policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 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 managed server security alert policy. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ManagedServerSecurityAlertPolicy or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - parameters: Union[_models.ManagedServerSecurityAlertPolicy, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ManagedServerSecurityAlertPolicy]: - """Creates or updates a threat detection policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 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 managed server security alert policy. Is either a - ManagedServerSecurityAlertPolicy type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ManagedServerSecurityAlertPolicy or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagedServerSecurityAlertPolicy] = 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, - managed_instance_name=managed_instance_name, - security_alert_policy_name=security_alert_policy_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedServerSecurityAlertPolicy", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedServerSecurityAlertPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ManagedServerSecurityAlertPolicy]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_by_instance( - self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either ManagedServerSecurityAlertPolicy or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedServerSecurityAlertPolicyListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 98111b23f429..f4ac0bc2e72f 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 @@ -1,12 +1,17 @@ +# pylint: disable=line-too-long,useless-suppression,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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar +import datetime +from io import IOBase +import json +from typing import Any, AsyncIterator, Callable, IO, Literal, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -16,21 +21,575 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import AsyncHttpResponse, 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 ..._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize from ..._utils.serialization import Deserializer, Serializer -from ...operations._operations import build_list_request +from ..._validation import api_version_validation +from ...operations._operations import ( + build_backup_short_term_retention_policies_create_or_update_request, + build_backup_short_term_retention_policies_get_request, + build_backup_short_term_retention_policies_list_by_database_request, + build_backup_short_term_retention_policies_update_request, + build_capabilities_list_by_location_request, + build_data_masking_policies_create_or_update_request, + build_data_masking_policies_get_request, + build_data_masking_rules_create_or_update_request, + build_data_masking_rules_list_by_database_request, + build_data_warehouse_user_activities_get_request, + build_data_warehouse_user_activities_list_by_database_request, + build_database_advanced_threat_protection_settings_create_or_update_request, + build_database_advanced_threat_protection_settings_get_request, + build_database_advanced_threat_protection_settings_list_by_database_request, + build_database_advisors_get_request, + build_database_advisors_list_by_database_request, + build_database_advisors_update_request, + build_database_automatic_tuning_get_request, + build_database_automatic_tuning_update_request, + build_database_blob_auditing_policies_create_or_update_request, + build_database_blob_auditing_policies_get_request, + build_database_blob_auditing_policies_list_by_database_request, + build_database_columns_get_request, + build_database_columns_list_by_database_request, + build_database_columns_list_by_table_request, + build_database_encryption_protectors_revalidate_request, + build_database_encryption_protectors_revert_request, + build_database_extensions_create_or_update_request, + build_database_extensions_get_request, + build_database_extensions_list_by_database_request, + build_database_operations_cancel_request, + build_database_operations_list_by_database_request, + build_database_recommended_actions_get_request, + build_database_recommended_actions_list_by_database_advisor_request, + build_database_recommended_actions_update_request, + build_database_schemas_get_request, + build_database_schemas_list_by_database_request, + build_database_security_alert_policies_create_or_update_request, + build_database_security_alert_policies_get_request, + build_database_security_alert_policies_list_by_database_request, + build_database_sql_vulnerability_assessment_baselines_create_or_update_request, + build_database_sql_vulnerability_assessment_baselines_get_request, + build_database_sql_vulnerability_assessment_baselines_list_by_sql_vulnerability_assessment_request, + build_database_sql_vulnerability_assessment_execute_scan_execute_request, + build_database_sql_vulnerability_assessment_rule_baselines_create_or_update_request, + build_database_sql_vulnerability_assessment_rule_baselines_delete_request, + build_database_sql_vulnerability_assessment_rule_baselines_get_request, + build_database_sql_vulnerability_assessment_rule_baselines_list_by_baseline_request, + build_database_sql_vulnerability_assessment_scan_result_get_request, + build_database_sql_vulnerability_assessment_scan_result_list_by_scan_request, + build_database_sql_vulnerability_assessment_scans_get_request, + build_database_sql_vulnerability_assessment_scans_list_by_sql_vulnerability_assessments_request, + build_database_sql_vulnerability_assessments_settings_get_request, + build_database_sql_vulnerability_assessments_settings_list_by_database_request, + build_database_tables_get_request, + build_database_tables_list_by_schema_request, + build_database_usages_list_by_database_request, + build_database_vulnerability_assessment_rule_baselines_create_or_update_request, + build_database_vulnerability_assessment_rule_baselines_delete_request, + build_database_vulnerability_assessment_rule_baselines_get_request, + build_database_vulnerability_assessment_scans_export_request, + build_database_vulnerability_assessment_scans_get_request, + build_database_vulnerability_assessment_scans_initiate_scan_request, + build_database_vulnerability_assessment_scans_list_by_database_request, + build_database_vulnerability_assessments_create_or_update_request, + build_database_vulnerability_assessments_delete_request, + build_database_vulnerability_assessments_get_request, + build_database_vulnerability_assessments_list_by_database_request, + build_databases_create_or_update_request, + build_databases_delete_request, + build_databases_export_request, + build_databases_failover_request, + build_databases_get_request, + build_databases_import_method_request, + build_databases_list_by_elastic_pool_request, + build_databases_list_by_server_request, + build_databases_list_inaccessible_by_server_request, + build_databases_pause_request, + build_databases_rename_request, + build_databases_resume_request, + build_databases_update_request, + build_databases_upgrade_data_warehouse_request, + build_deleted_servers_get_request, + build_deleted_servers_list_by_location_request, + build_deleted_servers_list_request, + build_deleted_servers_recover_request, + build_distributed_availability_groups_create_or_update_request, + build_distributed_availability_groups_delete_request, + build_distributed_availability_groups_failover_request, + build_distributed_availability_groups_get_request, + build_distributed_availability_groups_list_by_instance_request, + build_distributed_availability_groups_set_role_request, + build_distributed_availability_groups_update_request, + build_elastic_pool_operations_cancel_request, + build_elastic_pool_operations_list_by_elastic_pool_request, + build_elastic_pools_create_or_update_request, + build_elastic_pools_delete_request, + build_elastic_pools_failover_request, + build_elastic_pools_get_request, + build_elastic_pools_list_by_server_request, + build_elastic_pools_update_request, + build_encryption_protectors_create_or_update_request, + build_encryption_protectors_get_request, + build_encryption_protectors_list_by_server_request, + build_encryption_protectors_revalidate_request, + build_endpoint_certificates_get_request, + build_endpoint_certificates_list_by_instance_request, + build_extended_database_blob_auditing_policies_create_or_update_request, + build_extended_database_blob_auditing_policies_get_request, + build_extended_database_blob_auditing_policies_list_by_database_request, + build_extended_server_blob_auditing_policies_create_or_update_request, + build_extended_server_blob_auditing_policies_get_request, + build_extended_server_blob_auditing_policies_list_by_server_request, + build_failover_groups_create_or_update_request, + build_failover_groups_delete_request, + build_failover_groups_failover_request, + build_failover_groups_force_failover_allow_data_loss_request, + build_failover_groups_get_request, + build_failover_groups_list_by_server_request, + build_failover_groups_try_planned_before_forced_failover_request, + build_failover_groups_update_request, + build_firewall_rules_create_or_update_request, + build_firewall_rules_delete_request, + build_firewall_rules_get_request, + build_firewall_rules_list_by_server_request, + build_firewall_rules_replace_request, + build_geo_backup_policies_create_or_update_request, + build_geo_backup_policies_get_request, + build_geo_backup_policies_list_request, + build_instance_failover_groups_create_or_update_request, + build_instance_failover_groups_delete_request, + build_instance_failover_groups_failover_request, + build_instance_failover_groups_force_failover_allow_data_loss_request, + build_instance_failover_groups_get_request, + build_instance_failover_groups_list_by_location_request, + build_instance_pool_operations_get_request, + build_instance_pool_operations_list_by_instance_pool_request, + build_instance_pools_create_or_update_request, + build_instance_pools_delete_request, + build_instance_pools_get_request, + build_instance_pools_list_by_resource_group_request, + build_instance_pools_list_request, + build_instance_pools_update_request, + build_ipv6_firewall_rules_create_or_update_request, + build_ipv6_firewall_rules_delete_request, + build_ipv6_firewall_rules_get_request, + build_ipv6_firewall_rules_list_by_server_request, + build_job_agents_create_or_update_request, + build_job_agents_delete_request, + build_job_agents_get_request, + build_job_agents_list_by_server_request, + build_job_agents_update_request, + build_job_credentials_create_or_update_request, + build_job_credentials_delete_request, + build_job_credentials_get_request, + build_job_credentials_list_by_agent_request, + build_job_executions_cancel_request, + build_job_executions_create_or_update_request, + build_job_executions_create_request, + build_job_executions_get_request, + build_job_executions_list_by_agent_request, + build_job_executions_list_by_job_request, + build_job_private_endpoints_create_or_update_request, + build_job_private_endpoints_delete_request, + build_job_private_endpoints_get_request, + build_job_private_endpoints_list_by_agent_request, + build_job_step_executions_get_request, + build_job_step_executions_list_by_job_execution_request, + build_job_steps_create_or_update_request, + build_job_steps_delete_request, + build_job_steps_get_by_version_request, + build_job_steps_get_request, + build_job_steps_list_by_job_request, + build_job_steps_list_by_version_request, + build_job_target_executions_get_request, + build_job_target_executions_list_by_job_execution_request, + build_job_target_executions_list_by_step_request, + build_job_target_groups_create_or_update_request, + build_job_target_groups_delete_request, + build_job_target_groups_get_request, + build_job_target_groups_list_by_agent_request, + build_job_versions_get_request, + build_job_versions_list_by_job_request, + build_jobs_create_or_update_request, + build_jobs_delete_request, + build_jobs_get_request, + build_jobs_list_by_agent_request, + build_ledger_digest_uploads_create_or_update_request, + build_ledger_digest_uploads_disable_request, + build_ledger_digest_uploads_get_request, + build_ledger_digest_uploads_list_by_database_request, + build_long_term_retention_backups_change_access_tier_by_resource_group_request, + build_long_term_retention_backups_change_access_tier_request, + build_long_term_retention_backups_copy_by_resource_group_request, + build_long_term_retention_backups_copy_request, + build_long_term_retention_backups_delete_by_resource_group_request, + build_long_term_retention_backups_delete_request, + build_long_term_retention_backups_get_by_resource_group_request, + build_long_term_retention_backups_get_request, + build_long_term_retention_backups_list_by_database_request, + build_long_term_retention_backups_list_by_location_request, + build_long_term_retention_backups_list_by_resource_group_database_request, + build_long_term_retention_backups_list_by_resource_group_location_request, + build_long_term_retention_backups_list_by_resource_group_server_request, + build_long_term_retention_backups_list_by_server_request, + build_long_term_retention_backups_lock_time_based_immutability_by_resource_group_request, + build_long_term_retention_backups_lock_time_based_immutability_request, + build_long_term_retention_backups_remove_legal_hold_immutability_by_resource_group_request, + build_long_term_retention_backups_remove_legal_hold_immutability_request, + build_long_term_retention_backups_remove_time_based_immutability_by_resource_group_request, + build_long_term_retention_backups_remove_time_based_immutability_request, + build_long_term_retention_backups_set_legal_hold_immutability_by_resource_group_request, + build_long_term_retention_backups_set_legal_hold_immutability_request, + build_long_term_retention_backups_update_by_resource_group_request, + build_long_term_retention_backups_update_request, + build_long_term_retention_managed_instance_backups_delete_by_resource_group_request, + build_long_term_retention_managed_instance_backups_delete_request, + build_long_term_retention_managed_instance_backups_get_by_resource_group_request, + build_long_term_retention_managed_instance_backups_get_request, + build_long_term_retention_managed_instance_backups_list_by_database_request, + build_long_term_retention_managed_instance_backups_list_by_instance_request, + build_long_term_retention_managed_instance_backups_list_by_location_request, + build_long_term_retention_managed_instance_backups_list_by_resource_group_database_request, + build_long_term_retention_managed_instance_backups_list_by_resource_group_instance_request, + build_long_term_retention_managed_instance_backups_list_by_resource_group_location_request, + build_long_term_retention_policies_create_or_update_request, + build_long_term_retention_policies_get_request, + build_long_term_retention_policies_list_by_database_request, + build_maintenance_window_options_get_request, + build_maintenance_windows_create_or_update_request, + build_maintenance_windows_get_request, + build_managed_backup_short_term_retention_policies_create_or_update_request, + build_managed_backup_short_term_retention_policies_get_request, + build_managed_backup_short_term_retention_policies_list_by_database_request, + build_managed_backup_short_term_retention_policies_update_request, + build_managed_database_advanced_threat_protection_settings_create_or_update_request, + build_managed_database_advanced_threat_protection_settings_get_request, + build_managed_database_advanced_threat_protection_settings_list_by_database_request, + build_managed_database_columns_get_request, + build_managed_database_columns_list_by_database_request, + build_managed_database_columns_list_by_table_request, + build_managed_database_move_operations_get_request, + build_managed_database_move_operations_list_by_location_request, + build_managed_database_queries_get_request, + build_managed_database_queries_list_by_query_request, + build_managed_database_recommended_sensitivity_labels_update_request, + build_managed_database_restore_details_get_request, + build_managed_database_schemas_get_request, + build_managed_database_schemas_list_by_database_request, + build_managed_database_security_alert_policies_create_or_update_request, + build_managed_database_security_alert_policies_get_request, + build_managed_database_security_alert_policies_list_by_database_request, + build_managed_database_security_events_list_by_database_request, + build_managed_database_sensitivity_labels_create_or_update_request, + build_managed_database_sensitivity_labels_delete_request, + build_managed_database_sensitivity_labels_disable_recommendation_request, + build_managed_database_sensitivity_labels_enable_recommendation_request, + build_managed_database_sensitivity_labels_get_request, + build_managed_database_sensitivity_labels_list_by_database_request, + build_managed_database_sensitivity_labels_list_current_by_database_request, + build_managed_database_sensitivity_labels_list_recommended_by_database_request, + build_managed_database_sensitivity_labels_update_request, + build_managed_database_tables_get_request, + build_managed_database_tables_list_by_schema_request, + build_managed_database_transparent_data_encryption_create_or_update_request, + build_managed_database_transparent_data_encryption_get_request, + build_managed_database_transparent_data_encryption_list_by_database_request, + build_managed_database_vulnerability_assessment_rule_baselines_create_or_update_request, + build_managed_database_vulnerability_assessment_rule_baselines_delete_request, + build_managed_database_vulnerability_assessment_rule_baselines_get_request, + build_managed_database_vulnerability_assessment_scans_export_request, + build_managed_database_vulnerability_assessment_scans_get_request, + build_managed_database_vulnerability_assessment_scans_initiate_scan_request, + build_managed_database_vulnerability_assessment_scans_list_by_database_request, + build_managed_database_vulnerability_assessments_create_or_update_request, + build_managed_database_vulnerability_assessments_delete_request, + build_managed_database_vulnerability_assessments_get_request, + build_managed_database_vulnerability_assessments_list_by_database_request, + build_managed_databases_cancel_move_request, + build_managed_databases_complete_move_request, + build_managed_databases_complete_restore_request, + build_managed_databases_create_or_update_request, + build_managed_databases_delete_request, + build_managed_databases_get_request, + build_managed_databases_list_by_instance_request, + build_managed_databases_list_inaccessible_by_instance_request, + build_managed_databases_reevaluate_inaccessible_database_state_request, + build_managed_databases_start_move_request, + build_managed_databases_update_request, + build_managed_instance_administrators_create_or_update_request, + build_managed_instance_administrators_delete_request, + build_managed_instance_administrators_get_request, + build_managed_instance_administrators_list_by_instance_request, + build_managed_instance_advanced_threat_protection_settings_create_or_update_request, + build_managed_instance_advanced_threat_protection_settings_get_request, + build_managed_instance_advanced_threat_protection_settings_list_by_instance_request, + build_managed_instance_azure_ad_only_authentications_create_or_update_request, + build_managed_instance_azure_ad_only_authentications_delete_request, + build_managed_instance_azure_ad_only_authentications_get_request, + build_managed_instance_azure_ad_only_authentications_list_by_instance_request, + build_managed_instance_dtcs_create_or_update_request, + build_managed_instance_dtcs_get_request, + build_managed_instance_dtcs_list_by_managed_instance_request, + build_managed_instance_encryption_protectors_create_or_update_request, + build_managed_instance_encryption_protectors_get_request, + build_managed_instance_encryption_protectors_list_by_instance_request, + build_managed_instance_encryption_protectors_revalidate_request, + build_managed_instance_keys_create_or_update_request, + build_managed_instance_keys_delete_request, + build_managed_instance_keys_get_request, + build_managed_instance_keys_list_by_instance_request, + build_managed_instance_long_term_retention_policies_create_or_update_request, + build_managed_instance_long_term_retention_policies_delete_request, + build_managed_instance_long_term_retention_policies_get_request, + build_managed_instance_long_term_retention_policies_list_by_database_request, + build_managed_instance_operations_cancel_request, + build_managed_instance_operations_get_request, + build_managed_instance_operations_list_by_managed_instance_request, + build_managed_instance_private_endpoint_connections_create_or_update_request, + build_managed_instance_private_endpoint_connections_delete_request, + build_managed_instance_private_endpoint_connections_get_request, + build_managed_instance_private_endpoint_connections_list_by_managed_instance_request, + build_managed_instance_private_link_resources_get_request, + build_managed_instance_private_link_resources_list_by_managed_instance_request, + build_managed_instance_tde_certificates_create_request, + build_managed_instance_vulnerability_assessments_create_or_update_request, + build_managed_instance_vulnerability_assessments_delete_request, + build_managed_instance_vulnerability_assessments_get_request, + build_managed_instance_vulnerability_assessments_list_by_instance_request, + build_managed_instances_create_or_update_request, + build_managed_instances_delete_request, + build_managed_instances_failover_request, + build_managed_instances_get_request, + build_managed_instances_list_by_instance_pool_request, + build_managed_instances_list_by_managed_instance_request, + build_managed_instances_list_by_resource_group_request, + build_managed_instances_list_outbound_network_dependencies_by_managed_instance_request, + build_managed_instances_list_request, + build_managed_instances_reevaluate_inaccessible_database_state_request, + build_managed_instances_refresh_status_request, + build_managed_instances_start_request, + build_managed_instances_stop_request, + build_managed_instances_update_request, + build_managed_instances_validate_azure_key_vault_encryption_key_request, + build_managed_ledger_digest_uploads_create_or_update_request, + build_managed_ledger_digest_uploads_disable_request, + build_managed_ledger_digest_uploads_get_request, + build_managed_ledger_digest_uploads_list_by_database_request, + build_managed_restorable_dropped_database_backup_short_term_retention_policies_create_or_update_request, + build_managed_restorable_dropped_database_backup_short_term_retention_policies_get_request, + build_managed_restorable_dropped_database_backup_short_term_retention_policies_list_by_restorable_dropped_database_request, + build_managed_restorable_dropped_database_backup_short_term_retention_policies_update_request, + build_managed_server_dns_aliases_acquire_request, + build_managed_server_dns_aliases_create_or_update_request, + build_managed_server_dns_aliases_delete_request, + build_managed_server_dns_aliases_get_request, + build_managed_server_dns_aliases_list_by_managed_instance_request, + build_managed_server_security_alert_policies_create_or_update_request, + build_managed_server_security_alert_policies_get_request, + build_managed_server_security_alert_policies_list_by_instance_request, + build_network_security_perimeter_configurations_get_request, + build_network_security_perimeter_configurations_list_by_server_request, + build_network_security_perimeter_configurations_reconcile_request, + build_operations_list_request, + build_outbound_firewall_rules_create_or_update_request, + build_outbound_firewall_rules_delete_request, + build_outbound_firewall_rules_get_request, + build_outbound_firewall_rules_list_by_server_request, + build_private_endpoint_connections_create_or_update_request, + build_private_endpoint_connections_delete_request, + build_private_endpoint_connections_get_request, + build_private_endpoint_connections_list_by_server_request, + build_private_link_resources_get_request, + build_private_link_resources_list_by_server_request, + build_recommended_sensitivity_labels_update_request, + build_recoverable_databases_get_request, + build_recoverable_databases_list_by_server_request, + build_recoverable_managed_databases_get_request, + build_recoverable_managed_databases_list_by_instance_request, + build_replication_links_create_or_update_request, + build_replication_links_delete_request, + build_replication_links_failover_allow_data_loss_request, + build_replication_links_failover_request, + build_replication_links_get_request, + build_replication_links_list_by_database_request, + build_replication_links_list_by_server_request, + build_replication_links_update_request, + build_restorable_dropped_databases_get_request, + build_restorable_dropped_databases_list_by_server_request, + build_restorable_dropped_managed_databases_get_request, + build_restorable_dropped_managed_databases_list_by_instance_request, + build_restore_points_create_request, + build_restore_points_delete_request, + build_restore_points_get_request, + build_restore_points_list_by_database_request, + build_sensitivity_labels_create_or_update_request, + build_sensitivity_labels_delete_request, + build_sensitivity_labels_disable_recommendation_request, + build_sensitivity_labels_enable_recommendation_request, + build_sensitivity_labels_get_request, + build_sensitivity_labels_list_by_database_request, + build_sensitivity_labels_list_current_by_database_request, + build_sensitivity_labels_list_recommended_by_database_request, + build_sensitivity_labels_update_request, + build_server_advanced_threat_protection_settings_create_or_update_request, + build_server_advanced_threat_protection_settings_get_request, + build_server_advanced_threat_protection_settings_list_by_server_request, + build_server_advisors_get_request, + build_server_advisors_list_by_server_request, + build_server_advisors_update_request, + build_server_automatic_tuning_get_request, + build_server_automatic_tuning_update_request, + build_server_azure_ad_administrators_create_or_update_request, + build_server_azure_ad_administrators_delete_request, + build_server_azure_ad_administrators_get_request, + build_server_azure_ad_administrators_list_by_server_request, + build_server_azure_ad_only_authentications_create_or_update_request, + build_server_azure_ad_only_authentications_delete_request, + build_server_azure_ad_only_authentications_get_request, + build_server_azure_ad_only_authentications_list_by_server_request, + build_server_blob_auditing_policies_create_or_update_request, + build_server_blob_auditing_policies_get_request, + build_server_blob_auditing_policies_list_by_server_request, + build_server_configuration_options_create_or_update_request, + build_server_configuration_options_get_request, + build_server_configuration_options_list_by_managed_instance_request, + build_server_connection_policies_create_or_update_request, + build_server_connection_policies_get_request, + build_server_connection_policies_list_by_server_request, + build_server_dev_ops_audit_settings_create_or_update_request, + build_server_dev_ops_audit_settings_get_request, + build_server_dev_ops_audit_settings_list_by_server_request, + build_server_dns_aliases_acquire_request, + build_server_dns_aliases_create_or_update_request, + build_server_dns_aliases_delete_request, + build_server_dns_aliases_get_request, + build_server_dns_aliases_list_by_server_request, + build_server_keys_create_or_update_request, + build_server_keys_delete_request, + build_server_keys_get_request, + build_server_keys_list_by_server_request, + build_server_operations_list_by_server_request, + build_server_security_alert_policies_create_or_update_request, + build_server_security_alert_policies_get_request, + build_server_security_alert_policies_list_by_server_request, + build_server_trust_certificates_create_or_update_request, + build_server_trust_certificates_delete_request, + build_server_trust_certificates_get_request, + build_server_trust_certificates_list_by_instance_request, + build_server_trust_groups_create_or_update_request, + build_server_trust_groups_delete_request, + build_server_trust_groups_get_request, + build_server_trust_groups_list_by_instance_request, + build_server_trust_groups_list_by_location_request, + build_server_usages_list_by_server_request, + build_server_vulnerability_assessments_create_or_update_request, + build_server_vulnerability_assessments_delete_request, + build_server_vulnerability_assessments_get_request, + build_server_vulnerability_assessments_list_by_server_request, + build_servers_check_name_availability_request, + build_servers_create_or_update_request, + build_servers_delete_request, + build_servers_get_request, + build_servers_import_database_request, + build_servers_list_by_resource_group_request, + build_servers_list_request, + build_servers_refresh_status_request, + build_servers_update_request, + build_sql_agent_create_or_update_request, + build_sql_agent_get_request, + build_sql_vulnerability_assessment_baseline_get_request, + build_sql_vulnerability_assessment_baseline_list_by_sql_vulnerability_assessment_request, + build_sql_vulnerability_assessment_baselines_create_or_update_request, + build_sql_vulnerability_assessment_execute_scan_execute_request, + build_sql_vulnerability_assessment_rule_baseline_create_or_update_request, + build_sql_vulnerability_assessment_rule_baseline_get_request, + build_sql_vulnerability_assessment_rule_baseline_list_by_baseline_request, + build_sql_vulnerability_assessment_rule_baselines_delete_request, + build_sql_vulnerability_assessment_scan_result_get_request, + build_sql_vulnerability_assessment_scan_result_list_by_scan_request, + build_sql_vulnerability_assessment_scans_get_request, + build_sql_vulnerability_assessment_scans_list_by_sql_vulnerability_assessments_request, + build_sql_vulnerability_assessments_delete_request, + build_sql_vulnerability_assessments_settings_create_or_update_request, + build_sql_vulnerability_assessments_settings_get_request, + build_sql_vulnerability_assessments_settings_list_by_server_request, + build_start_stop_managed_instance_schedules_create_or_update_request, + build_start_stop_managed_instance_schedules_delete_request, + build_start_stop_managed_instance_schedules_get_request, + build_start_stop_managed_instance_schedules_list_by_instance_request, + build_subscription_usages_get_request, + build_subscription_usages_list_by_location_request, + build_synapse_link_workspaces_list_by_database_request, + build_sync_agents_create_or_update_request, + build_sync_agents_delete_request, + build_sync_agents_generate_key_request, + build_sync_agents_get_request, + build_sync_agents_list_by_server_request, + build_sync_agents_list_linked_databases_request, + build_sync_groups_cancel_sync_request, + build_sync_groups_create_or_update_request, + build_sync_groups_delete_request, + build_sync_groups_get_request, + build_sync_groups_list_by_database_request, + build_sync_groups_list_hub_schemas_request, + build_sync_groups_list_logs_request, + build_sync_groups_list_sync_database_ids_request, + build_sync_groups_refresh_hub_schema_request, + build_sync_groups_trigger_sync_request, + build_sync_groups_update_request, + build_sync_members_create_or_update_request, + build_sync_members_delete_request, + build_sync_members_get_request, + build_sync_members_list_by_sync_group_request, + build_sync_members_list_member_schemas_request, + build_sync_members_refresh_member_schema_request, + build_sync_members_update_request, + build_tde_certificates_create_request, + build_time_zones_get_request, + build_time_zones_list_by_location_request, + build_transparent_data_encryptions_create_or_update_request, + build_transparent_data_encryptions_get_request, + build_transparent_data_encryptions_list_by_database_request, + build_transparent_data_encryptions_resume_request, + build_transparent_data_encryptions_suspend_request, + build_usages_list_by_instance_pool_request, + build_virtual_clusters_create_or_update_request, + build_virtual_clusters_delete_request, + build_virtual_clusters_get_request, + build_virtual_clusters_list_by_resource_group_request, + build_virtual_clusters_list_request, + build_virtual_clusters_update_dns_servers_request, + build_virtual_clusters_update_request, + build_virtual_network_rules_create_or_update_request, + build_virtual_network_rules_delete_request, + build_virtual_network_rules_get_request, + build_virtual_network_rules_list_by_server_request, + build_workload_classifiers_create_or_update_request, + build_workload_classifiers_delete_request, + build_workload_classifiers_get_request, + build_workload_classifiers_list_by_workload_group_request, + build_workload_groups_create_or_update_request, + build_workload_groups_delete_request, + build_workload_groups_get_request, + build_workload_groups_list_by_database_request, +) from .._configuration import SqlManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +JSON = MutableMapping[str, Any] List = list @@ -44,8 +603,6 @@ class Operations: :attr:`operations` attribute. """ - models = _models - def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") @@ -57,15 +614,751 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Operation"]: """Lists all of the available SQL Rest API operations. - :return: An iterator like instance of either Operation or the result of cls(response) + :return: An iterator like instance of Operation :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Operation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_operations_list_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Operation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class BackupShortTermRetentionPoliciesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`backup_short_term_retention_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + policy_name: Union[str, _models.ShortTermRetentionPolicyName], + **kwargs: Any + ) -> _models.BackupShortTermRetentionPolicy: + """Gets a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 policy_name: The policy name. Should always be default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ShortTermRetentionPolicyName + :return: BackupShortTermRetentionPolicy. The BackupShortTermRetentionPolicy is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.BackupShortTermRetentionPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.BackupShortTermRetentionPolicy] = kwargs.pop("cls", None) + + _request = build_backup_short_term_retention_policies_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.BackupShortTermRetentionPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.ShortTermRetentionPolicyName], + parameters: Union[_models.BackupShortTermRetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_backup_short_term_retention_policies_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.ShortTermRetentionPolicyName], + parameters: _models.BackupShortTermRetentionPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupShortTermRetentionPolicy]: + """Updates a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 policy_name: The policy name. Should always be default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: ~azure.mgmt.sql.models.BackupShortTermRetentionPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns BackupShortTermRetentionPolicy. The + BackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.ShortTermRetentionPolicyName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupShortTermRetentionPolicy]: + """Updates a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 policy_name: The policy name. Should always be default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns BackupShortTermRetentionPolicy. The + BackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.ShortTermRetentionPolicyName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupShortTermRetentionPolicy]: + """Updates a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 policy_name: The policy name. Should always be default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns BackupShortTermRetentionPolicy. The + BackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.ShortTermRetentionPolicyName], + parameters: Union[_models.BackupShortTermRetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupShortTermRetentionPolicy]: + """Updates a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 policy_name: The policy name. Should always be default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Is one of the following types: + BackupShortTermRetentionPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.BackupShortTermRetentionPolicy or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns BackupShortTermRetentionPolicy. The + BackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + policy_name=policy_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.BackupShortTermRetentionPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.BackupShortTermRetentionPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.BackupShortTermRetentionPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.ShortTermRetentionPolicyName], + parameters: Union[_models.BackupShortTermRetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_backup_short_term_retention_policies_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.ShortTermRetentionPolicyName], + parameters: _models.BackupShortTermRetentionPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupShortTermRetentionPolicy]: + """Updates a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 policy_name: The policy name. Should always be default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: ~azure.mgmt.sql.models.BackupShortTermRetentionPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns BackupShortTermRetentionPolicy. The + BackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.ShortTermRetentionPolicyName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupShortTermRetentionPolicy]: + """Updates a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 policy_name: The policy name. Should always be default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns BackupShortTermRetentionPolicy. The + BackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.ShortTermRetentionPolicyName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupShortTermRetentionPolicy]: + """Updates a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 policy_name: The policy name. Should always be default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns BackupShortTermRetentionPolicy. The + BackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.ShortTermRetentionPolicyName], + parameters: Union[_models.BackupShortTermRetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupShortTermRetentionPolicy]: + """Updates a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 policy_name: The policy name. Should always be default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Is one of the following types: + BackupShortTermRetentionPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.BackupShortTermRetentionPolicy or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns BackupShortTermRetentionPolicy. The + BackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + policy_name=policy_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.BackupShortTermRetentionPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.BackupShortTermRetentionPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.BackupShortTermRetentionPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.BackupShortTermRetentionPolicy"]: + """Gets a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of BackupShortTermRetentionPolicy + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + cls: ClsType[List[_models.BackupShortTermRetentionPolicy]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -78,25 +1371,53 @@ def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - _request = build_list_request( - api_version=api_version, + _request = build_backup_short_term_retention_policies_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=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("OperationListResult", pipeline_response) - list_of_elem = deserialized.value + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.BackupShortTermRetentionPolicy], + deserialized.get("value", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -109,8 +1430,74803 @@ async def get_next(next_link=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) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) + + +class DatabaseColumnsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`database_columns` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + schema_name: str, + table_name: str, + column_name: str, + **kwargs: Any + ) -> _models.DatabaseColumn: + """Get database column. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: DatabaseColumn. The DatabaseColumn is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseColumn + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseColumn] = kwargs.pop("cls", None) + + _request = build_database_columns_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, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseColumn, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_table( + self, + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + *, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.DatabaseColumn"]: + """List database columns. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :keyword filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of DatabaseColumn + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseColumn] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseColumn]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_database_columns_list_by_table_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseColumn], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_database( + self, + resource_group_name: str, + server_name: str, + database_name: str, + *, + schema: Optional[List[str]] = None, + table: Optional[List[str]] = None, + column: Optional[List[str]] = None, + order_by: Optional[List[str]] = None, + skiptoken: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.DatabaseColumn"]: + """List database columns. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 schema: Default value is None. + :paramtype schema: list[str] + :keyword table: Default value is None. + :paramtype table: list[str] + :keyword column: Default value is None. + :paramtype column: list[str] + :keyword order_by: Default value is None. + :paramtype order_by: list[str] + :keyword skiptoken: An opaque token that identifies a starting point in the collection. Default + value is None. + :paramtype skiptoken: str + :return: An iterator like instance of DatabaseColumn + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseColumn] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseColumn]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_database_columns_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + schema=schema, + table=table, + column=column, + order_by=order_by, + skiptoken=skiptoken, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseColumn], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class RestorePointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`restore_points` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, restore_point_name: str, **kwargs: Any + ) -> _models.RestorePoint: + """Gets a restore point. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 restore_point_name: The name of the restore point. Required. + :type restore_point_name: str + :return: RestorePoint. The RestorePoint is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.RestorePoint + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RestorePoint] = kwargs.pop("cls", None) + + _request = build_restore_points_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + restore_point_name=restore_point_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RestorePoint, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, resource_group_name: str, server_name: str, database_name: str, restore_point_name: str, **kwargs: Any + ) -> None: + """Deletes a restore point. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 restore_point_name: The name of the restore point. Required. + :type restore_point_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_restore_points_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + restore_point_name=restore_point_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.RestorePoint"]: + """Gets a list of database restore points. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of RestorePoint + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.RestorePoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RestorePoint]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_restore_points_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RestorePoint], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _create_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.CreateDatabaseRestorePointDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_restore_points_create_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: _models.CreateDatabaseRestorePointDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RestorePoint]: + """Creates a restore point for a data warehouse. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The definition for creating the restore point of this database. Required. + :type parameters: ~azure.mgmt.sql.models.CreateDatabaseRestorePointDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns RestorePoint. The RestorePoint is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.RestorePoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RestorePoint]: + """Creates a restore point for a data warehouse. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The definition for creating the restore point of this database. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns RestorePoint. The RestorePoint is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.RestorePoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RestorePoint]: + """Creates a restore point for a data warehouse. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The definition for creating the restore point of this database. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns RestorePoint. The RestorePoint is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.RestorePoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.CreateDatabaseRestorePointDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.RestorePoint]: + """Creates a restore point for a data warehouse. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The definition for creating the restore point of this database. Is one of + the following types: CreateDatabaseRestorePointDefinition, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.CreateDatabaseRestorePointDefinition or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns RestorePoint. The RestorePoint is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.RestorePoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.RestorePoint, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.RestorePoint].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.RestorePoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class SensitivityLabelsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`sensitivity_labels` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_current_by_database( + self, + resource_group_name: str, + server_name: str, + database_name: str, + *, + skip_token: Optional[str] = None, + count: Optional[bool] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.SensitivityLabel"]: + """Gets the sensitivity labels of a given database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 skip_token: Default value is None. + :paramtype skip_token: str + :keyword count: Default value is None. + :paramtype count: bool + :keyword filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of SensitivityLabel + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SensitivityLabel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SensitivityLabel]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_sensitivity_labels_list_current_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + skip_token=skip_token, + count=count, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SensitivityLabel], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @overload + async def update( + self, + resource_group_name: str, + server_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. The name is case insensitive. + Required. + :type resource_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 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 + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: JSON, + *, + 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. The name is case insensitive. + Required. + :type resource_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 parameters: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: IO[bytes], + *, + 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. The name is case insensitive. + Required. + :type resource_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 parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.SensitivityLabelUpdateList, JSON, IO[bytes]], + **kwargs: Any + ) -> None: + """Update sensitivity labels of a given database using an operations batch. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: Is one of the following types: SensitivityLabelUpdateList, JSON, IO[bytes] + Required. + :type parameters: ~azure.mgmt.sql.models.SensitivityLabelUpdateList or JSON or IO[bytes] + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_sensitivity_labels_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_recommended_by_database( + self, + resource_group_name: str, + server_name: str, + database_name: str, + *, + skip_token: Optional[str] = None, + include_disabled_recommendations: Optional[bool] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.SensitivityLabel"]: + """Gets the sensitivity labels of a given database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 skip_token: Default value is None. + :paramtype skip_token: str + :keyword include_disabled_recommendations: Specifies whether to include disabled + recommendations or not. Default value is None. + :paramtype include_disabled_recommendations: bool + :keyword filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of SensitivityLabel + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SensitivityLabel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SensitivityLabel]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_sensitivity_labels_list_recommended_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + skip_token=skip_token, + include_disabled_recommendations=include_disabled_recommendations, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SensitivityLabel], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_database( + self, + resource_group_name: str, + server_name: str, + database_name: str, + *, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.SensitivityLabel"]: + """Gets the sensitivity labels of a given database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of SensitivityLabel + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SensitivityLabel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SensitivityLabel]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_sensitivity_labels_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SensitivityLabel], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + sensitivity_label_source: Union[str, _models.SensitivityLabelSource], + **kwargs: Any + ) -> _models.SensitivityLabel: + """Gets the sensitivity label of a given column. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :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 + :return: SensitivityLabel. The SensitivityLabel is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SensitivityLabel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SensitivityLabel] = kwargs.pop("cls", None) + + _request = build_sensitivity_labels_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SensitivityLabel, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + parameters: _models.SensitivityLabel, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SensitivityLabel: + """Creates or updates the sensitivity label of a given column. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :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 + :return: SensitivityLabel. The SensitivityLabel is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SensitivityLabel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SensitivityLabel: + """Creates or updates the sensitivity label of a given column. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :param parameters: The column sensitivity label resource. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SensitivityLabel. The SensitivityLabel is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SensitivityLabel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SensitivityLabel: + """Creates or updates the sensitivity label of a given column. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :param parameters: The column sensitivity label resource. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SensitivityLabel. The SensitivityLabel is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SensitivityLabel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + parameters: Union[_models.SensitivityLabel, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.SensitivityLabel: + """Creates or updates the sensitivity label of a given column. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :param parameters: The column sensitivity label resource. Is one of the following types: + SensitivityLabel, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.SensitivityLabel or JSON or IO[bytes] + :return: SensitivityLabel. The SensitivityLabel is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SensitivityLabel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_sensitivity_labels_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await 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]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SensitivityLabel, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + **kwargs: Any + ) -> None: + """Deletes the sensitivity label of a given column. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_sensitivity_labels_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def disable_recommendation( + 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. The name is case insensitive. + Required. + :type resource_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 + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_sensitivity_labels_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def enable_recommendation( + 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. The name is case insensitive. + Required. + :type resource_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 + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_sensitivity_labels_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class DatabasesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`databases` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + *, + expand: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> _models.Database: + """Gets a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 expand: The child resources to include in the response. Default value is None. + :paramtype expand: str + :keyword filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: Database. The Database is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Database + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Database] = kwargs.pop("cls", None) + + _request = build_databases_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + expand=expand, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Database, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.Database, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_databases_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: _models.Database, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Database]: + """Creates a new database or updates an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The requested database resource state. Required. + :type parameters: ~azure.mgmt.sql.models.Database + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Database. The Database is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Database]: + """Creates a new database or updates an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The requested database resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Database. The Database is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Database]: + """Creates a new database or updates an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The requested database resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Database. The Database is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.Database, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Database]: + """Creates a new database or updates an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The requested database resource state. Is one of the following types: + Database, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.Database or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Database. The Database is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Database, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Database].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Database]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.DatabaseUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_databases_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: _models.DatabaseUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Database]: + """Updates an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The requested database resource state. Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Database. The Database is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Database]: + """Updates an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The requested database resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Database. The Database is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Database]: + """Updates an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The requested database resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Database. The Database is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.DatabaseUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Database]: + """Updates an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The requested database resource state. Is one of the following types: + DatabaseUpdate, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseUpdate or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Database. The Database is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Database, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Database].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Database]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_databases_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + @api_version_validation( + params_added_on={"2025-02-01-preview": ["top", "skip", "filter", "orderby"]}, + api_versions_list=["2025-01-01", "2025-02-01-preview"], + ) + def list_by_server( + self, + resource_group_name: str, + server_name: str, + *, + top: Optional[int] = None, + skip: Optional[int] = None, + filter: Optional[str] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.Database"]: + """Gets a list of databases. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :keyword top: The number of elements to return from the collection. Default value is None. + :paramtype top: int + :keyword skip: The number of elements in the collection to skip. Default value is None. + :paramtype skip: int + :keyword filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :keyword orderby: How the results should be ordered. Default value is None. + :paramtype orderby: str + :return: An iterator like instance of Database + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Database]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_databases_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + top=top, + skip=skip, + filter=filter, + orderby=orderby, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Database], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _export_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.ExportDatabaseDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_databases_export_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_export( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: _models.ExportDatabaseDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportExportOperationResult]: + """Exports a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The database export request parameters. Required. + :type parameters: ~azure.mgmt.sql.models.ExportDatabaseDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ImportExportOperationResult. The + ImportExportOperationResult is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_export( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportExportOperationResult]: + """Exports a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The database export request parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ImportExportOperationResult. The + ImportExportOperationResult is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_export( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportExportOperationResult]: + """Exports a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The database export request parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ImportExportOperationResult. The + ImportExportOperationResult is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_export( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.ExportDatabaseDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportExportOperationResult]: + """Exports a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The database export request parameters. Is one of the following types: + ExportDatabaseDefinition, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ExportDatabaseDefinition or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ImportExportOperationResult. The + ImportExportOperationResult is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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._export_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ImportExportOperationResult, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ImportExportOperationResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ImportExportOperationResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _failover_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + *, + replica_type: Optional[Union[str, _models.ReplicaType]] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_databases_failover_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + replica_type=replica_type, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_failover( + self, + resource_group_name: str, + server_name: str, + database_name: str, + *, + replica_type: Optional[Union[str, _models.ReplicaType]] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Failovers a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 replica_type: The type of replica to be failed over. Known values are: "Primary" and + "ReadableSecondary". Default value is None. + :paramtype replica_type: str or ~azure.mgmt.sql.models.ReplicaType + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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._failover_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + replica_type=replica_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _import_method_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.ImportExistingDatabaseDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_databases_import_method_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_import_method( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: _models.ImportExistingDatabaseDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportExportOperationResult]: + """Imports a bacpac into a new database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The database import request parameters. Required. + :type parameters: ~azure.mgmt.sql.models.ImportExistingDatabaseDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ImportExportOperationResult. The + ImportExportOperationResult is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_import_method( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportExportOperationResult]: + """Imports a bacpac into a new database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The database import request parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ImportExportOperationResult. The + ImportExportOperationResult is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_import_method( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportExportOperationResult]: + """Imports a bacpac into a new database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The database import request parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ImportExportOperationResult. The + ImportExportOperationResult is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_import_method( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.ImportExistingDatabaseDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportExportOperationResult]: + """Imports a bacpac into a new database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The database import request parameters. Is one of the following types: + ImportExistingDatabaseDefinition, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ImportExistingDatabaseDefinition or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ImportExportOperationResult. The + ImportExportOperationResult is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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._import_method_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ImportExportOperationResult, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ImportExportOperationResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ImportExportOperationResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @overload + async def rename( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: _models.ResourceMoveDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Renames a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The resource move definition for renaming this database. Required. + :type parameters: ~azure.mgmt.sql.models.ResourceMoveDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def rename( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Renames a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The resource move definition for renaming this database. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def rename( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Renames a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The resource move definition for renaming this database. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def rename( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.ResourceMoveDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> None: + """Renames a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The resource move definition for renaming this database. Is one of the + following types: ResourceMoveDefinition, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ResourceMoveDefinition or JSON or IO[bytes] + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_databases_rename_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + async def _pause_initial( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_databases_pause_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_pause( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.Database]: + """Pauses a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An instance of AsyncLROPoller that returns Database. The Database is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._pause_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.Database, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Database].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Database]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _resume_initial( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_databases_resume_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_resume( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.Database]: + """Resumes a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An instance of AsyncLROPoller that returns Database. The Database is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._resume_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.Database, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Database].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Database]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _upgrade_data_warehouse_initial( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_databases_upgrade_data_warehouse_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_upgrade_data_warehouse( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Upgrades a data warehouse. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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._upgrade_data_warehouse_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_inaccessible_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.Database"]: + """Gets a list of inaccessible databases in a logical server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of Database + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Database]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_databases_list_inaccessible_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Database], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_elastic_pool( + self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.Database"]: + """Gets a list of databases in an elastic pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An iterator like instance of Database + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Database]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_databases_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Database], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class FirewallRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`firewall_rules` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: FirewallRule. The FirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.FirewallRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.FirewallRule] = kwargs.pop("cls", None) + + _request = build_firewall_rules_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.FirewallRule, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + parameters: _models.FirewallRule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FirewallRule: + """Creates or updates a firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: FirewallRule. The FirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.FirewallRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FirewallRule: + """Creates or updates a firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: FirewallRule. The FirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.FirewallRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FirewallRule: + """Creates or updates a firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: FirewallRule. The FirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.FirewallRule + :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, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.FirewallRule: + """Creates or updates a firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 one of + the following types: FirewallRule, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.FirewallRule or JSON or IO[bytes] + :return: FirewallRule. The FirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.FirewallRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FirewallRule] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_firewall_rules_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + firewall_rule_name=firewall_rule_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await 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]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.FirewallRule, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(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. The name is case insensitive. + 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 + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_firewall_rules_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await 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) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.FirewallRule"]: + """Gets a list of firewall rules. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of FirewallRule + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.FirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.FirewallRule]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_firewall_rules_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.FirewallRule], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @overload + async def replace( + self, + resource_group_name: str, + server_name: str, + parameters: _models.FirewallRuleList, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.FirewallRule]: + """Replaces all firewall rules on the server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: FirewallRule or None. The FirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.FirewallRule or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def replace( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.FirewallRule]: + """Replaces all firewall rules on the server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: FirewallRule or None. The FirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.FirewallRule or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def replace( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.FirewallRule]: + """Replaces all firewall rules on the server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: FirewallRule or None. The FirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.FirewallRule or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def replace( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.FirewallRuleList, JSON, IO[bytes]], + **kwargs: Any + ) -> Optional[_models.FirewallRule]: + """Replaces all firewall rules on the server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Is one of the following types: FirewallRuleList, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.FirewallRuleList or JSON or IO[bytes] + :return: FirewallRule or None. The FirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.FirewallRule or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.FirewallRule]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_firewall_rules_replace_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await 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]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.FirewallRule, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class ReplicationLinksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`replication_links` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, link_id: str, **kwargs: Any + ) -> _models.ReplicationLink: + """Gets a replication link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 link_id: The name of the replication link. Required. + :type link_id: str + :return: ReplicationLink. The ReplicationLink is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ReplicationLink + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ReplicationLink] = kwargs.pop("cls", None) + + _request = build_replication_links_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + link_id=link_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ReplicationLink, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + link_id: str, + parameters: Union[_models.ReplicationLink, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_replication_links_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + link_id=link_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + link_id: str, + parameters: _models.ReplicationLink, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ReplicationLink]: + """Updates the replication link type. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 link_id: The name of the replication link. Required. + :type link_id: str + :param parameters: Required. + :type parameters: ~azure.mgmt.sql.models.ReplicationLink + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ReplicationLink. The ReplicationLink is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ReplicationLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + link_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ReplicationLink]: + """Updates the replication link type. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 link_id: The name of the replication link. Required. + :type link_id: str + :param parameters: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ReplicationLink. The ReplicationLink is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ReplicationLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + link_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ReplicationLink]: + """Updates the replication link type. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 link_id: The name of the replication link. Required. + :type link_id: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ReplicationLink. The ReplicationLink is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ReplicationLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + link_id: str, + parameters: Union[_models.ReplicationLink, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ReplicationLink]: + """Updates the replication link type. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 link_id: The name of the replication link. Required. + :type link_id: str + :param parameters: Is one of the following types: ReplicationLink, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ReplicationLink or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ReplicationLink. The ReplicationLink is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ReplicationLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + 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) + 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, + link_id=link_id, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ReplicationLink, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ReplicationLink].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ReplicationLink]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + link_id: str, + parameters: Union[_models.ReplicationLinkUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_replication_links_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + link_id=link_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + link_id: str, + parameters: _models.ReplicationLinkUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ReplicationLink]: + """Updates the replication link type. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 link_id: The name of the replication link. Required. + :type link_id: str + :param parameters: Required. + :type parameters: ~azure.mgmt.sql.models.ReplicationLinkUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ReplicationLink. The ReplicationLink is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ReplicationLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + link_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ReplicationLink]: + """Updates the replication link type. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 link_id: The name of the replication link. Required. + :type link_id: str + :param parameters: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ReplicationLink. The ReplicationLink is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ReplicationLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + link_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ReplicationLink]: + """Updates the replication link type. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 link_id: The name of the replication link. Required. + :type link_id: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ReplicationLink. The ReplicationLink is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ReplicationLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + link_id: str, + parameters: Union[_models.ReplicationLinkUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ReplicationLink]: + """Updates the replication link type. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 link_id: The name of the replication link. Required. + :type link_id: str + :param parameters: Is one of the following types: ReplicationLinkUpdate, JSON, IO[bytes] + Required. + :type parameters: ~azure.mgmt.sql.models.ReplicationLinkUpdate or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ReplicationLink. The ReplicationLink is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ReplicationLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + 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) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + link_id=link_id, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ReplicationLink, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ReplicationLink].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ReplicationLink]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, server_name: str, database_name: str, link_id: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_replication_links_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + link_id=link_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, server_name: str, database_name: str, link_id: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the replication link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 link_id: The name of the replication link. Required. + :type link_id: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + link_id=link_id, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ReplicationLink"]: + """Gets a list of replication links on database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of ReplicationLink + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ReplicationLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ReplicationLink]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_replication_links_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ReplicationLink], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _failover_initial( + self, resource_group_name: str, server_name: str, database_name: str, link_id: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_replication_links_failover_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + link_id=link_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_failover( + self, resource_group_name: str, server_name: str, database_name: str, link_id: str, **kwargs: Any + ) -> AsyncLROPoller[_models.ReplicationLink]: + """Fails over from the current primary server to this server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 link_id: The name of the replication link. Required. + :type link_id: str + :return: An instance of AsyncLROPoller that returns ReplicationLink. The ReplicationLink is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ReplicationLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._failover_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + link_id=link_id, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ReplicationLink, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ReplicationLink].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ReplicationLink]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _failover_allow_data_loss_initial( + self, resource_group_name: str, server_name: str, database_name: str, link_id: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_replication_links_failover_allow_data_loss_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + link_id=link_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_failover_allow_data_loss( + self, resource_group_name: str, server_name: str, database_name: str, link_id: str, **kwargs: Any + ) -> AsyncLROPoller[_models.ReplicationLink]: + """Fails over from the current primary server to this server allowing data loss. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 link_id: The name of the replication link. Required. + :type link_id: str + :return: An instance of AsyncLROPoller that returns ReplicationLink. The ReplicationLink is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ReplicationLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._failover_allow_data_loss_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + link_id=link_id, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ReplicationLink, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ReplicationLink].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ReplicationLink]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ReplicationLink"]: + """Gets a list of replication links. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of ReplicationLink + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ReplicationLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ReplicationLink]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_replication_links_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ReplicationLink], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ServersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`servers` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, *, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Server: + """Gets a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :keyword expand: The child resources to include in the response. Default value is None. + :paramtype expand: str + :return: Server. The Server is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Server + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Server] = kwargs.pop("cls", None) + + _request = build_servers_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Server, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.Server, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_servers_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + parameters: _models.Server, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Server]: + """Creates or updates a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The requested server resource state. Required. + :type parameters: ~azure.mgmt.sql.models.Server + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Server]: + """Creates or updates a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The requested server resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Server]: + """Creates or updates a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The requested server resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.Server, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Server]: + """Creates or updates a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The requested server resource state. Is one of the following types: Server, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.Server or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Server, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Server].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Server]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_servers_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + parameters: _models.ServerUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Server]: + """Updates a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The requested server resource state. Required. + :type parameters: ~azure.mgmt.sql.models.ServerUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Server]: + """Updates a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The requested server resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Server]: + """Updates a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The requested server resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Server]: + """Updates a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The requested server resource state. Is one of the following types: + ServerUpdate, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ServerUpdate or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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( + resource_group_name=resource_group_name, + server_name=server_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Server, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Server].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Server]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial(self, resource_group_name: str, server_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_servers_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete(self, resource_group_name: str, server_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Deletes a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, *, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.Server"]: + """Gets a list of servers in a resource groups. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword expand: The child resources to include in the response. Default value is None. + :paramtype expand: str + :return: An iterator like instance of Server + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Server]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_servers_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Server], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, *, expand: Optional[str] = None, **kwargs: Any) -> AsyncItemPaged["_models.Server"]: + """Gets a list of all servers in the subscription. + + :keyword expand: The child resources to include in the response. Default value is None. + :paramtype expand: str + :return: An iterator like instance of Server + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Server]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_servers_list_request( + subscription_id=self._config.subscription_id, + expand=expand, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Server], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _import_database_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ImportNewDatabaseDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_servers_import_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_import_database( + self, + resource_group_name: str, + server_name: str, + parameters: _models.ImportNewDatabaseDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportExportOperationResult]: + """Imports a bacpac into a new database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The database import request parameters. Required. + :type parameters: ~azure.mgmt.sql.models.ImportNewDatabaseDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ImportExportOperationResult. The + ImportExportOperationResult is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_import_database( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportExportOperationResult]: + """Imports a bacpac into a new database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The database import request parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ImportExportOperationResult. The + ImportExportOperationResult is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_import_database( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportExportOperationResult]: + """Imports a bacpac into a new database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The database import request parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ImportExportOperationResult. The + ImportExportOperationResult is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_import_database( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ImportNewDatabaseDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportExportOperationResult]: + """Imports a bacpac into a new database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The database import request parameters. Is one of the following types: + ImportNewDatabaseDefinition, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ImportNewDatabaseDefinition or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ImportExportOperationResult. The + ImportExportOperationResult is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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._import_database_initial( + resource_group_name=resource_group_name, + server_name=server_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ImportExportOperationResult, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ImportExportOperationResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ImportExportOperationResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _refresh_status_initial( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_servers_refresh_status_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_refresh_status( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.RefreshExternalGovernanceStatusOperationResult]: + """Refresh external governance enablement status. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An instance of AsyncLROPoller that returns + RefreshExternalGovernanceStatusOperationResult. The + RefreshExternalGovernanceStatusOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.RefreshExternalGovernanceStatusOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + server_name=server_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.RefreshExternalGovernanceStatusOperationResult, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.RefreshExternalGovernanceStatusOperationResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.RefreshExternalGovernanceStatusOperationResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @overload + async def check_name_availability( + self, parameters: _models.CheckNameAvailabilityRequest, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResponse: + """Determines whether a resource can be created with the specified name. + + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.sql.models.CheckNameAvailabilityRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityResponse. The CheckNameAvailabilityResponse is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.CheckNameAvailabilityResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResponse: + """Determines whether a resource can be created with the specified name. + + :param parameters: The request body. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityResponse. The CheckNameAvailabilityResponse is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.CheckNameAvailabilityResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResponse: + """Determines whether a resource can be created with the specified name. + + :param parameters: The request body. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityResponse. The CheckNameAvailabilityResponse is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.CheckNameAvailabilityResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, parameters: Union[_models.CheckNameAvailabilityRequest, JSON, IO[bytes]], **kwargs: Any + ) -> _models.CheckNameAvailabilityResponse: + """Determines whether a resource can be created with the specified name. + + :param parameters: The request body. Is one of the following types: + CheckNameAvailabilityRequest, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.CheckNameAvailabilityRequest or JSON or IO[bytes] + :return: CheckNameAvailabilityResponse. The CheckNameAvailabilityResponse is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.CheckNameAvailabilityResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_servers_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CheckNameAvailabilityResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class ServerBlobAuditingPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`server_blob_auditing_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, **kwargs: Any) -> _models.ServerBlobAuditingPolicy: + """Gets a server's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: ServerBlobAuditingPolicy. The ServerBlobAuditingPolicy is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerBlobAuditingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") + cls: ClsType[_models.ServerBlobAuditingPolicy] = kwargs.pop("cls", None) + + _request = build_server_blob_auditing_policies_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + blob_auditing_policy_name=blob_auditing_policy_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ServerBlobAuditingPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerBlobAuditingPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_server_blob_auditing_policies_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + blob_auditing_policy_name=blob_auditing_policy_name, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + parameters: _models.ServerBlobAuditingPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerBlobAuditingPolicy]: + """Creates or updates a server's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Properties of blob auditing policy. Required. + :type parameters: ~azure.mgmt.sql.models.ServerBlobAuditingPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerBlobAuditingPolicy. The + ServerBlobAuditingPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerBlobAuditingPolicy]: + """Creates or updates a server's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Properties of blob auditing policy. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerBlobAuditingPolicy. The + ServerBlobAuditingPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerBlobAuditingPolicy]: + """Creates or updates a server's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Properties of blob auditing policy. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerBlobAuditingPolicy. The + ServerBlobAuditingPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerBlobAuditingPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerBlobAuditingPolicy]: + """Creates or updates a server's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Properties of blob auditing policy. Is one of the following types: + ServerBlobAuditingPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ServerBlobAuditingPolicy or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ServerBlobAuditingPolicy. The + ServerBlobAuditingPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") + 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) + 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, + parameters=parameters, + blob_auditing_policy_name=blob_auditing_policy_name, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ServerBlobAuditingPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ServerBlobAuditingPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ServerBlobAuditingPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ServerBlobAuditingPolicy"]: + """Lists auditing settings of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of ServerBlobAuditingPolicy + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerBlobAuditingPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_server_blob_auditing_policies_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ServerBlobAuditingPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class DatabaseBlobAuditingPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`database_blob_auditing_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, **kwargs: Any + ) -> _models.DatabaseBlobAuditingPolicy: + """Gets a database's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: DatabaseBlobAuditingPolicy. The DatabaseBlobAuditingPolicy is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseBlobAuditingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") + cls: ClsType[_models.DatabaseBlobAuditingPolicy] = kwargs.pop("cls", None) + + _request = build_database_blob_auditing_policies_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + blob_auditing_policy_name=blob_auditing_policy_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseBlobAuditingPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: _models.DatabaseBlobAuditingPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseBlobAuditingPolicy: + """Creates or updates a database's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The database blob auditing policy. Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseBlobAuditingPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseBlobAuditingPolicy. The DatabaseBlobAuditingPolicy is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseBlobAuditingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseBlobAuditingPolicy: + """Creates or updates a database's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The database blob auditing policy. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseBlobAuditingPolicy. The DatabaseBlobAuditingPolicy is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseBlobAuditingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseBlobAuditingPolicy: + """Creates or updates a database's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The database blob auditing policy. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseBlobAuditingPolicy. The DatabaseBlobAuditingPolicy is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseBlobAuditingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.DatabaseBlobAuditingPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.DatabaseBlobAuditingPolicy: + """Creates or updates a database's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The database blob auditing policy. Is one of the following types: + DatabaseBlobAuditingPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseBlobAuditingPolicy or JSON or IO[bytes] + :return: DatabaseBlobAuditingPolicy. The DatabaseBlobAuditingPolicy is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseBlobAuditingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_database_blob_auditing_policies_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + blob_auditing_policy_name=blob_auditing_policy_name, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await 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]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseBlobAuditingPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.DatabaseBlobAuditingPolicy"]: + """Lists auditing settings of a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of DatabaseBlobAuditingPolicy + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseBlobAuditingPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_database_blob_auditing_policies_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseBlobAuditingPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ExtendedDatabaseBlobAuditingPoliciesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`extended_database_blob_auditing_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, **kwargs: Any + ) -> _models.ExtendedDatabaseBlobAuditingPolicy: + """Gets an extended database's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: ExtendedDatabaseBlobAuditingPolicy. The ExtendedDatabaseBlobAuditingPolicy is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") + cls: ClsType[_models.ExtendedDatabaseBlobAuditingPolicy] = kwargs.pop("cls", None) + + _request = build_extended_database_blob_auditing_policies_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + blob_auditing_policy_name=blob_auditing_policy_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ExtendedDatabaseBlobAuditingPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: _models.ExtendedDatabaseBlobAuditingPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ExtendedDatabaseBlobAuditingPolicy: + """Creates or updates an extended database's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The extended database blob auditing policy. Required. + :type parameters: ~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ExtendedDatabaseBlobAuditingPolicy. The ExtendedDatabaseBlobAuditingPolicy is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ExtendedDatabaseBlobAuditingPolicy: + """Creates or updates an extended database's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The extended database blob auditing policy. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ExtendedDatabaseBlobAuditingPolicy. The ExtendedDatabaseBlobAuditingPolicy is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ExtendedDatabaseBlobAuditingPolicy: + """Creates or updates an extended database's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The extended database blob auditing policy. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ExtendedDatabaseBlobAuditingPolicy. The ExtendedDatabaseBlobAuditingPolicy is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.ExtendedDatabaseBlobAuditingPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ExtendedDatabaseBlobAuditingPolicy: + """Creates or updates an extended database's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The extended database blob auditing policy. Is one of the following types: + ExtendedDatabaseBlobAuditingPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicy or JSON or + IO[bytes] + :return: ExtendedDatabaseBlobAuditingPolicy. The ExtendedDatabaseBlobAuditingPolicy is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_extended_database_blob_auditing_policies_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + blob_auditing_policy_name=blob_auditing_policy_name, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await 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]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ExtendedDatabaseBlobAuditingPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ExtendedDatabaseBlobAuditingPolicy"]: + """Lists extended auditing settings of a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of ExtendedDatabaseBlobAuditingPolicy + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ExtendedDatabaseBlobAuditingPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_extended_database_blob_auditing_policies_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ExtendedDatabaseBlobAuditingPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ExtendedServerBlobAuditingPoliciesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`extended_server_blob_auditing_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, **kwargs: Any + ) -> _models.ExtendedServerBlobAuditingPolicy: + """Gets an extended server's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: ExtendedServerBlobAuditingPolicy. The ExtendedServerBlobAuditingPolicy is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") + cls: ClsType[_models.ExtendedServerBlobAuditingPolicy] = kwargs.pop("cls", None) + + _request = build_extended_server_blob_auditing_policies_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + blob_auditing_policy_name=blob_auditing_policy_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ExtendedServerBlobAuditingPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ExtendedServerBlobAuditingPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_extended_server_blob_auditing_policies_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + blob_auditing_policy_name=blob_auditing_policy_name, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + parameters: _models.ExtendedServerBlobAuditingPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ExtendedServerBlobAuditingPolicy]: + """Creates or updates an extended server's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Properties of extended blob auditing policy. Required. + :type parameters: ~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ExtendedServerBlobAuditingPolicy. The + ExtendedServerBlobAuditingPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ExtendedServerBlobAuditingPolicy]: + """Creates or updates an extended server's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Properties of extended blob auditing policy. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ExtendedServerBlobAuditingPolicy. The + ExtendedServerBlobAuditingPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ExtendedServerBlobAuditingPolicy]: + """Creates or updates an extended server's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Properties of extended blob auditing policy. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ExtendedServerBlobAuditingPolicy. The + ExtendedServerBlobAuditingPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ExtendedServerBlobAuditingPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ExtendedServerBlobAuditingPolicy]: + """Creates or updates an extended server's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Properties of extended blob auditing policy. Is one of the following types: + ExtendedServerBlobAuditingPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ExtendedServerBlobAuditingPolicy. The + ExtendedServerBlobAuditingPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") + 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) + 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, + parameters=parameters, + blob_auditing_policy_name=blob_auditing_policy_name, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ExtendedServerBlobAuditingPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ExtendedServerBlobAuditingPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ExtendedServerBlobAuditingPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ExtendedServerBlobAuditingPolicy"]: + """Lists extended auditing settings of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of ExtendedServerBlobAuditingPolicy + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ExtendedServerBlobAuditingPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_extended_server_blob_auditing_policies_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ExtendedServerBlobAuditingPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ServerAdvisorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`server_advisors` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, advisor_name: str, **kwargs: Any + ) -> _models.Advisor: + """Gets a server advisor. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param advisor_name: The name of the Server Advisor. Required. + :type advisor_name: str + :return: Advisor. The Advisor is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Advisor + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Advisor] = kwargs.pop("cls", None) + + _request = build_server_advisors_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + advisor_name=advisor_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Advisor, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + server_name: str, + advisor_name: str, + parameters: _models.Advisor, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Advisor: + """Updates a server advisor. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param advisor_name: The name of the Server Advisor. Required. + :type advisor_name: str + :param parameters: The requested advisor resource state. Required. + :type parameters: ~azure.mgmt.sql.models.Advisor + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Advisor. The Advisor is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Advisor + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + server_name: str, + advisor_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Advisor: + """Updates a server advisor. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param advisor_name: The name of the Server Advisor. Required. + :type advisor_name: str + :param parameters: The requested advisor resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Advisor. The Advisor is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Advisor + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + server_name: str, + advisor_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Advisor: + """Updates a server advisor. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param advisor_name: The name of the Server Advisor. Required. + :type advisor_name: str + :param parameters: The requested advisor resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Advisor. The Advisor is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Advisor + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + server_name: str, + advisor_name: str, + parameters: Union[_models.Advisor, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.Advisor: + """Updates a server advisor. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param advisor_name: The name of the Server Advisor. Required. + :type advisor_name: str + :param parameters: The requested advisor resource state. Is one of the following types: + Advisor, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.Advisor or JSON or IO[bytes] + :return: Advisor. The Advisor is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Advisor + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_server_advisors_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + advisor_name=advisor_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Advisor, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def list_by_server( + self, resource_group_name: str, server_name: str, *, expand: Optional[str] = None, **kwargs: Any + ) -> List[_models.Advisor]: + """Gets a list of server advisors. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :keyword expand: The child resources to include in the response. Default value is None. + :paramtype expand: str + :return: list of Advisor + :rtype: list[~azure.mgmt.sql.models.Advisor] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Advisor]] = kwargs.pop("cls", None) + + _request = build_server_advisors_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(List[_models.Advisor], response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class ManagedDatabaseColumnsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_database_columns` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + **kwargs: Any + ) -> _models.DatabaseColumn: + """Get managed database column. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: DatabaseColumn. The DatabaseColumn is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseColumn + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseColumn] = kwargs.pop("cls", None) + + _request = build_managed_database_columns_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + column_name=column_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseColumn, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_table( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + *, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.DatabaseColumn"]: + """List managed database columns. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :keyword filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of DatabaseColumn + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseColumn] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseColumn]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_database_columns_list_by_table_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseColumn], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_database( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + *, + schema: Optional[List[str]] = None, + table: Optional[List[str]] = None, + column: Optional[List[str]] = None, + order_by: Optional[List[str]] = None, + skiptoken: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.DatabaseColumn"]: + """List managed database columns. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 schema: Default value is None. + :paramtype schema: list[str] + :keyword table: Default value is None. + :paramtype table: list[str] + :keyword column: Default value is None. + :paramtype column: list[str] + :keyword order_by: Default value is None. + :paramtype order_by: list[str] + :keyword skiptoken: An opaque token that identifies a starting point in the collection. Default + value is None. + :paramtype skiptoken: str + :return: An iterator like instance of DatabaseColumn + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseColumn] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseColumn]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_database_columns_list_by_database_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + schema=schema, + table=table, + column=column, + order_by=order_by, + skiptoken=skiptoken, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseColumn], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class DatabaseTablesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`database_tables` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + schema_name: str, + table_name: str, + **kwargs: Any + ) -> _models.DatabaseTable: + """Get database table. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: DatabaseTable. The DatabaseTable is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseTable + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseTable] = kwargs.pop("cls", None) + + _request = build_database_tables_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseTable, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_schema( + self, + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + *, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.DatabaseTable"]: + """List database tables. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :keyword filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of DatabaseTable + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseTable] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseTable]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_database_tables_list_by_schema_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + schema_name=schema_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseTable], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ManagedDatabaseTablesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_database_tables` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + **kwargs: Any + ) -> _models.DatabaseTable: + """Get managed database table. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: DatabaseTable. The DatabaseTable is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseTable + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseTable] = kwargs.pop("cls", None) + + _request = build_managed_database_tables_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseTable, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_schema( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + *, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.DatabaseTable"]: + """List managed database tables. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :keyword filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of DatabaseTable + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseTable] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseTable]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_database_tables_list_by_schema_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseTable], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class DatabaseSchemasOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`database_schemas` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, schema_name: str, **kwargs: Any + ) -> _models.DatabaseSchema: + """Get database schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: DatabaseSchema. The DatabaseSchema is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSchema + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseSchema] = kwargs.pop("cls", None) + + _request = build_database_schemas_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + schema_name=schema_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseSchema, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_database( + self, + resource_group_name: str, + server_name: str, + database_name: str, + *, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.DatabaseSchema"]: + """List database schemas. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of DatabaseSchema + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseSchema] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseSchema]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_database_schemas_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseSchema], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ManagedDatabaseSchemasOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_database_schemas` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, managed_instance_name: str, database_name: str, schema_name: str, **kwargs: Any + ) -> _models.DatabaseSchema: + """Get managed database schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: DatabaseSchema. The DatabaseSchema is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSchema + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseSchema] = kwargs.pop("cls", None) + + _request = build_managed_database_schemas_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseSchema, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_database( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + *, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.DatabaseSchema"]: + """List managed database schemas. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of DatabaseSchema + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseSchema] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseSchema]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_database_schemas_list_by_database_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseSchema], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class DatabaseSecurityAlertPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`database_security_alert_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + **kwargs: Any + ) -> _models.DatabaseSecurityAlertPolicy: + """Gets a database's security alert policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 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 + :return: DatabaseSecurityAlertPolicy. The DatabaseSecurityAlertPolicy is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSecurityAlertPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseSecurityAlertPolicy] = kwargs.pop("cls", None) + + _request = build_database_security_alert_policies_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + security_alert_policy_name=security_alert_policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseSecurityAlertPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: _models.DatabaseSecurityAlertPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseSecurityAlertPolicy: + """Creates or updates a database's security alert policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseSecurityAlertPolicy. The DatabaseSecurityAlertPolicy is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSecurityAlertPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseSecurityAlertPolicy: + """Creates or updates a database's security alert policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseSecurityAlertPolicy. The DatabaseSecurityAlertPolicy is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSecurityAlertPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseSecurityAlertPolicy: + """Creates or updates a database's security alert policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 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[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseSecurityAlertPolicy. The DatabaseSecurityAlertPolicy is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSecurityAlertPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: Union[_models.DatabaseSecurityAlertPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.DatabaseSecurityAlertPolicy: + """Creates or updates a database's security alert policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 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 one of the following types: + DatabaseSecurityAlertPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseSecurityAlertPolicy or JSON or IO[bytes] + :return: DatabaseSecurityAlertPolicy. The DatabaseSecurityAlertPolicy is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSecurityAlertPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_database_security_alert_policies_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + security_alert_policy_name=security_alert_policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await 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]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseSecurityAlertPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.DatabaseSecurityAlertPolicy"]: + """Gets a list of database's security alert policies. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of DatabaseSecurityAlertPolicy + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseSecurityAlertPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_database_security_alert_policies_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseSecurityAlertPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class SqlVulnerabilityAssessmentBaselineOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`sql_vulnerability_assessment_baseline` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: + """Gets a list of database's sql vulnerability assessment rule baselines. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :keyword system_database_name: The vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :return: DatabaseSqlVulnerabilityAssessmentBaselineSet. The + DatabaseSqlVulnerabilityAssessmentBaselineSet is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentBaselineSet] = kwargs.pop("cls", None) + + _request = build_sql_vulnerability_assessment_baseline_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + system_database_name=system_database_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseSqlVulnerabilityAssessmentBaselineSet, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_sql_vulnerability_assessment( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any + ) -> AsyncItemPaged["_models.DatabaseSqlVulnerabilityAssessmentBaselineSet"]: + """Gets a list of database's sql vulnerability assessment rule baselines. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 system_database_name: The vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :return: An iterator like instance of DatabaseSqlVulnerabilityAssessmentBaselineSet + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseSqlVulnerabilityAssessmentBaselineSet]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_sql_vulnerability_assessment_baseline_list_by_sql_vulnerability_assessment_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + system_database_name=system_database_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseSqlVulnerabilityAssessmentBaselineSet], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class SqlVulnerabilityAssessmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`sql_vulnerability_assessments` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + **kwargs: Any + ) -> None: + """Removes SQL Vulnerability Assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" + Required. + :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_sql_vulnerability_assessments_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await 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) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class SqlVulnerabilityAssessmentsSettingsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`sql_vulnerability_assessments_settings` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], + **kwargs: Any + ) -> _models.SqlVulnerabilityAssessment: + """Gets SQL Vulnerability Assessment policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" + Required. + :type vulnerability_assessment_name: str or + ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentName + :return: SqlVulnerabilityAssessment. The SqlVulnerabilityAssessment is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SqlVulnerabilityAssessment] = kwargs.pop("cls", None) + + _request = build_sql_vulnerability_assessments_settings_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SqlVulnerabilityAssessment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: _models.SqlVulnerabilityAssessment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SqlVulnerabilityAssessment: + """Creates or updates SQL Vulnerability Assessment policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" + Required. + :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName + :param parameters: The requested resource. Required. + :type parameters: ~azure.mgmt.sql.models.SqlVulnerabilityAssessment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SqlVulnerabilityAssessment. The SqlVulnerabilityAssessment is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SqlVulnerabilityAssessment: + """Creates or updates SQL Vulnerability Assessment policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" + Required. + :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName + :param parameters: The requested resource. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SqlVulnerabilityAssessment. The SqlVulnerabilityAssessment is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SqlVulnerabilityAssessment: + """Creates or updates SQL Vulnerability Assessment policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" + Required. + :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName + :param parameters: The requested resource. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SqlVulnerabilityAssessment. The SqlVulnerabilityAssessment is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: Union[_models.SqlVulnerabilityAssessment, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.SqlVulnerabilityAssessment: + """Creates or updates SQL Vulnerability Assessment policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" + Required. + :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName + :param parameters: The requested resource. Is one of the following types: + SqlVulnerabilityAssessment, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.SqlVulnerabilityAssessment or JSON or IO[bytes] + :return: SqlVulnerabilityAssessment. The SqlVulnerabilityAssessment is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_sql_vulnerability_assessments_settings_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await 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]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SqlVulnerabilityAssessment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.SqlVulnerabilityAssessment"]: + """Lists SQL Vulnerability Assessment policies associated with a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of SqlVulnerabilityAssessment + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SqlVulnerabilityAssessment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SqlVulnerabilityAssessment]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_sql_vulnerability_assessments_settings_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SqlVulnerabilityAssessment], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`database_sql_vulnerability_assessment_rule_baselines` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + rule_id: str, + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: + """Gets a database's sql vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline. The + DatabaseSqlVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) + + _request = build_database_sql_vulnerability_assessment_rule_baselines_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + baseline_name=baseline_name, + rule_id=rule_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + rule_id: str, + parameters: _models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: + """Creates or updates a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param parameters: The requested rule baseline resource. Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline. The + DatabaseSqlVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + rule_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: + """Creates or updates a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param parameters: The requested rule baseline resource. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline. The + DatabaseSqlVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + rule_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: + """Creates or updates a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param parameters: The requested rule baseline resource. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline. The + DatabaseSqlVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + rule_id: str, + parameters: Union[_models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: + """Creates or updates a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param parameters: The requested rule baseline resource. Is one of the following types: + DatabaseSqlVulnerabilityAssessmentRuleBaselineInput, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput or + JSON or IO[bytes] + :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline. The + DatabaseSqlVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_database_sql_vulnerability_assessment_rule_baselines_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + baseline_name=baseline_name, + rule_id=rule_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + rule_id: str, + **kwargs: Any + ) -> None: + """Removes the database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_database_sql_vulnerability_assessment_rule_baselines_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + baseline_name=baseline_name, + rule_id=rule_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await 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) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_baseline( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + **kwargs: Any + ) -> AsyncItemPaged["_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline"]: + """Gets a list of database's sql vulnerability assessment rule baselines. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :return: An iterator like instance of DatabaseSqlVulnerabilityAssessmentRuleBaseline + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_database_sql_vulnerability_assessment_rule_baselines_list_by_baseline_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class SqlVulnerabilityAssessmentRuleBaselineOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`sql_vulnerability_assessment_rule_baseline` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + rule_id: str, + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: + """Gets a system database's sql vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :keyword system_database_name: The vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline. The + DatabaseSqlVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) + + _request = build_sql_vulnerability_assessment_rule_baseline_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + baseline_name=baseline_name, + rule_id=rule_id, + subscription_id=self._config.subscription_id, + system_database_name=system_database_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + rule_id: str, + parameters: _models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput, + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: + """Creates or updates a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param parameters: The requested rule baseline resource. Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput + :keyword system_database_name: The vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline. The + DatabaseSqlVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + rule_id: str, + parameters: JSON, + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: + """Creates or updates a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param parameters: The requested rule baseline resource. Required. + :type parameters: JSON + :keyword system_database_name: The vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline. The + DatabaseSqlVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + rule_id: str, + parameters: IO[bytes], + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: + """Creates or updates a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param parameters: The requested rule baseline resource. Required. + :type parameters: IO[bytes] + :keyword system_database_name: The vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline. The + DatabaseSqlVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + rule_id: str, + parameters: Union[_models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput, JSON, IO[bytes]], + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: + """Creates or updates a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param parameters: The requested rule baseline resource. Is one of the following types: + DatabaseSqlVulnerabilityAssessmentRuleBaselineInput, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput or + JSON or IO[bytes] + :keyword system_database_name: The vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline. The + DatabaseSqlVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_sql_vulnerability_assessment_rule_baseline_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + baseline_name=baseline_name, + rule_id=rule_id, + subscription_id=self._config.subscription_id, + system_database_name=system_database_name, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_baseline( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any + ) -> AsyncItemPaged["_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline"]: + """Gets a system database's sql vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :keyword system_database_name: The vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :return: An iterator like instance of DatabaseSqlVulnerabilityAssessmentRuleBaseline + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_sql_vulnerability_assessment_rule_baseline_list_by_baseline_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + system_database_name=system_database_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class DatabaseSqlVulnerabilityAssessmentScanResultOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`database_sql_vulnerability_assessment_scan_result` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], + scan_id: str, + scan_result_id: str, + **kwargs: Any + ) -> _models.SqlVulnerabilityAssessmentScanResults: + """Gets a vulnerability assessment scan record of a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 SQL Vulnerability Assessment. "default" + Required. + :type vulnerability_assessment_name: str or + ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentName + :param scan_id: The scan id of the SQL Vulnerability Assessment scan to retrieve result from. + Required. + :type scan_id: str + :param scan_result_id: The scan result id of the specific result to retrieve. Required. + :type scan_result_id: str + :return: SqlVulnerabilityAssessmentScanResults. The SqlVulnerabilityAssessmentScanResults is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanResults + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SqlVulnerabilityAssessmentScanResults] = kwargs.pop("cls", None) + + _request = build_database_sql_vulnerability_assessment_scan_result_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + scan_id=scan_id, + scan_result_id=scan_result_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SqlVulnerabilityAssessmentScanResults, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_scan( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], + scan_id: str, + **kwargs: Any + ) -> AsyncItemPaged["_models.SqlVulnerabilityAssessmentScanResults"]: + """Gets a vulnerability assessment scan record of a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 SQL Vulnerability Assessment. "default" + Required. + :type vulnerability_assessment_name: str or + ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentName + :param scan_id: The scan id of the SQL Vulnerability Assessment scan to retrieve result from. + Required. + :type scan_id: str + :return: An iterator like instance of SqlVulnerabilityAssessmentScanResults + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SqlVulnerabilityAssessmentScanResults]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_database_sql_vulnerability_assessment_scan_result_list_by_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SqlVulnerabilityAssessmentScanResults], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class SqlVulnerabilityAssessmentScanResultOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`sql_vulnerability_assessment_scan_result` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], + scan_id: str, + scan_result_id: str, + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any + ) -> _models.SqlVulnerabilityAssessmentScanResults: + """Gets a vulnerability assessment scan record of a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" + Required. + :type vulnerability_assessment_name: str or + ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentName + :param scan_id: The scan id of the SQL Vulnerability Assessment scan to retrieve result from. + Required. + :type scan_id: str + :param scan_result_id: The scan result id of the specific result to retrieve. Required. + :type scan_result_id: str + :keyword system_database_name: The SQL vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :return: SqlVulnerabilityAssessmentScanResults. The SqlVulnerabilityAssessmentScanResults is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanResults + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SqlVulnerabilityAssessmentScanResults] = kwargs.pop("cls", None) + + _request = build_sql_vulnerability_assessment_scan_result_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + scan_id=scan_id, + scan_result_id=scan_result_id, + subscription_id=self._config.subscription_id, + system_database_name=system_database_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SqlVulnerabilityAssessmentScanResults, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_scan( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], + scan_id: str, + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any + ) -> AsyncItemPaged["_models.SqlVulnerabilityAssessmentScanResults"]: + """Gets a vulnerability assessment scan record of a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" + Required. + :type vulnerability_assessment_name: str or + ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentName + :param scan_id: The scan id of the SQL Vulnerability Assessment scan to retrieve result from. + Required. + :type scan_id: str + :keyword system_database_name: The SQL vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :return: An iterator like instance of SqlVulnerabilityAssessmentScanResults + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SqlVulnerabilityAssessmentScanResults]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_sql_vulnerability_assessment_scan_result_list_by_scan_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + scan_id=scan_id, + subscription_id=self._config.subscription_id, + system_database_name=system_database_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SqlVulnerabilityAssessmentScanResults], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class SqlVulnerabilityAssessmentScansOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`sql_vulnerability_assessment_scans` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + scan_id: str, + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any + ) -> _models.SqlVulnerabilityAssessmentScanRecord: + """Get a system database vulnerability assessment scan record. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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: Required. + :type scan_id: str + :keyword system_database_name: The vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :return: SqlVulnerabilityAssessmentScanRecord. The SqlVulnerabilityAssessmentScanRecord is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanRecord + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SqlVulnerabilityAssessmentScanRecord] = kwargs.pop("cls", None) + + _request = build_sql_vulnerability_assessment_scans_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + scan_id=scan_id, + subscription_id=self._config.subscription_id, + system_database_name=system_database_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SqlVulnerabilityAssessmentScanRecord, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_sql_vulnerability_assessments( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any + ) -> AsyncItemPaged["_models.SqlVulnerabilityAssessmentScanRecord"]: + """Lists the vulnerability assessment scans of a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 system_database_name: The vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :return: An iterator like instance of SqlVulnerabilityAssessmentScanRecord + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanRecord] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SqlVulnerabilityAssessmentScanRecord]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_sql_vulnerability_assessment_scans_list_by_sql_vulnerability_assessments_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + system_database_name=system_database_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SqlVulnerabilityAssessmentScanRecord], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class DatabaseVulnerabilityAssessmentRuleBaselinesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`database_vulnerability_assessment_rule_baselines` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + rule_id: str, + baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: + """Gets a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 rule + baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a + baseline on a database level rule and master for server level rule). Known values are: "master" + and "default". Required. + :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName + :return: DatabaseVulnerabilityAssessmentRuleBaseline. The + DatabaseVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) + + _request = build_database_vulnerability_assessment_rule_baselines_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + rule_id=rule_id, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseVulnerabilityAssessmentRuleBaseline, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + rule_id: str, + baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], + parameters: _models.DatabaseVulnerabilityAssessmentRuleBaseline, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: + """Creates or updates a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 rule + baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a + baseline on a database level rule and master for server level rule). Known values are: "master" + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseVulnerabilityAssessmentRuleBaseline. The + DatabaseVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + rule_id: str, + baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: + """Creates or updates a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 rule + baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a + baseline on a database level rule and master for server level rule). Known values are: "master" + and "default". Required. + :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName + :param parameters: The requested rule baseline resource. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseVulnerabilityAssessmentRuleBaseline. The + DatabaseVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + rule_id: str, + baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: + """Creates or updates a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 rule + baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a + baseline on a database level rule and master for server level rule). Known values are: "master" + and "default". Required. + :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName + :param parameters: The requested rule baseline resource. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseVulnerabilityAssessmentRuleBaseline. The + DatabaseVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + rule_id: str, + baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], + parameters: Union[_models.DatabaseVulnerabilityAssessmentRuleBaseline, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: + """Creates or updates a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 rule + baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a + baseline on a database level rule and master for server level rule). Known values are: "master" + and "default". Required. + :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName + :param parameters: The requested rule baseline resource. Is one of the following types: + DatabaseVulnerabilityAssessmentRuleBaseline, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline or JSON or + IO[bytes] + :return: DatabaseVulnerabilityAssessmentRuleBaseline. The + DatabaseVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_database_vulnerability_assessment_rule_baselines_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + rule_id=rule_id, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseVulnerabilityAssessmentRuleBaseline, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + rule_id: str, + baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], + **kwargs: Any + ) -> None: + """Removes the database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 rule + baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a + baseline on a database level rule and master for server level rule). Known values are: "master" + and "default". Required. + :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_database_vulnerability_assessment_rule_baselines_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + rule_id=rule_id, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_database_vulnerability_assessment_rule_baselines` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + rule_id: str, + baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: + """Gets a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 rule + baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a + baseline on a database level rule and master for server level rule). Known values are: "master" + and "default". Required. + :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName + :return: DatabaseVulnerabilityAssessmentRuleBaseline. The + DatabaseVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) + + _request = build_managed_database_vulnerability_assessment_rule_baselines_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + rule_id=rule_id, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseVulnerabilityAssessmentRuleBaseline, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + rule_id: str, + baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], + parameters: _models.DatabaseVulnerabilityAssessmentRuleBaseline, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: + """Creates or updates a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 rule + baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a + baseline on a database level rule and master for server level rule). Known values are: "master" + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseVulnerabilityAssessmentRuleBaseline. The + DatabaseVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + rule_id: str, + baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: + """Creates or updates a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 rule + baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a + baseline on a database level rule and master for server level rule). Known values are: "master" + and "default". Required. + :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName + :param parameters: The requested rule baseline resource. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseVulnerabilityAssessmentRuleBaseline. The + DatabaseVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + rule_id: str, + baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: + """Creates or updates a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 rule + baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a + baseline on a database level rule and master for server level rule). Known values are: "master" + and "default". Required. + :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName + :param parameters: The requested rule baseline resource. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseVulnerabilityAssessmentRuleBaseline. The + DatabaseVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + rule_id: str, + baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], + parameters: Union[_models.DatabaseVulnerabilityAssessmentRuleBaseline, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: + """Creates or updates a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 rule + baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a + baseline on a database level rule and master for server level rule). Known values are: "master" + and "default". Required. + :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName + :param parameters: The requested rule baseline resource. Is one of the following types: + DatabaseVulnerabilityAssessmentRuleBaseline, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline or JSON or + IO[bytes] + :return: DatabaseVulnerabilityAssessmentRuleBaseline. The + DatabaseVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_database_vulnerability_assessment_rule_baselines_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + rule_id=rule_id, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseVulnerabilityAssessmentRuleBaseline, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + rule_id: str, + baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], + **kwargs: Any + ) -> None: + """Removes the database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 rule + baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a + baseline on a database level rule and master for server level rule). Known values are: "master" + and "default". Required. + :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_managed_database_vulnerability_assessment_rule_baselines_delete_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + rule_id=rule_id, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class DatabaseVulnerabilityAssessmentsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`database_vulnerability_assessments` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessment: + """Gets the database's vulnerability assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 is + defined. 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 + :return: DatabaseVulnerabilityAssessment. The DatabaseVulnerabilityAssessment is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseVulnerabilityAssessment] = kwargs.pop("cls", None) + + _request = build_database_vulnerability_assessments_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseVulnerabilityAssessment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: _models.DatabaseVulnerabilityAssessment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessment: + """Creates or updates the database's vulnerability assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 is + defined. 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 parameters: The requested resource. Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseVulnerabilityAssessment. The DatabaseVulnerabilityAssessment is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessment: + """Creates or updates the database's vulnerability assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 is + defined. 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 parameters: The requested resource. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseVulnerabilityAssessment. The DatabaseVulnerabilityAssessment is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessment: + """Creates or updates the database's vulnerability assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 is + defined. 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 parameters: The requested resource. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseVulnerabilityAssessment. The DatabaseVulnerabilityAssessment is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: Union[_models.DatabaseVulnerabilityAssessment, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessment: + """Creates or updates the database's vulnerability assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 is + defined. 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 parameters: The requested resource. Is one of the following types: + DatabaseVulnerabilityAssessment, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment or JSON or IO[bytes] + :return: DatabaseVulnerabilityAssessment. The DatabaseVulnerabilityAssessment is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_database_vulnerability_assessments_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await 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]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseVulnerabilityAssessment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + **kwargs: Any + ) -> None: + """Removes the database's vulnerability assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 is + defined. 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 + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_database_vulnerability_assessments_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.DatabaseVulnerabilityAssessment"]: + """Lists the vulnerability assessment policies associated with a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 is + defined. Required. + :type database_name: str + :return: An iterator like instance of DatabaseVulnerabilityAssessment + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseVulnerabilityAssessment]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_database_vulnerability_assessments_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseVulnerabilityAssessment], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ManagedDatabaseVulnerabilityAssessmentsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_database_vulnerability_assessments` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessment: + """Gets the database's vulnerability assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. + :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName + :return: DatabaseVulnerabilityAssessment. The DatabaseVulnerabilityAssessment is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseVulnerabilityAssessment] = kwargs.pop("cls", None) + + _request = build_managed_database_vulnerability_assessments_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseVulnerabilityAssessment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: _models.DatabaseVulnerabilityAssessment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessment: + """Creates or updates the database's vulnerability assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. + :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName + :param parameters: The requested resource. Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseVulnerabilityAssessment. The DatabaseVulnerabilityAssessment is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessment: + """Creates or updates the database's vulnerability assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. + :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName + :param parameters: The requested resource. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseVulnerabilityAssessment. The DatabaseVulnerabilityAssessment is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessment: + """Creates or updates the database's vulnerability assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. + :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName + :param parameters: The requested resource. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseVulnerabilityAssessment. The DatabaseVulnerabilityAssessment is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: Union[_models.DatabaseVulnerabilityAssessment, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessment: + """Creates or updates the database's vulnerability assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. + :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName + :param parameters: The requested resource. Is one of the following types: + DatabaseVulnerabilityAssessment, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment or JSON or IO[bytes] + :return: DatabaseVulnerabilityAssessment. The DatabaseVulnerabilityAssessment is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_database_vulnerability_assessments_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await 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]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseVulnerabilityAssessment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + **kwargs: Any + ) -> None: + """Removes the database's vulnerability assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. + :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_managed_database_vulnerability_assessments_delete_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_database( + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.DatabaseVulnerabilityAssessment"]: + """Lists the vulnerability assessments of a managed database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An iterator like instance of DatabaseVulnerabilityAssessment + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseVulnerabilityAssessment]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_database_vulnerability_assessments_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseVulnerabilityAssessment], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ManagedDatabaseVulnerabilityAssessmentScansOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_database_vulnerability_assessment_scans` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + scan_id: str, + **kwargs: Any + ) -> _models.VulnerabilityAssessmentScanRecord: + """Gets a vulnerability assessment scan record of a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. Required. + :type scan_id: str + :return: VulnerabilityAssessmentScanRecord. The VulnerabilityAssessmentScanRecord is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecord + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.VulnerabilityAssessmentScanRecord] = kwargs.pop("cls", None) + + _request = build_managed_database_vulnerability_assessment_scans_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.VulnerabilityAssessmentScanRecord, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @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], + **kwargs: Any + ) -> AsyncItemPaged["_models.VulnerabilityAssessmentScanRecord"]: + """Lists the vulnerability assessment scans of a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An iterator like instance of VulnerabilityAssessmentScanRecord + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecord] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.VulnerabilityAssessmentScanRecord]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_database_vulnerability_assessment_scans_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.VulnerabilityAssessmentScanRecord], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def export( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + scan_id: str, + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessmentScansExport: + """Convert an existing scan result to a human readable format. If already exists nothing happens. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. Required. + :type scan_id: str + :return: DatabaseVulnerabilityAssessmentScansExport. The + DatabaseVulnerabilityAssessmentScansExport is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentScansExport + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseVulnerabilityAssessmentScansExport] = kwargs.pop("cls", None) + + _request = build_managed_database_vulnerability_assessment_scans_export_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + scan_id=scan_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await 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]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseVulnerabilityAssessmentScansExport, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _initiate_scan_initial( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + scan_id: str, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_database_vulnerability_assessment_scans_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_initiate_scan( + self, + resource_group_name: str, + managed_instance_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. The name is case insensitive. + 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 + :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. Required. + :type scan_id: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class DataMaskingPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`data_masking_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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. The name is case insensitive. + Required. + :type resource_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 + :return: DataMaskingPolicy. The DataMaskingPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DataMaskingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DataMaskingPolicy] = kwargs.pop("cls", None) + + _request = build_data_masking_policies_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DataMaskingPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @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", + **kwargs: Any + ) -> _models.DataMaskingPolicy: + """Creates or updates a database data masking policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :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 + :return: DataMaskingPolicy. The DataMaskingPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DataMaskingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataMaskingPolicy: + """Creates or updates a database data masking policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :param parameters: Parameters for creating or updating a data masking policy. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DataMaskingPolicy. The DataMaskingPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DataMaskingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataMaskingPolicy: + """Creates or updates a database data masking policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :param parameters: Parameters for creating or updating a data masking policy. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DataMaskingPolicy. The DataMaskingPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DataMaskingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + 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: Union[_models.DataMaskingPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.DataMaskingPolicy: + """Creates or updates a database data masking policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :param parameters: Parameters for creating or updating a data masking policy. Is one of the + following types: DataMaskingPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DataMaskingPolicy or JSON or IO[bytes] + :return: DataMaskingPolicy. The DataMaskingPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DataMaskingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_data_masking_policies_create_or_update_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await 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]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DataMaskingPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class DeletedServersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`deleted_servers` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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 + :return: DeletedServer. The DeletedServer is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DeletedServer + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DeletedServer] = kwargs.pop("cls", None) + + _request = build_deleted_servers_get_request( + location_name=location_name, + deleted_server_name=deleted_server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DeletedServer, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_location(self, location_name: str, **kwargs: Any) -> AsyncItemPaged["_models.DeletedServer"]: + """Gets a list of deleted servers for a location. + + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :return: An iterator like instance of DeletedServer + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DeletedServer] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DeletedServer]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_deleted_servers_list_by_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DeletedServer], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _recover_initial( + self, location_name: str, deleted_server_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_deleted_servers_recover_request( + location_name=location_name, + deleted_server_name=deleted_server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_recover( + self, location_name: str, deleted_server_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.DeletedServer]: + """Recovers 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 + :return: An instance of AsyncLROPoller that returns DeletedServer. The DeletedServer is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.DeletedServer] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._recover_initial( + location_name=location_name, + deleted_server_name=deleted_server_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.DeletedServer, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.DeletedServer].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.DeletedServer]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncItemPaged["_models.DeletedServer"]: + """Gets a list of all deleted servers in a subscription. + + :return: An iterator like instance of DeletedServer + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DeletedServer] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DeletedServer]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_deleted_servers_list_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DeletedServer], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class DistributedAvailabilityGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`distributed_availability_groups` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + **kwargs: Any + ) -> _models.DistributedAvailabilityGroup: + """Gets a distributed availability group info. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: DistributedAvailabilityGroup. The DistributedAvailabilityGroup is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.DistributedAvailabilityGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DistributedAvailabilityGroup] = kwargs.pop("cls", None) + + _request = build_distributed_availability_groups_get_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DistributedAvailabilityGroup, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: Union[_models.DistributedAvailabilityGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_distributed_availability_groups_create_or_update_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: _models.DistributedAvailabilityGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DistributedAvailabilityGroup]: + """Creates a distributed availability group between Sql On-Prem and Sql Managed Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 info. Required. + :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns DistributedAvailabilityGroup. The + DistributedAvailabilityGroup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DistributedAvailabilityGroup]: + """Creates a distributed availability group between Sql On-Prem and Sql Managed Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 info. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns DistributedAvailabilityGroup. The + DistributedAvailabilityGroup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DistributedAvailabilityGroup]: + """Creates a distributed availability group between Sql On-Prem and Sql Managed Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 info. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns DistributedAvailabilityGroup. The + DistributedAvailabilityGroup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: Union[_models.DistributedAvailabilityGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.DistributedAvailabilityGroup]: + """Creates a distributed availability group between Sql On-Prem and Sql Managed Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 info. Is one of the following types: + DistributedAvailabilityGroup, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroup or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns DistributedAvailabilityGroup. The + DistributedAvailabilityGroup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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._create_or_update_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + distributed_availability_group_name=distributed_availability_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.DistributedAvailabilityGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.DistributedAvailabilityGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.DistributedAvailabilityGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: Union[_models.DistributedAvailabilityGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_distributed_availability_groups_update_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: _models.DistributedAvailabilityGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DistributedAvailabilityGroup]: + """Updates a distributed availability group replication mode. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 info. Required. + :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns DistributedAvailabilityGroup. The + DistributedAvailabilityGroup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DistributedAvailabilityGroup]: + """Updates a distributed availability group replication mode. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 info. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns DistributedAvailabilityGroup. The + DistributedAvailabilityGroup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DistributedAvailabilityGroup]: + """Updates a distributed availability group replication mode. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 info. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns DistributedAvailabilityGroup. The + DistributedAvailabilityGroup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: Union[_models.DistributedAvailabilityGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.DistributedAvailabilityGroup]: + """Updates a distributed availability group replication mode. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 info. Is one of the following types: + DistributedAvailabilityGroup, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroup or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns DistributedAvailabilityGroup. The + DistributedAvailabilityGroup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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._update_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + distributed_availability_group_name=distributed_availability_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.DistributedAvailabilityGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.DistributedAvailabilityGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.DistributedAvailabilityGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_distributed_availability_groups_delete_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Drops a distributed availability group between Sql On-Prem and Sql Managed Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + distributed_availability_group_name=distributed_availability_group_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.DistributedAvailabilityGroup"]: + """Gets a list of a distributed availability groups in instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of DistributedAvailabilityGroup + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DistributedAvailabilityGroup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_distributed_availability_groups_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DistributedAvailabilityGroup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _failover_initial( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: Union[_models.DistributedAvailabilityGroupsFailoverRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_distributed_availability_groups_failover_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_failover( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: _models.DistributedAvailabilityGroupsFailoverRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DistributedAvailabilityGroup]: + """Performs requested failover type in this distributed availability group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 failover request parameters. Required. + :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroupsFailoverRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns DistributedAvailabilityGroup. The + DistributedAvailabilityGroup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_failover( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DistributedAvailabilityGroup]: + """Performs requested failover type in this distributed availability group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 failover request parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns DistributedAvailabilityGroup. The + DistributedAvailabilityGroup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_failover( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DistributedAvailabilityGroup]: + """Performs requested failover type in this distributed availability group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 failover request parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns DistributedAvailabilityGroup. The + DistributedAvailabilityGroup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_failover( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: Union[_models.DistributedAvailabilityGroupsFailoverRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.DistributedAvailabilityGroup]: + """Performs requested failover type in this distributed availability group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 failover request parameters. Is one of + the following types: DistributedAvailabilityGroupsFailoverRequest, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroupsFailoverRequest or JSON + or IO[bytes] + :return: An instance of AsyncLROPoller that returns DistributedAvailabilityGroup. The + DistributedAvailabilityGroup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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._failover_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + distributed_availability_group_name=distributed_availability_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.DistributedAvailabilityGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.DistributedAvailabilityGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.DistributedAvailabilityGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _set_role_initial( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: Union[_models.DistributedAvailabilityGroupSetRole, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_distributed_availability_groups_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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. The name is case insensitive. + 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 + :return: An instance of AsyncLROPoller that returns DistributedAvailabilityGroup. The + DistributedAvailabilityGroup is compatible with MutableMapping + :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: JSON, + *, + 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. The name is case insensitive. + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns DistributedAvailabilityGroup. The + DistributedAvailabilityGroup is compatible with MutableMapping + :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[bytes], + *, + 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. The name is case insensitive. + 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[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns DistributedAvailabilityGroup. The + DistributedAvailabilityGroup is compatible with MutableMapping + :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, JSON, IO[bytes]], + **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. The name is case insensitive. + 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 one of + the following types: DistributedAvailabilityGroupSetRole, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroupSetRole or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns DistributedAvailabilityGroup. The + DistributedAvailabilityGroup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.DistributedAvailabilityGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.DistributedAvailabilityGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.DistributedAvailabilityGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class ManagedDatabasesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_databases` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> _models.ManagedDatabase: + """Gets a managed database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: ManagedDatabase. The ManagedDatabase is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedDatabase + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedDatabase] = kwargs.pop("cls", None) + + _request = build_managed_databases_get_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedDatabase, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: Union[_models.ManagedDatabase, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_databases_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: _models.ManagedDatabase, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedDatabase]: + """Creates a new database or updates an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: The requested database resource state. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedDatabase + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedDatabase. The ManagedDatabase is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedDatabase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedDatabase]: + """Creates a new database or updates an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: The requested database resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedDatabase. The ManagedDatabase is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedDatabase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedDatabase]: + """Creates a new database or updates an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: The requested database resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedDatabase. The ManagedDatabase is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedDatabase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: Union[_models.ManagedDatabase, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedDatabase]: + """Creates a new database or updates an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: The requested database resource state. Is one of the following types: + ManagedDatabase, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedDatabase or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ManagedDatabase. The ManagedDatabase is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedDatabase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + database_name=database_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedDatabase, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ManagedDatabase].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ManagedDatabase]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: Union[_models.ManagedDatabaseUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_databases_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: _models.ManagedDatabaseUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedDatabase]: + """Updates an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: The requested database resource state. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedDatabase. The ManagedDatabase is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedDatabase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedDatabase]: + """Updates an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: The requested database resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedDatabase. The ManagedDatabase is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedDatabase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedDatabase]: + """Updates an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: The requested database resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedDatabase. The ManagedDatabase is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedDatabase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: Union[_models.ManagedDatabaseUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedDatabase]: + """Updates an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: The requested database resource state. Is one of the following types: + ManagedDatabaseUpdate, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseUpdate or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ManagedDatabase. The ManagedDatabase is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedDatabase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedDatabase, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ManagedDatabase].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ManagedDatabase]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_databases_delete_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a managed database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ManagedDatabase"]: + """Gets a list of managed databases. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of ManagedDatabase + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedDatabase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedDatabase]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_databases_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedDatabase], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _cancel_move_initial( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: Union[_models.ManagedDatabaseMoveDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_databases_cancel_move_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_cancel_move( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: _models.ManagedDatabaseMoveDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Cancels a managed database move operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: Parameters of the cancel managed database move operation. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseMoveDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_cancel_move( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Cancels a managed database move operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: Parameters of the cancel managed database move operation. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_cancel_move( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Cancels a managed database move operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: Parameters of the cancel managed database move operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_cancel_move( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: Union[_models.ManagedDatabaseMoveDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Cancels a managed database move operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: Parameters of the cancel managed database move operation. Is one of the + following types: ManagedDatabaseMoveDefinition, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseMoveDefinition or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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._cancel_move_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _complete_move_initial( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: Union[_models.ManagedDatabaseMoveDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_databases_complete_move_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_complete_move( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: _models.ManagedDatabaseMoveDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Completes a managed database move operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: Parameters of the complete managed database move operation. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseMoveDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_complete_move( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Completes a managed database move operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: Parameters of the complete managed database move operation. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_complete_move( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Completes a managed database move operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: Parameters of the complete managed database move operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_complete_move( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: Union[_models.ManagedDatabaseMoveDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Completes a managed database move operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: Parameters of the complete managed database move operation. Is one of the + following types: ManagedDatabaseMoveDefinition, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseMoveDefinition or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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._complete_move_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _complete_restore_initial( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: Union[_models.CompleteDatabaseRestoreDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_databases_complete_restore_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_complete_restore( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: _models.CompleteDatabaseRestoreDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Completes the restore operation on a managed database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: The definition for completing the restore of this managed database. + Required. + :type parameters: ~azure.mgmt.sql.models.CompleteDatabaseRestoreDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_complete_restore( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Completes the restore operation on a managed database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: The definition for completing the restore of this managed database. + Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_complete_restore( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Completes the restore operation on a managed database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: The definition for completing the restore of this managed database. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_complete_restore( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: Union[_models.CompleteDatabaseRestoreDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Completes the restore operation on a managed database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: The definition for completing the restore of this managed database. Is one + of the following types: CompleteDatabaseRestoreDefinition, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.CompleteDatabaseRestoreDefinition or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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._complete_restore_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _reevaluate_inaccessible_database_state_initial( # pylint: disable=name-too-long + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_databases_reevaluate_inaccessible_database_state_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_reevaluate_inaccessible_database_state( # pylint: disable=name-too-long + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedDatabase]: + """Reevaluates the inaccessibility state of a managed database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An instance of AsyncLROPoller that returns ManagedDatabase. The ManagedDatabase is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedDatabase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedDatabase] = 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._reevaluate_inaccessible_database_state_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ManagedDatabase, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ManagedDatabase].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ManagedDatabase]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _start_move_initial( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: Union[_models.ManagedDatabaseStartMoveDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_databases_start_move_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_start_move( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: _models.ManagedDatabaseStartMoveDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Starts a managed database move operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: Parameters of the start managed database move operation. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseStartMoveDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_start_move( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Starts a managed database move operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: Parameters of the start managed database move operation. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_start_move( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Starts a managed database move operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: Parameters of the start managed database move operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_start_move( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: Union[_models.ManagedDatabaseStartMoveDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Starts a managed database move operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: Parameters of the start managed database move operation. Is one of the + following types: ManagedDatabaseStartMoveDefinition, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseStartMoveDefinition or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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_move_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_inaccessible_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ManagedDatabase"]: + """Gets a list of inaccessible managed databases in a managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of ManagedDatabase + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedDatabase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedDatabase]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_databases_list_inaccessible_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedDatabase], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ServerTrustGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`server_trust_groups` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, location_name: str, server_trust_group_name: str, **kwargs: Any + ) -> _models.ServerTrustGroup: + """Gets a server trust group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :param server_trust_group_name: The name of the server trust group. Required. + :type server_trust_group_name: str + :return: ServerTrustGroup. The ServerTrustGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerTrustGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ServerTrustGroup] = kwargs.pop("cls", None) + + _request = build_server_trust_groups_get_request( + resource_group_name=resource_group_name, + location_name=location_name, + server_trust_group_name=server_trust_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ServerTrustGroup, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + location_name: str, + server_trust_group_name: str, + parameters: Union[_models.ServerTrustGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_server_trust_groups_create_or_update_request( + resource_group_name=resource_group_name, + location_name=location_name, + server_trust_group_name=server_trust_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + location_name: str, + server_trust_group_name: str, + parameters: _models.ServerTrustGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerTrustGroup]: + """Creates or updates a server trust group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :param server_trust_group_name: The name of the server trust group. Required. + :type server_trust_group_name: str + :param parameters: The server trust group parameters. Required. + :type parameters: ~azure.mgmt.sql.models.ServerTrustGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerTrustGroup. The ServerTrustGroup is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerTrustGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + location_name: str, + server_trust_group_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerTrustGroup]: + """Creates or updates a server trust group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :param server_trust_group_name: The name of the server trust group. Required. + :type server_trust_group_name: str + :param parameters: The server trust group parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerTrustGroup. The ServerTrustGroup is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerTrustGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + location_name: str, + server_trust_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerTrustGroup]: + """Creates or updates a server trust group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :param server_trust_group_name: The name of the server trust group. Required. + :type server_trust_group_name: str + :param parameters: The server trust group parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerTrustGroup. The ServerTrustGroup is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerTrustGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + location_name: str, + server_trust_group_name: str, + parameters: Union[_models.ServerTrustGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerTrustGroup]: + """Creates or updates a server trust group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :param server_trust_group_name: The name of the server trust group. Required. + :type server_trust_group_name: str + :param parameters: The server trust group parameters. Is one of the following types: + ServerTrustGroup, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ServerTrustGroup or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ServerTrustGroup. The ServerTrustGroup is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerTrustGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + location_name=location_name, + server_trust_group_name=server_trust_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ServerTrustGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ServerTrustGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ServerTrustGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, location_name: str, server_trust_group_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_server_trust_groups_delete_request( + resource_group_name=resource_group_name, + location_name=location_name, + server_trust_group_name=server_trust_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, location_name: str, server_trust_group_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a server trust group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :param server_trust_group_name: The name of the server trust group. Required. + :type server_trust_group_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + location_name=location_name, + server_trust_group_name=server_trust_group_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_location( + self, resource_group_name: str, location_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ServerTrustGroup"]: + """Lists a server trust group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :return: An iterator like instance of ServerTrustGroup + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerTrustGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerTrustGroup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_server_trust_groups_list_by_location_request( + resource_group_name=resource_group_name, + location_name=location_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ServerTrustGroup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ServerTrustGroup"]: + """Gets a server trust groups by instance name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of ServerTrustGroup + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerTrustGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerTrustGroup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_server_trust_groups_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ServerTrustGroup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ManagedInstancesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_instances` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, managed_instance_name: str, *, expand: Optional[str] = None, **kwargs: Any + ) -> _models.ManagedInstance: + """Gets a managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :keyword expand: The child resources to include in the response. Default value is None. + :paramtype expand: str + :return: ManagedInstance. The ManagedInstance is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedInstance] = kwargs.pop("cls", None) + + _request = build_managed_instances_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedInstance, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: Union[_models.ManagedInstance, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_instances_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: _models.ManagedInstance, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstance]: + """Creates or updates a managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: The requested managed instance resource state. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstance + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedInstance. The ManagedInstance is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstance]: + """Creates or updates a managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: The requested managed instance resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedInstance. The ManagedInstance is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstance]: + """Creates or updates a managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: The requested managed instance resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedInstance. The ManagedInstance is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: Union[_models.ManagedInstance, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstance]: + """Creates or updates a managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: The requested managed instance resource state. Is one of the following + types: ManagedInstance, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstance or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ManagedInstance. The ManagedInstance is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedInstance, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ManagedInstance].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ManagedInstance]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: Union[_models.ManagedInstanceUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_instances_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: _models.ManagedInstanceUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstance]: + """Updates a managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: The requested managed instance resource state. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedInstance. The ManagedInstance is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstance]: + """Updates a managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: The requested managed instance resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedInstance. The ManagedInstance is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstance]: + """Updates a managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: The requested managed instance resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedInstance. The ManagedInstance is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: Union[_models.ManagedInstanceUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstance]: + """Updates a managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: The requested managed instance resource state. Is one of the following + types: ManagedInstanceUpdate, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceUpdate or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ManagedInstance. The ManagedInstance is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedInstance, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ManagedInstance].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ManagedInstance]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_instances_delete_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, *, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.ManagedInstance"]: + """Gets a list of managed instances in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword expand: The child resources to include in the response. Default value is None. + :paramtype expand: str + :return: An iterator like instance of ManagedInstance + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstance]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_instances_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstance], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, *, expand: Optional[str] = None, **kwargs: Any) -> AsyncItemPaged["_models.ManagedInstance"]: + """Gets a list of all managed instances in the subscription. + + :keyword expand: The child resources to include in the response. Default value is None. + :paramtype expand: str + :return: An iterator like instance of ManagedInstance + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstance]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_instances_list_request( + subscription_id=self._config.subscription_id, + expand=expand, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstance], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _failover_initial( + self, + resource_group_name: str, + managed_instance_name: str, + *, + replica_type: Optional[Union[str, _models.ReplicaType]] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_instances_failover_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + replica_type=replica_type, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_failover( + self, + resource_group_name: str, + managed_instance_name: str, + *, + replica_type: Optional[Union[str, _models.ReplicaType]] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Failovers a managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :keyword replica_type: The type of replica to be failed over. Known values are: "Primary" and + "ReadableSecondary". Default value is None. + :paramtype replica_type: str or ~azure.mgmt.sql.models.ReplicaType + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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._failover_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + replica_type=replica_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_outbound_network_dependencies_by_managed_instance( # pylint: disable=name-too-long + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.OutboundEnvironmentEndpoint"]: + """Gets the collection of outbound network dependencies for the given managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of OutboundEnvironmentEndpoint + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.OutboundEnvironmentEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.OutboundEnvironmentEndpoint]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_instances_list_outbound_network_dependencies_by_managed_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.OutboundEnvironmentEndpoint], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _reevaluate_inaccessible_database_state_initial( # pylint: disable=name-too-long + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_instances_reevaluate_inaccessible_database_state_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_reevaluate_inaccessible_database_state( # pylint: disable=name-too-long + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Reevaluates the inaccessibility state of all managed databases. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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._reevaluate_inaccessible_database_state_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _refresh_status_initial( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_instances_refresh_status_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An instance of AsyncLROPoller that returns + RefreshExternalGovernanceStatusOperationResultMI. The + RefreshExternalGovernanceStatusOperationResultMI is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.RefreshExternalGovernanceStatusOperationResultMI] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.RefreshExternalGovernanceStatusOperationResultMI, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.RefreshExternalGovernanceStatusOperationResultMI].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.RefreshExternalGovernanceStatusOperationResultMI]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _start_initial( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_instances_start_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_start( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstance]: + """Starts the managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An instance of AsyncLROPoller that returns ManagedInstance. The ManagedInstance is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ManagedInstance, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ManagedInstance].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ManagedInstance]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _stop_initial( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_instances_stop_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_stop( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstance]: + """Stops the managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An instance of AsyncLROPoller that returns ManagedInstance. The ManagedInstance is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ManagedInstance, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ManagedInstance].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ManagedInstance]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_managed_instance( + self, + resource_group_name: str, + managed_instance_name: str, + *, + number_of_queries: Optional[int] = None, + databases: Optional[str] = None, + start_time: Optional[str] = None, + end_time: Optional[str] = None, + interval: Optional[Union[str, _models.QueryTimeGrainType]] = None, + aggregation_function: Optional[Union[str, _models.AggregationFunctionType]] = None, + observation_metric: Optional[Union[str, _models.MetricType]] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.TopQueries"]: + """Get top resource consuming queries of a managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :keyword number_of_queries: How many 'top queries' to return. Default is 5. Default value is + None. + :paramtype number_of_queries: int + :keyword databases: Comma separated list of databases to be included into search. All DB's are + included if this parameter is not specified. Default value is None. + :paramtype databases: str + :keyword start_time: Start time for observed period. Default value is None. + :paramtype start_time: str + :keyword end_time: End time for observed period. Default value is None. + :paramtype end_time: str + :keyword interval: The time step to be used to summarize the metric values. Default value is + PT1H. Known values are: "PT1H" and "P1D". Default value is None. + :paramtype interval: str or ~azure.mgmt.sql.models.QueryTimeGrainType + :keyword aggregation_function: Aggregation function to be used, default value is 'sum'. Known + values are: "avg", "min", "max", "stdev", and "sum". Default value is None. + :paramtype aggregation_function: str or ~azure.mgmt.sql.models.AggregationFunctionType + :keyword observation_metric: Metric to be used for ranking top queries. Default is 'cpu'. Known + values are: "cpu", "io", "logIo", "duration", and "dtu". Default value is None. + :paramtype observation_metric: str or ~azure.mgmt.sql.models.MetricType + :return: An iterator like instance of TopQueries + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.TopQueries] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TopQueries]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_instances_list_by_managed_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + number_of_queries=number_of_queries, + databases=databases, + start_time=start_time, + end_time=end_time, + interval=interval, + aggregation_function=aggregation_function, + observation_metric=observation_metric, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TopQueries], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _validate_azure_key_vault_encryption_key_initial( # pylint: disable=name-too-long + self, + resource_group_name: str, + managed_instance_name: str, + parameters: Union[_models.ManagedInstanceValidateAzureKeyVaultEncryptionKeyRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_instances_validate_azure_key_vault_encryption_key_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_validate_azure_key_vault_encryption_key( # pylint: disable=name-too-long + self, + resource_group_name: str, + managed_instance_name: str, + parameters: _models.ManagedInstanceValidateAzureKeyVaultEncryptionKeyRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Validates customer managed key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: The validate azure key vault encryption key parameters. Required. + :type parameters: + ~azure.mgmt.sql.models.ManagedInstanceValidateAzureKeyVaultEncryptionKeyRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_validate_azure_key_vault_encryption_key( # pylint: disable=name-too-long + self, + resource_group_name: str, + managed_instance_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Validates customer managed key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: The validate azure key vault encryption key parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_validate_azure_key_vault_encryption_key( # pylint: disable=name-too-long + self, + resource_group_name: str, + managed_instance_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Validates customer managed key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: The validate azure key vault encryption key parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_azure_key_vault_encryption_key( # pylint: disable=name-too-long + self, + resource_group_name: str, + managed_instance_name: str, + parameters: Union[_models.ManagedInstanceValidateAzureKeyVaultEncryptionKeyRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Validates customer managed key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: The validate azure key vault encryption key parameters. Is one of the + following types: ManagedInstanceValidateAzureKeyVaultEncryptionKeyRequest, JSON, IO[bytes] + Required. + :type parameters: + ~azure.mgmt.sql.models.ManagedInstanceValidateAzureKeyVaultEncryptionKeyRequest or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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._validate_azure_key_vault_encryption_key_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_instance_pool( + self, resource_group_name: str, instance_pool_name: str, *, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.ManagedInstance"]: + """Gets a list of all managed instances in an instance pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param instance_pool_name: The name of the instance pool to be retrieved. Required. + :type instance_pool_name: str + :keyword expand: The child resources to include in the response. Default value is None. + :paramtype expand: str + :return: An iterator like instance of ManagedInstance + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstance]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_instances_list_by_instance_pool_request( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstance], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ElasticPoolsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`elastic_pools` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, elastic_pool_name: str, **kwargs: Any + ) -> _models.ElasticPool: + """Gets an elastic pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: ElasticPool. The ElasticPool is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ElasticPool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ElasticPool] = kwargs.pop("cls", None) + + _request = build_elastic_pools_get_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ElasticPool, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + parameters: Union[_models.ElasticPool, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_elastic_pools_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + parameters: _models.ElasticPool, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ElasticPool]: + """Creates or updates an elastic pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 parameters: The elastic pool parameters. Required. + :type parameters: ~azure.mgmt.sql.models.ElasticPool + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ElasticPool. The ElasticPool is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ElasticPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ElasticPool]: + """Creates or updates an elastic pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 parameters: The elastic pool parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ElasticPool. The ElasticPool is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ElasticPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ElasticPool]: + """Creates or updates an elastic pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 parameters: The elastic pool parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ElasticPool. The ElasticPool is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ElasticPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + parameters: Union[_models.ElasticPool, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ElasticPool]: + """Creates or updates an elastic pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 parameters: The elastic pool parameters. Is one of the following types: ElasticPool, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ElasticPool or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ElasticPool. The ElasticPool is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ElasticPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + elastic_pool_name=elastic_pool_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ElasticPool, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ElasticPool].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ElasticPool]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + parameters: Union[_models.ElasticPoolUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_elastic_pools_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + parameters: _models.ElasticPoolUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ElasticPool]: + """Updates an elastic pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 parameters: The elastic pool update parameters. Required. + :type parameters: ~azure.mgmt.sql.models.ElasticPoolUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ElasticPool. The ElasticPool is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ElasticPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ElasticPool]: + """Updates an elastic pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 parameters: The elastic pool update parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ElasticPool. The ElasticPool is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ElasticPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ElasticPool]: + """Updates an elastic pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 parameters: The elastic pool update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ElasticPool. The ElasticPool is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ElasticPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + parameters: Union[_models.ElasticPoolUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ElasticPool]: + """Updates an elastic pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 parameters: The elastic pool update parameters. Is one of the following types: + ElasticPoolUpdate, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ElasticPoolUpdate or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ElasticPool. The ElasticPool is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ElasticPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ElasticPool, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ElasticPool].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ElasticPool]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_elastic_pools_delete_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an elastic pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, *, skip: Optional[int] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.ElasticPool"]: + """Gets all elastic pools in a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :keyword skip: The number of elements in the collection to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ElasticPool + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ElasticPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ElasticPool]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_elastic_pools_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ElasticPool], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _failover_initial( + self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_elastic_pools_failover_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_failover( + self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Failovers an elastic pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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._failover_initial( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class EncryptionProtectorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`encryption_protectors` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + **kwargs: Any + ) -> _models.EncryptionProtector: + """Gets a server encryption protector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param encryption_protector_name: The name of the encryption protector to be retrieved. + "current" Required. + :type encryption_protector_name: str or ~azure.mgmt.sql.models.EncryptionProtectorName + :return: EncryptionProtector. The EncryptionProtector is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.EncryptionProtector + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.EncryptionProtector] = kwargs.pop("cls", None) + + _request = build_encryption_protectors_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + encryption_protector_name=encryption_protector_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.EncryptionProtector, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + parameters: Union[_models.EncryptionProtector, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_encryption_protectors_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + encryption_protector_name=encryption_protector_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + parameters: _models.EncryptionProtector, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EncryptionProtector]: + """Updates an existing encryption protector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param encryption_protector_name: The name of the encryption protector to be retrieved. + "current" Required. + :type encryption_protector_name: str or ~azure.mgmt.sql.models.EncryptionProtectorName + :param parameters: The requested encryption protector resource state. Required. + :type parameters: ~azure.mgmt.sql.models.EncryptionProtector + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns EncryptionProtector. The + EncryptionProtector is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.EncryptionProtector] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EncryptionProtector]: + """Updates an existing encryption protector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param encryption_protector_name: The name of the encryption protector to be retrieved. + "current" Required. + :type encryption_protector_name: str or ~azure.mgmt.sql.models.EncryptionProtectorName + :param parameters: The requested encryption protector resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns EncryptionProtector. The + EncryptionProtector is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.EncryptionProtector] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EncryptionProtector]: + """Updates an existing encryption protector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param encryption_protector_name: The name of the encryption protector to be retrieved. + "current" Required. + :type encryption_protector_name: str or ~azure.mgmt.sql.models.EncryptionProtectorName + :param parameters: The requested encryption protector resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns EncryptionProtector. The + EncryptionProtector is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.EncryptionProtector] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + parameters: Union[_models.EncryptionProtector, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.EncryptionProtector]: + """Updates an existing encryption protector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param encryption_protector_name: The name of the encryption protector to be retrieved. + "current" Required. + :type encryption_protector_name: str or ~azure.mgmt.sql.models.EncryptionProtectorName + :param parameters: The requested encryption protector resource state. Is one of the following + types: EncryptionProtector, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.EncryptionProtector or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns EncryptionProtector. The + EncryptionProtector is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.EncryptionProtector] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + encryption_protector_name=encryption_protector_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.EncryptionProtector, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.EncryptionProtector].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.EncryptionProtector]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.EncryptionProtector"]: + """Gets a list of server encryption protectors. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of EncryptionProtector + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.EncryptionProtector] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.EncryptionProtector]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_encryption_protectors_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.EncryptionProtector], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _revalidate_initial( + self, + resource_group_name: str, + server_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_encryption_protectors_revalidate_request( + resource_group_name=resource_group_name, + server_name=server_name, + encryption_protector_name=encryption_protector_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_revalidate( + self, + resource_group_name: str, + server_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. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param encryption_protector_name: The name of the encryption protector to be retrieved. + "current" Required. + :type encryption_protector_name: str or ~azure.mgmt.sql.models.EncryptionProtectorName + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + encryption_protector_name=encryption_protector_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class EndpointCertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`endpoint_certificates` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, managed_instance_name: str, endpoint_type: str, **kwargs: Any + ) -> _models.EndpointCertificate: + """Gets a certificate used on the endpoint with the given id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param endpoint_type: Type of the endpoint whose certificate the customer is looking for. + Required. + :type endpoint_type: str + :return: EndpointCertificate. The EndpointCertificate is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.EndpointCertificate + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.EndpointCertificate] = kwargs.pop("cls", None) + + _request = build_endpoint_certificates_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + endpoint_type=endpoint_type, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.EndpointCertificate, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.EndpointCertificate"]: + """List certificates used on endpoints on the target instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of EndpointCertificate + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.EndpointCertificate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.EndpointCertificate]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_endpoint_certificates_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.EndpointCertificate], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class FailoverGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`failover_groups` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, failover_group_name: str, **kwargs: Any + ) -> _models.FailoverGroup: + """Gets a failover group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: FailoverGroup. The FailoverGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.FailoverGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.FailoverGroup] = kwargs.pop("cls", None) + + _request = build_failover_groups_get_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.FailoverGroup, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + failover_group_name: str, + parameters: Union[_models.FailoverGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_failover_groups_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + failover_group_name: str, + parameters: _models.FailoverGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FailoverGroup]: + """Creates or updates a failover group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param parameters: The failover group parameters. Required. + :type parameters: ~azure.mgmt.sql.models.FailoverGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns FailoverGroup. The FailoverGroup is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.FailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + failover_group_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FailoverGroup]: + """Creates or updates a failover group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param parameters: The failover group parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns FailoverGroup. The FailoverGroup is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.FailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + failover_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FailoverGroup]: + """Creates or updates a failover group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param parameters: The failover group parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns FailoverGroup. The FailoverGroup is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.FailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + failover_group_name: str, + parameters: Union[_models.FailoverGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.FailoverGroup]: + """Creates or updates a failover group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param parameters: The failover group parameters. Is one of the following types: FailoverGroup, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.FailoverGroup or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns FailoverGroup. The FailoverGroup is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.FailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + failover_group_name=failover_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.FailoverGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.FailoverGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.FailoverGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + server_name: str, + failover_group_name: str, + parameters: Union[_models.FailoverGroupUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_failover_groups_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + failover_group_name: str, + parameters: _models.FailoverGroupUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FailoverGroup]: + """Updates a failover group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param parameters: The failover group parameters. Required. + :type parameters: ~azure.mgmt.sql.models.FailoverGroupUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns FailoverGroup. The FailoverGroup is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.FailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + failover_group_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FailoverGroup]: + """Updates a failover group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param parameters: The failover group parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns FailoverGroup. The FailoverGroup is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.FailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + failover_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.FailoverGroup]: + """Updates a failover group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param parameters: The failover group parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns FailoverGroup. The FailoverGroup is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.FailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + server_name: str, + failover_group_name: str, + parameters: Union[_models.FailoverGroupUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.FailoverGroup]: + """Updates a failover group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param parameters: The failover group parameters. Is one of the following types: + FailoverGroupUpdate, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.FailoverGroupUpdate or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns FailoverGroup. The FailoverGroup is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.FailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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( + resource_group_name=resource_group_name, + server_name=server_name, + failover_group_name=failover_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.FailoverGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.FailoverGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.FailoverGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, server_name: str, failover_group_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_failover_groups_delete_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, server_name: str, failover_group_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a failover group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + failover_group_name=failover_group_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.FailoverGroup"]: + """Lists the failover groups in a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of FailoverGroup + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.FailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.FailoverGroup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_failover_groups_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.FailoverGroup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _failover_initial( + self, resource_group_name: str, server_name: str, failover_group_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_failover_groups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An instance of AsyncLROPoller that returns FailoverGroup. The FailoverGroup is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.FailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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._failover_initial( + resource_group_name=resource_group_name, + server_name=server_name, + failover_group_name=failover_group_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.FailoverGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.FailoverGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.FailoverGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _force_failover_allow_data_loss_initial( + self, resource_group_name: str, server_name: str, failover_group_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_failover_groups_force_failover_allow_data_loss_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_force_failover_allow_data_loss( + 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 might result in data + loss. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An instance of AsyncLROPoller that returns FailoverGroup. The FailoverGroup is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.FailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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._force_failover_allow_data_loss_initial( + resource_group_name=resource_group_name, + server_name=server_name, + failover_group_name=failover_group_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.FailoverGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.FailoverGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.FailoverGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _try_planned_before_forced_failover_initial( # pylint: disable=name-too-long + self, resource_group_name: str, server_name: str, failover_group_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_failover_groups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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. The name is case insensitive. + 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 + :return: An instance of AsyncLROPoller that returns FailoverGroup. The FailoverGroup is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.FailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.FailoverGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.FailoverGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.FailoverGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class GeoBackupPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`geo_backup_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + 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. The name is case insensitive. + Required. + :type resource_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 + :return: GeoBackupPolicy. The GeoBackupPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.GeoBackupPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.GeoBackupPolicy] = kwargs.pop("cls", None) + + _request = build_geo_backup_policies_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GeoBackupPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + geo_backup_policy_name: Union[str, _models.GeoBackupPolicyName], + parameters: _models.GeoBackupPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GeoBackupPolicy: + """Create or update a database default Geo backup policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :param parameters: The required parameters for creating or updating the geo backup policy. + Required. + :type parameters: ~azure.mgmt.sql.models.GeoBackupPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GeoBackupPolicy. The GeoBackupPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.GeoBackupPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + geo_backup_policy_name: Union[str, _models.GeoBackupPolicyName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GeoBackupPolicy: + """Create or update a database default Geo backup policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :param parameters: The required parameters for creating or updating the geo backup policy. + Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GeoBackupPolicy. The GeoBackupPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.GeoBackupPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + geo_backup_policy_name: Union[str, _models.GeoBackupPolicyName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GeoBackupPolicy: + """Create or update a database default Geo backup policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :param parameters: The required parameters for creating or updating the geo backup policy. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: GeoBackupPolicy. The GeoBackupPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.GeoBackupPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + geo_backup_policy_name: Union[str, _models.GeoBackupPolicyName], + parameters: Union[_models.GeoBackupPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.GeoBackupPolicy: + """Create or update a database default Geo backup policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :param parameters: The required parameters for creating or updating the geo backup policy. Is + one of the following types: GeoBackupPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.GeoBackupPolicy or JSON or IO[bytes] + :return: GeoBackupPolicy. The GeoBackupPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.GeoBackupPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_geo_backup_policies_create_or_update_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await 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]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GeoBackupPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.GeoBackupPolicy"]: + """Gets a list of Geo backup policies for the given database resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of GeoBackupPolicy + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.GeoBackupPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.GeoBackupPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_geo_backup_policies_list_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.GeoBackupPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class InstanceFailoverGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`instance_failover_groups` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, location_name: str, failover_group_name: str, **kwargs: Any + ) -> _models.InstanceFailoverGroup: + """Gets a failover group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :param failover_group_name: The name of the failover group. Required. + :type failover_group_name: str + :return: InstanceFailoverGroup. The InstanceFailoverGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.InstanceFailoverGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.InstanceFailoverGroup] = kwargs.pop("cls", None) + + _request = build_instance_failover_groups_get_request( + resource_group_name=resource_group_name, + location_name=location_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.InstanceFailoverGroup, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + location_name: str, + failover_group_name: str, + parameters: Union[_models.InstanceFailoverGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_instance_failover_groups_create_or_update_request( + resource_group_name=resource_group_name, + location_name=location_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + location_name: str, + failover_group_name: str, + parameters: _models.InstanceFailoverGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.InstanceFailoverGroup]: + """Creates or updates a failover group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :param failover_group_name: The name of the failover group. Required. + :type failover_group_name: str + :param parameters: The failover group parameters. Required. + :type parameters: ~azure.mgmt.sql.models.InstanceFailoverGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns InstanceFailoverGroup. The + InstanceFailoverGroup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.InstanceFailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + location_name: str, + failover_group_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.InstanceFailoverGroup]: + """Creates or updates a failover group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :param failover_group_name: The name of the failover group. Required. + :type failover_group_name: str + :param parameters: The failover group parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns InstanceFailoverGroup. The + InstanceFailoverGroup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.InstanceFailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + location_name: str, + failover_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.InstanceFailoverGroup]: + """Creates or updates a failover group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :param failover_group_name: The name of the failover group. Required. + :type failover_group_name: str + :param parameters: The failover group parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns InstanceFailoverGroup. The + InstanceFailoverGroup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.InstanceFailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + location_name: str, + failover_group_name: str, + parameters: Union[_models.InstanceFailoverGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.InstanceFailoverGroup]: + """Creates or updates a failover group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :param failover_group_name: The name of the failover group. Required. + :type failover_group_name: str + :param parameters: The failover group parameters. Is one of the following types: + InstanceFailoverGroup, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.InstanceFailoverGroup or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns InstanceFailoverGroup. The + InstanceFailoverGroup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.InstanceFailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + location_name=location_name, + failover_group_name=failover_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.InstanceFailoverGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.InstanceFailoverGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.InstanceFailoverGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, location_name: str, failover_group_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_instance_failover_groups_delete_request( + resource_group_name=resource_group_name, + location_name=location_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, location_name: str, failover_group_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a failover group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :param failover_group_name: The name of the failover group. Required. + :type failover_group_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + location_name=location_name, + failover_group_name=failover_group_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_location( + self, resource_group_name: str, location_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.InstanceFailoverGroup"]: + """Lists the failover groups in a location. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :return: An iterator like instance of InstanceFailoverGroup + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.InstanceFailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.InstanceFailoverGroup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_instance_failover_groups_list_by_location_request( + resource_group_name=resource_group_name, + location_name=location_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.InstanceFailoverGroup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _failover_initial( + self, resource_group_name: str, location_name: str, failover_group_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_instance_failover_groups_failover_request( + resource_group_name=resource_group_name, + location_name=location_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_failover( + self, resource_group_name: str, location_name: str, failover_group_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.InstanceFailoverGroup]: + """Fails over from the current primary managed instance to this managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :param failover_group_name: The name of the failover group. Required. + :type failover_group_name: str + :return: An instance of AsyncLROPoller that returns InstanceFailoverGroup. The + InstanceFailoverGroup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.InstanceFailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._failover_initial( + resource_group_name=resource_group_name, + location_name=location_name, + failover_group_name=failover_group_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.InstanceFailoverGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.InstanceFailoverGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.InstanceFailoverGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _force_failover_allow_data_loss_initial( + self, resource_group_name: str, location_name: str, failover_group_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_instance_failover_groups_force_failover_allow_data_loss_request( + resource_group_name=resource_group_name, + location_name=location_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_force_failover_allow_data_loss( + self, resource_group_name: str, location_name: str, failover_group_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.InstanceFailoverGroup]: + """Fails over from the current primary managed instance to this managed instance. This operation + might result in data loss. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :param failover_group_name: The name of the failover group. Required. + :type failover_group_name: str + :return: An instance of AsyncLROPoller that returns InstanceFailoverGroup. The + InstanceFailoverGroup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.InstanceFailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._force_failover_allow_data_loss_initial( + resource_group_name=resource_group_name, + location_name=location_name, + failover_group_name=failover_group_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.InstanceFailoverGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.InstanceFailoverGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.InstanceFailoverGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class InstancePoolOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`instance_pool_operations` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, instance_pool_name: str, operation_id: str, **kwargs: Any + ) -> _models.InstancePoolOperation: + """Gets a management operation on a instance pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param instance_pool_name: The name of the instance pool to be retrieved. Required. + :type instance_pool_name: str + :param operation_id: Required. + :type operation_id: str + :return: InstancePoolOperation. The InstancePoolOperation is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.InstancePoolOperation + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.InstancePoolOperation] = kwargs.pop("cls", None) + + _request = build_instance_pool_operations_get_request( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.InstancePoolOperation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_instance_pool( + self, resource_group_name: str, instance_pool_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.InstancePoolOperation"]: + """Gets a list of operations performed on the instance pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param instance_pool_name: The name of the instance pool to be retrieved. Required. + :type instance_pool_name: str + :return: An iterator like instance of InstancePoolOperation + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.InstancePoolOperation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.InstancePoolOperation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_instance_pool_operations_list_by_instance_pool_request( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.InstancePoolOperation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class InstancePoolsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`instance_pools` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, resource_group_name: str, instance_pool_name: str, **kwargs: Any) -> _models.InstancePool: + """Gets an instance pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param instance_pool_name: The name of the instance pool to be retrieved. Required. + :type instance_pool_name: str + :return: InstancePool. The InstancePool is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.InstancePool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.InstancePool] = kwargs.pop("cls", None) + + _request = build_instance_pools_get_request( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.InstancePool, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + instance_pool_name: str, + parameters: Union[_models.InstancePool, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_instance_pools_create_or_update_request( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + instance_pool_name: str, + parameters: _models.InstancePool, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.InstancePool]: + """Creates or updates an instance pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param instance_pool_name: The name of the instance pool to be retrieved. Required. + :type instance_pool_name: str + :param parameters: The requested instance pool resource state. Required. + :type parameters: ~azure.mgmt.sql.models.InstancePool + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns InstancePool. The InstancePool is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.InstancePool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + instance_pool_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.InstancePool]: + """Creates or updates an instance pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param instance_pool_name: The name of the instance pool to be retrieved. Required. + :type instance_pool_name: str + :param parameters: The requested instance pool resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns InstancePool. The InstancePool is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.InstancePool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + instance_pool_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.InstancePool]: + """Creates or updates an instance pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param instance_pool_name: The name of the instance pool to be retrieved. Required. + :type instance_pool_name: str + :param parameters: The requested instance pool resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns InstancePool. The InstancePool is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.InstancePool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + instance_pool_name: str, + parameters: Union[_models.InstancePool, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.InstancePool]: + """Creates or updates an instance pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param instance_pool_name: The name of the instance pool to be retrieved. Required. + :type instance_pool_name: str + :param parameters: The requested instance pool resource state. Is one of the following types: + InstancePool, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.InstancePool or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns InstancePool. The InstancePool is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.InstancePool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + instance_pool_name=instance_pool_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.InstancePool, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.InstancePool].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.InstancePool]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + instance_pool_name: str, + parameters: Union[_models.InstancePoolUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_instance_pools_update_request( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + instance_pool_name: str, + parameters: _models.InstancePoolUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.InstancePool]: + """Updates an instance pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param instance_pool_name: The name of the instance pool to be retrieved. Required. + :type instance_pool_name: str + :param parameters: The requested instance pool resource state. Required. + :type parameters: ~azure.mgmt.sql.models.InstancePoolUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns InstancePool. The InstancePool is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.InstancePool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + instance_pool_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.InstancePool]: + """Updates an instance pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param instance_pool_name: The name of the instance pool to be retrieved. Required. + :type instance_pool_name: str + :param parameters: The requested instance pool resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns InstancePool. The InstancePool is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.InstancePool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + instance_pool_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.InstancePool]: + """Updates an instance pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param instance_pool_name: The name of the instance pool to be retrieved. Required. + :type instance_pool_name: str + :param parameters: The requested instance pool resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns InstancePool. The InstancePool is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.InstancePool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + instance_pool_name: str, + parameters: Union[_models.InstancePoolUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.InstancePool]: + """Updates an instance pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param instance_pool_name: The name of the instance pool to be retrieved. Required. + :type instance_pool_name: str + :param parameters: The requested instance pool resource state. Is one of the following types: + InstancePoolUpdate, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.InstancePoolUpdate or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns InstancePool. The InstancePool is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.InstancePool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.InstancePool, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.InstancePool].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.InstancePool]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, instance_pool_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_instance_pools_delete_request( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, instance_pool_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an instance pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param instance_pool_name: The name of the instance pool to be retrieved. Required. + :type instance_pool_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncItemPaged["_models.InstancePool"]: + """Gets a list of instance pools in the resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of InstancePool + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.InstancePool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.InstancePool]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_instance_pools_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.InstancePool], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncItemPaged["_models.InstancePool"]: + """Gets a list of all instance pools in the subscription. + + :return: An iterator like instance of InstancePool + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.InstancePool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.InstancePool]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_instance_pools_list_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.InstancePool], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class IPv6FirewallRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`ipv6_firewall_rules` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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.IPv6FirewallRule: + """Gets an IPv6 firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: IPv6FirewallRule. The IPv6FirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.IPv6FirewallRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.IPv6FirewallRule] = kwargs.pop("cls", None) + + _request = build_ipv6_firewall_rules_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.IPv6FirewallRule, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + parameters: _models.IPv6FirewallRule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IPv6FirewallRule: + """Creates or updates an IPv6 firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 an IPv6 firewall rule. + Required. + :type parameters: ~azure.mgmt.sql.models.IPv6FirewallRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: IPv6FirewallRule. The IPv6FirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.IPv6FirewallRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IPv6FirewallRule: + """Creates or updates an IPv6 firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 an IPv6 firewall rule. + Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: IPv6FirewallRule. The IPv6FirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.IPv6FirewallRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IPv6FirewallRule: + """Creates or updates an IPv6 firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 an IPv6 firewall rule. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: IPv6FirewallRule. The IPv6FirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.IPv6FirewallRule + :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.IPv6FirewallRule, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.IPv6FirewallRule: + """Creates or updates an IPv6 firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 an IPv6 firewall rule. Is + one of the following types: IPv6FirewallRule, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.IPv6FirewallRule or JSON or IO[bytes] + :return: IPv6FirewallRule. The IPv6FirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.IPv6FirewallRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_ipv6_firewall_rules_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + firewall_rule_name=firewall_rule_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await 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]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.IPv6FirewallRule, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, resource_group_name: str, server_name: str, firewall_rule_name: str, **kwargs: Any) -> None: + """Deletes an IPv6 firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_ipv6_firewall_rules_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await 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) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.IPv6FirewallRule"]: + """Gets a list of IPv6 firewall rules. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of IPv6FirewallRule + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.IPv6FirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.IPv6FirewallRule]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_ipv6_firewall_rules_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.IPv6FirewallRule], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class JobExecutionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`job_executions` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + job_agent_name: str, + job_name: str, + job_execution_id: str, + **kwargs: Any + ) -> _models.JobExecution: + """Gets a job execution. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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_execution_id: The id of the job execution. Required. + :type job_execution_id: str + :return: JobExecution. The JobExecution is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobExecution + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.JobExecution] = kwargs.pop("cls", None) + + _request = build_job_executions_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JobExecution, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + 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 + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_job_executions_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 + ) -> AsyncLROPoller[_models.JobExecution]: + """Creates or updates a job execution. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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_execution_id: The id of the job execution. Required. + :type job_execution_id: str + :return: An instance of AsyncLROPoller that returns JobExecution. The JobExecution is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.JobExecution] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.JobExecution, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.JobExecution].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.JobExecution]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace_async + async def cancel( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_execution_id: str, + **kwargs: Any + ) -> None: + """Requests cancellation of a job execution. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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_execution_id: The id of the job execution. Required. + :type job_execution_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_job_executions_cancel_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_models.JobExecution"]: + """Lists a job's executions. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :keyword create_time_min: If specified, only job executions created at or after the specified + time are included. Default value is None. + :paramtype create_time_min: ~datetime.datetime + :keyword create_time_max: If specified, only job executions created before the specified time + are included. Default value is None. + :paramtype create_time_max: ~datetime.datetime + :keyword end_time_min: If specified, only job executions completed at or after the specified + time are included. Default value is None. + :paramtype end_time_min: ~datetime.datetime + :keyword end_time_max: If specified, only job executions completed before the specified time + are included. Default value is None. + :paramtype end_time_max: ~datetime.datetime + :keyword is_active: If specified, only active or only completed job executions are included. + Default value is None. + :paramtype is_active: bool + :keyword skip: The number of elements in the collection to skip. Default value is None. + :paramtype skip: int + :keyword top: The number of elements to return from the collection. Default value is None. + :paramtype top: int + :return: An iterator like instance of JobExecution + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobExecution] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.JobExecution]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_job_executions_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.JobExecution], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_agent( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + *, + create_time_min: Optional[datetime.datetime] = None, + create_time_max: Optional[datetime.datetime] = None, + end_time_min: Optional[datetime.datetime] = None, + end_time_max: Optional[datetime.datetime] = None, + is_active: Optional[bool] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.JobExecution"]: + """Lists all executions in a job agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :keyword create_time_min: If specified, only job executions created at or after the specified + time are included. Default value is None. + :paramtype create_time_min: ~datetime.datetime + :keyword create_time_max: If specified, only job executions created before the specified time + are included. Default value is None. + :paramtype create_time_max: ~datetime.datetime + :keyword end_time_min: If specified, only job executions completed at or after the specified + time are included. Default value is None. + :paramtype end_time_min: ~datetime.datetime + :keyword end_time_max: If specified, only job executions completed before the specified time + are included. Default value is None. + :paramtype end_time_max: ~datetime.datetime + :keyword is_active: If specified, only active or only completed job executions are included. + Default value is None. + :paramtype is_active: bool + :keyword skip: The number of elements in the collection to skip. Default value is None. + :paramtype skip: int + :keyword top: The number of elements to return from the collection. Default value is None. + :paramtype top: int + :return: An iterator like instance of JobExecution + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobExecution] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.JobExecution]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_job_executions_list_by_agent_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + create_time_min=create_time_min, + create_time_max=create_time_max, + end_time_min=end_time_min, + end_time_max=end_time_max, + is_active=is_active, + skip=skip, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.JobExecution], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _create_initial( + self, resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_job_executions_create_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, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_create( + self, resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.JobExecution]: + """Starts an elastic job execution. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param job_name: The name of the job to get. Required. + :type job_name: str + :return: An instance of AsyncLROPoller that returns JobExecution. The JobExecution is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.JobExecution] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.JobExecution, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.JobExecution].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.JobExecution]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class JobAgentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`job_agents` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, job_agent_name: str, **kwargs: Any + ) -> _models.JobAgent: + """Gets a job agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :return: JobAgent. The JobAgent is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobAgent + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.JobAgent] = kwargs.pop("cls", None) + + _request = build_job_agents_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JobAgent, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + parameters: Union[_models.JobAgent, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_job_agents_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + parameters: _models.JobAgent, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.JobAgent]: + """Creates or updates a job agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param parameters: The requested job agent resource state. Required. + :type parameters: ~azure.mgmt.sql.models.JobAgent + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns JobAgent. The JobAgent is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.JobAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.JobAgent]: + """Creates or updates a job agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param parameters: The requested job agent resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns JobAgent. The JobAgent is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.JobAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.JobAgent]: + """Creates or updates a job agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param parameters: The requested job agent resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns JobAgent. The JobAgent is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.JobAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + parameters: Union[_models.JobAgent, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.JobAgent]: + """Creates or updates a job agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param parameters: The requested job agent resource state. Is one of the following types: + JobAgent, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.JobAgent or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns JobAgent. The JobAgent is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.JobAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + job_agent_name=job_agent_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.JobAgent, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.JobAgent].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.JobAgent]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + parameters: Union[_models.JobAgentUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_job_agents_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + parameters: _models.JobAgentUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.JobAgent]: + """Updates a job agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param parameters: The update to the job agent. Required. + :type parameters: ~azure.mgmt.sql.models.JobAgentUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns JobAgent. The JobAgent is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.JobAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.JobAgent]: + """Updates a job agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param parameters: The update to the job agent. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns JobAgent. The JobAgent is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.JobAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.JobAgent]: + """Updates a job agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param parameters: The update to the job agent. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns JobAgent. The JobAgent is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.JobAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + parameters: Union[_models.JobAgentUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.JobAgent]: + """Updates a job agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param parameters: The update to the job agent. Is one of the following types: JobAgentUpdate, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.JobAgentUpdate or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns JobAgent. The JobAgent is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.JobAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.JobAgent, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.JobAgent].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.JobAgent]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, server_name: str, job_agent_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_job_agents_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, server_name: str, job_agent_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a job agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.JobAgent"]: + """Gets a list of job agents in a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of JobAgent + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.JobAgent]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_job_agents_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.JobAgent], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class JobCredentialsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`job_credentials` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, job_agent_name: str, credential_name: str, **kwargs: Any + ) -> _models.JobCredential: + """Gets a jobs credential. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param credential_name: The name of the credential. Required. + :type credential_name: str + :return: JobCredential. The JobCredential is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobCredential + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.JobCredential] = kwargs.pop("cls", None) + + _request = build_job_credentials_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + credential_name=credential_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JobCredential, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + credential_name: str, + parameters: _models.JobCredential, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobCredential: + """Creates or updates a job credential. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param credential_name: The name of the credential. Required. + :type credential_name: str + :param parameters: The requested job credential state. Required. + :type parameters: ~azure.mgmt.sql.models.JobCredential + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JobCredential. The JobCredential is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobCredential + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + credential_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobCredential: + """Creates or updates a job credential. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param credential_name: The name of the credential. Required. + :type credential_name: str + :param parameters: The requested job credential state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JobCredential. The JobCredential is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobCredential + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + credential_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobCredential: + """Creates or updates a job credential. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param credential_name: The name of the credential. Required. + :type credential_name: str + :param parameters: The requested job credential state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JobCredential. The JobCredential is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobCredential + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + credential_name: str, + parameters: Union[_models.JobCredential, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.JobCredential: + """Creates or updates a job credential. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param credential_name: The name of the credential. Required. + :type credential_name: str + :param parameters: The requested job credential state. Is one of the following types: + JobCredential, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.JobCredential or JSON or IO[bytes] + :return: JobCredential. The JobCredential is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobCredential + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_job_credentials_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + credential_name=credential_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await 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]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JobCredential, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, resource_group_name: str, server_name: str, job_agent_name: str, credential_name: str, **kwargs: Any + ) -> None: + """Deletes a job credential. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param credential_name: The name of the credential. Required. + :type credential_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_job_credentials_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + credential_name=credential_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await 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) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_agent( + self, resource_group_name: str, server_name: str, job_agent_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.JobCredential"]: + """Gets a list of jobs credentials. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :return: An iterator like instance of JobCredential + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.JobCredential]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_job_credentials_list_by_agent_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.JobCredential], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class JobStepExecutionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`job_step_executions` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + job_agent_name: str, + job_name: str, + job_execution_id: str, + step_name: str, + **kwargs: Any + ) -> _models.JobExecution: + """Gets a step execution of a job execution. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: JobExecution. The JobExecution is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobExecution + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.JobExecution] = kwargs.pop("cls", None) + + _request = build_job_step_executions_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + step_name=step_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JobExecution, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_job_execution( # pylint: disable=too-many-locals + 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, + end_time_max: Optional[datetime.datetime] = None, + is_active: Optional[bool] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.JobExecution"]: + """Lists the step executions of a job execution. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :keyword create_time_min: If specified, only job executions created at or after the specified + time are included. Default value is None. + :paramtype create_time_min: ~datetime.datetime + :keyword create_time_max: If specified, only job executions created before the specified time + are included. Default value is None. + :paramtype create_time_max: ~datetime.datetime + :keyword end_time_min: If specified, only job executions completed at or after the specified + time are included. Default value is None. + :paramtype end_time_min: ~datetime.datetime + :keyword end_time_max: If specified, only job executions completed before the specified time + are included. Default value is None. + :paramtype end_time_max: ~datetime.datetime + :keyword is_active: If specified, only active or only completed job executions are included. + Default value is None. + :paramtype is_active: bool + :keyword skip: The number of elements in the collection to skip. Default value is None. + :paramtype skip: int + :keyword top: The number of elements to return from the collection. Default value is None. + :paramtype top: int + :return: An iterator like instance of JobExecution + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobExecution] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.JobExecution]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_job_step_executions_list_by_job_execution_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + subscription_id=self._config.subscription_id, + create_time_min=create_time_min, + create_time_max=create_time_max, + end_time_min=end_time_min, + end_time_max=end_time_max, + is_active=is_active, + skip=skip, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.JobExecution], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class JobTargetExecutionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`job_target_executions` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + 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. The name is case insensitive. + 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 + :return: JobExecution. The JobExecution is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobExecution + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.JobExecution] = kwargs.pop("cls", None) + + _request = build_job_target_executions_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JobExecution, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_step( # pylint: disable=too-many-locals + 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, + end_time_max: Optional[datetime.datetime] = None, + is_active: Optional[bool] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.JobExecution"]: + """Lists the target executions of a job step execution. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :keyword create_time_min: If specified, only job executions created at or after the specified + time are included. Default value is None. + :paramtype create_time_min: ~datetime.datetime + :keyword create_time_max: If specified, only job executions created before the specified time + are included. Default value is None. + :paramtype create_time_max: ~datetime.datetime + :keyword end_time_min: If specified, only job executions completed at or after the specified + time are included. Default value is None. + :paramtype end_time_min: ~datetime.datetime + :keyword end_time_max: If specified, only job executions completed before the specified time + are included. Default value is None. + :paramtype end_time_max: ~datetime.datetime + :keyword is_active: If specified, only active or only completed job executions are included. + Default value is None. + :paramtype is_active: bool + :keyword skip: The number of elements in the collection to skip. Default value is None. + :paramtype skip: int + :keyword top: The number of elements to return from the collection. Default value is None. + :paramtype top: int + :return: An iterator like instance of JobExecution + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobExecution] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.JobExecution]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_job_target_executions_list_by_step_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + step_name=step_name, + subscription_id=self._config.subscription_id, + create_time_min=create_time_min, + create_time_max=create_time_max, + end_time_min=end_time_min, + end_time_max=end_time_max, + is_active=is_active, + skip=skip, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.JobExecution], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_job_execution( # pylint: disable=too-many-locals + 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, + end_time_max: Optional[datetime.datetime] = None, + is_active: Optional[bool] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.JobExecution"]: + """Lists target executions for all steps of a job execution. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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_execution_id: The id of the job execution. Required. + :type job_execution_id: str + :keyword create_time_min: If specified, only job executions created at or after the specified + time are included. Default value is None. + :paramtype create_time_min: ~datetime.datetime + :keyword create_time_max: If specified, only job executions created before the specified time + are included. Default value is None. + :paramtype create_time_max: ~datetime.datetime + :keyword end_time_min: If specified, only job executions completed at or after the specified + time are included. Default value is None. + :paramtype end_time_min: ~datetime.datetime + :keyword end_time_max: If specified, only job executions completed before the specified time + are included. Default value is None. + :paramtype end_time_max: ~datetime.datetime + :keyword is_active: If specified, only active or only completed job executions are included. + Default value is None. + :paramtype is_active: bool + :keyword skip: The number of elements in the collection to skip. Default value is None. + :paramtype skip: int + :keyword top: The number of elements to return from the collection. Default value is None. + :paramtype top: int + :return: An iterator like instance of JobExecution + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobExecution] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.JobExecution]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_job_target_executions_list_by_job_execution_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + subscription_id=self._config.subscription_id, + create_time_min=create_time_min, + create_time_max=create_time_max, + end_time_min=end_time_min, + end_time_max=end_time_max, + is_active=is_active, + skip=skip, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.JobExecution], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class JobsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`jobs` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, job_agent_name: str, job_name: str, **kwargs: Any + ) -> _models.Job: + """Gets a job. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param job_name: The name of the job to get. Required. + :type job_name: str + :return: Job. The Job is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Job + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + _request = build_jobs_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Job, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + parameters: _models.Job, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Job: + """Creates or updates a job. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param job_name: The name of the job to get. Required. + :type job_name: str + :param parameters: The requested job state. Required. + :type parameters: ~azure.mgmt.sql.models.Job + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Job. The Job is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Job + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Job: + """Creates or updates a job. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param job_name: The name of the job to get. Required. + :type job_name: str + :param parameters: The requested job state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Job. The Job is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Job + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Job: + """Creates or updates a job. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param job_name: The name of the job to get. Required. + :type job_name: str + :param parameters: The requested job state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Job. The Job is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Job + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + parameters: Union[_models.Job, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.Job: + """Creates or updates a job. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param job_name: The name of the job to get. Required. + :type job_name: str + :param parameters: The requested job state. Is one of the following types: Job, JSON, IO[bytes] + Required. + :type parameters: ~azure.mgmt.sql.models.Job or JSON or IO[bytes] + :return: Job. The Job is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Job + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_jobs_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await 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]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Job, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, **kwargs: Any + ) -> None: + """Deletes a job. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param job_name: The name of the job to get. Required. + :type job_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_jobs_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await 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) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_agent( + self, resource_group_name: str, server_name: str, job_agent_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.Job"]: + """Gets a list of jobs. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :return: An iterator like instance of Job + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.Job] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Job]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_jobs_list_by_agent_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Job], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class JobPrivateEndpointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`job_private_endpoints` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, job_agent_name: str, private_endpoint_name: str, **kwargs: Any + ) -> _models.JobPrivateEndpoint: + """Gets a private endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param private_endpoint_name: The name of the private endpoint to get. Required. + :type private_endpoint_name: str + :return: JobPrivateEndpoint. The JobPrivateEndpoint is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobPrivateEndpoint + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.JobPrivateEndpoint] = kwargs.pop("cls", None) + + _request = build_job_private_endpoints_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + private_endpoint_name=private_endpoint_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JobPrivateEndpoint, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + private_endpoint_name: str, + parameters: Union[_models.JobPrivateEndpoint, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_job_private_endpoints_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + private_endpoint_name=private_endpoint_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + private_endpoint_name: str, + parameters: _models.JobPrivateEndpoint, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.JobPrivateEndpoint]: + """Creates or updates a private endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param private_endpoint_name: The name of the private endpoint to get. Required. + :type private_endpoint_name: str + :param parameters: The requested private endpoint state. Required. + :type parameters: ~azure.mgmt.sql.models.JobPrivateEndpoint + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns JobPrivateEndpoint. The JobPrivateEndpoint + is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.JobPrivateEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + private_endpoint_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.JobPrivateEndpoint]: + """Creates or updates a private endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param private_endpoint_name: The name of the private endpoint to get. Required. + :type private_endpoint_name: str + :param parameters: The requested private endpoint state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns JobPrivateEndpoint. The JobPrivateEndpoint + is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.JobPrivateEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + private_endpoint_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.JobPrivateEndpoint]: + """Creates or updates a private endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param private_endpoint_name: The name of the private endpoint to get. Required. + :type private_endpoint_name: str + :param parameters: The requested private endpoint state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns JobPrivateEndpoint. The JobPrivateEndpoint + is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.JobPrivateEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + private_endpoint_name: str, + parameters: Union[_models.JobPrivateEndpoint, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.JobPrivateEndpoint]: + """Creates or updates a private endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param private_endpoint_name: The name of the private endpoint to get. Required. + :type private_endpoint_name: str + :param parameters: The requested private endpoint state. Is one of the following types: + JobPrivateEndpoint, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.JobPrivateEndpoint or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns JobPrivateEndpoint. The JobPrivateEndpoint + is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.JobPrivateEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.JobPrivateEndpoint] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + private_endpoint_name=private_endpoint_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.JobPrivateEndpoint, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.JobPrivateEndpoint].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.JobPrivateEndpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, server_name: str, job_agent_name: str, private_endpoint_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_job_private_endpoints_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + private_endpoint_name=private_endpoint_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, server_name: str, job_agent_name: str, private_endpoint_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a private endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param private_endpoint_name: The name of the private endpoint to get. Required. + :type private_endpoint_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + private_endpoint_name=private_endpoint_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_agent( + self, resource_group_name: str, server_name: str, job_agent_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.JobPrivateEndpoint"]: + """Gets a list of job agent private endpoints. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :return: An iterator like instance of JobPrivateEndpoint + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobPrivateEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.JobPrivateEndpoint]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_job_private_endpoints_list_by_agent_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.JobPrivateEndpoint], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class JobStepsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`job_steps` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + job_agent_name: str, + job_name: str, + step_name: str, + **kwargs: Any + ) -> _models.JobStep: + """Gets a job step in a job's current version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 step_name: The name of the job step. Required. + :type step_name: str + :return: JobStep. The JobStep is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobStep + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.JobStep] = kwargs.pop("cls", None) + + _request = build_job_steps_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + step_name=step_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JobStep, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + step_name: str, + parameters: _models.JobStep, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobStep: + """Creates or updates a job step. This will implicitly create a new job version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 step_name: The name of the job step. Required. + :type step_name: str + :param parameters: The requested state of the job step. Required. + :type parameters: ~azure.mgmt.sql.models.JobStep + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JobStep. The JobStep is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobStep + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + step_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobStep: + """Creates or updates a job step. This will implicitly create a new job version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 step_name: The name of the job step. Required. + :type step_name: str + :param parameters: The requested state of the job step. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JobStep. The JobStep is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobStep + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + step_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobStep: + """Creates or updates a job step. This will implicitly create a new job version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 step_name: The name of the job step. Required. + :type step_name: str + :param parameters: The requested state of the job step. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JobStep. The JobStep is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobStep + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + step_name: str, + parameters: Union[_models.JobStep, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.JobStep: + """Creates or updates a job step. This will implicitly create a new job version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 step_name: The name of the job step. Required. + :type step_name: str + :param parameters: The requested state of the job step. Is one of the following types: JobStep, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.JobStep or JSON or IO[bytes] + :return: JobStep. The JobStep is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobStep + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_job_steps_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + step_name=step_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await 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]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JobStep, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + step_name: str, + **kwargs: Any + ) -> None: + """Deletes a job step. This will implicitly create a new job version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 step_name: The name of the job step. Required. + :type step_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_job_steps_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + step_name=step_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await 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) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_job( + self, resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.JobStep"]: + """Gets all job steps for a job's current version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An iterator like instance of JobStep + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobStep] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.JobStep]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_job_steps_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, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.JobStep], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @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. The name is case insensitive. + 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 + :return: JobStep. The JobStep is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobStep + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.JobStep] = kwargs.pop("cls", None) + + _request = build_job_steps_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JobStep, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @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 + ) -> AsyncItemPaged["_models.JobStep"]: + """Gets all job steps in the specified job version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An iterator like instance of JobStep + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobStep] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.JobStep]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_job_steps_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.JobStep], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class JobTargetGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`job_target_groups` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, job_agent_name: str, target_group_name: str, **kwargs: Any + ) -> _models.JobTargetGroup: + """Gets a target group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param target_group_name: The name of the target group. Required. + :type target_group_name: str + :return: JobTargetGroup. The JobTargetGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobTargetGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.JobTargetGroup] = kwargs.pop("cls", None) + + _request = build_job_target_groups_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + target_group_name=target_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JobTargetGroup, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + target_group_name: str, + parameters: _models.JobTargetGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobTargetGroup: + """Creates or updates a target group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param target_group_name: The name of the target group. Required. + :type target_group_name: str + :param parameters: The requested state of the target group. Required. + :type parameters: ~azure.mgmt.sql.models.JobTargetGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JobTargetGroup. The JobTargetGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobTargetGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + target_group_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobTargetGroup: + """Creates or updates a target group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param target_group_name: The name of the target group. Required. + :type target_group_name: str + :param parameters: The requested state of the target group. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JobTargetGroup. The JobTargetGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobTargetGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + target_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobTargetGroup: + """Creates or updates a target group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param target_group_name: The name of the target group. Required. + :type target_group_name: str + :param parameters: The requested state of the target group. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JobTargetGroup. The JobTargetGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobTargetGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + target_group_name: str, + parameters: Union[_models.JobTargetGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.JobTargetGroup: + """Creates or updates a target group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param target_group_name: The name of the target group. Required. + :type target_group_name: str + :param parameters: The requested state of the target group. Is one of the following types: + JobTargetGroup, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.JobTargetGroup or JSON or IO[bytes] + :return: JobTargetGroup. The JobTargetGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobTargetGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_job_target_groups_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + target_group_name=target_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await 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]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JobTargetGroup, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, resource_group_name: str, server_name: str, job_agent_name: str, target_group_name: str, **kwargs: Any + ) -> None: + """Deletes a target group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param target_group_name: The name of the target group. Required. + :type target_group_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_job_target_groups_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + target_group_name=target_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await 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) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_agent( + self, resource_group_name: str, server_name: str, job_agent_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.JobTargetGroup"]: + """Gets all target groups in an agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :return: An iterator like instance of JobTargetGroup + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobTargetGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.JobTargetGroup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_job_target_groups_list_by_agent_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.JobTargetGroup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class JobVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`job_versions` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + job_agent_name: str, + job_name: str, + job_version: int, + **kwargs: Any + ) -> _models.JobVersion: + """Gets a job version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: JobVersion. The JobVersion is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.JobVersion] = kwargs.pop("cls", None) + + _request = build_job_versions_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_version=job_version, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JobVersion, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_job( + self, resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.JobVersion"]: + """Gets all versions of a job. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param job_name: The name of the job to get. Required. + :type job_name: str + :return: An iterator like instance of JobVersion + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.JobVersion]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_job_versions_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, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.JobVersion], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class LongTermRetentionBackupsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`long_term_retention_backups` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + **kwargs: Any + ) -> _models.LongTermRetentionBackup: + """Gets a long term retention backup. + + :param location_name: The location of the database. 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 + :return: LongTermRetentionBackup. The LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.LongTermRetentionBackup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) + + _request = build_long_term_retention_backups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.LongTermRetentionBackup, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _delete_initial( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_long_term_retention_backups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 + :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 + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_database( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.LongTermRetentionBackup"]: + """Lists all long term retention backups for a database. + + :param location_name: The location of the database. Required. + :type location_name: str + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :keyword only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :paramtype only_latest_per_database: bool + :keyword 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. + :paramtype database_state: str or ~azure.mgmt.sql.models.DatabaseState + :return: An iterator like instance of LongTermRetentionBackup + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.LongTermRetentionBackup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_long_term_retention_backups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.LongTermRetentionBackup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _change_access_tier_initial( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: Union[_models.ChangeLongTermRetentionBackupAccessTierParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_long_term_retention_backups_change_access_tier_request( + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_change_access_tier( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: _models.ChangeLongTermRetentionBackupAccessTierParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: + """Change a long term retention backup access tier. + + :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: Required. + :type parameters: ~azure.mgmt.sql.models.ChangeLongTermRetentionBackupAccessTierParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns LongTermRetentionBackup. The + LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_change_access_tier( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: + """Change a long term retention backup access tier. + + :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: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns LongTermRetentionBackup. The + LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_change_access_tier( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: + """Change a long term retention backup access tier. + + :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: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns LongTermRetentionBackup. The + LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_change_access_tier( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: Union[_models.ChangeLongTermRetentionBackupAccessTierParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: + """Change a long term retention backup access tier. + + :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: Is one of the following types: + ChangeLongTermRetentionBackupAccessTierParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ChangeLongTermRetentionBackupAccessTierParameters or + JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns LongTermRetentionBackup. The + LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._change_access_tier_initial( + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + backup_name=backup_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LongTermRetentionBackup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.LongTermRetentionBackup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.LongTermRetentionBackup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _copy_initial( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: Union[_models.CopyLongTermRetentionBackupParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_long_term_retention_backups_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_copy( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: _models.CopyLongTermRetentionBackupParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_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 + :return: An instance of AsyncLROPoller that returns LongTermRetentionBackupOperationResult. The + LongTermRetentionBackupOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_copy( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns LongTermRetentionBackupOperationResult. The + LongTermRetentionBackupOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_copy( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_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: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns LongTermRetentionBackupOperationResult. The + LongTermRetentionBackupOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_copy( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: Union[_models.CopyLongTermRetentionBackupParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_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. Is one of the + following types: CopyLongTermRetentionBackupParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.CopyLongTermRetentionBackupParameters or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns LongTermRetentionBackupOperationResult. The + LongTermRetentionBackupOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LongTermRetentionBackupOperationResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._copy_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, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LongTermRetentionBackupOperationResult, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.LongTermRetentionBackupOperationResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _lock_time_based_immutability_initial( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_long_term_retention_backups_lock_time_based_immutability_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_lock_time_based_immutability( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + **kwargs: Any + ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: + """Lock time based immutability of 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 + :return: An instance of AsyncLROPoller that returns LongTermRetentionBackup. The + LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._lock_time_based_immutability_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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LongTermRetentionBackup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.LongTermRetentionBackup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.LongTermRetentionBackup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _remove_legal_hold_immutability_initial( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_long_term_retention_backups_remove_legal_hold_immutability_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_remove_legal_hold_immutability( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + **kwargs: Any + ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: + """Remove legal hold immutability of 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 + :return: An instance of AsyncLROPoller that returns LongTermRetentionBackup. The + LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._remove_legal_hold_immutability_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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LongTermRetentionBackup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.LongTermRetentionBackup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.LongTermRetentionBackup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _remove_time_based_immutability_initial( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_long_term_retention_backups_remove_time_based_immutability_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_remove_time_based_immutability( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + **kwargs: Any + ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: + """Remove time based immutability of 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 + :return: An instance of AsyncLROPoller that returns LongTermRetentionBackup. The + LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._remove_time_based_immutability_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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LongTermRetentionBackup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.LongTermRetentionBackup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.LongTermRetentionBackup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _set_legal_hold_immutability_initial( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_long_term_retention_backups_set_legal_hold_immutability_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_set_legal_hold_immutability( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + **kwargs: Any + ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: + """Set legal hold immutability of 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 + :return: An instance of AsyncLROPoller that returns LongTermRetentionBackup. The + LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._set_legal_hold_immutability_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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LongTermRetentionBackup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.LongTermRetentionBackup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.LongTermRetentionBackup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + 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, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_long_term_retention_backups_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: _models.UpdateLongTermRetentionBackupParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: + """Updates an existing long term retention backup. + + :param location_name: The location of the database. Required. + :type location_name: str + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :param parameters: The requested backup resource state. Required. + :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns LongTermRetentionBackupOperationResult. The + LongTermRetentionBackupOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: + """Updates an existing long term retention backup. + + :param location_name: The location of the database. Required. + :type location_name: str + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :param parameters: The requested backup resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns LongTermRetentionBackupOperationResult. The + LongTermRetentionBackupOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: + """Updates an existing long term retention backup. + + :param location_name: The location of the database. Required. + :type location_name: str + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :param parameters: The requested backup resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns LongTermRetentionBackupOperationResult. The + LongTermRetentionBackupOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: Union[_models.UpdateLongTermRetentionBackupParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: + """Updates an existing long term retention backup. + + :param location_name: The location of the database. Required. + :type location_name: str + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :param parameters: The requested backup resource state. Is one of the following types: + UpdateLongTermRetentionBackupParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns LongTermRetentionBackupOperationResult. The + LongTermRetentionBackupOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LongTermRetentionBackupOperationResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + backup_name=backup_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LongTermRetentionBackupOperationResult, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.LongTermRetentionBackupOperationResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @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, + **kwargs: Any + ) -> _models.LongTermRetentionBackup: + """Gets a long term retention backup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: LongTermRetentionBackup. The LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.LongTermRetentionBackup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) + + _request = build_long_term_retention_backups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.LongTermRetentionBackup, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _delete_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, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_long_term_retention_backups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a long term retention backup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @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 + ) -> AsyncItemPaged["_models.LongTermRetentionBackup"]: + """Lists all long term retention backups for a database based on a particular resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :keyword only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :paramtype only_latest_per_database: bool + :keyword 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. + :paramtype database_state: str or ~azure.mgmt.sql.models.DatabaseState + :return: An iterator like instance of LongTermRetentionBackup + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.LongTermRetentionBackup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_long_term_retention_backups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.LongTermRetentionBackup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _change_access_tier_by_resource_group_initial( # pylint: disable=name-too-long + 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.ChangeLongTermRetentionBackupAccessTierParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_long_term_retention_backups_change_access_tier_by_resource_group_request( + resource_group_name=resource_group_name, + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_change_access_tier_by_resource_group( # pylint: disable=name-too-long + 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.ChangeLongTermRetentionBackupAccessTierParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: + """Change a long term retention backup access tier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: Required. + :type parameters: ~azure.mgmt.sql.models.ChangeLongTermRetentionBackupAccessTierParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns LongTermRetentionBackup. The + LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_change_access_tier_by_resource_group( # pylint: disable=name-too-long + self, + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: + """Change a long term retention backup access tier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns LongTermRetentionBackup. The + LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_change_access_tier_by_resource_group( # pylint: disable=name-too-long + 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[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: + """Change a long term retention backup access tier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns LongTermRetentionBackup. The + LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_change_access_tier_by_resource_group( # pylint: disable=name-too-long + 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.ChangeLongTermRetentionBackupAccessTierParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: + """Change a long term retention backup access tier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: Is one of the following types: + ChangeLongTermRetentionBackupAccessTierParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ChangeLongTermRetentionBackupAccessTierParameters or + JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns LongTermRetentionBackup. The + LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._change_access_tier_by_resource_group_initial( + resource_group_name=resource_group_name, + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + backup_name=backup_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LongTermRetentionBackup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.LongTermRetentionBackup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.LongTermRetentionBackup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _copy_by_resource_group_initial( + self, + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: Union[_models.CopyLongTermRetentionBackupParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_long_term_retention_backups_copy_by_resource_group_request( + resource_group_name=resource_group_name, + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_copy_by_resource_group( + self, + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: _models.CopyLongTermRetentionBackupParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: + """Copy an existing long term retention backup to a different server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An instance of AsyncLROPoller that returns LongTermRetentionBackupOperationResult. The + LongTermRetentionBackupOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_copy_by_resource_group( + self, + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **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. The name is case insensitive. + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns LongTermRetentionBackupOperationResult. The + LongTermRetentionBackupOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_copy_by_resource_group( + self, + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **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. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The location of the database. Required. + :type location_name: str + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :param parameters: The parameters needed for long term retention copy request. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns LongTermRetentionBackupOperationResult. The + LongTermRetentionBackupOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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, JSON, IO[bytes]], + **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. The name is case insensitive. + 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 one of the + following types: CopyLongTermRetentionBackupParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.CopyLongTermRetentionBackupParameters or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns LongTermRetentionBackupOperationResult. The + LongTermRetentionBackupOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LongTermRetentionBackupOperationResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._copy_by_resource_group_initial( + resource_group_name=resource_group_name, + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + backup_name=backup_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LongTermRetentionBackupOperationResult, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.LongTermRetentionBackupOperationResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _lock_time_based_immutability_by_resource_group_initial( # pylint: disable=name-too-long + 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 + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_long_term_retention_backups_lock_time_based_immutability_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_lock_time_based_immutability_by_resource_group( # pylint: disable=name-too-long + 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 + ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: + """Lock time based immutability of an existing long term retention backup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An instance of AsyncLROPoller that returns LongTermRetentionBackup. The + LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._lock_time_based_immutability_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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LongTermRetentionBackup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.LongTermRetentionBackup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.LongTermRetentionBackup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _remove_legal_hold_immutability_by_resource_group_initial( # pylint: disable=name-too-long + 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 + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_long_term_retention_backups_remove_legal_hold_immutability_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_remove_legal_hold_immutability_by_resource_group( # pylint: disable=name-too-long + 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 + ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: + """Remove legal hold immutability of an existing long term retention backup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An instance of AsyncLROPoller that returns LongTermRetentionBackup. The + LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._remove_legal_hold_immutability_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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LongTermRetentionBackup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.LongTermRetentionBackup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.LongTermRetentionBackup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _remove_time_based_immutability_by_resource_group_initial( # pylint: disable=name-too-long + 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 + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_long_term_retention_backups_remove_time_based_immutability_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_remove_time_based_immutability_by_resource_group( # pylint: disable=name-too-long + 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 + ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: + """Remove time based immutability of an existing long term retention backup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An instance of AsyncLROPoller that returns LongTermRetentionBackup. The + LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._remove_time_based_immutability_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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LongTermRetentionBackup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.LongTermRetentionBackup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.LongTermRetentionBackup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _set_legal_hold_immutability_by_resource_group_initial( # pylint: disable=name-too-long + 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 + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_long_term_retention_backups_set_legal_hold_immutability_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_set_legal_hold_immutability_by_resource_group( # pylint: disable=name-too-long + 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 + ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: + """Set legal hold immutability of an existing long term retention backup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An instance of AsyncLROPoller that returns LongTermRetentionBackup. The + LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._set_legal_hold_immutability_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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LongTermRetentionBackup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.LongTermRetentionBackup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.LongTermRetentionBackup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + 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, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_long_term_retention_backups_update_by_resource_group_request( + resource_group_name=resource_group_name, + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update_by_resource_group( + self, + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: _models.UpdateLongTermRetentionBackupParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: + """Updates an existing long term retention backup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An instance of AsyncLROPoller that returns LongTermRetentionBackupOperationResult. The + LongTermRetentionBackupOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: + """Updates an existing long term retention backup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns LongTermRetentionBackupOperationResult. The + LongTermRetentionBackupOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: + """Updates an existing long term retention backup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The location of the database. Required. + :type location_name: str + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :param parameters: The requested backup resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns LongTermRetentionBackupOperationResult. The + LongTermRetentionBackupOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: + """Updates an existing long term retention backup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 one of the following types: + UpdateLongTermRetentionBackupParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns LongTermRetentionBackupOperationResult. The + LongTermRetentionBackupOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LongTermRetentionBackupOperationResult, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.LongTermRetentionBackupOperationResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @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 + ) -> AsyncItemPaged["_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 + :keyword only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :paramtype only_latest_per_database: bool + :keyword 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. + :paramtype database_state: str or ~azure.mgmt.sql.models.DatabaseState + :return: An iterator like instance of LongTermRetentionBackup + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.LongTermRetentionBackup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_long_term_retention_backups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.LongTermRetentionBackup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_server( + self, + location_name: str, + long_term_retention_server_name: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, + **kwargs: Any + ) -> AsyncItemPaged["_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 + :keyword only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :paramtype only_latest_per_database: bool + :keyword 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. + :paramtype database_state: str or ~azure.mgmt.sql.models.DatabaseState + :return: An iterator like instance of LongTermRetentionBackup + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.LongTermRetentionBackup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_long_term_retention_backups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.LongTermRetentionBackup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @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 + ) -> AsyncItemPaged["_models.LongTermRetentionBackup"]: + """Lists the long term retention backups for a given location based on resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The location of the database. Required. + :type location_name: str + :keyword only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :paramtype only_latest_per_database: bool + :keyword 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. + :paramtype database_state: str or ~azure.mgmt.sql.models.DatabaseState + :return: An iterator like instance of LongTermRetentionBackup + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.LongTermRetentionBackup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_long_term_retention_backups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.LongTermRetentionBackup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @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 + ) -> AsyncItemPaged["_models.LongTermRetentionBackup"]: + """Lists the long term retention backups for a given server based on resource groups. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :keyword only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :paramtype only_latest_per_database: bool + :keyword 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. + :paramtype database_state: str or ~azure.mgmt.sql.models.DatabaseState + :return: An iterator like instance of LongTermRetentionBackup + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.LongTermRetentionBackup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_long_term_retention_backups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.LongTermRetentionBackup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class LongTermRetentionManagedInstanceBackupsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`long_term_retention_managed_instance_backups` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get_by_resource_group( + self, + resource_group_name: str, + location_name: str, + managed_instance_name: str, + database_name: str, + backup_name: str, + **kwargs: Any + ) -> _models.ManagedInstanceLongTermRetentionBackup: + """Gets a long term retention backup for a managed database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 backup_name: The backup name. Required. + :type backup_name: str + :return: ManagedInstanceLongTermRetentionBackup. The ManagedInstanceLongTermRetentionBackup is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedInstanceLongTermRetentionBackup] = kwargs.pop("cls", None) + + _request = build_long_term_retention_managed_instance_backups_get_by_resource_group_request( + resource_group_name=resource_group_name, + location_name=location_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedInstanceLongTermRetentionBackup, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _delete_by_resource_group_initial( + self, + resource_group_name: str, + location_name: str, + managed_instance_name: str, + database_name: str, + backup_name: str, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_long_term_retention_managed_instance_backups_delete_by_resource_group_request( + resource_group_name=resource_group_name, + location_name=location_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete_by_resource_group( + self, + resource_group_name: str, + location_name: str, + managed_instance_name: str, + database_name: str, + backup_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a long term retention backup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 backup_name: The backup name. Required. + :type backup_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + location_name=location_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + backup_name=backup_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @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 + ) -> AsyncItemPaged["_models.ManagedInstanceLongTermRetentionBackup"]: + """Lists all long term retention backups for a managed database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :keyword only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :paramtype only_latest_per_database: bool + :keyword 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. + :paramtype database_state: str or ~azure.mgmt.sql.models.DatabaseState + :return: An iterator like instance of ManagedInstanceLongTermRetentionBackup + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstanceLongTermRetentionBackup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_long_term_retention_managed_instance_backups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstanceLongTermRetentionBackup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, location_name: str, managed_instance_name: str, database_name: str, backup_name: str, **kwargs: Any + ) -> _models.ManagedInstanceLongTermRetentionBackup: + """Gets a long term retention backup for a managed database. + + :param location_name: The location of the database. 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 backup_name: The backup name. Required. + :type backup_name: str + :return: ManagedInstanceLongTermRetentionBackup. The ManagedInstanceLongTermRetentionBackup is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedInstanceLongTermRetentionBackup] = kwargs.pop("cls", None) + + _request = build_long_term_retention_managed_instance_backups_get_request( + location_name=location_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedInstanceLongTermRetentionBackup, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _delete_initial( + self, location_name: str, managed_instance_name: str, database_name: str, backup_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_long_term_retention_managed_instance_backups_delete_request( + location_name=location_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, location_name: str, managed_instance_name: str, 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 + :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 backup_name: The backup name. Required. + :type backup_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + location_name=location_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + backup_name=backup_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @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 + ) -> AsyncItemPaged["_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 + :keyword only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :paramtype only_latest_per_database: bool + :keyword 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. + :paramtype database_state: str or ~azure.mgmt.sql.models.DatabaseState + :return: An iterator like instance of ManagedInstanceLongTermRetentionBackup + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstanceLongTermRetentionBackup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_long_term_retention_managed_instance_backups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstanceLongTermRetentionBackup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_location( + self, + location_name: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_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 + :keyword only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :paramtype only_latest_per_database: bool + :keyword 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. + :paramtype database_state: str or ~azure.mgmt.sql.models.DatabaseState + :keyword skip: The number of elements in the collection to skip. Default value is None. + :paramtype skip: int + :keyword top: The number of elements to return from the collection. Default value is None. + :paramtype top: int + :keyword filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of ManagedInstanceLongTermRetentionBackup + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstanceLongTermRetentionBackup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_long_term_retention_managed_instance_backups_list_by_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + skip=skip, + top=top, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstanceLongTermRetentionBackup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_instance( + self, + location_name: str, + managed_instance_name: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.ManagedInstanceLongTermRetentionBackup"]: + """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 + :keyword only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :paramtype only_latest_per_database: bool + :keyword 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. + :paramtype database_state: str or ~azure.mgmt.sql.models.DatabaseState + :return: An iterator like instance of ManagedInstanceLongTermRetentionBackup + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstanceLongTermRetentionBackup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_long_term_retention_managed_instance_backups_list_by_instance_request( + location_name=location_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstanceLongTermRetentionBackup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @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, + skip: Optional[int] = None, + top: Optional[int] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_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. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The location of the database. Required. + :type location_name: str + :keyword only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :paramtype only_latest_per_database: bool + :keyword 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. + :paramtype database_state: str or ~azure.mgmt.sql.models.DatabaseState + :keyword skip: The number of elements in the collection to skip. Default value is None. + :paramtype skip: int + :keyword top: The number of elements to return from the collection. Default value is None. + :paramtype top: int + :keyword filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of ManagedInstanceLongTermRetentionBackup + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstanceLongTermRetentionBackup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_long_term_retention_managed_instance_backups_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, + skip=skip, + top=top, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstanceLongTermRetentionBackup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group_instance( + 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 + ) -> AsyncItemPaged["_models.ManagedInstanceLongTermRetentionBackup"]: + """Lists the long term retention backups for a given managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :keyword only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :paramtype only_latest_per_database: bool + :keyword 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. + :paramtype database_state: str or ~azure.mgmt.sql.models.DatabaseState + :return: An iterator like instance of ManagedInstanceLongTermRetentionBackup + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstanceLongTermRetentionBackup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_long_term_retention_managed_instance_backups_list_by_resource_group_instance_request( + resource_group_name=resource_group_name, + location_name=location_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstanceLongTermRetentionBackup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class LongTermRetentionPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`long_term_retention_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + policy_name: Union[str, _models.LongTermRetentionPolicyName], + **kwargs: Any + ) -> _models.LongTermRetentionPolicy: + """Gets a database's long term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 policy_name: The policy name. Should always be Default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.LongTermRetentionPolicyName + :return: LongTermRetentionPolicy. The LongTermRetentionPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.LongTermRetentionPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LongTermRetentionPolicy] = kwargs.pop("cls", None) + + _request = build_long_term_retention_policies_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.LongTermRetentionPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.LongTermRetentionPolicyName], + parameters: Union[_models.LongTermRetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_long_term_retention_policies_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.LongTermRetentionPolicyName], + parameters: _models.LongTermRetentionPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LongTermRetentionPolicy]: + """Set or update a database's long term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 policy_name: The policy name. Should always be Default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.LongTermRetentionPolicyName + :param parameters: The long term retention policy info. Required. + :type parameters: ~azure.mgmt.sql.models.LongTermRetentionPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns LongTermRetentionPolicy. The + LongTermRetentionPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.LongTermRetentionPolicyName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LongTermRetentionPolicy]: + """Set or update a database's long term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 policy_name: The policy name. Should always be Default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.LongTermRetentionPolicyName + :param parameters: The long term retention policy info. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns LongTermRetentionPolicy. The + LongTermRetentionPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.LongTermRetentionPolicyName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LongTermRetentionPolicy]: + """Set or update a database's long term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 policy_name: The policy name. Should always be Default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.LongTermRetentionPolicyName + :param parameters: The long term retention policy info. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns LongTermRetentionPolicy. The + LongTermRetentionPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.LongTermRetentionPolicyName], + parameters: Union[_models.LongTermRetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.LongTermRetentionPolicy]: + """Set or update a database's long term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 policy_name: The policy name. Should always be Default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.LongTermRetentionPolicyName + :param parameters: The long term retention policy info. Is one of the following types: + LongTermRetentionPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.LongTermRetentionPolicy or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns LongTermRetentionPolicy. The + LongTermRetentionPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + policy_name=policy_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LongTermRetentionPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.LongTermRetentionPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.LongTermRetentionPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.LongTermRetentionPolicy"]: + """Gets a database's long term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of LongTermRetentionPolicy + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LongTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.LongTermRetentionPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_long_term_retention_policies_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.LongTermRetentionPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ManagedBackupShortTermRetentionPoliciesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_backup_short_term_retention_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + **kwargs: Any + ) -> _models.ManagedBackupShortTermRetentionPolicy: + """Gets a managed database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :return: ManagedBackupShortTermRetentionPolicy. The ManagedBackupShortTermRetentionPolicy is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedBackupShortTermRetentionPolicy] = kwargs.pop("cls", None) + + _request = build_managed_backup_short_term_retention_policies_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedBackupShortTermRetentionPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: Union[_models.ManagedBackupShortTermRetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_backup_short_term_retention_policies_create_or_update_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: _models.ManagedBackupShortTermRetentionPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]: + """Updates a managed database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedBackupShortTermRetentionPolicy. The + ManagedBackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]: + """Updates a managed database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedBackupShortTermRetentionPolicy. The + ManagedBackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]: + """Updates a managed database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedBackupShortTermRetentionPolicy. The + ManagedBackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: Union[_models.ManagedBackupShortTermRetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]: + """Updates a managed database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Is one of the following types: + ManagedBackupShortTermRetentionPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns ManagedBackupShortTermRetentionPolicy. The + ManagedBackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + database_name=database_name, + policy_name=policy_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedBackupShortTermRetentionPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: Union[_models.ManagedBackupShortTermRetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_backup_short_term_retention_policies_update_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: _models.ManagedBackupShortTermRetentionPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]: + """Updates a managed database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedBackupShortTermRetentionPolicy. The + ManagedBackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]: + """Updates a managed database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedBackupShortTermRetentionPolicy. The + ManagedBackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]: + """Updates a managed database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedBackupShortTermRetentionPolicy. The + ManagedBackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: Union[_models.ManagedBackupShortTermRetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]: + """Updates a managed database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Is one of the following types: + ManagedBackupShortTermRetentionPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns ManagedBackupShortTermRetentionPolicy. The + ManagedBackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + policy_name=policy_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedBackupShortTermRetentionPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_database( + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ManagedBackupShortTermRetentionPolicy"]: + """Gets a managed database's short term retention policy list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An iterator like instance of ManagedBackupShortTermRetentionPolicy + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedBackupShortTermRetentionPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_backup_short_term_retention_policies_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedBackupShortTermRetentionPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_restorable_dropped_database_backup_short_term_retention_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + **kwargs: Any + ) -> _models.ManagedBackupShortTermRetentionPolicy: + """Gets a dropped database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :return: ManagedBackupShortTermRetentionPolicy. The ManagedBackupShortTermRetentionPolicy is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedBackupShortTermRetentionPolicy] = kwargs.pop("cls", None) + + _request = build_managed_restorable_dropped_database_backup_short_term_retention_policies_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + restorable_dropped_database_id=restorable_dropped_database_id, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedBackupShortTermRetentionPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: Union[_models.ManagedBackupShortTermRetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = ( + build_managed_restorable_dropped_database_backup_short_term_retention_policies_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + restorable_dropped_database_id=restorable_dropped_database_id, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: _models.ManagedBackupShortTermRetentionPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]: + """Sets a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedBackupShortTermRetentionPolicy. The + ManagedBackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]: + """Sets a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedBackupShortTermRetentionPolicy. The + ManagedBackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]: + """Sets a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedBackupShortTermRetentionPolicy. The + ManagedBackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: Union[_models.ManagedBackupShortTermRetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]: + """Sets a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Is one of the following types: + ManagedBackupShortTermRetentionPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns ManagedBackupShortTermRetentionPolicy. The + ManagedBackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + restorable_dropped_database_id=restorable_dropped_database_id, + policy_name=policy_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedBackupShortTermRetentionPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: Union[_models.ManagedBackupShortTermRetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_restorable_dropped_database_backup_short_term_retention_policies_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + restorable_dropped_database_id=restorable_dropped_database_id, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: _models.ManagedBackupShortTermRetentionPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]: + """Sets a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedBackupShortTermRetentionPolicy. The + ManagedBackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]: + """Sets a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedBackupShortTermRetentionPolicy. The + ManagedBackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]: + """Sets a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedBackupShortTermRetentionPolicy. The + ManagedBackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: Union[_models.ManagedBackupShortTermRetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]: + """Sets a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Is one of the following types: + ManagedBackupShortTermRetentionPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns ManagedBackupShortTermRetentionPolicy. The + ManagedBackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + restorable_dropped_database_id=restorable_dropped_database_id, + policy_name=policy_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedBackupShortTermRetentionPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ManagedBackupShortTermRetentionPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_restorable_dropped_database( + self, resource_group_name: str, managed_instance_name: str, restorable_dropped_database_id: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ManagedBackupShortTermRetentionPolicy"]: + """Gets a dropped database's short term retention policy list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An iterator like instance of ManagedBackupShortTermRetentionPolicy + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedBackupShortTermRetentionPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_restorable_dropped_database_backup_short_term_retention_policies_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedBackupShortTermRetentionPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ManagedDatabaseSecurityAlertPoliciesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_database_security_alert_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + **kwargs: Any + ) -> _models.ManagedDatabaseSecurityAlertPolicy: + """Gets a managed database's security alert policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 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 + :return: ManagedDatabaseSecurityAlertPolicy. The ManagedDatabaseSecurityAlertPolicy is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedDatabaseSecurityAlertPolicy] = kwargs.pop("cls", None) + + _request = build_managed_database_security_alert_policies_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + security_alert_policy_name=security_alert_policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedDatabaseSecurityAlertPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: _models.ManagedDatabaseSecurityAlertPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedDatabaseSecurityAlertPolicy: + """Creates or updates a database's security alert policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedDatabaseSecurityAlertPolicy. The ManagedDatabaseSecurityAlertPolicy is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedDatabaseSecurityAlertPolicy: + """Creates or updates a database's security alert policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedDatabaseSecurityAlertPolicy. The ManagedDatabaseSecurityAlertPolicy is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedDatabaseSecurityAlertPolicy: + """Creates or updates a database's security alert policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 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[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedDatabaseSecurityAlertPolicy. The ManagedDatabaseSecurityAlertPolicy is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: Union[_models.ManagedDatabaseSecurityAlertPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ManagedDatabaseSecurityAlertPolicy: + """Creates or updates a database's security alert policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 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 one of the following types: + ManagedDatabaseSecurityAlertPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy or JSON or + IO[bytes] + :return: ManagedDatabaseSecurityAlertPolicy. The ManagedDatabaseSecurityAlertPolicy is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_database_security_alert_policies_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + security_alert_policy_name=security_alert_policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await 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]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedDatabaseSecurityAlertPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_database( + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ManagedDatabaseSecurityAlertPolicy"]: + """Gets a list of managed database's security alert policies. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An iterator like instance of ManagedDatabaseSecurityAlertPolicy + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedDatabaseSecurityAlertPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_database_security_alert_policies_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedDatabaseSecurityAlertPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ManagedInstanceAdministratorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_instance_administrators` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + managed_instance_name: str, + administrator_name: Union[str, _models.AdministratorName], + **kwargs: Any + ) -> _models.ManagedInstanceAdministrator: + """Gets a managed instance administrator. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param administrator_name: "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName + :return: ManagedInstanceAdministrator. The ManagedInstanceAdministrator is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstanceAdministrator + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedInstanceAdministrator] = kwargs.pop("cls", None) + + _request = build_managed_instance_administrators_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + administrator_name=administrator_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedInstanceAdministrator, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + administrator_name: Union[str, _models.AdministratorName], + parameters: Union[_models.ManagedInstanceAdministrator, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_instance_administrators_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + administrator_name=administrator_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + administrator_name: Union[str, _models.AdministratorName], + parameters: _models.ManagedInstanceAdministrator, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstanceAdministrator]: + """Creates or updates a managed instance administrator. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param administrator_name: "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName + :param parameters: The requested administrator parameters. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceAdministrator + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedInstanceAdministrator. The + ManagedInstanceAdministrator is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceAdministrator] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + administrator_name: Union[str, _models.AdministratorName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstanceAdministrator]: + """Creates or updates a managed instance administrator. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param administrator_name: "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName + :param parameters: The requested administrator parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedInstanceAdministrator. The + ManagedInstanceAdministrator is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceAdministrator] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + administrator_name: Union[str, _models.AdministratorName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstanceAdministrator]: + """Creates or updates a managed instance administrator. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param administrator_name: "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName + :param parameters: The requested administrator parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedInstanceAdministrator. The + ManagedInstanceAdministrator is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceAdministrator] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + administrator_name: Union[str, _models.AdministratorName], + parameters: Union[_models.ManagedInstanceAdministrator, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstanceAdministrator]: + """Creates or updates a managed instance administrator. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param administrator_name: "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName + :param parameters: The requested administrator parameters. Is one of the following types: + ManagedInstanceAdministrator, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceAdministrator or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ManagedInstanceAdministrator. The + ManagedInstanceAdministrator is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceAdministrator] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + administrator_name=administrator_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedInstanceAdministrator, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ManagedInstanceAdministrator].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ManagedInstanceAdministrator]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, + resource_group_name: str, + managed_instance_name: str, + administrator_name: Union[str, _models.AdministratorName], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_instance_administrators_delete_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + administrator_name=administrator_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + managed_instance_name: str, + administrator_name: Union[str, _models.AdministratorName], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a managed instance administrator. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param administrator_name: "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + administrator_name=administrator_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ManagedInstanceAdministrator"]: + """Gets a list of managed instance administrators. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of ManagedInstanceAdministrator + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceAdministrator] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstanceAdministrator]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_instance_administrators_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstanceAdministrator], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ManagedInstanceAzureADOnlyAuthenticationsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_instance_azure_ad_only_authentications` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + managed_instance_name: str, + authentication_name: Union[str, _models.AuthenticationName], + **kwargs: Any + ) -> _models.ManagedInstanceAzureADOnlyAuthentication: + """Gets a specific Azure Active Directory only authentication property. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param authentication_name: The name of server azure active directory only authentication. + "Default" Required. + :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName + :return: ManagedInstanceAzureADOnlyAuthentication. The ManagedInstanceAzureADOnlyAuthentication + is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedInstanceAzureADOnlyAuthentication] = kwargs.pop("cls", None) + + _request = build_managed_instance_azure_ad_only_authentications_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + authentication_name=authentication_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedInstanceAzureADOnlyAuthentication, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + authentication_name: Union[str, _models.AuthenticationName], + parameters: Union[_models.ManagedInstanceAzureADOnlyAuthentication, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_instance_azure_ad_only_authentications_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + authentication_name=authentication_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + authentication_name: Union[str, _models.AuthenticationName], + parameters: _models.ManagedInstanceAzureADOnlyAuthentication, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstanceAzureADOnlyAuthentication]: + """Sets Server Active Directory only authentication property or updates an existing server Active + Directory only authentication property. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param authentication_name: The name of server azure active directory only authentication. + "Default" Required. + :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName + :param parameters: The required parameters for creating or updating an Active Directory only + authentication property. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedInstanceAzureADOnlyAuthentication. + The ManagedInstanceAzureADOnlyAuthentication is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + authentication_name: Union[str, _models.AuthenticationName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstanceAzureADOnlyAuthentication]: + """Sets Server Active Directory only authentication property or updates an existing server Active + Directory only authentication property. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param authentication_name: The name of server azure active directory only authentication. + "Default" Required. + :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName + :param parameters: The required parameters for creating or updating an Active Directory only + authentication property. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedInstanceAzureADOnlyAuthentication. + The ManagedInstanceAzureADOnlyAuthentication is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + authentication_name: Union[str, _models.AuthenticationName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstanceAzureADOnlyAuthentication]: + """Sets Server Active Directory only authentication property or updates an existing server Active + Directory only authentication property. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param authentication_name: The name of server azure active directory only authentication. + "Default" Required. + :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName + :param parameters: The required parameters for creating or updating an Active Directory only + authentication property. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedInstanceAzureADOnlyAuthentication. + The ManagedInstanceAzureADOnlyAuthentication is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + authentication_name: Union[str, _models.AuthenticationName], + parameters: Union[_models.ManagedInstanceAzureADOnlyAuthentication, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstanceAzureADOnlyAuthentication]: + """Sets Server Active Directory only authentication property or updates an existing server Active + Directory only authentication property. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param authentication_name: The name of server azure active directory only authentication. + "Default" Required. + :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName + :param parameters: The required parameters for creating or updating an Active Directory only + authentication property. Is one of the following types: + ManagedInstanceAzureADOnlyAuthentication, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns ManagedInstanceAzureADOnlyAuthentication. + The ManagedInstanceAzureADOnlyAuthentication is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + authentication_name=authentication_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedInstanceAzureADOnlyAuthentication, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ManagedInstanceAzureADOnlyAuthentication].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ManagedInstanceAzureADOnlyAuthentication]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, + resource_group_name: str, + managed_instance_name: str, + authentication_name: Union[str, _models.AuthenticationName], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_instance_azure_ad_only_authentications_delete_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + authentication_name=authentication_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + managed_instance_name: str, + authentication_name: Union[str, _models.AuthenticationName], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an existing server Active Directory only authentication property. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param authentication_name: The name of server azure active directory only authentication. + "Default" Required. + :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + authentication_name=authentication_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ManagedInstanceAzureADOnlyAuthentication"]: + """Gets a list of server Azure Active Directory only authentications. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of ManagedInstanceAzureADOnlyAuthentication + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstanceAzureADOnlyAuthentication]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_instance_azure_ad_only_authentications_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstanceAzureADOnlyAuthentication], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ManagedInstanceDtcsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_instance_dtcs` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, managed_instance_name: str, dtc_name: Union[str, _models.DtcName], **kwargs: Any + ) -> _models.ManagedInstanceDtc: + """Gets managed instance DTC settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param dtc_name: The name of the managed instance DTC. "current" Required. + :type dtc_name: str or ~azure.mgmt.sql.models.DtcName + :return: ManagedInstanceDtc. The ManagedInstanceDtc is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstanceDtc + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedInstanceDtc] = kwargs.pop("cls", None) + + _request = build_managed_instance_dtcs_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + dtc_name=dtc_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedInstanceDtc, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + dtc_name: Union[str, _models.DtcName], + parameters: Union[_models.ManagedInstanceDtc, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_instance_dtcs_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + dtc_name=dtc_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + dtc_name: Union[str, _models.DtcName], + parameters: _models.ManagedInstanceDtc, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstanceDtc]: + """Updates managed instance DTC settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param dtc_name: The name of the managed instance DTC. "current" Required. + :type dtc_name: str or ~azure.mgmt.sql.models.DtcName + :param parameters: Managed instance DTC settings. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceDtc + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedInstanceDtc. The ManagedInstanceDtc + is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceDtc] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + dtc_name: Union[str, _models.DtcName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstanceDtc]: + """Updates managed instance DTC settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param dtc_name: The name of the managed instance DTC. "current" Required. + :type dtc_name: str or ~azure.mgmt.sql.models.DtcName + :param parameters: Managed instance DTC settings. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedInstanceDtc. The ManagedInstanceDtc + is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceDtc] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + dtc_name: Union[str, _models.DtcName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstanceDtc]: + """Updates managed instance DTC settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param dtc_name: The name of the managed instance DTC. "current" Required. + :type dtc_name: str or ~azure.mgmt.sql.models.DtcName + :param parameters: Managed instance DTC settings. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedInstanceDtc. The ManagedInstanceDtc + is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceDtc] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + dtc_name: Union[str, _models.DtcName], + parameters: Union[_models.ManagedInstanceDtc, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstanceDtc]: + """Updates managed instance DTC settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param dtc_name: The name of the managed instance DTC. "current" Required. + :type dtc_name: str or ~azure.mgmt.sql.models.DtcName + :param parameters: Managed instance DTC settings. Is one of the following types: + ManagedInstanceDtc, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceDtc or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ManagedInstanceDtc. The ManagedInstanceDtc + is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceDtc] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + dtc_name=dtc_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = _deserialize(_models.ManagedInstanceDtc, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ManagedInstanceDtc].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ManagedInstanceDtc]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_managed_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ManagedInstanceDtc"]: + """Gets a list of managed instance DTC settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of ManagedInstanceDtc + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceDtc] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstanceDtc]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_instance_dtcs_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstanceDtc], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ManagedInstanceEncryptionProtectorsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_instance_encryption_protectors` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + managed_instance_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + **kwargs: Any + ) -> _models.ManagedInstanceEncryptionProtector: + """Gets a managed instance encryption protector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 retrieved. + "current" Required. + :type encryption_protector_name: str or ~azure.mgmt.sql.models.EncryptionProtectorName + :return: ManagedInstanceEncryptionProtector. The ManagedInstanceEncryptionProtector is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedInstanceEncryptionProtector] = kwargs.pop("cls", None) + + _request = build_managed_instance_encryption_protectors_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + encryption_protector_name=encryption_protector_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedInstanceEncryptionProtector, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + parameters: Union[_models.ManagedInstanceEncryptionProtector, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_instance_encryption_protectors_create_or_update_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + parameters: _models.ManagedInstanceEncryptionProtector, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstanceEncryptionProtector]: + """Updates an existing encryption protector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 retrieved. + "current" Required. + :type encryption_protector_name: str or ~azure.mgmt.sql.models.EncryptionProtectorName + :param parameters: The requested encryption protector resource state. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedInstanceEncryptionProtector. The + ManagedInstanceEncryptionProtector is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstanceEncryptionProtector]: + """Updates an existing encryption protector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 retrieved. + "current" Required. + :type encryption_protector_name: str or ~azure.mgmt.sql.models.EncryptionProtectorName + :param parameters: The requested encryption protector resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedInstanceEncryptionProtector. The + ManagedInstanceEncryptionProtector is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstanceEncryptionProtector]: + """Updates an existing encryption protector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 retrieved. + "current" Required. + :type encryption_protector_name: str or ~azure.mgmt.sql.models.EncryptionProtectorName + :param parameters: The requested encryption protector resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedInstanceEncryptionProtector. The + ManagedInstanceEncryptionProtector is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + parameters: Union[_models.ManagedInstanceEncryptionProtector, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstanceEncryptionProtector]: + """Updates an existing encryption protector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 retrieved. + "current" Required. + :type encryption_protector_name: str or ~azure.mgmt.sql.models.EncryptionProtectorName + :param parameters: The requested encryption protector resource state. Is one of the following + types: ManagedInstanceEncryptionProtector, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns ManagedInstanceEncryptionProtector. The + ManagedInstanceEncryptionProtector is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + encryption_protector_name=encryption_protector_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedInstanceEncryptionProtector, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ManagedInstanceEncryptionProtector].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ManagedInstanceEncryptionProtector]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ManagedInstanceEncryptionProtector"]: + """Gets a list of managed instance encryption protectors. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of ManagedInstanceEncryptionProtector + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstanceEncryptionProtector]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_instance_encryption_protectors_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstanceEncryptionProtector], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _revalidate_initial( + self, + resource_group_name: str, + managed_instance_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_instance_encryption_protectors_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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. The name is case insensitive. + 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 retrieved. + "current" Required. + :type encryption_protector_name: str or ~azure.mgmt.sql.models.EncryptionProtectorName + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + encryption_protector_name=encryption_protector_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class ManagedInstanceKeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_instance_keys` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, managed_instance_name: str, key_name: str, **kwargs: Any + ) -> _models.ManagedInstanceKey: + """Gets a managed instance key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param key_name: The name of the managed instance key to be retrieved. Required. + :type key_name: str + :return: ManagedInstanceKey. The ManagedInstanceKey is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstanceKey + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedInstanceKey] = kwargs.pop("cls", None) + + _request = build_managed_instance_keys_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedInstanceKey, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + key_name: str, + parameters: Union[_models.ManagedInstanceKey, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_instance_keys_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + key_name: str, + parameters: _models.ManagedInstanceKey, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstanceKey]: + """Creates or updates a managed instance key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param key_name: The name of the managed instance key to be retrieved. Required. + :type key_name: str + :param parameters: The requested managed instance key resource state. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceKey + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedInstanceKey. The ManagedInstanceKey + is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceKey] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + key_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstanceKey]: + """Creates or updates a managed instance key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param key_name: The name of the managed instance key to be retrieved. Required. + :type key_name: str + :param parameters: The requested managed instance key resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedInstanceKey. The ManagedInstanceKey + is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceKey] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + key_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstanceKey]: + """Creates or updates a managed instance key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param key_name: The name of the managed instance key to be retrieved. Required. + :type key_name: str + :param parameters: The requested managed instance key resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedInstanceKey. The ManagedInstanceKey + is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceKey] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + key_name: str, + parameters: Union[_models.ManagedInstanceKey, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstanceKey]: + """Creates or updates a managed instance key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param key_name: The name of the managed instance key to be retrieved. Required. + :type key_name: str + :param parameters: The requested managed instance key resource state. Is one of the following + types: ManagedInstanceKey, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceKey or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ManagedInstanceKey. The ManagedInstanceKey + is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceKey] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + key_name=key_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedInstanceKey, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ManagedInstanceKey].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ManagedInstanceKey]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, managed_instance_name: str, key_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_instance_keys_delete_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, managed_instance_name: str, key_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the managed instance key with the given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param key_name: The name of the managed instance key to be retrieved. Required. + :type key_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + key_name=key_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, *, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.ManagedInstanceKey"]: + """Gets a list of managed instance keys. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :keyword filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of ManagedInstanceKey + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceKey] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstanceKey]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_instance_keys_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstanceKey], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ManagedInstanceLongTermRetentionPoliciesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_instance_long_term_retention_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedInstanceLongTermRetentionPolicyName], + **kwargs: Any + ) -> _models.ManagedInstanceLongTermRetentionPolicy: + """Gets a managed database's long term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 policy_name: The policy name. Should always be Default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicyName + :return: ManagedInstanceLongTermRetentionPolicy. The ManagedInstanceLongTermRetentionPolicy is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedInstanceLongTermRetentionPolicy] = kwargs.pop("cls", None) + + _request = build_managed_instance_long_term_retention_policies_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedInstanceLongTermRetentionPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedInstanceLongTermRetentionPolicyName], + parameters: Union[_models.ManagedInstanceLongTermRetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_instance_long_term_retention_policies_create_or_update_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedInstanceLongTermRetentionPolicyName], + parameters: _models.ManagedInstanceLongTermRetentionPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstanceLongTermRetentionPolicy]: + """Sets a managed database's long term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 policy_name: The policy name. Should always be Default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicyName + :param parameters: The long term retention policy info. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedInstanceLongTermRetentionPolicy. The + ManagedInstanceLongTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedInstanceLongTermRetentionPolicyName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstanceLongTermRetentionPolicy]: + """Sets a managed database's long term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 policy_name: The policy name. Should always be Default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicyName + :param parameters: The long term retention policy info. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedInstanceLongTermRetentionPolicy. The + ManagedInstanceLongTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedInstanceLongTermRetentionPolicyName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstanceLongTermRetentionPolicy]: + """Sets a managed database's long term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 policy_name: The policy name. Should always be Default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicyName + :param parameters: The long term retention policy info. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedInstanceLongTermRetentionPolicy. The + ManagedInstanceLongTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedInstanceLongTermRetentionPolicyName], + parameters: Union[_models.ManagedInstanceLongTermRetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstanceLongTermRetentionPolicy]: + """Sets a managed database's long term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 policy_name: The policy name. Should always be Default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicyName + :param parameters: The long term retention policy info. Is one of the following types: + ManagedInstanceLongTermRetentionPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns ManagedInstanceLongTermRetentionPolicy. The + ManagedInstanceLongTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + database_name=database_name, + policy_name=policy_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedInstanceLongTermRetentionPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ManagedInstanceLongTermRetentionPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ManagedInstanceLongTermRetentionPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedInstanceLongTermRetentionPolicyName], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_instance_long_term_retention_policies_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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. The name is case insensitive. + 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 policy_name: The policy name. Should always be Default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicyName + :return: An instance of AsyncLROPoller that returns ManagedInstanceLongTermRetentionPolicy. The + ManagedInstanceLongTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedInstanceLongTermRetentionPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ManagedInstanceLongTermRetentionPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ManagedInstanceLongTermRetentionPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_database( + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ManagedInstanceLongTermRetentionPolicy"]: + """Gets a database's long term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An iterator like instance of ManagedInstanceLongTermRetentionPolicy + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstanceLongTermRetentionPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_instance_long_term_retention_policies_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstanceLongTermRetentionPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ManagedInstanceOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_instance_operations` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, managed_instance_name: str, operation_id: str, **kwargs: Any + ) -> _models.ManagedInstanceOperation: + """Gets a management operation on a managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param operation_id: Required. + :type operation_id: str + :return: ManagedInstanceOperation. The ManagedInstanceOperation is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstanceOperation + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedInstanceOperation] = kwargs.pop("cls", None) + + _request = build_managed_instance_operations_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedInstanceOperation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_managed_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ManagedInstanceOperation"]: + """Gets a list of operations performed on the managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of ManagedInstanceOperation + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceOperation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstanceOperation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_instance_operations_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstanceOperation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def cancel( + self, resource_group_name: str, managed_instance_name: str, operation_id: str, **kwargs: Any + ) -> None: + """Cancels the asynchronous operation on the managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param operation_id: Required. + :type operation_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_managed_instance_operations_cancel_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class ManagedInstancePrivateEndpointConnectionsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_instance_private_endpoint_connections` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, managed_instance_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.ManagedInstancePrivateEndpointConnection: + """Gets a private endpoint connection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :return: ManagedInstancePrivateEndpointConnection. The ManagedInstancePrivateEndpointConnection + is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedInstancePrivateEndpointConnection] = kwargs.pop("cls", None) + + _request = build_managed_instance_private_endpoint_connections_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedInstancePrivateEndpointConnection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.ManagedInstancePrivateEndpointConnection, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_instance_private_endpoint_connections_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + private_endpoint_connection_name: str, + parameters: _models.ManagedInstancePrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstancePrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedInstancePrivateEndpointConnection. + The ManagedInstancePrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + private_endpoint_connection_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstancePrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedInstancePrivateEndpointConnection. + The ManagedInstancePrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + private_endpoint_connection_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstancePrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedInstancePrivateEndpointConnection. + The ManagedInstancePrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.ManagedInstancePrivateEndpointConnection, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstancePrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Is one of the following types: ManagedInstancePrivateEndpointConnection, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns ManagedInstancePrivateEndpointConnection. + The ManagedInstancePrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + private_endpoint_connection_name=private_endpoint_connection_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedInstancePrivateEndpointConnection, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ManagedInstancePrivateEndpointConnection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ManagedInstancePrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, managed_instance_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_instance_private_endpoint_connections_delete_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, managed_instance_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + private_endpoint_connection_name=private_endpoint_connection_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_managed_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ManagedInstancePrivateEndpointConnection"]: + """Gets all private endpoint connections on a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of ManagedInstancePrivateEndpointConnection + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstancePrivateEndpointConnection]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_instance_private_endpoint_connections_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstancePrivateEndpointConnection], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ManagedInstanceVulnerabilityAssessmentsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_instance_vulnerability_assessments` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + managed_instance_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + **kwargs: Any + ) -> _models.ManagedInstanceVulnerabilityAssessment: + """Gets the managed instance's vulnerability assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_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 + :return: ManagedInstanceVulnerabilityAssessment. The ManagedInstanceVulnerabilityAssessment is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedInstanceVulnerabilityAssessment] = kwargs.pop("cls", None) + + _request = build_managed_instance_vulnerability_assessments_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedInstanceVulnerabilityAssessment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: _models.ManagedInstanceVulnerabilityAssessment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedInstanceVulnerabilityAssessment: + """Creates or updates the managed instance's vulnerability assessment. Learn more about setting + SQL vulnerability assessment with managed identity - + `https://docs.microsoft.com/azure/azure-sql/database/sql-database-vulnerability-assessment-storage + `_. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_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 parameters: The requested resource. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedInstanceVulnerabilityAssessment. The ManagedInstanceVulnerabilityAssessment is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedInstanceVulnerabilityAssessment: + """Creates or updates the managed instance's vulnerability assessment. Learn more about setting + SQL vulnerability assessment with managed identity - + `https://docs.microsoft.com/azure/azure-sql/database/sql-database-vulnerability-assessment-storage + `_. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_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 parameters: The requested resource. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedInstanceVulnerabilityAssessment. The ManagedInstanceVulnerabilityAssessment is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedInstanceVulnerabilityAssessment: + """Creates or updates the managed instance's vulnerability assessment. Learn more about setting + SQL vulnerability assessment with managed identity - + `https://docs.microsoft.com/azure/azure-sql/database/sql-database-vulnerability-assessment-storage + `_. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_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 parameters: The requested resource. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedInstanceVulnerabilityAssessment. The ManagedInstanceVulnerabilityAssessment is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: Union[_models.ManagedInstanceVulnerabilityAssessment, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ManagedInstanceVulnerabilityAssessment: + """Creates or updates the managed instance's vulnerability assessment. Learn more about setting + SQL vulnerability assessment with managed identity - + `https://docs.microsoft.com/azure/azure-sql/database/sql-database-vulnerability-assessment-storage + `_. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_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 parameters: The requested resource. Is one of the following types: + ManagedInstanceVulnerabilityAssessment, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment or JSON or + IO[bytes] + :return: ManagedInstanceVulnerabilityAssessment. The ManagedInstanceVulnerabilityAssessment is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_instance_vulnerability_assessments_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await 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]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedInstanceVulnerabilityAssessment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + managed_instance_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + **kwargs: Any + ) -> None: + """Removes the managed instance's vulnerability assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_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 + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_managed_instance_vulnerability_assessments_delete_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ManagedInstanceVulnerabilityAssessment"]: + """Gets the managed instance's vulnerability assessment policies. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of ManagedInstanceVulnerabilityAssessment + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstanceVulnerabilityAssessment]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_instance_vulnerability_assessments_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstanceVulnerabilityAssessment], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ManagedServerDnsAliasesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_server_dns_aliases` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, managed_instance_name: str, dns_alias_name: str, **kwargs: Any + ) -> _models.ManagedServerDnsAlias: + """Gets a server DNS alias. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param dns_alias_name: Required. + :type dns_alias_name: str + :return: ManagedServerDnsAlias. The ManagedServerDnsAlias is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedServerDnsAlias + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedServerDnsAlias] = kwargs.pop("cls", None) + + _request = build_managed_server_dns_aliases_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + dns_alias_name=dns_alias_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedServerDnsAlias, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + dns_alias_name: str, + parameters: Union[_models.ManagedServerDnsAliasCreation, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_server_dns_aliases_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + dns_alias_name=dns_alias_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + dns_alias_name: str, + parameters: _models.ManagedServerDnsAliasCreation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedServerDnsAlias]: + """Creates a managed server DNS alias. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param dns_alias_name: Required. + :type dns_alias_name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.sql.models.ManagedServerDnsAliasCreation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedServerDnsAlias. The + ManagedServerDnsAlias is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedServerDnsAlias] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + dns_alias_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedServerDnsAlias]: + """Creates a managed server DNS alias. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param dns_alias_name: Required. + :type dns_alias_name: str + :param parameters: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedServerDnsAlias. The + ManagedServerDnsAlias is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedServerDnsAlias] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + dns_alias_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedServerDnsAlias]: + """Creates a managed server DNS alias. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param dns_alias_name: Required. + :type dns_alias_name: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedServerDnsAlias. The + ManagedServerDnsAlias is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedServerDnsAlias] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + dns_alias_name: str, + parameters: Union[_models.ManagedServerDnsAliasCreation, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedServerDnsAlias]: + """Creates a managed server DNS alias. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param dns_alias_name: Required. + :type dns_alias_name: str + :param parameters: Is one of the following types: ManagedServerDnsAliasCreation, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedServerDnsAliasCreation or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ManagedServerDnsAlias. The + ManagedServerDnsAlias is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedServerDnsAlias] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + dns_alias_name=dns_alias_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedServerDnsAlias, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ManagedServerDnsAlias].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ManagedServerDnsAlias]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, managed_instance_name: str, dns_alias_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_server_dns_aliases_delete_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + dns_alias_name=dns_alias_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, managed_instance_name: str, dns_alias_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the managed server DNS alias with the given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param dns_alias_name: Required. + :type dns_alias_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + dns_alias_name=dns_alias_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_managed_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ManagedServerDnsAlias"]: + """Gets a list of managed server DNS aliases for a managed server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of ManagedServerDnsAlias + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedServerDnsAlias] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedServerDnsAlias]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_server_dns_aliases_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedServerDnsAlias], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _acquire_initial( + self, + resource_group_name: str, + managed_instance_name: str, + dns_alias_name: str, + parameters: Union[_models.ManagedServerDnsAliasAcquisition, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_server_dns_aliases_acquire_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + dns_alias_name=dns_alias_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_acquire( + self, + resource_group_name: str, + managed_instance_name: str, + dns_alias_name: str, + parameters: _models.ManagedServerDnsAliasAcquisition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedServerDnsAlias]: + """Acquires managed server DNS alias from another managed server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param dns_alias_name: Required. + :type dns_alias_name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.sql.models.ManagedServerDnsAliasAcquisition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedServerDnsAlias. The + ManagedServerDnsAlias is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedServerDnsAlias] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_acquire( + self, + resource_group_name: str, + managed_instance_name: str, + dns_alias_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedServerDnsAlias]: + """Acquires managed server DNS alias from another managed server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param dns_alias_name: Required. + :type dns_alias_name: str + :param parameters: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedServerDnsAlias. The + ManagedServerDnsAlias is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedServerDnsAlias] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_acquire( + self, + resource_group_name: str, + managed_instance_name: str, + dns_alias_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedServerDnsAlias]: + """Acquires managed server DNS alias from another managed server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param dns_alias_name: Required. + :type dns_alias_name: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedServerDnsAlias. The + ManagedServerDnsAlias is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedServerDnsAlias] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_acquire( + self, + resource_group_name: str, + managed_instance_name: str, + dns_alias_name: str, + parameters: Union[_models.ManagedServerDnsAliasAcquisition, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedServerDnsAlias]: + """Acquires managed server DNS alias from another managed server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param dns_alias_name: Required. + :type dns_alias_name: str + :param parameters: Is one of the following types: ManagedServerDnsAliasAcquisition, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedServerDnsAliasAcquisition or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ManagedServerDnsAlias. The + ManagedServerDnsAlias is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedServerDnsAlias] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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._acquire_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + dns_alias_name=dns_alias_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ManagedServerDnsAlias, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ManagedServerDnsAlias].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ManagedServerDnsAlias]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class ManagedServerSecurityAlertPoliciesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_server_security_alert_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + managed_instance_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + **kwargs: Any + ) -> _models.ManagedServerSecurityAlertPolicy: + """Get a managed server's threat detection policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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 + :return: ManagedServerSecurityAlertPolicy. The ManagedServerSecurityAlertPolicy is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedServerSecurityAlertPolicy] = kwargs.pop("cls", None) + + _request = build_managed_server_security_alert_policies_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + security_alert_policy_name=security_alert_policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedServerSecurityAlertPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: Union[_models.ManagedServerSecurityAlertPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_server_security_alert_policies_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + security_alert_policy_name=security_alert_policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: _models.ManagedServerSecurityAlertPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedServerSecurityAlertPolicy]: + """Creates or updates a threat detection policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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 + :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. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedServerSecurityAlertPolicy. The + ManagedServerSecurityAlertPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedServerSecurityAlertPolicy]: + """Creates or updates a threat detection policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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 + :param parameters: The managed server security alert policy. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedServerSecurityAlertPolicy. The + ManagedServerSecurityAlertPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedServerSecurityAlertPolicy]: + """Creates or updates a threat detection policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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 + :param parameters: The managed server security alert policy. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedServerSecurityAlertPolicy. The + ManagedServerSecurityAlertPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: Union[_models.ManagedServerSecurityAlertPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedServerSecurityAlertPolicy]: + """Creates or updates a threat detection policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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 + :param parameters: The managed server security alert policy. Is one of the following types: + ManagedServerSecurityAlertPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ManagedServerSecurityAlertPolicy. The + ManagedServerSecurityAlertPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + security_alert_policy_name=security_alert_policy_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedServerSecurityAlertPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ManagedServerSecurityAlertPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ManagedServerSecurityAlertPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ManagedServerSecurityAlertPolicy"]: + """Get the managed server's threat detection policies. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of ManagedServerSecurityAlertPolicy + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedServerSecurityAlertPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_server_security_alert_policies_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedServerSecurityAlertPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class NetworkSecurityPerimeterConfigurationsOperations: # pylint: disable=name-too-long + """ + .. 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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, nsp_config_name: str, **kwargs: Any + ) -> _models.NetworkSecurityPerimeterConfiguration: + """Gets a network security perimeter configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: NetworkSecurityPerimeterConfiguration. The NetworkSecurityPerimeterConfiguration is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.NetworkSecurityPerimeterConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NetworkSecurityPerimeterConfiguration] = kwargs.pop("cls", None) + + _request = build_network_security_perimeter_configurations_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.NetworkSecurityPerimeterConfiguration, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.NetworkSecurityPerimeterConfiguration"]: + """Gets a list of NSP configurations for a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of NetworkSecurityPerimeterConfiguration + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.NetworkSecurityPerimeterConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.NetworkSecurityPerimeterConfiguration]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_network_security_perimeter_configurations_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.NetworkSecurityPerimeterConfiguration], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _reconcile_initial( + self, resource_group_name: str, server_name: str, nsp_config_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_network_security_perimeter_configurations_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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. The name is case insensitive. + 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 + :return: An instance of AsyncLROPoller that returns NetworkSecurityPerimeterConfiguration. The + NetworkSecurityPerimeterConfiguration is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.NetworkSecurityPerimeterConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.NetworkSecurityPerimeterConfiguration, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.NetworkSecurityPerimeterConfiguration].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.NetworkSecurityPerimeterConfiguration]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class OutboundFirewallRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`outbound_firewall_rules` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, outbound_rule_fqdn: str, **kwargs: Any + ) -> _models.OutboundFirewallRule: + """Gets an outbound firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: OutboundFirewallRule. The OutboundFirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.OutboundFirewallRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.OutboundFirewallRule] = kwargs.pop("cls", None) + + _request = build_outbound_firewall_rules_get_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.OutboundFirewallRule, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, resource_group_name: str, server_name: str, outbound_rule_fqdn: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_outbound_firewall_rules_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_create_or_update( + 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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An instance of AsyncLROPoller that returns OutboundFirewallRule. The + OutboundFirewallRule is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.OutboundFirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + outbound_rule_fqdn=outbound_rule_fqdn, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.OutboundFirewallRule, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.OutboundFirewallRule].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.OutboundFirewallRule]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, server_name: str, outbound_rule_fqdn: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_outbound_firewall_rules_delete_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, server_name: str, outbound_rule_fqdn: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a outbound firewall rule with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + outbound_rule_fqdn=outbound_rule_fqdn, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.OutboundFirewallRule"]: + """Gets all outbound firewall rules on a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of OutboundFirewallRule + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.OutboundFirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.OutboundFirewallRule]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_outbound_firewall_rules_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.OutboundFirewallRule], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`private_endpoint_connections` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets a private endpoint connection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :return: PrivateEndpointConnection. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + _request = build_private_endpoint_connections_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PrivateEndpointConnection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_private_endpoint_connections_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + private_endpoint_connection_name: str, + parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.sql.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + private_endpoint_connection_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + private_endpoint_connection_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Is one of the following types: PrivateEndpointConnection, JSON, IO[bytes] + Required. + :type parameters: ~azure.mgmt.sql.models.PrivateEndpointConnection or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + private_endpoint_connection_name=private_endpoint_connection_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.PrivateEndpointConnection, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.PrivateEndpointConnection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, server_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_private_endpoint_connections_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, server_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + private_endpoint_connection_name=private_endpoint_connection_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.PrivateEndpointConnection"]: + """Gets all private endpoint connections on a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of PrivateEndpointConnection + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_private_endpoint_connections_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PrivateEndpointConnection], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`private_link_resources` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, group_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: + """Gets a private link resource for SQL server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param group_name: The name of the private link resource. Required. + :type group_name: str + :return: PrivateLinkResource. The PrivateLinkResource is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.PrivateLinkResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) + + _request = build_private_link_resources_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + group_name=group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PrivateLinkResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.PrivateLinkResource"]: + """Gets the private link resources for SQL server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of PrivateLinkResource + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PrivateLinkResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_private_link_resources_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PrivateLinkResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class RecoverableDatabasesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`recoverable_databases` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + *, + expand: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> _models.RecoverableDatabase: + """Gets a recoverable database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 expand: The child resources to include in the response. Default value is None. + :paramtype expand: str + :keyword filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: RecoverableDatabase. The RecoverableDatabase is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.RecoverableDatabase + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RecoverableDatabase] = kwargs.pop("cls", None) + + _request = build_recoverable_databases_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + expand=expand, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RecoverableDatabase, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.RecoverableDatabase"]: + """Gets a list of recoverable databases. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of RecoverableDatabase + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.RecoverableDatabase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RecoverableDatabase]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_recoverable_databases_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RecoverableDatabase], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class RecoverableManagedDatabasesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`recoverable_managed_databases` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, managed_instance_name: str, recoverable_database_name: str, **kwargs: Any + ) -> _models.RecoverableManagedDatabase: + """Gets a recoverable managed database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param recoverable_database_name: Required. + :type recoverable_database_name: str + :return: RecoverableManagedDatabase. The RecoverableManagedDatabase is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.RecoverableManagedDatabase + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RecoverableManagedDatabase] = kwargs.pop("cls", None) + + _request = build_recoverable_managed_databases_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + recoverable_database_name=recoverable_database_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RecoverableManagedDatabase, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.RecoverableManagedDatabase"]: + """Gets a list of recoverable managed databases. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of RecoverableManagedDatabase + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.RecoverableManagedDatabase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RecoverableManagedDatabase]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_recoverable_managed_databases_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RecoverableManagedDatabase], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class RestorableDroppedDatabasesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`restorable_dropped_databases` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + restorable_dropped_database_id: str, + *, + expand: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> _models.RestorableDroppedDatabase: + """Gets a restorable dropped database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param restorable_dropped_database_id: Required. + :type restorable_dropped_database_id: str + :keyword expand: The child resources to include in the response. Default value is None. + :paramtype expand: str + :keyword filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: RestorableDroppedDatabase. The RestorableDroppedDatabase is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.RestorableDroppedDatabase + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RestorableDroppedDatabase] = kwargs.pop("cls", None) + + _request = build_restorable_dropped_databases_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + restorable_dropped_database_id=restorable_dropped_database_id, + subscription_id=self._config.subscription_id, + expand=expand, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RestorableDroppedDatabase, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.RestorableDroppedDatabase"]: + """Gets a list of restorable dropped databases. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of RestorableDroppedDatabase + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.RestorableDroppedDatabase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RestorableDroppedDatabase]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_restorable_dropped_databases_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RestorableDroppedDatabase], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class RestorableDroppedManagedDatabasesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`restorable_dropped_managed_databases` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, managed_instance_name: str, restorable_dropped_database_id: str, **kwargs: Any + ) -> _models.RestorableDroppedManagedDatabase: + """Gets a restorable dropped managed database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: RestorableDroppedManagedDatabase. The RestorableDroppedManagedDatabase is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.RestorableDroppedManagedDatabase + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RestorableDroppedManagedDatabase] = kwargs.pop("cls", None) + + _request = build_restorable_dropped_managed_databases_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + restorable_dropped_database_id=restorable_dropped_database_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RestorableDroppedManagedDatabase, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.RestorableDroppedManagedDatabase"]: + """Gets a list of restorable dropped managed databases. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of RestorableDroppedManagedDatabase + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.RestorableDroppedManagedDatabase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RestorableDroppedManagedDatabase]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_restorable_dropped_managed_databases_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RestorableDroppedManagedDatabase], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ServerAzureADAdministratorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`server_azure_ad_administrators` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + administrator_name: Union[str, _models.AdministratorName], + **kwargs: Any + ) -> _models.ServerAzureADAdministrator: + """Gets a Azure Active Directory administrator. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param administrator_name: The name of server active directory administrator. "ActiveDirectory" + Required. + :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName + :return: ServerAzureADAdministrator. The ServerAzureADAdministrator is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerAzureADAdministrator + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ServerAzureADAdministrator] = kwargs.pop("cls", None) + + _request = build_server_azure_ad_administrators_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + administrator_name=administrator_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ServerAzureADAdministrator, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + administrator_name: Union[str, _models.AdministratorName], + parameters: Union[_models.ServerAzureADAdministrator, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_server_azure_ad_administrators_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + administrator_name=administrator_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + administrator_name: Union[str, _models.AdministratorName], + parameters: _models.ServerAzureADAdministrator, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerAzureADAdministrator]: + """Creates or updates an existing Azure Active Directory administrator. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param administrator_name: The name of server active directory administrator. "ActiveDirectory" + Required. + :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName + :param parameters: The requested Azure Active Directory administrator Resource state. Required. + :type parameters: ~azure.mgmt.sql.models.ServerAzureADAdministrator + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerAzureADAdministrator. The + ServerAzureADAdministrator is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerAzureADAdministrator] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + administrator_name: Union[str, _models.AdministratorName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerAzureADAdministrator]: + """Creates or updates an existing Azure Active Directory administrator. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param administrator_name: The name of server active directory administrator. "ActiveDirectory" + Required. + :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName + :param parameters: The requested Azure Active Directory administrator Resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerAzureADAdministrator. The + ServerAzureADAdministrator is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerAzureADAdministrator] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + administrator_name: Union[str, _models.AdministratorName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerAzureADAdministrator]: + """Creates or updates an existing Azure Active Directory administrator. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param administrator_name: The name of server active directory administrator. "ActiveDirectory" + Required. + :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName + :param parameters: The requested Azure Active Directory administrator Resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerAzureADAdministrator. The + ServerAzureADAdministrator is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerAzureADAdministrator] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + administrator_name: Union[str, _models.AdministratorName], + parameters: Union[_models.ServerAzureADAdministrator, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerAzureADAdministrator]: + """Creates or updates an existing Azure Active Directory administrator. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param administrator_name: The name of server active directory administrator. "ActiveDirectory" + Required. + :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName + :param parameters: The requested Azure Active Directory administrator Resource state. Is one of + the following types: ServerAzureADAdministrator, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ServerAzureADAdministrator or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ServerAzureADAdministrator. The + ServerAzureADAdministrator is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerAzureADAdministrator] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + administrator_name=administrator_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ServerAzureADAdministrator, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ServerAzureADAdministrator].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ServerAzureADAdministrator]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, + resource_group_name: str, + server_name: str, + administrator_name: Union[str, _models.AdministratorName], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_server_azure_ad_administrators_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + administrator_name=administrator_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + server_name: str, + administrator_name: Union[str, _models.AdministratorName], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the Azure Active Directory administrator with the given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param administrator_name: The name of server active directory administrator. "ActiveDirectory" + Required. + :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + administrator_name=administrator_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ServerAzureADAdministrator"]: + """Gets a list of Azure Active Directory administrators in a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of ServerAzureADAdministrator + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerAzureADAdministrator] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerAzureADAdministrator]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_server_azure_ad_administrators_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ServerAzureADAdministrator], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ServerAzureADOnlyAuthenticationsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`server_azure_ad_only_authentications` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + authentication_name: Union[str, _models.AuthenticationName], + **kwargs: Any + ) -> _models.ServerAzureADOnlyAuthentication: + """Gets a specific Azure Active Directory only authentication property. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param authentication_name: The name of server azure active directory only authentication. + "Default" Required. + :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName + :return: ServerAzureADOnlyAuthentication. The ServerAzureADOnlyAuthentication is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ServerAzureADOnlyAuthentication] = kwargs.pop("cls", None) + + _request = build_server_azure_ad_only_authentications_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + authentication_name=authentication_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ServerAzureADOnlyAuthentication, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + authentication_name: Union[str, _models.AuthenticationName], + parameters: Union[_models.ServerAzureADOnlyAuthentication, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_server_azure_ad_only_authentications_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + authentication_name=authentication_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + authentication_name: Union[str, _models.AuthenticationName], + parameters: _models.ServerAzureADOnlyAuthentication, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerAzureADOnlyAuthentication]: + """Sets Server Active Directory only authentication property or updates an existing server Active + Directory only authentication property. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param authentication_name: The name of server azure active directory only authentication. + "Default" Required. + :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName + :param parameters: The required parameters for creating or updating an Active Directory only + authentication property. Required. + :type parameters: ~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerAzureADOnlyAuthentication. The + ServerAzureADOnlyAuthentication is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + authentication_name: Union[str, _models.AuthenticationName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerAzureADOnlyAuthentication]: + """Sets Server Active Directory only authentication property or updates an existing server Active + Directory only authentication property. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param authentication_name: The name of server azure active directory only authentication. + "Default" Required. + :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName + :param parameters: The required parameters for creating or updating an Active Directory only + authentication property. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerAzureADOnlyAuthentication. The + ServerAzureADOnlyAuthentication is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + authentication_name: Union[str, _models.AuthenticationName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerAzureADOnlyAuthentication]: + """Sets Server Active Directory only authentication property or updates an existing server Active + Directory only authentication property. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param authentication_name: The name of server azure active directory only authentication. + "Default" Required. + :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName + :param parameters: The required parameters for creating or updating an Active Directory only + authentication property. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerAzureADOnlyAuthentication. The + ServerAzureADOnlyAuthentication is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + authentication_name: Union[str, _models.AuthenticationName], + parameters: Union[_models.ServerAzureADOnlyAuthentication, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerAzureADOnlyAuthentication]: + """Sets Server Active Directory only authentication property or updates an existing server Active + Directory only authentication property. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param authentication_name: The name of server azure active directory only authentication. + "Default" Required. + :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName + :param parameters: The required parameters for creating or updating an Active Directory only + authentication property. Is one of the following types: ServerAzureADOnlyAuthentication, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ServerAzureADOnlyAuthentication. The + ServerAzureADOnlyAuthentication is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + authentication_name=authentication_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ServerAzureADOnlyAuthentication, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ServerAzureADOnlyAuthentication].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ServerAzureADOnlyAuthentication]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, + resource_group_name: str, + server_name: str, + authentication_name: Union[str, _models.AuthenticationName], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_server_azure_ad_only_authentications_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + authentication_name=authentication_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + server_name: str, + authentication_name: Union[str, _models.AuthenticationName], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an existing server Active Directory only authentication property. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param authentication_name: The name of server azure active directory only authentication. + "Default" Required. + :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + authentication_name=authentication_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ServerAzureADOnlyAuthentication"]: + """Gets a list of server Azure Active Directory only authentications. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of ServerAzureADOnlyAuthentication + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerAzureADOnlyAuthentication]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_server_azure_ad_only_authentications_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ServerAzureADOnlyAuthentication], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ServerConfigurationOptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`server_configuration_options` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + managed_instance_name: str, + server_configuration_option_name: Union[str, _models.ServerConfigurationOptionName], + **kwargs: Any + ) -> _models.ServerConfigurationOption: + """Gets managed instance server configuration option. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param server_configuration_option_name: The name of the server configuration option. + "allowPolybaseExport" Required. + :type server_configuration_option_name: str or + ~azure.mgmt.sql.models.ServerConfigurationOptionName + :return: ServerConfigurationOption. The ServerConfigurationOption is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerConfigurationOption + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ServerConfigurationOption] = kwargs.pop("cls", None) + + _request = build_server_configuration_options_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + server_configuration_option_name=server_configuration_option_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ServerConfigurationOption, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + server_configuration_option_name: Union[str, _models.ServerConfigurationOptionName], + parameters: Union[_models.ServerConfigurationOption, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_server_configuration_options_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + server_configuration_option_name=server_configuration_option_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + server_configuration_option_name: Union[str, _models.ServerConfigurationOptionName], + parameters: _models.ServerConfigurationOption, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerConfigurationOption]: + """Updates managed instance server configuration option. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param server_configuration_option_name: The name of the server configuration option. + "allowPolybaseExport" Required. + :type server_configuration_option_name: str or + ~azure.mgmt.sql.models.ServerConfigurationOptionName + :param parameters: Server configuration option parameters. Required. + :type parameters: ~azure.mgmt.sql.models.ServerConfigurationOption + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerConfigurationOption. The + ServerConfigurationOption is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerConfigurationOption] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + server_configuration_option_name: Union[str, _models.ServerConfigurationOptionName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerConfigurationOption]: + """Updates managed instance server configuration option. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param server_configuration_option_name: The name of the server configuration option. + "allowPolybaseExport" Required. + :type server_configuration_option_name: str or + ~azure.mgmt.sql.models.ServerConfigurationOptionName + :param parameters: Server configuration option parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerConfigurationOption. The + ServerConfigurationOption is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerConfigurationOption] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + server_configuration_option_name: Union[str, _models.ServerConfigurationOptionName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerConfigurationOption]: + """Updates managed instance server configuration option. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param server_configuration_option_name: The name of the server configuration option. + "allowPolybaseExport" Required. + :type server_configuration_option_name: str or + ~azure.mgmt.sql.models.ServerConfigurationOptionName + :param parameters: Server configuration option parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerConfigurationOption. The + ServerConfigurationOption is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerConfigurationOption] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + server_configuration_option_name: Union[str, _models.ServerConfigurationOptionName], + parameters: Union[_models.ServerConfigurationOption, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerConfigurationOption]: + """Updates managed instance server configuration option. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param server_configuration_option_name: The name of the server configuration option. + "allowPolybaseExport" Required. + :type server_configuration_option_name: str or + ~azure.mgmt.sql.models.ServerConfigurationOptionName + :param parameters: Server configuration option parameters. Is one of the following types: + ServerConfigurationOption, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ServerConfigurationOption or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ServerConfigurationOption. The + ServerConfigurationOption is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerConfigurationOption] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + server_configuration_option_name=server_configuration_option_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = _deserialize(_models.ServerConfigurationOption, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ServerConfigurationOption].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ServerConfigurationOption]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_managed_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ServerConfigurationOption"]: + """Gets a list of managed instance server configuration options. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of ServerConfigurationOption + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerConfigurationOption] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerConfigurationOption]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_server_configuration_options_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ServerConfigurationOption], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ServerConnectionPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`server_connection_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + connection_policy_name: Union[str, _models.ConnectionPolicyName], + **kwargs: Any + ) -> _models.ServerConnectionPolicy: + """Gets a server connection policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param connection_policy_name: The name of the connection policy. "default" Required. + :type connection_policy_name: str or ~azure.mgmt.sql.models.ConnectionPolicyName + :return: ServerConnectionPolicy. The ServerConnectionPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerConnectionPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ServerConnectionPolicy] = kwargs.pop("cls", None) + + _request = build_server_connection_policies_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + connection_policy_name=connection_policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ServerConnectionPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + connection_policy_name: Union[str, _models.ConnectionPolicyName], + parameters: Union[_models.ServerConnectionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_server_connection_policies_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + connection_policy_name=connection_policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + connection_policy_name: Union[str, _models.ConnectionPolicyName], + parameters: _models.ServerConnectionPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerConnectionPolicy]: + """Updates a server connection policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param connection_policy_name: The name of the connection policy. "default" Required. + :type connection_policy_name: str or ~azure.mgmt.sql.models.ConnectionPolicyName + :param parameters: The required parameters for updating a server connection policy. Required. + :type parameters: ~azure.mgmt.sql.models.ServerConnectionPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerConnectionPolicy. The + ServerConnectionPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerConnectionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + connection_policy_name: Union[str, _models.ConnectionPolicyName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerConnectionPolicy]: + """Updates a server connection policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param connection_policy_name: The name of the connection policy. "default" Required. + :type connection_policy_name: str or ~azure.mgmt.sql.models.ConnectionPolicyName + :param parameters: The required parameters for updating a server connection policy. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerConnectionPolicy. The + ServerConnectionPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerConnectionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + connection_policy_name: Union[str, _models.ConnectionPolicyName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerConnectionPolicy]: + """Updates a server connection policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param connection_policy_name: The name of the connection policy. "default" Required. + :type connection_policy_name: str or ~azure.mgmt.sql.models.ConnectionPolicyName + :param parameters: The required parameters for updating a server connection policy. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerConnectionPolicy. The + ServerConnectionPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerConnectionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + connection_policy_name: Union[str, _models.ConnectionPolicyName], + parameters: Union[_models.ServerConnectionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerConnectionPolicy]: + """Updates a server connection policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param connection_policy_name: The name of the connection policy. "default" Required. + :type connection_policy_name: str or ~azure.mgmt.sql.models.ConnectionPolicyName + :param parameters: The required parameters for updating a server connection policy. Is one of + the following types: ServerConnectionPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ServerConnectionPolicy or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ServerConnectionPolicy. The + ServerConnectionPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerConnectionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + connection_policy_name=connection_policy_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ServerConnectionPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ServerConnectionPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ServerConnectionPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ServerConnectionPolicy"]: + """Lists connection policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of ServerConnectionPolicy + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerConnectionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerConnectionPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_server_connection_policies_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ServerConnectionPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ServerDevOpsAuditSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`server_dev_ops_audit_settings` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + dev_ops_auditing_settings_name: Union[str, _models.DevOpsAuditingSettingsName], + **kwargs: Any + ) -> _models.ServerDevOpsAuditingSettings: + """Gets a server's DevOps audit settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param dev_ops_auditing_settings_name: "Default" Required. + :type dev_ops_auditing_settings_name: str or ~azure.mgmt.sql.models.DevOpsAuditingSettingsName + :return: ServerDevOpsAuditingSettings. The ServerDevOpsAuditingSettings is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerDevOpsAuditingSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ServerDevOpsAuditingSettings] = kwargs.pop("cls", None) + + _request = build_server_dev_ops_audit_settings_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + dev_ops_auditing_settings_name=dev_ops_auditing_settings_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ServerDevOpsAuditingSettings, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + dev_ops_auditing_settings_name: Union[str, _models.DevOpsAuditingSettingsName], + parameters: Union[_models.ServerDevOpsAuditingSettings, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_server_dev_ops_audit_settings_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + dev_ops_auditing_settings_name=dev_ops_auditing_settings_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + dev_ops_auditing_settings_name: Union[str, _models.DevOpsAuditingSettingsName], + parameters: _models.ServerDevOpsAuditingSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerDevOpsAuditingSettings]: + """Creates or updates a server's DevOps audit settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param dev_ops_auditing_settings_name: "Default" Required. + :type dev_ops_auditing_settings_name: str or ~azure.mgmt.sql.models.DevOpsAuditingSettingsName + :param parameters: Properties of DevOps audit settings. Required. + :type parameters: ~azure.mgmt.sql.models.ServerDevOpsAuditingSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerDevOpsAuditingSettings. The + ServerDevOpsAuditingSettings is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerDevOpsAuditingSettings] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + dev_ops_auditing_settings_name: Union[str, _models.DevOpsAuditingSettingsName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerDevOpsAuditingSettings]: + """Creates or updates a server's DevOps audit settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param dev_ops_auditing_settings_name: "Default" Required. + :type dev_ops_auditing_settings_name: str or ~azure.mgmt.sql.models.DevOpsAuditingSettingsName + :param parameters: Properties of DevOps audit settings. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerDevOpsAuditingSettings. The + ServerDevOpsAuditingSettings is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerDevOpsAuditingSettings] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + dev_ops_auditing_settings_name: Union[str, _models.DevOpsAuditingSettingsName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerDevOpsAuditingSettings]: + """Creates or updates a server's DevOps audit settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param dev_ops_auditing_settings_name: "Default" Required. + :type dev_ops_auditing_settings_name: str or ~azure.mgmt.sql.models.DevOpsAuditingSettingsName + :param parameters: Properties of DevOps audit settings. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerDevOpsAuditingSettings. The + ServerDevOpsAuditingSettings is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerDevOpsAuditingSettings] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + dev_ops_auditing_settings_name: Union[str, _models.DevOpsAuditingSettingsName], + parameters: Union[_models.ServerDevOpsAuditingSettings, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerDevOpsAuditingSettings]: + """Creates or updates a server's DevOps audit settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param dev_ops_auditing_settings_name: "Default" Required. + :type dev_ops_auditing_settings_name: str or ~azure.mgmt.sql.models.DevOpsAuditingSettingsName + :param parameters: Properties of DevOps audit settings. Is one of the following types: + ServerDevOpsAuditingSettings, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ServerDevOpsAuditingSettings or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ServerDevOpsAuditingSettings. The + ServerDevOpsAuditingSettings is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerDevOpsAuditingSettings] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + dev_ops_auditing_settings_name=dev_ops_auditing_settings_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ServerDevOpsAuditingSettings, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ServerDevOpsAuditingSettings].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ServerDevOpsAuditingSettings]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ServerDevOpsAuditingSettings"]: + """Lists DevOps audit settings of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of ServerDevOpsAuditingSettings + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerDevOpsAuditingSettings] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerDevOpsAuditingSettings]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_server_dev_ops_audit_settings_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ServerDevOpsAuditingSettings], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ServerDnsAliasesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`server_dns_aliases` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, dns_alias_name: str, **kwargs: Any + ) -> _models.ServerDnsAlias: + """Gets a server DNS alias. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param dns_alias_name: The name of the server dns alias. Required. + :type dns_alias_name: str + :return: ServerDnsAlias. The ServerDnsAlias is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerDnsAlias + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ServerDnsAlias] = kwargs.pop("cls", None) + + _request = build_server_dns_aliases_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + dns_alias_name=dns_alias_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ServerDnsAlias, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, resource_group_name: str, server_name: str, dns_alias_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_server_dns_aliases_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + dns_alias_name=dns_alias_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, server_name: str, dns_alias_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.ServerDnsAlias]: + """Creates a server DNS alias. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param dns_alias_name: The name of the server dns alias. Required. + :type dns_alias_name: str + :return: An instance of AsyncLROPoller that returns ServerDnsAlias. The ServerDnsAlias is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerDnsAlias] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + dns_alias_name=dns_alias_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ServerDnsAlias, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ServerDnsAlias].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ServerDnsAlias]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, server_name: str, dns_alias_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_server_dns_aliases_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + dns_alias_name=dns_alias_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, server_name: str, dns_alias_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the server DNS alias with the given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param dns_alias_name: The name of the server dns alias. Required. + :type dns_alias_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + dns_alias_name=dns_alias_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ServerDnsAlias"]: + """Gets a list of server DNS aliases for a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of ServerDnsAlias + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerDnsAlias] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerDnsAlias]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_server_dns_aliases_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ServerDnsAlias], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _acquire_initial( + self, + resource_group_name: str, + server_name: str, + dns_alias_name: str, + parameters: Union[_models.ServerDnsAliasAcquisition, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_server_dns_aliases_acquire_request( + resource_group_name=resource_group_name, + server_name=server_name, + dns_alias_name=dns_alias_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_acquire( + self, + resource_group_name: str, + server_name: str, + dns_alias_name: str, + parameters: _models.ServerDnsAliasAcquisition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerDnsAlias]: + """Acquires server DNS alias from another server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param dns_alias_name: The name of the server dns alias. Required. + :type dns_alias_name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.sql.models.ServerDnsAliasAcquisition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerDnsAlias. The ServerDnsAlias is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerDnsAlias] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_acquire( + self, + resource_group_name: str, + server_name: str, + dns_alias_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerDnsAlias]: + """Acquires server DNS alias from another server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param dns_alias_name: The name of the server dns alias. Required. + :type dns_alias_name: str + :param parameters: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerDnsAlias. The ServerDnsAlias is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerDnsAlias] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_acquire( + self, + resource_group_name: str, + server_name: str, + dns_alias_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerDnsAlias]: + """Acquires server DNS alias from another server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param dns_alias_name: The name of the server dns alias. Required. + :type dns_alias_name: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerDnsAlias. The ServerDnsAlias is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerDnsAlias] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_acquire( + self, + resource_group_name: str, + server_name: str, + dns_alias_name: str, + parameters: Union[_models.ServerDnsAliasAcquisition, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerDnsAlias]: + """Acquires server DNS alias from another server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param dns_alias_name: The name of the server dns alias. Required. + :type dns_alias_name: str + :param parameters: Is one of the following types: ServerDnsAliasAcquisition, JSON, IO[bytes] + Required. + :type parameters: ~azure.mgmt.sql.models.ServerDnsAliasAcquisition or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ServerDnsAlias. The ServerDnsAlias is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerDnsAlias] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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._acquire_initial( + resource_group_name=resource_group_name, + server_name=server_name, + dns_alias_name=dns_alias_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ServerDnsAlias, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ServerDnsAlias].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ServerDnsAlias]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class ServerKeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`server_keys` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, key_name: str, **kwargs: Any) -> _models.ServerKey: + """Gets a server key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param key_name: The name of the server key to be retrieved. Required. + :type key_name: str + :return: ServerKey. The ServerKey is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerKey + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ServerKey] = kwargs.pop("cls", None) + + _request = build_server_keys_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ServerKey, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + key_name: str, + parameters: Union[_models.ServerKey, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_server_keys_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + key_name: str, + parameters: _models.ServerKey, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerKey]: + """Creates or updates a server key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param key_name: The name of the server key to be retrieved. Required. + :type key_name: str + :param parameters: The requested server key resource state. Required. + :type parameters: ~azure.mgmt.sql.models.ServerKey + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerKey. The ServerKey is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerKey] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + key_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerKey]: + """Creates or updates a server key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param key_name: The name of the server key to be retrieved. Required. + :type key_name: str + :param parameters: The requested server key resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerKey. The ServerKey is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerKey] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + key_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerKey]: + """Creates or updates a server key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param key_name: The name of the server key to be retrieved. Required. + :type key_name: str + :param parameters: The requested server key resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerKey. The ServerKey is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerKey] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + key_name: str, + parameters: Union[_models.ServerKey, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerKey]: + """Creates or updates a server key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param key_name: The name of the server key to be retrieved. Required. + :type key_name: str + :param parameters: The requested server key resource state. Is one of the following types: + ServerKey, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ServerKey or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ServerKey. The ServerKey is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerKey] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + key_name=key_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ServerKey, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ServerKey].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ServerKey]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, server_name: str, key_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_server_keys_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, server_name: str, key_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the server key with the given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param key_name: The name of the server key to be retrieved. Required. + :type key_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + key_name=key_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ServerKey"]: + """Gets a list of server keys. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of ServerKey + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerKey] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerKey]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_server_keys_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ServerKey], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ServerSecurityAlertPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`server_security_alert_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + **kwargs: Any + ) -> _models.ServerSecurityAlertPolicy: + """Get a server's security alert policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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 + :return: ServerSecurityAlertPolicy. The ServerSecurityAlertPolicy is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerSecurityAlertPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ServerSecurityAlertPolicy] = kwargs.pop("cls", None) + + _request = build_server_security_alert_policies_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + security_alert_policy_name=security_alert_policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ServerSecurityAlertPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: Union[_models.ServerSecurityAlertPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_server_security_alert_policies_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + security_alert_policy_name=security_alert_policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: _models.ServerSecurityAlertPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerSecurityAlertPolicy]: + """Creates or updates a threat detection policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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 + :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. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerSecurityAlertPolicy. The + ServerSecurityAlertPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerSecurityAlertPolicy]: + """Creates or updates a threat detection policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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 + :param parameters: The server security alert policy. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerSecurityAlertPolicy. The + ServerSecurityAlertPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerSecurityAlertPolicy]: + """Creates or updates a threat detection policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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 + :param parameters: The server security alert policy. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerSecurityAlertPolicy. The + ServerSecurityAlertPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: Union[_models.ServerSecurityAlertPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerSecurityAlertPolicy]: + """Creates or updates a threat detection policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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 + :param parameters: The server security alert policy. Is one of the following types: + ServerSecurityAlertPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ServerSecurityAlertPolicy or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ServerSecurityAlertPolicy. The + ServerSecurityAlertPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + security_alert_policy_name=security_alert_policy_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ServerSecurityAlertPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ServerSecurityAlertPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ServerSecurityAlertPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ServerSecurityAlertPolicy"]: + """Get the server's threat detection policies. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of ServerSecurityAlertPolicy + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerSecurityAlertPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_server_security_alert_policies_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ServerSecurityAlertPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ServerTrustCertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`server_trust_certificates` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, managed_instance_name: str, certificate_name: str, **kwargs: Any + ) -> _models.ServerTrustCertificate: + """Gets a server trust certificate that was uploaded from SQL Server to SQL Managed Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param certificate_name: Name of of the certificate to get. Required. + :type certificate_name: str + :return: ServerTrustCertificate. The ServerTrustCertificate is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerTrustCertificate + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ServerTrustCertificate] = kwargs.pop("cls", None) + + _request = build_server_trust_certificates_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ServerTrustCertificate, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + certificate_name: str, + parameters: Union[_models.ServerTrustCertificate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_server_trust_certificates_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + certificate_name: str, + parameters: _models.ServerTrustCertificate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerTrustCertificate]: + """Uploads a server trust certificate from SQL Server to SQL Managed Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param certificate_name: Name of of the certificate to get. Required. + :type certificate_name: str + :param parameters: The server trust certificate info. Required. + :type parameters: ~azure.mgmt.sql.models.ServerTrustCertificate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerTrustCertificate. The + ServerTrustCertificate is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerTrustCertificate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + certificate_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerTrustCertificate]: + """Uploads a server trust certificate from SQL Server to SQL Managed Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param certificate_name: Name of of the certificate to get. Required. + :type certificate_name: str + :param parameters: The server trust certificate info. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerTrustCertificate. The + ServerTrustCertificate is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerTrustCertificate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + certificate_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerTrustCertificate]: + """Uploads a server trust certificate from SQL Server to SQL Managed Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param certificate_name: Name of of the certificate to get. Required. + :type certificate_name: str + :param parameters: The server trust certificate info. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerTrustCertificate. The + ServerTrustCertificate is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerTrustCertificate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + certificate_name: str, + parameters: Union[_models.ServerTrustCertificate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerTrustCertificate]: + """Uploads a server trust certificate from SQL Server to SQL Managed Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param certificate_name: Name of of the certificate to get. Required. + :type certificate_name: str + :param parameters: The server trust certificate info. Is one of the following types: + ServerTrustCertificate, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ServerTrustCertificate or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ServerTrustCertificate. The + ServerTrustCertificate is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerTrustCertificate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + certificate_name=certificate_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ServerTrustCertificate, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ServerTrustCertificate].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ServerTrustCertificate]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, managed_instance_name: str, certificate_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_server_trust_certificates_delete_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, managed_instance_name: str, certificate_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a server trust certificate that was uploaded from SQL Server to SQL Managed Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param certificate_name: Name of of the certificate to get. Required. + :type certificate_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + certificate_name=certificate_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ServerTrustCertificate"]: + """Gets a list of the server trust certificates used to secure communication between SQL Server + and the specified SQL Managed Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of ServerTrustCertificate + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerTrustCertificate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerTrustCertificate]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_server_trust_certificates_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ServerTrustCertificate], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ServerVulnerabilityAssessmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`server_vulnerability_assessments` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + **kwargs: Any + ) -> _models.ServerVulnerabilityAssessment: + """Gets the server's vulnerability assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 + :return: ServerVulnerabilityAssessment. The ServerVulnerabilityAssessment is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ServerVulnerabilityAssessment] = kwargs.pop("cls", None) + + _request = build_server_vulnerability_assessments_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ServerVulnerabilityAssessment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: _models.ServerVulnerabilityAssessment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ServerVulnerabilityAssessment: + """Creates or updates the server's vulnerability assessment. Learn more about setting SQL + vulnerability assessment with managed identity - + `https://docs.microsoft.com/azure/azure-sql/database/sql-database-vulnerability-assessment-storage + `_. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 parameters: The requested resource. Required. + :type parameters: ~azure.mgmt.sql.models.ServerVulnerabilityAssessment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ServerVulnerabilityAssessment. The ServerVulnerabilityAssessment is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ServerVulnerabilityAssessment: + """Creates or updates the server's vulnerability assessment. Learn more about setting SQL + vulnerability assessment with managed identity - + `https://docs.microsoft.com/azure/azure-sql/database/sql-database-vulnerability-assessment-storage + `_. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 parameters: The requested resource. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ServerVulnerabilityAssessment. The ServerVulnerabilityAssessment is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ServerVulnerabilityAssessment: + """Creates or updates the server's vulnerability assessment. Learn more about setting SQL + vulnerability assessment with managed identity - + `https://docs.microsoft.com/azure/azure-sql/database/sql-database-vulnerability-assessment-storage + `_. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 parameters: The requested resource. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ServerVulnerabilityAssessment. The ServerVulnerabilityAssessment is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: Union[_models.ServerVulnerabilityAssessment, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ServerVulnerabilityAssessment: + """Creates or updates the server's vulnerability assessment. Learn more about setting SQL + vulnerability assessment with managed identity - + `https://docs.microsoft.com/azure/azure-sql/database/sql-database-vulnerability-assessment-storage + `_. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 parameters: The requested resource. Is one of the following types: + ServerVulnerabilityAssessment, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ServerVulnerabilityAssessment or JSON or IO[bytes] + :return: ServerVulnerabilityAssessment. The ServerVulnerabilityAssessment is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_server_vulnerability_assessments_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await 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]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ServerVulnerabilityAssessment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + **kwargs: Any + ) -> None: + """Removes the server's vulnerability assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_server_vulnerability_assessments_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ServerVulnerabilityAssessment"]: + """Lists the vulnerability assessment policies associated with a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of ServerVulnerabilityAssessment + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerVulnerabilityAssessment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerVulnerabilityAssessment]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_server_vulnerability_assessments_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ServerVulnerabilityAssessment], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class StartStopManagedInstanceSchedulesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`start_stop_managed_instance_schedules` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + managed_instance_name: str, + start_stop_schedule_name: Union[str, _models.StartStopScheduleName], + **kwargs: Any + ) -> _models.StartStopManagedInstanceSchedule: + """Gets the managed instance's Start/Stop schedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param start_stop_schedule_name: Name of the managed instance Start/Stop schedule. "default" + Required. + :type start_stop_schedule_name: str or ~azure.mgmt.sql.models.StartStopScheduleName + :return: StartStopManagedInstanceSchedule. The StartStopManagedInstanceSchedule is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.StartStopManagedInstanceSchedule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.StartStopManagedInstanceSchedule] = kwargs.pop("cls", None) + + _request = build_start_stop_managed_instance_schedules_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + start_stop_schedule_name=start_stop_schedule_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.StartStopManagedInstanceSchedule, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + start_stop_schedule_name: Union[str, _models.StartStopScheduleName], + parameters: _models.StartStopManagedInstanceSchedule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StartStopManagedInstanceSchedule: + """Creates or updates the managed instance's Start/Stop schedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param start_stop_schedule_name: Name of the managed instance Start/Stop schedule. "default" + Required. + :type start_stop_schedule_name: str or ~azure.mgmt.sql.models.StartStopScheduleName + :param parameters: The requested managed instance Start/Stop schedule. Required. + :type parameters: ~azure.mgmt.sql.models.StartStopManagedInstanceSchedule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: StartStopManagedInstanceSchedule. The StartStopManagedInstanceSchedule is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.StartStopManagedInstanceSchedule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + start_stop_schedule_name: Union[str, _models.StartStopScheduleName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StartStopManagedInstanceSchedule: + """Creates or updates the managed instance's Start/Stop schedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param start_stop_schedule_name: Name of the managed instance Start/Stop schedule. "default" + Required. + :type start_stop_schedule_name: str or ~azure.mgmt.sql.models.StartStopScheduleName + :param parameters: The requested managed instance Start/Stop schedule. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: StartStopManagedInstanceSchedule. The StartStopManagedInstanceSchedule is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.StartStopManagedInstanceSchedule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + start_stop_schedule_name: Union[str, _models.StartStopScheduleName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StartStopManagedInstanceSchedule: + """Creates or updates the managed instance's Start/Stop schedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param start_stop_schedule_name: Name of the managed instance Start/Stop schedule. "default" + Required. + :type start_stop_schedule_name: str or ~azure.mgmt.sql.models.StartStopScheduleName + :param parameters: The requested managed instance Start/Stop schedule. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: StartStopManagedInstanceSchedule. The StartStopManagedInstanceSchedule is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.StartStopManagedInstanceSchedule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + start_stop_schedule_name: Union[str, _models.StartStopScheduleName], + parameters: Union[_models.StartStopManagedInstanceSchedule, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.StartStopManagedInstanceSchedule: + """Creates or updates the managed instance's Start/Stop schedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param start_stop_schedule_name: Name of the managed instance Start/Stop schedule. "default" + Required. + :type start_stop_schedule_name: str or ~azure.mgmt.sql.models.StartStopScheduleName + :param parameters: The requested managed instance Start/Stop schedule. Is one of the following + types: StartStopManagedInstanceSchedule, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.StartStopManagedInstanceSchedule or JSON or IO[bytes] + :return: StartStopManagedInstanceSchedule. The StartStopManagedInstanceSchedule is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.StartStopManagedInstanceSchedule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_start_stop_managed_instance_schedules_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + start_stop_schedule_name=start_stop_schedule_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await 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]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.StartStopManagedInstanceSchedule, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + managed_instance_name: str, + start_stop_schedule_name: Union[str, _models.StartStopScheduleName], + **kwargs: Any + ) -> None: + """Deletes the managed instance's Start/Stop schedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param start_stop_schedule_name: Name of the managed instance Start/Stop schedule. "default" + Required. + :type start_stop_schedule_name: str or ~azure.mgmt.sql.models.StartStopScheduleName + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_start_stop_managed_instance_schedules_delete_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + start_stop_schedule_name=start_stop_schedule_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await 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) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.StartStopManagedInstanceSchedule"]: + """Lists the managed instance's Start/Stop schedules. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of StartStopManagedInstanceSchedule + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.StartStopManagedInstanceSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.StartStopManagedInstanceSchedule]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_start_stop_managed_instance_schedules_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.StartStopManagedInstanceSchedule], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class SubscriptionUsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`subscription_usages` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, location_name: str, usage_name: str, **kwargs: Any) -> _models.SubscriptionUsage: + """Gets a subscription usage metric. + + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :param usage_name: Name of usage metric to return. Required. + :type usage_name: str + :return: SubscriptionUsage. The SubscriptionUsage is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SubscriptionUsage + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SubscriptionUsage] = kwargs.pop("cls", None) + + _request = build_subscription_usages_get_request( + location_name=location_name, + usage_name=usage_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SubscriptionUsage, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_location(self, location_name: str, **kwargs: Any) -> AsyncItemPaged["_models.SubscriptionUsage"]: + """Gets all subscription usage metrics in a given location. + + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :return: An iterator like instance of SubscriptionUsage + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SubscriptionUsage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SubscriptionUsage]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_subscription_usages_list_by_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SubscriptionUsage], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class SyncAgentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`sync_agents` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, sync_agent_name: str, **kwargs: Any + ) -> _models.SyncAgent: + """Gets a sync agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param sync_agent_name: The name of the sync agent. Required. + :type sync_agent_name: str + :return: SyncAgent. The SyncAgent is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SyncAgent + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SyncAgent] = kwargs.pop("cls", None) + + _request = build_sync_agents_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + sync_agent_name=sync_agent_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SyncAgent, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + sync_agent_name: str, + parameters: Union[_models.SyncAgent, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_sync_agents_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + sync_agent_name=sync_agent_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + sync_agent_name: str, + parameters: _models.SyncAgent, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SyncAgent]: + """Creates or updates a sync agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param sync_agent_name: The name of the sync agent. Required. + :type sync_agent_name: str + :param parameters: The requested sync agent resource state. Required. + :type parameters: ~azure.mgmt.sql.models.SyncAgent + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns SyncAgent. The SyncAgent is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + sync_agent_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SyncAgent]: + """Creates or updates a sync agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param sync_agent_name: The name of the sync agent. Required. + :type sync_agent_name: str + :param parameters: The requested sync agent resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns SyncAgent. The SyncAgent is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + sync_agent_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SyncAgent]: + """Creates or updates a sync agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param sync_agent_name: The name of the sync agent. Required. + :type sync_agent_name: str + :param parameters: The requested sync agent resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns SyncAgent. The SyncAgent is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + sync_agent_name: str, + parameters: Union[_models.SyncAgent, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.SyncAgent]: + """Creates or updates a sync agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param sync_agent_name: The name of the sync agent. Required. + :type sync_agent_name: str + :param parameters: The requested sync agent resource state. Is one of the following types: + SyncAgent, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.SyncAgent or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns SyncAgent. The SyncAgent is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + sync_agent_name=sync_agent_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.SyncAgent, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.SyncAgent].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.SyncAgent]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, server_name: str, sync_agent_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_sync_agents_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + sync_agent_name=sync_agent_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, server_name: str, sync_agent_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a sync agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param sync_agent_name: The name of the sync agent. Required. + :type sync_agent_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + sync_agent_name=sync_agent_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.SyncAgent"]: + """Lists sync agents in a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of SyncAgent + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SyncAgent]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_sync_agents_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SyncAgent], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def generate_key( + self, resource_group_name: str, server_name: str, sync_agent_name: str, **kwargs: Any + ) -> _models.SyncAgentKeyProperties: + """Generates a sync agent key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param sync_agent_name: The name of the sync agent. Required. + :type sync_agent_name: str + :return: SyncAgentKeyProperties. The SyncAgentKeyProperties is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SyncAgentKeyProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SyncAgentKeyProperties] = kwargs.pop("cls", None) + + _request = build_sync_agents_generate_key_request( + resource_group_name=resource_group_name, + server_name=server_name, + sync_agent_name=sync_agent_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SyncAgentKeyProperties, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_linked_databases( + self, resource_group_name: str, server_name: str, sync_agent_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.SyncAgentLinkedDatabase"]: + """Lists databases linked to a sync agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param sync_agent_name: The name of the sync agent. Required. + :type sync_agent_name: str + :return: An iterator like instance of SyncAgentLinkedDatabase + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncAgentLinkedDatabase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SyncAgentLinkedDatabase]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_sync_agents_list_linked_databases_request( + resource_group_name=resource_group_name, + server_name=server_name, + sync_agent_name=sync_agent_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SyncAgentLinkedDatabase], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class SyncGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`sync_groups` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, sync_group_name: str, **kwargs: Any + ) -> _models.SyncGroup: + """Gets a sync group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :return: SyncGroup. The SyncGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SyncGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SyncGroup] = kwargs.pop("cls", None) + + _request = build_sync_groups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SyncGroup, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + 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, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_sync_groups_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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. The name is case insensitive. + Required. + :type resource_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 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 + :return: An instance of AsyncLROPoller that returns SyncGroup. The SyncGroup is compatible with + MutableMapping + :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: JSON, + *, + 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. The name is case insensitive. + Required. + :type resource_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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns SyncGroup. The SyncGroup is compatible with + MutableMapping + :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[bytes], + *, + 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. The name is case insensitive. + Required. + :type resource_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 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[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns SyncGroup. The SyncGroup is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + 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, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.SyncGroup]: + """Creates or updates a sync group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :param parameters: The requested sync group resource state. Is one of the following types: + SyncGroup, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.SyncGroup or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns SyncGroup. The SyncGroup is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.SyncGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.SyncGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.SyncGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + parameters: Union[_models.SyncGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_sync_groups_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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. The name is case insensitive. + Required. + :type resource_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 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 + :return: An instance of AsyncLROPoller that returns SyncGroup. The SyncGroup is compatible with + MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SyncGroup]: + """Updates a sync group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns SyncGroup. The SyncGroup is compatible with + MutableMapping + :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[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SyncGroup]: + """Updates a sync group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 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[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns SyncGroup. The SyncGroup is compatible with + MutableMapping + :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, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.SyncGroup]: + """Updates a sync group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :param parameters: The requested sync group resource state. Is one of the following types: + SyncGroup, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.SyncGroup or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns SyncGroup. The SyncGroup is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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._update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.SyncGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.SyncGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.SyncGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_sync_groups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a sync group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.SyncGroup"]: + """Lists sync groups under a hub database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of SyncGroup + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SyncGroup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_sync_groups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SyncGroup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def cancel_sync( + 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. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_sync_groups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_hub_schemas( + self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.SyncFullSchemaProperties"]: + """Gets a collection of hub database schemas. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :return: An iterator like instance of SyncFullSchemaProperties + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncFullSchemaProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SyncFullSchemaProperties]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_sync_groups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SyncFullSchemaProperties], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @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 + ) -> AsyncItemPaged["_models.SyncGroupLogProperties"]: + """Gets a collection of sync group logs. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :keyword start_time: Get logs generated after this time. Required. + :paramtype start_time: str + :keyword end_time: Get logs generated before this time. Required. + :paramtype end_time: str + :keyword type: The types of logs to retrieve. Known values are: "All", "Error", "Warning", and + "Success". Required. + :paramtype type: str or ~azure.mgmt.sql.models.SyncGroupsType + :keyword continuation_token_parameter: The continuation token for this operation. Default value + is None. + :paramtype continuation_token_parameter: str + :return: An iterator like instance of SyncGroupLogProperties + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncGroupLogProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SyncGroupLogProperties]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_sync_groups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SyncGroupLogProperties], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _refresh_hub_schema_initial( + self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_sync_groups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace_async + async def trigger_sync( + 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. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_sync_groups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_sync_database_ids( + self, location_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.SyncDatabaseIdProperties"]: + """Gets a collection of sync database ids. + + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :return: An iterator like instance of SyncDatabaseIdProperties + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncDatabaseIdProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SyncDatabaseIdProperties]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_sync_groups_list_sync_database_ids_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SyncDatabaseIdProperties], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class SyncMembersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`sync_members` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + sync_group_name: str, + sync_member_name: str, + **kwargs: Any + ) -> _models.SyncMember: + """Gets a sync member. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :param sync_member_name: The name of the sync member. Required. + :type sync_member_name: str + :return: SyncMember. The SyncMember is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SyncMember + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SyncMember] = kwargs.pop("cls", None) + + _request = build_sync_members_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + sync_member_name=sync_member_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SyncMember, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + parameters: Union[_models.SyncMember, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_sync_members_create_or_update_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + parameters: _models.SyncMember, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SyncMember]: + """Creates or updates a sync member. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :param sync_member_name: The name of the sync member. Required. + :type sync_member_name: str + :param parameters: The requested sync member resource state. Required. + :type parameters: ~azure.mgmt.sql.models.SyncMember + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns SyncMember. The SyncMember is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncMember] + :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, + sync_member_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SyncMember]: + """Creates or updates a sync member. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :param sync_member_name: The name of the sync member. Required. + :type sync_member_name: str + :param parameters: The requested sync member resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns SyncMember. The SyncMember is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncMember] + :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, + sync_member_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SyncMember]: + """Creates or updates a sync member. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :param sync_member_name: The name of the sync member. Required. + :type sync_member_name: str + :param parameters: The requested sync member resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns SyncMember. The SyncMember is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncMember] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + parameters: Union[_models.SyncMember, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.SyncMember]: + """Creates or updates a sync member. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :param sync_member_name: The name of the sync member. Required. + :type sync_member_name: str + :param parameters: The requested sync member resource state. Is one of the following types: + SyncMember, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.SyncMember or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns SyncMember. The SyncMember is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncMember] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + sync_member_name=sync_member_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.SyncMember, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.SyncMember].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.SyncMember]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + parameters: Union[_models.SyncMember, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_sync_members_update_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + parameters: _models.SyncMember, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SyncMember]: + """Updates an existing sync member. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :param sync_member_name: The name of the sync member. Required. + :type sync_member_name: str + :param parameters: The requested sync member resource state. Required. + :type parameters: ~azure.mgmt.sql.models.SyncMember + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns SyncMember. The SyncMember is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncMember] + :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, + sync_member_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SyncMember]: + """Updates an existing sync member. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :param sync_member_name: The name of the sync member. Required. + :type sync_member_name: str + :param parameters: The requested sync member resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns SyncMember. The SyncMember is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncMember] + :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, + sync_member_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SyncMember]: + """Updates an existing sync member. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :param sync_member_name: The name of the sync member. Required. + :type sync_member_name: str + :param parameters: The requested sync member resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns SyncMember. The SyncMember is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncMember] + :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, + sync_member_name: str, + parameters: Union[_models.SyncMember, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.SyncMember]: + """Updates an existing sync member. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :param sync_member_name: The name of the sync member. Required. + :type sync_member_name: str + :param parameters: The requested sync member resource state. Is one of the following types: + SyncMember, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.SyncMember or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns SyncMember. The SyncMember is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncMember] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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( + 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, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.SyncMember, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.SyncMember].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.SyncMember]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_sync_members_delete_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a sync member. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :param sync_member_name: The name of the sync member. Required. + :type sync_member_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_sync_group( + self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.SyncMember"]: + """Lists sync members in the given sync group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :return: An iterator like instance of SyncMember + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncMember] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SyncMember]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_sync_members_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SyncMember], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _refresh_member_schema_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_sync_members_refresh_member_schema_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_refresh_member_schema( + self, + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Refreshes a sync member database schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :param sync_member_name: The name of the sync member. Required. + :type sync_member_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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_member_schema_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + sync_member_name=sync_member_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @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 + ) -> AsyncItemPaged["_models.SyncFullSchemaProperties"]: + """Gets a sync member database schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :param sync_member_name: The name of the sync member. Required. + :type sync_member_name: str + :return: An iterator like instance of SyncFullSchemaProperties + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncFullSchemaProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SyncFullSchemaProperties]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_sync_members_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SyncFullSchemaProperties], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class TimeZonesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`time_zones` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, location_name: str, time_zone_id: str, **kwargs: Any) -> _models.TimeZone: + """Gets a managed instance time zone. + + :param location_name: The location of the database. Required. + :type location_name: str + :param time_zone_id: The time zone ID. Required. + :type time_zone_id: str + :return: TimeZone. The TimeZone is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.TimeZone + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TimeZone] = kwargs.pop("cls", None) + + _request = build_time_zones_get_request( + location_name=location_name, + time_zone_id=time_zone_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TimeZone, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_location(self, location_name: str, **kwargs: Any) -> AsyncItemPaged["_models.TimeZone"]: + """Gets a list of managed instance time zones by location. + + :param location_name: The location of the database. Required. + :type location_name: str + :return: An iterator like instance of TimeZone + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.TimeZone] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TimeZone]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_time_zones_list_by_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TimeZone], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class VirtualClustersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`virtual_clusters` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, resource_group_name: str, virtual_cluster_name: str, **kwargs: Any) -> _models.VirtualCluster: + """Gets a virtual cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param virtual_cluster_name: The name of the virtual cluster. Required. + :type virtual_cluster_name: str + :return: VirtualCluster. The VirtualCluster is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.VirtualCluster + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.VirtualCluster] = kwargs.pop("cls", None) + + _request = build_virtual_clusters_get_request( + resource_group_name=resource_group_name, + virtual_cluster_name=virtual_cluster_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.VirtualCluster, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + virtual_cluster_name: str, + parameters: Union[_models.VirtualCluster, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_virtual_clusters_create_or_update_request( + resource_group_name=resource_group_name, + virtual_cluster_name=virtual_cluster_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + virtual_cluster_name: str, + parameters: _models.VirtualCluster, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualCluster]: + """Creates virtual cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param virtual_cluster_name: The name of the virtual cluster. Required. + :type virtual_cluster_name: str + :param parameters: The requested virtual cluster resource state. Required. + :type parameters: ~azure.mgmt.sql.models.VirtualCluster + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns VirtualCluster. The VirtualCluster is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.VirtualCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + virtual_cluster_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualCluster]: + """Creates virtual cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param virtual_cluster_name: The name of the virtual cluster. Required. + :type virtual_cluster_name: str + :param parameters: The requested virtual cluster resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns VirtualCluster. The VirtualCluster is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.VirtualCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + virtual_cluster_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualCluster]: + """Creates virtual cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param virtual_cluster_name: The name of the virtual cluster. Required. + :type virtual_cluster_name: str + :param parameters: The requested virtual cluster resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns VirtualCluster. The VirtualCluster is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.VirtualCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + virtual_cluster_name: str, + parameters: Union[_models.VirtualCluster, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualCluster]: + """Creates virtual cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param virtual_cluster_name: The name of the virtual cluster. Required. + :type virtual_cluster_name: str + :param parameters: The requested virtual cluster resource state. Is one of the following types: + VirtualCluster, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.VirtualCluster or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns VirtualCluster. The VirtualCluster is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.VirtualCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + virtual_cluster_name=virtual_cluster_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.VirtualCluster, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.VirtualCluster].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.VirtualCluster]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + virtual_cluster_name: str, + parameters: Union[_models.VirtualClusterUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_virtual_clusters_update_request( + resource_group_name=resource_group_name, + virtual_cluster_name=virtual_cluster_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + virtual_cluster_name: str, + parameters: _models.VirtualClusterUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualCluster]: + """Updates an existing virtual cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param virtual_cluster_name: The name of the virtual cluster. Required. + :type virtual_cluster_name: str + :param parameters: The requested virtual cluster resource state. Required. + :type parameters: ~azure.mgmt.sql.models.VirtualClusterUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns VirtualCluster. The VirtualCluster is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.VirtualCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + virtual_cluster_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualCluster]: + """Updates an existing virtual cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param virtual_cluster_name: The name of the virtual cluster. Required. + :type virtual_cluster_name: str + :param parameters: The requested virtual cluster resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns VirtualCluster. The VirtualCluster is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.VirtualCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + virtual_cluster_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualCluster]: + """Updates an existing virtual cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param virtual_cluster_name: The name of the virtual cluster. Required. + :type virtual_cluster_name: str + :param parameters: The requested virtual cluster resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns VirtualCluster. The VirtualCluster is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.VirtualCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + virtual_cluster_name: str, + parameters: Union[_models.VirtualClusterUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualCluster]: + """Updates an existing virtual cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param virtual_cluster_name: The name of the virtual cluster. Required. + :type virtual_cluster_name: str + :param parameters: The requested virtual cluster resource state. Is one of the following types: + VirtualClusterUpdate, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.VirtualClusterUpdate or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns VirtualCluster. The VirtualCluster is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.VirtualCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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( + resource_group_name=resource_group_name, + virtual_cluster_name=virtual_cluster_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.VirtualCluster, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.VirtualCluster].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.VirtualCluster]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, virtual_cluster_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_virtual_clusters_delete_request( + resource_group_name=resource_group_name, + virtual_cluster_name=virtual_cluster_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, virtual_cluster_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a virtual cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param virtual_cluster_name: The name of the virtual cluster. Required. + :type virtual_cluster_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + virtual_cluster_name=virtual_cluster_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.VirtualCluster"]: + """Gets a list of virtual clusters in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of VirtualCluster + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.VirtualCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.VirtualCluster]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_virtual_clusters_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.VirtualCluster], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncItemPaged["_models.VirtualCluster"]: + """Gets a list of all virtualClusters in the subscription. + + :return: An iterator like instance of VirtualCluster + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.VirtualCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.VirtualCluster]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_virtual_clusters_list_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.VirtualCluster], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _update_dns_servers_initial( + self, resource_group_name: str, virtual_cluster_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_virtual_clusters_update_dns_servers_request( + resource_group_name=resource_group_name, + virtual_cluster_name=virtual_cluster_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_update_dns_servers( + self, resource_group_name: str, virtual_cluster_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.UpdateVirtualClusterDnsServersOperation]: + """Synchronizes the DNS server settings used by the managed instances inside the given virtual + cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param virtual_cluster_name: The name of the virtual cluster. Required. + :type virtual_cluster_name: str + :return: An instance of AsyncLROPoller that returns UpdateVirtualClusterDnsServersOperation. + The UpdateVirtualClusterDnsServersOperation is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.UpdateVirtualClusterDnsServersOperation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_dns_servers_initial( + resource_group_name=resource_group_name, + virtual_cluster_name=virtual_cluster_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.UpdateVirtualClusterDnsServersOperation, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.UpdateVirtualClusterDnsServersOperation].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.UpdateVirtualClusterDnsServersOperation]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class VirtualNetworkRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`virtual_network_rules` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, virtual_network_rule_name: str, **kwargs: Any + ) -> _models.VirtualNetworkRule: + """Gets a virtual network rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param virtual_network_rule_name: The name of the virtual network rule. Required. + :type virtual_network_rule_name: str + :return: VirtualNetworkRule. The VirtualNetworkRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.VirtualNetworkRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.VirtualNetworkRule] = kwargs.pop("cls", None) + + _request = build_virtual_network_rules_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + virtual_network_rule_name=virtual_network_rule_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.VirtualNetworkRule, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + virtual_network_rule_name: str, + parameters: Union[_models.VirtualNetworkRule, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_virtual_network_rules_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + virtual_network_rule_name=virtual_network_rule_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + virtual_network_rule_name: str, + parameters: _models.VirtualNetworkRule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualNetworkRule]: + """Creates or updates an existing virtual network rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param virtual_network_rule_name: The name of the virtual network rule. Required. + :type virtual_network_rule_name: str + :param parameters: The requested virtual Network Rule Resource state. Required. + :type parameters: ~azure.mgmt.sql.models.VirtualNetworkRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns VirtualNetworkRule. The VirtualNetworkRule + is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.VirtualNetworkRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + virtual_network_rule_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualNetworkRule]: + """Creates or updates an existing virtual network rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param virtual_network_rule_name: The name of the virtual network rule. Required. + :type virtual_network_rule_name: str + :param parameters: The requested virtual Network Rule Resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns VirtualNetworkRule. The VirtualNetworkRule + is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.VirtualNetworkRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + virtual_network_rule_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualNetworkRule]: + """Creates or updates an existing virtual network rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param virtual_network_rule_name: The name of the virtual network rule. Required. + :type virtual_network_rule_name: str + :param parameters: The requested virtual Network Rule Resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns VirtualNetworkRule. The VirtualNetworkRule + is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.VirtualNetworkRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + virtual_network_rule_name: str, + parameters: Union[_models.VirtualNetworkRule, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualNetworkRule]: + """Creates or updates an existing virtual network rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param virtual_network_rule_name: The name of the virtual network rule. Required. + :type virtual_network_rule_name: str + :param parameters: The requested virtual Network Rule Resource state. Is one of the following + types: VirtualNetworkRule, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.VirtualNetworkRule or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns VirtualNetworkRule. The VirtualNetworkRule + is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.VirtualNetworkRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + virtual_network_rule_name=virtual_network_rule_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.VirtualNetworkRule, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.VirtualNetworkRule].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.VirtualNetworkRule]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, server_name: str, virtual_network_rule_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_virtual_network_rules_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + virtual_network_rule_name=virtual_network_rule_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, server_name: str, virtual_network_rule_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the virtual network rule with the given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param virtual_network_rule_name: The name of the virtual network rule. Required. + :type virtual_network_rule_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + virtual_network_rule_name=virtual_network_rule_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.VirtualNetworkRule"]: + """Gets a list of virtual network rules in a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of VirtualNetworkRule + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.VirtualNetworkRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.VirtualNetworkRule]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_virtual_network_rules_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.VirtualNetworkRule], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class WorkloadClassifiersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`workload_classifiers` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + workload_group_name: str, + workload_classifier_name: str, + **kwargs: Any + ) -> _models.WorkloadClassifier: + """Gets a workload classifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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. Required. + :type workload_group_name: str + :param workload_classifier_name: The name of the workload classifier. Required. + :type workload_classifier_name: str + :return: WorkloadClassifier. The WorkloadClassifier is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.WorkloadClassifier + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.WorkloadClassifier] = kwargs.pop("cls", None) + + _request = build_workload_classifiers_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + workload_group_name=workload_group_name, + workload_classifier_name=workload_classifier_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.WorkloadClassifier, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + workload_classifier_name: str, + parameters: Union[_models.WorkloadClassifier, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workload_classifiers_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + workload_group_name=workload_group_name, + workload_classifier_name=workload_classifier_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + workload_classifier_name: str, + parameters: _models.WorkloadClassifier, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadClassifier]: + """Creates or updates a workload classifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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. Required. + :type workload_group_name: str + :param workload_classifier_name: The name of the workload classifier. Required. + :type workload_classifier_name: str + :param parameters: The properties of the workload classifier. Required. + :type parameters: ~azure.mgmt.sql.models.WorkloadClassifier + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns WorkloadClassifier. The WorkloadClassifier + is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.WorkloadClassifier] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + workload_classifier_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadClassifier]: + """Creates or updates a workload classifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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. Required. + :type workload_group_name: str + :param workload_classifier_name: The name of the workload classifier. Required. + :type workload_classifier_name: str + :param parameters: The properties of the workload classifier. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns WorkloadClassifier. The WorkloadClassifier + is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.WorkloadClassifier] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + workload_classifier_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadClassifier]: + """Creates or updates a workload classifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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. Required. + :type workload_group_name: str + :param workload_classifier_name: The name of the workload classifier. Required. + :type workload_classifier_name: str + :param parameters: The properties of the workload classifier. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns WorkloadClassifier. The WorkloadClassifier + is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.WorkloadClassifier] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + workload_classifier_name: str, + parameters: Union[_models.WorkloadClassifier, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadClassifier]: + """Creates or updates a workload classifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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. Required. + :type workload_group_name: str + :param workload_classifier_name: The name of the workload classifier. Required. + :type workload_classifier_name: str + :param parameters: The properties of the workload classifier. Is one of the following types: + WorkloadClassifier, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.WorkloadClassifier or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns WorkloadClassifier. The WorkloadClassifier + is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.WorkloadClassifier] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + workload_group_name=workload_group_name, + workload_classifier_name=workload_classifier_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.WorkloadClassifier, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.WorkloadClassifier].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.WorkloadClassifier]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + workload_classifier_name: str, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_workload_classifiers_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + workload_group_name=workload_group_name, + workload_classifier_name=workload_classifier_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + workload_classifier_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a workload classifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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. Required. + :type workload_group_name: str + :param workload_classifier_name: The name of the workload classifier. Required. + :type workload_classifier_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + workload_group_name=workload_group_name, + workload_classifier_name=workload_classifier_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_workload_group( + self, resource_group_name: str, server_name: str, database_name: str, workload_group_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.WorkloadClassifier"]: + """Gets the list of workload classifiers for a workload group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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. Required. + :type workload_group_name: str + :return: An iterator like instance of WorkloadClassifier + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.WorkloadClassifier] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.WorkloadClassifier]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_workload_classifiers_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.WorkloadClassifier], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class WorkloadGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`workload_groups` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, workload_group_name: str, **kwargs: Any + ) -> _models.WorkloadGroup: + """Gets a workload group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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. Required. + :type workload_group_name: str + :return: WorkloadGroup. The WorkloadGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.WorkloadGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.WorkloadGroup] = kwargs.pop("cls", None) + + _request = build_workload_groups_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + workload_group_name=workload_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.WorkloadGroup, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + parameters: Union[_models.WorkloadGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workload_groups_create_or_update_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + parameters: _models.WorkloadGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadGroup]: + """Creates or updates a workload group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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. Required. + :type workload_group_name: str + :param parameters: The requested workload group state. Required. + :type parameters: ~azure.mgmt.sql.models.WorkloadGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns WorkloadGroup. The WorkloadGroup is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.WorkloadGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadGroup]: + """Creates or updates a workload group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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. Required. + :type workload_group_name: str + :param parameters: The requested workload group state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns WorkloadGroup. The WorkloadGroup is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.WorkloadGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadGroup]: + """Creates or updates a workload group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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. Required. + :type workload_group_name: str + :param parameters: The requested workload group state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns WorkloadGroup. The WorkloadGroup is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.WorkloadGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + parameters: Union[_models.WorkloadGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadGroup]: + """Creates or updates a workload group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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. Required. + :type workload_group_name: str + :param parameters: The requested workload group state. Is one of the following types: + WorkloadGroup, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.WorkloadGroup or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns WorkloadGroup. The WorkloadGroup is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.WorkloadGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + workload_group_name=workload_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.WorkloadGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.WorkloadGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.WorkloadGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, server_name: str, database_name: str, workload_group_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_workload_groups_delete_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, server_name: str, database_name: str, workload_group_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a workload group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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. Required. + :type workload_group_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + workload_group_name=workload_group_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.WorkloadGroup"]: + """Gets the list of workload groups. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of WorkloadGroup + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.WorkloadGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.WorkloadGroup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_workload_groups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.WorkloadGroup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ManagedDatabaseSensitivityLabelsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_database_sensitivity_labels` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async 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. The name is case insensitive. + 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 + :return: SensitivityLabel. The SensitivityLabel is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SensitivityLabel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SensitivityLabel] = kwargs.pop("cls", None) + + _request = build_managed_database_sensitivity_labels_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SensitivityLabel, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + parameters: _models.SensitivityLabel, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SensitivityLabel: + """Creates or updates the sensitivity label of a given column. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 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 + :return: SensitivityLabel. The SensitivityLabel is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SensitivityLabel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SensitivityLabel: + """Creates or updates the sensitivity label of a given column. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 parameters: The column sensitivity label resource. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SensitivityLabel. The SensitivityLabel is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SensitivityLabel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SensitivityLabel: + """Creates or updates the sensitivity label of a given column. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 parameters: The column sensitivity label resource. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SensitivityLabel. The SensitivityLabel is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SensitivityLabel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + parameters: Union[_models.SensitivityLabel, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.SensitivityLabel: + """Creates or updates the sensitivity label of a given column. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 parameters: The column sensitivity label resource. Is one of the following types: + SensitivityLabel, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.SensitivityLabel or JSON or IO[bytes] + :return: SensitivityLabel. The SensitivityLabel is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SensitivityLabel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_database_sensitivity_labels_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + column_name=column_name, + subscription_id=self._config.subscription_id, + sensitivity_label_source=sensitivity_label_source, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await 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]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SensitivityLabel, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + **kwargs: Any + ) -> None: + """Deletes the sensitivity label of a given column. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_managed_database_sensitivity_labels_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def disable_recommendation( + 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. The name is case insensitive. + 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 + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_managed_database_sensitivity_labels_disable_recommendation_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + column_name=column_name, + subscription_id=self._config.subscription_id, + sensitivity_label_source=sensitivity_label_source, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def enable_recommendation( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + **kwargs: Any + ) -> None: + """Enables sensitivity recommendations on a given column (recommendations are enabled by default + on all columns). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_managed_database_sensitivity_labels_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_models.SensitivityLabel"]: + """Gets the sensitivity labels of a given database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 skip_token: Default value is None. + :paramtype skip_token: str + :keyword count: Default value is None. + :paramtype count: bool + :keyword filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of SensitivityLabel + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SensitivityLabel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SensitivityLabel]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_database_sensitivity_labels_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SensitivityLabel], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @overload + async def update( + 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. The name is case insensitive. + 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 + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: JSON, + *, + 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. The name is case insensitive. + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: IO[bytes], + *, + 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. The name is case insensitive. + 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[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: Union[_models.SensitivityLabelUpdateList, JSON, IO[bytes]], + **kwargs: Any + ) -> None: + """Update sensitivity labels of a given database using an operations batch. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 one of the following types: SensitivityLabelUpdateList, JSON, IO[bytes] + Required. + :type parameters: ~azure.mgmt.sql.models.SensitivityLabelUpdateList or JSON or IO[bytes] + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_database_sensitivity_labels_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_models.SensitivityLabel"]: + """Gets the sensitivity labels of a given database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 skip_token: Default value is None. + :paramtype skip_token: str + :keyword include_disabled_recommendations: Specifies whether to include disabled + recommendations or not. Default value is None. + :paramtype include_disabled_recommendations: bool + :keyword filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of SensitivityLabel + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SensitivityLabel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SensitivityLabel]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_database_sensitivity_labels_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SensitivityLabel], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_database( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + *, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.SensitivityLabel"]: + """Gets the sensitivity labels of a given database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of SensitivityLabel + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SensitivityLabel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SensitivityLabel]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_database_sensitivity_labels_list_by_database_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SensitivityLabel], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class DatabaseEncryptionProtectorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`database_encryption_protectors` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _revalidate_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_database_encryption_protectors_revalidate_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + encryption_protector_name=encryption_protector_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_revalidate( + self, + resource_group_name: str, + server_name: str, + database_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Revalidates an existing encryption protector for a particular database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 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 + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + encryption_protector_name=encryption_protector_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _revert_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_database_encryption_protectors_revert_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + encryption_protector_name=encryption_protector_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_revert( + self, + resource_group_name: str, + server_name: str, + database_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Reverts an existing encryption protector for a particular database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 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 + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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._revert_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + encryption_protector_name=encryption_protector_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class DatabaseOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`database_operations` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + ) -> AsyncItemPaged["_models.DatabaseOperation"]: + """Gets a list of operations performed on the database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of DatabaseOperation + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseOperation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseOperation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_database_operations_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseOperation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def cancel( + 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. The name is case insensitive. + Required. + :type resource_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 + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_database_operations_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class DatabaseUsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`database_usages` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + ) -> AsyncItemPaged["_models.DatabaseUsage"]: + """Gets database usages. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of DatabaseUsage + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseUsage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseUsage]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_database_usages_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseUsage], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class RecommendedSensitivityLabelsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`recommended_sensitivity_labels` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + async def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: _models.RecommendedSensitivityLabelUpdateList, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update recommended sensitivity labels states of a given database using an operations batch. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: Required. + :type parameters: ~azure.mgmt.sql.models.RecommendedSensitivityLabelUpdateList + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update recommended sensitivity labels states of a given database using an operations batch. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update recommended sensitivity labels states of a given database using an operations batch. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.RecommendedSensitivityLabelUpdateList, JSON, IO[bytes]], + **kwargs: Any + ) -> None: + """Update recommended sensitivity labels states of a given database using an operations batch. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: Is one of the following types: RecommendedSensitivityLabelUpdateList, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.RecommendedSensitivityLabelUpdateList or JSON or + IO[bytes] + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_recommended_sensitivity_labels_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class SynapseLinkWorkspacesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`synapse_link_workspaces` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + ) -> AsyncItemPaged["_models.SynapseLinkWorkspace"]: + """Gets all synapselink workspaces for a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of SynapseLinkWorkspace + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SynapseLinkWorkspace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SynapseLinkWorkspace]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_synapse_link_workspaces_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SynapseLinkWorkspace], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ServerOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`server_operations` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + ) -> AsyncItemPaged["_models.ServerOperation"]: + """Gets a list of operations performed on the server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of ServerOperation + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerOperation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerOperation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_server_operations_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ServerOperation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ServerUsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`server_usages` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + ) -> AsyncItemPaged["_models.ServerUsage"]: + """Gets server usages. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of ServerUsage + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerUsage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerUsage]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_server_usages_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ServerUsage], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class TdeCertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`tde_certificates` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _create_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.TdeCertificate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_tde_certificates_create_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + server_name: str, + parameters: _models.TdeCertificate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Creates a TDE certificate for a given server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The requested TDE certificate to be created or updated. Required. + :type parameters: ~azure.mgmt.sql.models.TdeCertificate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Creates a TDE certificate for a given server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The requested TDE certificate to be created or updated. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Creates a TDE certificate for a given server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The requested TDE certificate to be created or updated. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.TdeCertificate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Creates a TDE certificate for a given server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The requested TDE certificate to be created or updated. Is one of the + following types: TdeCertificate, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.TdeCertificate or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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( + resource_group_name=resource_group_name, + server_name=server_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class DatabaseAdvancedThreatProtectionSettingsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`database_advanced_threat_protection_settings` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + **kwargs: Any + ) -> _models.DatabaseAdvancedThreatProtection: + """Gets a database's Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :return: DatabaseAdvancedThreatProtection. The DatabaseAdvancedThreatProtection is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseAdvancedThreatProtection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseAdvancedThreatProtection] = kwargs.pop("cls", None) + + _request = build_database_advanced_threat_protection_settings_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + advanced_threat_protection_name=advanced_threat_protection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseAdvancedThreatProtection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: _models.DatabaseAdvancedThreatProtection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseAdvancedThreatProtection: + """Creates or updates a database's Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The database Advanced Threat Protection state. Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseAdvancedThreatProtection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseAdvancedThreatProtection. The DatabaseAdvancedThreatProtection is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseAdvancedThreatProtection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseAdvancedThreatProtection: + """Creates or updates a database's Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The database Advanced Threat Protection state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseAdvancedThreatProtection. The DatabaseAdvancedThreatProtection is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseAdvancedThreatProtection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseAdvancedThreatProtection: + """Creates or updates a database's Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The database Advanced Threat Protection state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseAdvancedThreatProtection. The DatabaseAdvancedThreatProtection is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseAdvancedThreatProtection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: Union[_models.DatabaseAdvancedThreatProtection, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.DatabaseAdvancedThreatProtection: + """Creates or updates a database's Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The database Advanced Threat Protection state. Is one of the following + types: DatabaseAdvancedThreatProtection, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseAdvancedThreatProtection or JSON or IO[bytes] + :return: DatabaseAdvancedThreatProtection. The DatabaseAdvancedThreatProtection is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseAdvancedThreatProtection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_database_advanced_threat_protection_settings_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + advanced_threat_protection_name=advanced_threat_protection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await 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]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseAdvancedThreatProtection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.DatabaseAdvancedThreatProtection"]: + """Gets a list of database's Advanced Threat Protection states. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of DatabaseAdvancedThreatProtection + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseAdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseAdvancedThreatProtection]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_database_advanced_threat_protection_settings_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseAdvancedThreatProtection], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class DatabaseAdvisorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`database_advisors` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, advisor_name: str, **kwargs: Any + ) -> _models.Advisor: + """Gets a database advisor. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 advisor_name: The name of the Database Advisor. Required. + :type advisor_name: str + :return: Advisor. The Advisor is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Advisor + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Advisor] = kwargs.pop("cls", None) + + _request = build_database_advisors_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + advisor_name=advisor_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Advisor, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + advisor_name: str, + parameters: _models.Advisor, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Advisor: + """Updates a database advisor. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 advisor_name: The name of the Database Advisor. Required. + :type advisor_name: str + :param parameters: The requested advisor resource state. Required. + :type parameters: ~azure.mgmt.sql.models.Advisor + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Advisor. The Advisor is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Advisor + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + advisor_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Advisor: + """Updates a database advisor. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 advisor_name: The name of the Database Advisor. Required. + :type advisor_name: str + :param parameters: The requested advisor resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Advisor. The Advisor is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Advisor + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + advisor_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Advisor: + """Updates a database advisor. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 advisor_name: The name of the Database Advisor. Required. + :type advisor_name: str + :param parameters: The requested advisor resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Advisor. The Advisor is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Advisor + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + advisor_name: str, + parameters: Union[_models.Advisor, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.Advisor: + """Updates a database advisor. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 advisor_name: The name of the Database Advisor. Required. + :type advisor_name: str + :param parameters: The requested advisor resource state. Is one of the following types: + Advisor, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.Advisor or JSON or IO[bytes] + :return: Advisor. The Advisor is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Advisor + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_database_advisors_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + advisor_name=advisor_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Advisor, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def list_by_database( + self, + resource_group_name: str, + server_name: str, + database_name: str, + *, + expand: Optional[str] = None, + **kwargs: Any + ) -> List[_models.Advisor]: + """Gets a list of database advisors. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 expand: The child resources to include in the response. Default value is None. + :paramtype expand: str + :return: list of Advisor + :rtype: list[~azure.mgmt.sql.models.Advisor] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Advisor]] = kwargs.pop("cls", None) + + _request = build_database_advisors_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(List[_models.Advisor], response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class DatabaseAutomaticTuningOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`database_automatic_tuning` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, **kwargs: Any + ) -> _models.DatabaseAutomaticTuning: + """Gets a database's automatic tuning. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: DatabaseAutomaticTuning. The DatabaseAutomaticTuning is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseAutomaticTuning + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseAutomaticTuning] = kwargs.pop("cls", None) + + _request = build_database_automatic_tuning_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseAutomaticTuning, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: _models.DatabaseAutomaticTuning, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseAutomaticTuning: + """Update automatic tuning properties for target database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The requested automatic tuning resource state. Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseAutomaticTuning + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseAutomaticTuning. The DatabaseAutomaticTuning is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseAutomaticTuning + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseAutomaticTuning: + """Update automatic tuning properties for target database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The requested automatic tuning resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseAutomaticTuning. The DatabaseAutomaticTuning is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseAutomaticTuning + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseAutomaticTuning: + """Update automatic tuning properties for target database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The requested automatic tuning resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseAutomaticTuning. The DatabaseAutomaticTuning is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseAutomaticTuning + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.DatabaseAutomaticTuning, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.DatabaseAutomaticTuning: + """Update automatic tuning properties for target database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The requested automatic tuning resource state. Is one of the following + types: DatabaseAutomaticTuning, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseAutomaticTuning or JSON or IO[bytes] + :return: DatabaseAutomaticTuning. The DatabaseAutomaticTuning is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseAutomaticTuning + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_database_automatic_tuning_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseAutomaticTuning, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class DatabaseExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`database_extensions` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, extension_name: str, **kwargs: Any + ) -> None: + """Gets a database extension. This will return resource not found as it is not supported. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 extension_name: Required. + :type extension_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_database_extensions_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + extension_name: str, + parameters: Union[_models.DatabaseExtensions, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_database_extensions_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + extension_name: str, + parameters: _models.DatabaseExtensions, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportExportExtensionsOperationResult]: + """Perform a database extension operation, like database import, database export, or polybase + import. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 extension_name: Required. + :type extension_name: str + :param parameters: The database import request parameters. Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseExtensions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ImportExportExtensionsOperationResult. The + ImportExportExtensionsOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportExtensionsOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + extension_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportExportExtensionsOperationResult]: + """Perform a database extension operation, like database import, database export, or polybase + import. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 extension_name: Required. + :type extension_name: str + :param parameters: The database import request parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ImportExportExtensionsOperationResult. The + ImportExportExtensionsOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportExtensionsOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + extension_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportExportExtensionsOperationResult]: + """Perform a database extension operation, like database import, database export, or polybase + import. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 extension_name: Required. + :type extension_name: str + :param parameters: The database import request parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ImportExportExtensionsOperationResult. The + ImportExportExtensionsOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportExtensionsOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + extension_name: str, + parameters: Union[_models.DatabaseExtensions, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ImportExportExtensionsOperationResult]: + """Perform a database extension operation, like database import, database export, or polybase + import. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 extension_name: Required. + :type extension_name: str + :param parameters: The database import request parameters. Is one of the following types: + DatabaseExtensions, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseExtensions or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ImportExportExtensionsOperationResult. The + ImportExportExtensionsOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportExtensionsOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + extension_name=extension_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ImportExportExtensionsOperationResult, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ImportExportExtensionsOperationResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ImportExportExtensionsOperationResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncItemPaged["_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. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of ImportExportExtensionsOperationResult + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ImportExportExtensionsOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ImportExportExtensionsOperationResult]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_database_extensions_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ImportExportExtensionsOperationResult], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class DatabaseRecommendedActionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`database_recommended_actions` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + advisor_name: str, + recommended_action_name: str, + **kwargs: Any + ) -> _models.RecommendedAction: + """Gets a database recommended action. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 advisor_name: The name of the Database Advisor. Required. + :type advisor_name: str + :param recommended_action_name: The name of Database Recommended Action. Required. + :type recommended_action_name: str + :return: RecommendedAction. The RecommendedAction is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.RecommendedAction + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RecommendedAction] = kwargs.pop("cls", None) + + _request = build_database_recommended_actions_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + advisor_name=advisor_name, + recommended_action_name=recommended_action_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RecommendedAction, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + advisor_name: str, + recommended_action_name: str, + parameters: _models.RecommendedAction, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RecommendedAction: + """Updates a database recommended action. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 advisor_name: The name of the Database Advisor. Required. + :type advisor_name: str + :param recommended_action_name: The name of Database Recommended Action. Required. + :type recommended_action_name: str + :param parameters: The requested recommended action resource state. Required. + :type parameters: ~azure.mgmt.sql.models.RecommendedAction + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RecommendedAction. The RecommendedAction is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.RecommendedAction + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + advisor_name: str, + recommended_action_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RecommendedAction: + """Updates a database recommended action. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 advisor_name: The name of the Database Advisor. Required. + :type advisor_name: str + :param recommended_action_name: The name of Database Recommended Action. Required. + :type recommended_action_name: str + :param parameters: The requested recommended action resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RecommendedAction. The RecommendedAction is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.RecommendedAction + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + advisor_name: str, + recommended_action_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RecommendedAction: + """Updates a database recommended action. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 advisor_name: The name of the Database Advisor. Required. + :type advisor_name: str + :param recommended_action_name: The name of Database Recommended Action. Required. + :type recommended_action_name: str + :param parameters: The requested recommended action resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: RecommendedAction. The RecommendedAction is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.RecommendedAction + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + advisor_name: str, + recommended_action_name: str, + parameters: Union[_models.RecommendedAction, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.RecommendedAction: + """Updates a database recommended action. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 advisor_name: The name of the Database Advisor. Required. + :type advisor_name: str + :param recommended_action_name: The name of Database Recommended Action. Required. + :type recommended_action_name: str + :param parameters: The requested recommended action resource state. Is one of the following + types: RecommendedAction, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.RecommendedAction or JSON or IO[bytes] + :return: RecommendedAction. The RecommendedAction is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.RecommendedAction + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_database_recommended_actions_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + advisor_name=advisor_name, + recommended_action_name=recommended_action_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RecommendedAction, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def list_by_database_advisor( + self, resource_group_name: str, server_name: str, database_name: str, advisor_name: str, **kwargs: Any + ) -> List[_models.RecommendedAction]: + """Gets list of Database Recommended Actions. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 advisor_name: The name of the Database Advisor. Required. + :type advisor_name: str + :return: list of RecommendedAction + :rtype: list[~azure.mgmt.sql.models.RecommendedAction] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RecommendedAction]] = kwargs.pop("cls", None) + + _request = build_database_recommended_actions_list_by_database_advisor_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + advisor_name=advisor_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(List[_models.RecommendedAction], response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class DatabaseSqlVulnerabilityAssessmentBaselinesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`database_sql_vulnerability_assessment_baselines` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: + """Gets a list of database's sql vulnerability assessment rule baselines. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :return: DatabaseSqlVulnerabilityAssessmentBaselineSet. The + DatabaseSqlVulnerabilityAssessmentBaselineSet is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentBaselineSet] = kwargs.pop("cls", None) + + _request = build_database_sql_vulnerability_assessment_baselines_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseSqlVulnerabilityAssessmentBaselineSet, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + parameters: _models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: + """Add a database's vulnerability assessment rule baseline list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param parameters: The requested rule baseline resource. Required. + :type parameters: + ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseSqlVulnerabilityAssessmentBaselineSet. The + DatabaseSqlVulnerabilityAssessmentBaselineSet is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: + """Add a database's vulnerability assessment rule baseline list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param parameters: The requested rule baseline resource. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseSqlVulnerabilityAssessmentBaselineSet. The + DatabaseSqlVulnerabilityAssessmentBaselineSet is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: + """Add a database's vulnerability assessment rule baseline list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param parameters: The requested rule baseline resource. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseSqlVulnerabilityAssessmentBaselineSet. The + DatabaseSqlVulnerabilityAssessmentBaselineSet is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + parameters: Union[_models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: + """Add a database's vulnerability assessment rule baseline list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param parameters: The requested rule baseline resource. Is one of the following types: + DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput, JSON, IO[bytes] Required. + :type parameters: + ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput or JSON or + IO[bytes] + :return: DatabaseSqlVulnerabilityAssessmentBaselineSet. The + DatabaseSqlVulnerabilityAssessmentBaselineSet is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_database_sql_vulnerability_assessment_baselines_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseSqlVulnerabilityAssessmentBaselineSet, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_sql_vulnerability_assessment( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + **kwargs: Any + ) -> AsyncItemPaged["_models.DatabaseSqlVulnerabilityAssessmentBaselineSet"]: + """Gets a list of database's sql vulnerability assessment rule baselines. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of DatabaseSqlVulnerabilityAssessmentBaselineSet + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseSqlVulnerabilityAssessmentBaselineSet]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = ( + build_database_sql_vulnerability_assessment_baselines_list_by_sql_vulnerability_assessment_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseSqlVulnerabilityAssessmentBaselineSet], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class SqlVulnerabilityAssessmentBaselinesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`sql_vulnerability_assessment_baselines` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + parameters: _models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput, + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: + """Add a database's vulnerability assessment rule baseline list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param parameters: The requested rule baseline resource. Required. + :type parameters: + ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput + :keyword system_database_name: The vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseSqlVulnerabilityAssessmentBaselineSet. The + DatabaseSqlVulnerabilityAssessmentBaselineSet is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + parameters: JSON, + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: + """Add a database's vulnerability assessment rule baseline list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param parameters: The requested rule baseline resource. Required. + :type parameters: JSON + :keyword system_database_name: The vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseSqlVulnerabilityAssessmentBaselineSet. The + DatabaseSqlVulnerabilityAssessmentBaselineSet is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + parameters: IO[bytes], + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: + """Add a database's vulnerability assessment rule baseline list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param parameters: The requested rule baseline resource. Required. + :type parameters: IO[bytes] + :keyword system_database_name: The vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseSqlVulnerabilityAssessmentBaselineSet. The + DatabaseSqlVulnerabilityAssessmentBaselineSet is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + parameters: Union[_models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput, JSON, IO[bytes]], + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: + """Add a database's vulnerability assessment rule baseline list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param parameters: The requested rule baseline resource. Is one of the following types: + DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput, JSON, IO[bytes] Required. + :type parameters: + ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput or JSON or + IO[bytes] + :keyword system_database_name: The vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :return: DatabaseSqlVulnerabilityAssessmentBaselineSet. The + DatabaseSqlVulnerabilityAssessmentBaselineSet is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_sql_vulnerability_assessment_baselines_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + system_database_name=system_database_name, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseSqlVulnerabilityAssessmentBaselineSet, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class DatabaseSqlVulnerabilityAssessmentsSettingsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`database_sql_vulnerability_assessments_settings` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], + **kwargs: Any + ) -> _models.SqlVulnerabilityAssessment: + """Gets SQL Vulnerability Assessment policy for database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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.SqlVulnerabilityAssessmentName + :return: SqlVulnerabilityAssessment. The SqlVulnerabilityAssessment is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SqlVulnerabilityAssessment] = kwargs.pop("cls", None) + + _request = build_database_sql_vulnerability_assessments_settings_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SqlVulnerabilityAssessment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.SqlVulnerabilityAssessment"]: + """Lists SQL Vulnerability Assessment policies associated with a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of SqlVulnerabilityAssessment + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SqlVulnerabilityAssessment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SqlVulnerabilityAssessment]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_database_sql_vulnerability_assessments_settings_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SqlVulnerabilityAssessment], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class DatabaseSqlVulnerabilityAssessmentExecuteScanOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`database_sql_vulnerability_assessment_execute_scan` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _execute_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_database_sql_vulnerability_assessment_execute_scan_execute_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_execute( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Executes a Vulnerability Assessment database scan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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._execute_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class SqlVulnerabilityAssessmentExecuteScanOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`sql_vulnerability_assessment_execute_scan` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _execute_initial( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_sql_vulnerability_assessment_execute_scan_execute_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + system_database_name=system_database_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_execute( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Executes a Vulnerability Assessment database scan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" + Required. + :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName + :keyword system_database_name: The vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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._execute_initial( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + system_database_name=system_database_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class SqlVulnerabilityAssessmentRuleBaselinesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`sql_vulnerability_assessment_rule_baselines` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + rule_id: str, + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any + ) -> None: + """Removes the database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :keyword system_database_name: The vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_sql_vulnerability_assessment_rule_baselines_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + baseline_name=baseline_name, + rule_id=rule_id, + subscription_id=self._config.subscription_id, + system_database_name=system_database_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await 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) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class DatabaseSqlVulnerabilityAssessmentScansOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`database_sql_vulnerability_assessment_scans` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + scan_id: str, + **kwargs: Any + ) -> _models.SqlVulnerabilityAssessmentScanRecord: + """Get a database vulnerability assessment scan result. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: SqlVulnerabilityAssessmentScanRecord. The SqlVulnerabilityAssessmentScanRecord is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanRecord + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SqlVulnerabilityAssessmentScanRecord] = kwargs.pop("cls", None) + + _request = build_database_sql_vulnerability_assessment_scans_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + scan_id=scan_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SqlVulnerabilityAssessmentScanRecord, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_sql_vulnerability_assessments( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + **kwargs: Any + ) -> AsyncItemPaged["_models.SqlVulnerabilityAssessmentScanRecord"]: + """Lists the vulnerability assessment scans of a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of SqlVulnerabilityAssessmentScanRecord + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanRecord] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SqlVulnerabilityAssessmentScanRecord]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = ( + build_database_sql_vulnerability_assessment_scans_list_by_sql_vulnerability_assessments_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SqlVulnerabilityAssessmentScanRecord], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class DatabaseVulnerabilityAssessmentScansOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`database_vulnerability_assessment_scans` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + scan_id: str, + **kwargs: Any + ) -> _models.VulnerabilityAssessmentScanRecord: + """Gets a vulnerability assessment scan record of a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: VulnerabilityAssessmentScanRecord. The VulnerabilityAssessmentScanRecord is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecord + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.VulnerabilityAssessmentScanRecord] = kwargs.pop("cls", None) + + _request = build_database_vulnerability_assessment_scans_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + scan_id=scan_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.VulnerabilityAssessmentScanRecord, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_database( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + **kwargs: Any + ) -> AsyncItemPaged["_models.VulnerabilityAssessmentScanRecord"]: + """Lists the vulnerability assessment scans of a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of VulnerabilityAssessmentScanRecord + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecord] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.VulnerabilityAssessmentScanRecord]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_database_vulnerability_assessment_scans_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.VulnerabilityAssessmentScanRecord], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def export( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + scan_id: str, + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessmentScansExport: + """Convert an existing scan result to a human readable format. If already exists nothing happens. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: DatabaseVulnerabilityAssessmentScansExport. The + DatabaseVulnerabilityAssessmentScansExport is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentScansExport + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseVulnerabilityAssessmentScansExport] = kwargs.pop("cls", None) + + _request = build_database_vulnerability_assessment_scans_export_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + scan_id=scan_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await 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]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseVulnerabilityAssessmentScansExport, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _initiate_scan_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + scan_id: str, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_database_vulnerability_assessment_scans_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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. The name is case insensitive. + Required. + :type resource_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 + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + scan_id=scan_id, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class DataMaskingRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`data_masking_rules` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + @api_version_validation( + params_added_on={"2025-02-01-preview": ["skip"]}, + api_versions_list=["2025-01-01", "2025-02-01-preview"], + ) + def list_by_database( + self, + resource_group_name: str, + server_name: str, + database_name: str, + data_masking_policy_name: Union[str, _models.DataMaskingPolicyName], + *, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.DataMaskingRule"]: + """Gets a list of database data masking rules. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 skip: The number of elements in the collection to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of DataMaskingRule + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DataMaskingRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DataMaskingRule]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_data_masking_rules_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, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DataMaskingRule], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataMaskingRule: + """Creates or updates a database data masking rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :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. + Required. + :type parameters: ~azure.mgmt.sql.models.DataMaskingRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DataMaskingRule. The DataMaskingRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DataMaskingRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataMaskingRule: + """Creates or updates a database data masking rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :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. + Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DataMaskingRule. The DataMaskingRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DataMaskingRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataMaskingRule: + """Creates or updates a database data masking rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :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. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DataMaskingRule. The DataMaskingRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DataMaskingRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + 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: Union[_models.DataMaskingRule, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.DataMaskingRule: + """Creates or updates a database data masking rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :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 one + of the following types: DataMaskingRule, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DataMaskingRule or JSON or IO[bytes] + :return: DataMaskingRule. The DataMaskingRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DataMaskingRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_data_masking_rules_create_or_update_request( + 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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await 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]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DataMaskingRule, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class DataWarehouseUserActivitiesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`data_warehouse_user_activities` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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. The name is case insensitive. + Required. + :type resource_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 + :return: DataWarehouseUserActivities. The DataWarehouseUserActivities is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.DataWarehouseUserActivities + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DataWarehouseUserActivities] = kwargs.pop("cls", None) + + _request = build_data_warehouse_user_activities_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DataWarehouseUserActivities, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.DataWarehouseUserActivities"]: + """List the user activities of a data warehouse which includes running and suspended queries. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of DataWarehouseUserActivities + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DataWarehouseUserActivities] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DataWarehouseUserActivities]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_data_warehouse_user_activities_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DataWarehouseUserActivities], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ManagedDatabaseSecurityEventsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_database_security_events` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + *, + filter: Optional[str] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + skiptoken: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.SecurityEvent"]: + """Gets a list of security events. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :keyword skip: The number of elements in the collection to skip. Default value is None. + :paramtype skip: int + :keyword top: The number of elements to return from the collection. Default value is None. + :paramtype top: int + :keyword skiptoken: An opaque token that identifies a starting point in the collection. Default + value is None. + :paramtype skiptoken: str + :return: An iterator like instance of SecurityEvent + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SecurityEvent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SecurityEvent]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_database_security_events_list_by_database_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + filter=filter, + skip=skip, + top=top, + skiptoken=skiptoken, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SecurityEvent], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ManagedDatabaseRecommendedSensitivityLabelsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_database_recommended_sensitivity_labels` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + async def update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: _models.RecommendedSensitivityLabelUpdateList, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update recommended sensitivity labels states of a given database using an operations batch. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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.RecommendedSensitivityLabelUpdateList + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update recommended sensitivity labels states of a given database using an operations batch. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update recommended sensitivity labels states of a given database using an operations batch. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: Union[_models.RecommendedSensitivityLabelUpdateList, JSON, IO[bytes]], + **kwargs: Any + ) -> None: + """Update recommended sensitivity labels states of a given database using an operations batch. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 one of the following types: RecommendedSensitivityLabelUpdateList, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.RecommendedSensitivityLabelUpdateList or JSON or + IO[bytes] + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_database_recommended_sensitivity_labels_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class ManagedInstanceTdeCertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_instance_tde_certificates` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _create_initial( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: Union[_models.TdeCertificate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_instance_tde_certificates_create_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: _models.TdeCertificate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Creates a TDE certificate for a given server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: The requested TDE certificate to be created or updated. Required. + :type parameters: ~azure.mgmt.sql.models.TdeCertificate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Creates a TDE certificate for a given server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: The requested TDE certificate to be created or updated. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Creates a TDE certificate for a given server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: The requested TDE certificate to be created or updated. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: Union[_models.TdeCertificate, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Creates a TDE certificate for a given server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: The requested TDE certificate to be created or updated. Is one of the + following types: TdeCertificate, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.TdeCertificate or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class ElasticPoolOperationsOperations: + """ + .. 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_operations` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + ) -> AsyncItemPaged["_models.ElasticPoolOperation"]: + """Gets a list of operations performed on the elastic pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An iterator like instance of ElasticPoolOperation + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ElasticPoolOperation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ElasticPoolOperation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_elastic_pool_operations_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ElasticPoolOperation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def cancel( + 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. The name is case insensitive. + 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 operation_id: The operation identifier. Required. + :type operation_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_elastic_pool_operations_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class UsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`usages` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_instance_pool( + self, + resource_group_name: str, + instance_pool_name: str, + *, + expand_children: Optional[bool] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.Usage"]: + """Gets all instance pool usage metrics. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param instance_pool_name: The name of the instance pool to be retrieved. Required. + :type instance_pool_name: str + :keyword expand_children: Optional request parameter to include managed instance usages within + the instance pool. Default value is None. + :paramtype expand_children: bool + :return: An iterator like instance of Usage + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Usage]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_usages_list_by_instance_pool_request( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + subscription_id=self._config.subscription_id, + expand_children=expand_children, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Usage], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class LedgerDigestUploadsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`ledger_digest_uploads` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], + **kwargs: Any + ) -> _models.LedgerDigestUploads: + """Gets the current ledger digest upload configuration for a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 ledger_digest_uploads: "current" Required. + :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName + :return: LedgerDigestUploads. The LedgerDigestUploads is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.LedgerDigestUploads + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LedgerDigestUploads] = kwargs.pop("cls", None) + + _request = build_ledger_digest_uploads_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + ledger_digest_uploads=ledger_digest_uploads, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.LedgerDigestUploads, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], + parameters: Union[_models.LedgerDigestUploads, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_ledger_digest_uploads_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + ledger_digest_uploads=ledger_digest_uploads, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], + parameters: _models.LedgerDigestUploads, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LedgerDigestUploads]: + """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 ledger_digest_uploads: "current" Required. + :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName + :param parameters: Required. + :type parameters: ~azure.mgmt.sql.models.LedgerDigestUploads + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns LedgerDigestUploads. The + LedgerDigestUploads is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LedgerDigestUploads] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LedgerDigestUploads]: + """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 ledger_digest_uploads: "current" Required. + :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName + :param parameters: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns LedgerDigestUploads. The + LedgerDigestUploads is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LedgerDigestUploads] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LedgerDigestUploads]: + """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 ledger_digest_uploads: "current" Required. + :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns LedgerDigestUploads. The + LedgerDigestUploads is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LedgerDigestUploads] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], + parameters: Union[_models.LedgerDigestUploads, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.LedgerDigestUploads]: + """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 ledger_digest_uploads: "current" Required. + :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName + :param parameters: Is one of the following types: LedgerDigestUploads, JSON, IO[bytes] + Required. + :type parameters: ~azure.mgmt.sql.models.LedgerDigestUploads or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns LedgerDigestUploads. The + LedgerDigestUploads is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LedgerDigestUploads] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + ledger_digest_uploads=ledger_digest_uploads, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LedgerDigestUploads, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.LedgerDigestUploads].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.LedgerDigestUploads]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.LedgerDigestUploads"]: + """Gets all ledger digest upload settings on a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of LedgerDigestUploads + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LedgerDigestUploads] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.LedgerDigestUploads]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_ledger_digest_uploads_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.LedgerDigestUploads], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _disable_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_ledger_digest_uploads_disable_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + ledger_digest_uploads=ledger_digest_uploads, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_disable( + self, + resource_group_name: str, + server_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], + **kwargs: Any + ) -> AsyncLROPoller[_models.LedgerDigestUploads]: + """Disables uploading ledger digests to an Azure Storage account or an Azure Confidential Ledger + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 ledger_digest_uploads: "current" Required. + :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName + :return: An instance of AsyncLROPoller that returns LedgerDigestUploads. The + LedgerDigestUploads is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LedgerDigestUploads] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._disable_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + ledger_digest_uploads=ledger_digest_uploads, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.LedgerDigestUploads, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.LedgerDigestUploads].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.LedgerDigestUploads]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class MaintenanceWindowOptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`maintenance_window_options` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + *, + maintenance_window_options_name: str, + **kwargs: Any + ) -> _models.MaintenanceWindowOptions: + """Gets a list of available maintenance windows. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 maintenance_window_options_name: Maintenance window options name. Required. + :paramtype maintenance_window_options_name: str + :return: MaintenanceWindowOptions. The MaintenanceWindowOptions is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.MaintenanceWindowOptions + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.MaintenanceWindowOptions] = kwargs.pop("cls", None) + + _request = build_maintenance_window_options_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + maintenance_window_options_name=maintenance_window_options_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.MaintenanceWindowOptions, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class MaintenanceWindowsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`maintenance_windows` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + *, + maintenance_window_name: str, + **kwargs: Any + ) -> _models.MaintenanceWindows: + """Gets maintenance windows settings for a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 maintenance_window_name: Maintenance window name. Required. + :paramtype maintenance_window_name: str + :return: MaintenanceWindows. The MaintenanceWindows is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.MaintenanceWindows + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.MaintenanceWindows] = kwargs.pop("cls", None) + + _request = build_maintenance_windows_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + maintenance_window_name=maintenance_window_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.MaintenanceWindows, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: _models.MaintenanceWindows, + *, + maintenance_window_name: str, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Sets maintenance windows settings for a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: Required. + :type parameters: ~azure.mgmt.sql.models.MaintenanceWindows + :keyword maintenance_window_name: Maintenance window name. Required. + :paramtype maintenance_window_name: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: JSON, + *, + maintenance_window_name: str, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Sets maintenance windows settings for a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: Required. + :type parameters: JSON + :keyword maintenance_window_name: Maintenance window name. Required. + :paramtype maintenance_window_name: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: IO[bytes], + *, + maintenance_window_name: str, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Sets maintenance windows settings for a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: Required. + :type parameters: IO[bytes] + :keyword maintenance_window_name: Maintenance window name. Required. + :paramtype maintenance_window_name: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.MaintenanceWindows, JSON, IO[bytes]], + *, + maintenance_window_name: str, + **kwargs: Any + ) -> None: + """Sets maintenance windows settings for a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: Is one of the following types: MaintenanceWindows, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.MaintenanceWindows or JSON or IO[bytes] + :keyword maintenance_window_name: Maintenance window name. Required. + :paramtype maintenance_window_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_maintenance_windows_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + maintenance_window_name=maintenance_window_name, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class ManagedDatabaseAdvancedThreatProtectionSettingsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_database_advanced_threat_protection_settings` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + **kwargs: Any + ) -> _models.ManagedDatabaseAdvancedThreatProtection: + """Gets a managed database's Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :return: ManagedDatabaseAdvancedThreatProtection. The ManagedDatabaseAdvancedThreatProtection + is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedDatabaseAdvancedThreatProtection] = kwargs.pop("cls", None) + + _request = build_managed_database_advanced_threat_protection_settings_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + advanced_threat_protection_name=advanced_threat_protection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedDatabaseAdvancedThreatProtection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: _models.ManagedDatabaseAdvancedThreatProtection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedDatabaseAdvancedThreatProtection: + """Creates or updates a managed database's Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The managed database Advanced Threat Protection state. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedDatabaseAdvancedThreatProtection. The ManagedDatabaseAdvancedThreatProtection + is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedDatabaseAdvancedThreatProtection: + """Creates or updates a managed database's Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The managed database Advanced Threat Protection state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedDatabaseAdvancedThreatProtection. The ManagedDatabaseAdvancedThreatProtection + is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedDatabaseAdvancedThreatProtection: + """Creates or updates a managed database's Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The managed database Advanced Threat Protection state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedDatabaseAdvancedThreatProtection. The ManagedDatabaseAdvancedThreatProtection + is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: Union[_models.ManagedDatabaseAdvancedThreatProtection, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ManagedDatabaseAdvancedThreatProtection: + """Creates or updates a managed database's Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The managed database Advanced Threat Protection state. Is one of the + following types: ManagedDatabaseAdvancedThreatProtection, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection or JSON or + IO[bytes] + :return: ManagedDatabaseAdvancedThreatProtection. The ManagedDatabaseAdvancedThreatProtection + is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_database_advanced_threat_protection_settings_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + advanced_threat_protection_name=advanced_threat_protection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await 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]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedDatabaseAdvancedThreatProtection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_database( + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ManagedDatabaseAdvancedThreatProtection"]: + """Gets a list of managed database's Advanced Threat Protection states. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An iterator like instance of ManagedDatabaseAdvancedThreatProtection + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedDatabaseAdvancedThreatProtection]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_database_advanced_threat_protection_settings_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedDatabaseAdvancedThreatProtection], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ManagedDatabaseMoveOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_database_move_operations` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, location_name: str, operation_id: str, **kwargs: Any + ) -> _models.ManagedDatabaseMoveOperationResult: + """Gets a managed database move operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :param operation_id: The ID of the managed database move operation. Required. + :type operation_id: str + :return: ManagedDatabaseMoveOperationResult. The ManagedDatabaseMoveOperationResult is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedDatabaseMoveOperationResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedDatabaseMoveOperationResult] = kwargs.pop("cls", None) + + _request = build_managed_database_move_operations_get_request( + resource_group_name=resource_group_name, + location_name=location_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedDatabaseMoveOperationResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_location( + self, + resource_group_name: str, + location_name: str, + *, + only_latest_per_database: Optional[bool] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.ManagedDatabaseMoveOperationResult"]: + """Lists managed database move operations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 only_latest_per_database: Whether or not to only get the latest operation for each + database. Has higher priority than $filter. Default value is None. + :paramtype only_latest_per_database: bool + :keyword filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of ManagedDatabaseMoveOperationResult + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedDatabaseMoveOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedDatabaseMoveOperationResult]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_database_move_operations_list_by_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, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedDatabaseMoveOperationResult], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ManagedDatabaseQueriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_database_queries` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, managed_instance_name: str, database_name: str, query_id: str, **kwargs: Any + ) -> _models.ManagedInstanceQuery: + """Get query by query id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 query_id: Required. + :type query_id: str + :return: ManagedInstanceQuery. The ManagedInstanceQuery is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstanceQuery + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedInstanceQuery] = kwargs.pop("cls", None) + + _request = build_managed_database_queries_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + query_id=query_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedInstanceQuery, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_query( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + query_id: str, + *, + start_time: Optional[str] = None, + end_time: Optional[str] = None, + interval: Optional[Union[str, _models.QueryTimeGrainType]] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.QueryStatistics"]: + """Get query execution statistics by query id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 query_id: Required. + :type query_id: str + :keyword start_time: Start time for observed period. Default value is None. + :paramtype start_time: str + :keyword end_time: End time for observed period. Default value is None. + :paramtype end_time: str + :keyword interval: The time step to be used to summarize the metric values. Known values are: + "PT1H" and "P1D". Default value is None. + :paramtype interval: str or ~azure.mgmt.sql.models.QueryTimeGrainType + :return: An iterator like instance of QueryStatistics + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.QueryStatistics] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.QueryStatistics]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_database_queries_list_by_query_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + query_id=query_id, + subscription_id=self._config.subscription_id, + start_time=start_time, + end_time=end_time, + interval=interval, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.QueryStatistics], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ManagedDatabaseRestoreDetailsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_database_restore_details` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + restore_details_name: Union[str, _models.RestoreDetailsName], + **kwargs: Any + ) -> _models.ManagedDatabaseRestoreDetailsResult: + """Gets managed database restore details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 restore_details_name: The name of the restore details to retrieve. "Default" Required. + :type restore_details_name: str or ~azure.mgmt.sql.models.RestoreDetailsName + :return: ManagedDatabaseRestoreDetailsResult. The ManagedDatabaseRestoreDetailsResult is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedDatabaseRestoreDetailsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedDatabaseRestoreDetailsResult] = kwargs.pop("cls", None) + + _request = build_managed_database_restore_details_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + restore_details_name=restore_details_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedDatabaseRestoreDetailsResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class ManagedDatabaseTransparentDataEncryptionOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_database_transparent_data_encryption` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + tde_name: Union[str, _models.TransparentDataEncryptionName], + **kwargs: Any + ) -> _models.ManagedTransparentDataEncryption: + """Gets a managed database's transparent data encryption. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 tde_name: The name of the transparent data encryption configuration. "current" Required. + :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName + :return: ManagedTransparentDataEncryption. The ManagedTransparentDataEncryption is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedTransparentDataEncryption + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedTransparentDataEncryption] = kwargs.pop("cls", None) + + _request = build_managed_database_transparent_data_encryption_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + tde_name=tde_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedTransparentDataEncryption, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + tde_name: Union[str, _models.TransparentDataEncryptionName], + parameters: _models.ManagedTransparentDataEncryption, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedTransparentDataEncryption: + """Updates a database's transparent data encryption configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 tde_name: The name of the transparent data encryption configuration. "current" Required. + :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName + :param parameters: The database transparent data encryption. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedTransparentDataEncryption + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedTransparentDataEncryption. The ManagedTransparentDataEncryption is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedTransparentDataEncryption + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + tde_name: Union[str, _models.TransparentDataEncryptionName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedTransparentDataEncryption: + """Updates a database's transparent data encryption configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 tde_name: The name of the transparent data encryption configuration. "current" Required. + :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName + :param parameters: The database transparent data encryption. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedTransparentDataEncryption. The ManagedTransparentDataEncryption is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedTransparentDataEncryption + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + tde_name: Union[str, _models.TransparentDataEncryptionName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedTransparentDataEncryption: + """Updates a database's transparent data encryption configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 tde_name: The name of the transparent data encryption configuration. "current" Required. + :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName + :param parameters: The database transparent data encryption. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedTransparentDataEncryption. The ManagedTransparentDataEncryption is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedTransparentDataEncryption + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + tde_name: Union[str, _models.TransparentDataEncryptionName], + parameters: Union[_models.ManagedTransparentDataEncryption, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ManagedTransparentDataEncryption: + """Updates a database's transparent data encryption configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 tde_name: The name of the transparent data encryption configuration. "current" Required. + :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName + :param parameters: The database transparent data encryption. Is one of the following types: + ManagedTransparentDataEncryption, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedTransparentDataEncryption or JSON or IO[bytes] + :return: ManagedTransparentDataEncryption. The ManagedTransparentDataEncryption is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedTransparentDataEncryption + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_database_transparent_data_encryption_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + tde_name=tde_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await 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]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedTransparentDataEncryption, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_database( + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ManagedTransparentDataEncryption"]: + """Gets a list of managed database's transparent data encryptions. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An iterator like instance of ManagedTransparentDataEncryption + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedTransparentDataEncryption] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedTransparentDataEncryption]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_database_transparent_data_encryption_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedTransparentDataEncryption], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ManagedInstanceAdvancedThreatProtectionSettingsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_instance_advanced_threat_protection_settings` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + managed_instance_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + **kwargs: Any + ) -> _models.ManagedInstanceAdvancedThreatProtection: + """Get a managed instance's Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :return: ManagedInstanceAdvancedThreatProtection. The ManagedInstanceAdvancedThreatProtection + is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedInstanceAdvancedThreatProtection] = kwargs.pop("cls", None) + + _request = build_managed_instance_advanced_threat_protection_settings_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + advanced_threat_protection_name=advanced_threat_protection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedInstanceAdvancedThreatProtection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: Union[_models.ManagedInstanceAdvancedThreatProtection, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_instance_advanced_threat_protection_settings_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + advanced_threat_protection_name=advanced_threat_protection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: _models.ManagedInstanceAdvancedThreatProtection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstanceAdvancedThreatProtection]: + """Creates or updates Advanced Threat Protection settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The managed instance Advanced Threat Protection state. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedInstanceAdvancedThreatProtection. + The ManagedInstanceAdvancedThreatProtection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstanceAdvancedThreatProtection]: + """Creates or updates Advanced Threat Protection settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The managed instance Advanced Threat Protection state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedInstanceAdvancedThreatProtection. + The ManagedInstanceAdvancedThreatProtection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstanceAdvancedThreatProtection]: + """Creates or updates Advanced Threat Protection settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The managed instance Advanced Threat Protection state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedInstanceAdvancedThreatProtection. + The ManagedInstanceAdvancedThreatProtection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: Union[_models.ManagedInstanceAdvancedThreatProtection, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstanceAdvancedThreatProtection]: + """Creates or updates Advanced Threat Protection settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The managed instance Advanced Threat Protection state. Is one of the + following types: ManagedInstanceAdvancedThreatProtection, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns ManagedInstanceAdvancedThreatProtection. + The ManagedInstanceAdvancedThreatProtection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + advanced_threat_protection_name=advanced_threat_protection_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedInstanceAdvancedThreatProtection, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ManagedInstanceAdvancedThreatProtection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ManagedInstanceAdvancedThreatProtection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ManagedInstanceAdvancedThreatProtection"]: + """Get the managed instance's Advanced Threat Protection settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of ManagedInstanceAdvancedThreatProtection + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstanceAdvancedThreatProtection]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_instance_advanced_threat_protection_settings_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstanceAdvancedThreatProtection], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ManagedInstancePrivateLinkResourcesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_instance_private_link_resources` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, managed_instance_name: str, group_name: str, **kwargs: Any + ) -> _models.ManagedInstancePrivateLink: + """Gets a private link resource for SQL server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param group_name: The name of the private link resource. Required. + :type group_name: str + :return: ManagedInstancePrivateLink. The ManagedInstancePrivateLink is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstancePrivateLink + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedInstancePrivateLink] = kwargs.pop("cls", None) + + _request = build_managed_instance_private_link_resources_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + group_name=group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedInstancePrivateLink, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_managed_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ManagedInstancePrivateLink"]: + """Gets the private link resources for SQL server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of ManagedInstancePrivateLink + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstancePrivateLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstancePrivateLink]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_instance_private_link_resources_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstancePrivateLink], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ManagedLedgerDigestUploadsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`managed_ledger_digest_uploads` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], + **kwargs: Any + ) -> _models.ManagedLedgerDigestUploads: + """Gets the current ledger digest upload configuration for a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ledger_digest_uploads: "current" Required. + :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.ManagedLedgerDigestUploadsName + :return: ManagedLedgerDigestUploads. The ManagedLedgerDigestUploads is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedLedgerDigestUploads + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedLedgerDigestUploads] = kwargs.pop("cls", None) + + _request = build_managed_ledger_digest_uploads_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + ledger_digest_uploads=ledger_digest_uploads, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedLedgerDigestUploads, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], + parameters: Union[_models.ManagedLedgerDigestUploads, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_ledger_digest_uploads_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + ledger_digest_uploads=ledger_digest_uploads, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], + parameters: _models.ManagedLedgerDigestUploads, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedLedgerDigestUploads]: + """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ledger_digest_uploads: "current" Required. + :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.ManagedLedgerDigestUploadsName + :param parameters: The Ledger Digest Storage Endpoint. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedLedgerDigestUploads + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedLedgerDigestUploads. The + ManagedLedgerDigestUploads is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedLedgerDigestUploads] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedLedgerDigestUploads]: + """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ledger_digest_uploads: "current" Required. + :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.ManagedLedgerDigestUploadsName + :param parameters: The Ledger Digest Storage Endpoint. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedLedgerDigestUploads. The + ManagedLedgerDigestUploads is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedLedgerDigestUploads] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedLedgerDigestUploads]: + """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ledger_digest_uploads: "current" Required. + :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.ManagedLedgerDigestUploadsName + :param parameters: The Ledger Digest Storage Endpoint. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedLedgerDigestUploads. The + ManagedLedgerDigestUploads is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedLedgerDigestUploads] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], + parameters: Union[_models.ManagedLedgerDigestUploads, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedLedgerDigestUploads]: + """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ledger_digest_uploads: "current" Required. + :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.ManagedLedgerDigestUploadsName + :param parameters: The Ledger Digest Storage Endpoint. Is one of the following types: + ManagedLedgerDigestUploads, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedLedgerDigestUploads or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ManagedLedgerDigestUploads. The + ManagedLedgerDigestUploads is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedLedgerDigestUploads] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + database_name=database_name, + ledger_digest_uploads=ledger_digest_uploads, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedLedgerDigestUploads, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ManagedLedgerDigestUploads].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ManagedLedgerDigestUploads]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_database( + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ManagedLedgerDigestUploads"]: + """Gets all ledger digest upload settings on a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An iterator like instance of ManagedLedgerDigestUploads + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedLedgerDigestUploads] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedLedgerDigestUploads]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_ledger_digest_uploads_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedLedgerDigestUploads], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _disable_initial( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_ledger_digest_uploads_disable_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + ledger_digest_uploads=ledger_digest_uploads, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_disable( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedLedgerDigestUploads]: + """Disables uploading ledger digests to an Azure Storage account or an Azure Confidential Ledger + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ledger_digest_uploads: "current" Required. + :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.ManagedLedgerDigestUploadsName + :return: An instance of AsyncLROPoller that returns ManagedLedgerDigestUploads. The + ManagedLedgerDigestUploads is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedLedgerDigestUploads] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._disable_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + ledger_digest_uploads=ledger_digest_uploads, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ManagedLedgerDigestUploads, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ManagedLedgerDigestUploads].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ManagedLedgerDigestUploads]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class ServerAdvancedThreatProtectionSettingsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`server_advanced_threat_protection_settings` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + **kwargs: Any + ) -> _models.ServerAdvancedThreatProtection: + """Get a server's Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :return: ServerAdvancedThreatProtection. The ServerAdvancedThreatProtection is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerAdvancedThreatProtection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ServerAdvancedThreatProtection] = kwargs.pop("cls", None) + + _request = build_server_advanced_threat_protection_settings_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + advanced_threat_protection_name=advanced_threat_protection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ServerAdvancedThreatProtection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: Union[_models.ServerAdvancedThreatProtection, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_server_advanced_threat_protection_settings_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + advanced_threat_protection_name=advanced_threat_protection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: _models.ServerAdvancedThreatProtection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerAdvancedThreatProtection]: + """Creates or updates an Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The server Advanced Threat Protection state. Required. + :type parameters: ~azure.mgmt.sql.models.ServerAdvancedThreatProtection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerAdvancedThreatProtection. The + ServerAdvancedThreatProtection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerAdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerAdvancedThreatProtection]: + """Creates or updates an Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The server Advanced Threat Protection state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerAdvancedThreatProtection. The + ServerAdvancedThreatProtection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerAdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerAdvancedThreatProtection]: + """Creates or updates an Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The server Advanced Threat Protection state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ServerAdvancedThreatProtection. The + ServerAdvancedThreatProtection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerAdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: Union[_models.ServerAdvancedThreatProtection, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerAdvancedThreatProtection]: + """Creates or updates an Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The server Advanced Threat Protection state. Is one of the following types: + ServerAdvancedThreatProtection, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ServerAdvancedThreatProtection or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ServerAdvancedThreatProtection. The + ServerAdvancedThreatProtection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerAdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + advanced_threat_protection_name=advanced_threat_protection_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ServerAdvancedThreatProtection, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ServerAdvancedThreatProtection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ServerAdvancedThreatProtection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ServerAdvancedThreatProtection"]: + """Get a list of the server's Advanced Threat Protection states. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of ServerAdvancedThreatProtection + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerAdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerAdvancedThreatProtection]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_server_advanced_threat_protection_settings_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ServerAdvancedThreatProtection], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ServerAutomaticTuningOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`server_automatic_tuning` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, **kwargs: Any) -> _models.ServerAutomaticTuning: + """Retrieves server automatic tuning options. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: ServerAutomaticTuning. The ServerAutomaticTuning is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerAutomaticTuning + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ServerAutomaticTuning] = kwargs.pop("cls", None) + + _request = build_server_automatic_tuning_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ServerAutomaticTuning, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + server_name: str, + parameters: _models.ServerAutomaticTuning, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ServerAutomaticTuning: + """Update automatic tuning options on server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The requested automatic tuning resource state. Required. + :type parameters: ~azure.mgmt.sql.models.ServerAutomaticTuning + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ServerAutomaticTuning. The ServerAutomaticTuning is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerAutomaticTuning + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ServerAutomaticTuning: + """Update automatic tuning options on server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The requested automatic tuning resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ServerAutomaticTuning. The ServerAutomaticTuning is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerAutomaticTuning + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ServerAutomaticTuning: + """Update automatic tuning options on server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The requested automatic tuning resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ServerAutomaticTuning. The ServerAutomaticTuning is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerAutomaticTuning + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerAutomaticTuning, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ServerAutomaticTuning: + """Update automatic tuning options on server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The requested automatic tuning resource state. Is one of the following + types: ServerAutomaticTuning, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ServerAutomaticTuning or JSON or IO[bytes] + :return: ServerAutomaticTuning. The ServerAutomaticTuning is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerAutomaticTuning + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_server_automatic_tuning_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ServerAutomaticTuning, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class SqlAgentOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`sql_agent` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> _models.SqlAgentConfiguration: + """Gets current instance sql agent configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: SqlAgentConfiguration. The SqlAgentConfiguration is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SqlAgentConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SqlAgentConfiguration] = kwargs.pop("cls", None) + + _request = build_sql_agent_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SqlAgentConfiguration, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: _models.SqlAgentConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SqlAgentConfiguration: + """Puts new sql agent configuration to instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.sql.models.SqlAgentConfiguration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SqlAgentConfiguration. The SqlAgentConfiguration is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SqlAgentConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SqlAgentConfiguration: + """Puts new sql agent configuration to instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SqlAgentConfiguration. The SqlAgentConfiguration is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SqlAgentConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SqlAgentConfiguration: + """Puts new sql agent configuration to instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SqlAgentConfiguration. The SqlAgentConfiguration is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SqlAgentConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: Union[_models.SqlAgentConfiguration, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.SqlAgentConfiguration: + """Puts new sql agent configuration to instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: Is one of the following types: SqlAgentConfiguration, JSON, IO[bytes] + Required. + :type parameters: ~azure.mgmt.sql.models.SqlAgentConfiguration or JSON or IO[bytes] + :return: SqlAgentConfiguration. The SqlAgentConfiguration is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SqlAgentConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_sql_agent_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SqlAgentConfiguration, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class TransparentDataEncryptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`transparent_data_encryptions` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + tde_name: Union[str, _models.TransparentDataEncryptionName], + **kwargs: Any + ) -> _models.LogicalDatabaseTransparentDataEncryption: + """Gets a logical database's transparent data encryption. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 tde_name: The name of the transparent data encryption configuration. "current" Required. + :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName + :return: LogicalDatabaseTransparentDataEncryption. The LogicalDatabaseTransparentDataEncryption + is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LogicalDatabaseTransparentDataEncryption] = kwargs.pop("cls", None) + + _request = build_transparent_data_encryptions_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + tde_name=tde_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.LogicalDatabaseTransparentDataEncryption, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + tde_name: Union[str, _models.TransparentDataEncryptionName], + parameters: Union[_models.LogicalDatabaseTransparentDataEncryption, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_transparent_data_encryptions_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + tde_name=tde_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + tde_name: Union[str, _models.TransparentDataEncryptionName], + parameters: _models.LogicalDatabaseTransparentDataEncryption, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LogicalDatabaseTransparentDataEncryption]: + """Updates a logical database's transparent data encryption configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 tde_name: The name of the transparent data encryption configuration. "current" Required. + :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName + :param parameters: The database transparent data encryption. Required. + :type parameters: ~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns LogicalDatabaseTransparentDataEncryption. + The LogicalDatabaseTransparentDataEncryption is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + tde_name: Union[str, _models.TransparentDataEncryptionName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LogicalDatabaseTransparentDataEncryption]: + """Updates a logical database's transparent data encryption configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 tde_name: The name of the transparent data encryption configuration. "current" Required. + :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName + :param parameters: The database transparent data encryption. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns LogicalDatabaseTransparentDataEncryption. + The LogicalDatabaseTransparentDataEncryption is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + tde_name: Union[str, _models.TransparentDataEncryptionName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LogicalDatabaseTransparentDataEncryption]: + """Updates a logical database's transparent data encryption configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 tde_name: The name of the transparent data encryption configuration. "current" Required. + :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName + :param parameters: The database transparent data encryption. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns LogicalDatabaseTransparentDataEncryption. + The LogicalDatabaseTransparentDataEncryption is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + tde_name: Union[str, _models.TransparentDataEncryptionName], + parameters: Union[_models.LogicalDatabaseTransparentDataEncryption, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.LogicalDatabaseTransparentDataEncryption]: + """Updates a logical database's transparent data encryption configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 tde_name: The name of the transparent data encryption configuration. "current" Required. + :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName + :param parameters: The database transparent data encryption. Is one of the following types: + LogicalDatabaseTransparentDataEncryption, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns LogicalDatabaseTransparentDataEncryption. + The LogicalDatabaseTransparentDataEncryption is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + tde_name=tde_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LogicalDatabaseTransparentDataEncryption, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.LogicalDatabaseTransparentDataEncryption].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.LogicalDatabaseTransparentDataEncryption]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.LogicalDatabaseTransparentDataEncryption"]: + """Gets a list of the logical database's transparent data encryption. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of LogicalDatabaseTransparentDataEncryption + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.LogicalDatabaseTransparentDataEncryption]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_transparent_data_encryptions_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.LogicalDatabaseTransparentDataEncryption], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _resume_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + tde_name: Union[str, _models.TransparentDataEncryptionName], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_transparent_data_encryptions_resume_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + tde_name=tde_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_resume( + self, + resource_group_name: str, + server_name: str, + database_name: str, + tde_name: Union[str, _models.TransparentDataEncryptionName], + **kwargs: Any + ) -> AsyncLROPoller[_models.LogicalDatabaseTransparentDataEncryption]: + """Resume ongoing logical database's Transparent Data Encryption scan configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 tde_name: The name of the transparent data encryption configuration. "current" Required. + :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName + :return: An instance of AsyncLROPoller that returns LogicalDatabaseTransparentDataEncryption. + The LogicalDatabaseTransparentDataEncryption is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LogicalDatabaseTransparentDataEncryption] = 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._resume_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + tde_name=tde_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.LogicalDatabaseTransparentDataEncryption, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.LogicalDatabaseTransparentDataEncryption].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.LogicalDatabaseTransparentDataEncryption]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _suspend_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + tde_name: Union[str, _models.TransparentDataEncryptionName], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_transparent_data_encryptions_suspend_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + tde_name=tde_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_suspend( + self, + resource_group_name: str, + server_name: str, + database_name: str, + tde_name: Union[str, _models.TransparentDataEncryptionName], + **kwargs: Any + ) -> AsyncLROPoller[_models.LogicalDatabaseTransparentDataEncryption]: + """Suspend ongoing logical database's Transparent Data Encryption scan configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 tde_name: The name of the transparent data encryption configuration. "current" Required. + :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName + :return: An instance of AsyncLROPoller that returns LogicalDatabaseTransparentDataEncryption. + The LogicalDatabaseTransparentDataEncryption is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LogicalDatabaseTransparentDataEncryption] = 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._suspend_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + tde_name=tde_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.LogicalDatabaseTransparentDataEncryption, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.LogicalDatabaseTransparentDataEncryption].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.LogicalDatabaseTransparentDataEncryption]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class CapabilitiesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`capabilities` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list_by_location( + self, location_name: str, *, include: Optional[Union[str, _models.CapabilityGroup]] = None, **kwargs: Any + ) -> _models.LocationCapabilities: + """Gets the subscription capabilities available for the specified location. + + :param location_name: The location name whose capabilities are retrieved. Required. + :type location_name: str + :keyword include: If specified, restricts the response to only include the selected item. Known + values are: "supportedEditions", "supportedElasticPoolEditions", + "supportedManagedInstanceVersions", "supportedInstancePoolEditions", + "supportedManagedInstanceEditions", and "supportedJobAgentVersions". Default value is None. + :paramtype include: str or ~azure.mgmt.sql.models.CapabilityGroup + :return: LocationCapabilities. The LocationCapabilities is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.LocationCapabilities + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LocationCapabilities] = kwargs.pop("cls", None) + + _request = build_capabilities_list_by_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + include=include, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.LocationCapabilities, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_outbound_firewall_rules_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_outbound_firewall_rules_operations.py deleted file mode 100644 index de424589cfd5..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_outbound_firewall_rules_operations.py +++ /dev/null @@ -1,510 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._outbound_firewall_rules_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_server_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class OutboundFirewallRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`outbound_firewall_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, outbound_rule_fqdn: str, **kwargs: Any - ) -> _models.OutboundFirewallRule: - """Gets an outbound firewall rule. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 - :return: OutboundFirewallRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.OutboundFirewallRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[_models.OutboundFirewallRule] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - outbound_rule_fqdn=outbound_rule_fqdn, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("OutboundFirewallRule", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - outbound_rule_fqdn: str, - parameters: Union[_models.OutboundFirewallRule, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2021-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "OutboundFirewallRule") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - outbound_rule_fqdn=outbound_rule_fqdn, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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: Is either a OutboundFirewallRule type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.OutboundFirewallRule or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - 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) - 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, - 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, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OutboundFirewallRule", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.OutboundFirewallRule].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OutboundFirewallRule]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, server_name: str, outbound_rule_fqdn: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, server_name: str, outbound_rule_fqdn: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a outbound firewall rule with a given name. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 - :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", "2021-02-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( - resource_group_name=resource_group_name, - server_name=server_name, - outbound_rule_fqdn=outbound_rule_fqdn, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either OutboundFirewallRule or the result of - cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.OutboundFirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[_models.OutboundFirewallRuleListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_patch.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_patch.py index f7dd32510333..87676c65a8f0 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_patch.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_patch.py @@ -1,14 +1,15 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): 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 deleted file mode 100644 index 9a83237d6c53..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,511 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._private_endpoint_connections_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_server_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class PrivateEndpointConnectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`private_endpoint_connections` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_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 - :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", "2022-08-01-preview")) - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace_async - async def get( - self, resource_group_name: str, server_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Gets a private endpoint connection. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("PrivateEndpointConnection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "PrivateEndpointConnection") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - private_endpoint_connection_name: str, - parameters: _models.PrivateEndpointConnection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param private_endpoint_connection_name: Required. - :type private_endpoint_connection_name: str - :param parameters: Required. - :type parameters: ~azure.mgmt.sql.models.PrivateEndpointConnection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - private_endpoint_connection_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param private_endpoint_connection_name: Required. - :type private_endpoint_connection_name: str - :param parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param private_endpoint_connection_name: Required. - :type private_endpoint_connection_name: str - :param parameters: Is either a PrivateEndpointConnection type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.PrivateEndpointConnection or IO[bytes] - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - 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) - 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, - private_endpoint_connection_name=private_endpoint_connection_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, server_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, server_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param private_endpoint_connection_name: Required. - :type private_endpoint_connection_name: str - :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", "2022-08-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( - resource_group_name=resource_group_name, - server_name=server_name, - private_endpoint_connection_name=private_endpoint_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index 8286d23bf0cd..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_private_link_resources_operations.py +++ /dev/null @@ -1,187 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._private_link_resources_operations import build_get_request, build_list_by_server_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class PrivateLinkResourcesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`private_link_resources` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.PrivateLinkResource"]: - """Gets the private link resources for SQL 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 - :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.PrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, server_name: str, group_name: str, **kwargs: Any - ) -> _models.PrivateLinkResource: - """Gets a private link resource for SQL server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param group_name: The name of the private link resource. Required. - :type group_name: str - :return: PrivateLinkResource or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.PrivateLinkResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - group_name=group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("PrivateLinkResource", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_recommended_sensitivity_labels_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_recommended_sensitivity_labels_operations.py deleted file mode 100644 index 20df45163564..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_recommended_sensitivity_labels_operations.py +++ /dev/null @@ -1,190 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -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 ..._utils.serialization import Deserializer, Serializer -from ...operations._recommended_sensitivity_labels_operations import build_update_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class RecommendedSensitivityLabelsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`recommended_sensitivity_labels` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: _models.RecommendedSensitivityLabelUpdateList, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Update recommended sensitivity labels states of a given database using an operations batch. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: Required. - :type parameters: ~azure.mgmt.sql.models.RecommendedSensitivityLabelUpdateList - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Update recommended sensitivity labels states of a given database using an operations batch. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.RecommendedSensitivityLabelUpdateList, IO[bytes]], - **kwargs: Any - ) -> None: - """Update recommended sensitivity labels states of a given database using an operations batch. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: Is either a RecommendedSensitivityLabelUpdateList type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.sql.models.RecommendedSensitivityLabelUpdateList or IO[bytes] - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, "RecommendedSensitivityLabelUpdateList") - - _request = build_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_recoverable_databases_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_recoverable_databases_operations.py deleted file mode 100644 index 323ad74b8373..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_recoverable_databases_operations.py +++ /dev/null @@ -1,200 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._recoverable_databases_operations import build_get_request, build_list_by_server_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class RecoverableDatabasesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`recoverable_databases` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.RecoverableDatabase"]: - """Gets a list of recoverable databases. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either RecoverableDatabase or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.RecoverableDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.RecoverableDatabaseListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RecoverableDatabaseListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - server_name: str, - database_name: str, - expand: Optional[str] = None, - filter: Optional[str] = None, - **kwargs: Any - ) -> _models.RecoverableDatabase: - """Gets a recoverable 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 expand: The child resources to include in the response. Default value is None. - :type expand: str - :param filter: An OData filter expression that filters elements in the collection. Default - value is None. - :type filter: str - :return: RecoverableDatabase or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.RecoverableDatabase - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - cls: ClsType[_models.RecoverableDatabase] = 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, - expand=expand, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("RecoverableDatabase", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index c3cb6055a908..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_recoverable_managed_databases_operations.py +++ /dev/null @@ -1,189 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._recoverable_managed_databases_operations import build_get_request, build_list_by_instance_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class RecoverableManagedDatabasesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`recoverable_managed_databases` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.RecoverableManagedDatabase"]: - """Gets a list of recoverable managed databases. - - :param resource_group_name: The name of the resource group that 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 - :return: An iterator like instance of either RecoverableManagedDatabase or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.RecoverableManagedDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.RecoverableManagedDatabaseListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RecoverableManagedDatabaseListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, managed_instance_name: str, recoverable_database_name: str, **kwargs: Any - ) -> _models.RecoverableManagedDatabase: - """Gets a recoverable managed database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 recoverable_database_name: Required. - :type recoverable_database_name: str - :return: RecoverableManagedDatabase or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.RecoverableManagedDatabase - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.RecoverableManagedDatabase] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - recoverable_database_name=recoverable_database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("RecoverableManagedDatabase", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_replication_links_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_replication_links_operations.py deleted file mode 100644 index 79b7e13d604d..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_replication_links_operations.py +++ /dev/null @@ -1,1061 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._replication_links_operations import ( - build_create_or_update_request, - build_delete_request, - build_failover_allow_data_loss_request, - build_failover_request, - build_get_request, - build_list_by_database_request, - build_list_by_server_request, - build_update_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ReplicationLinksOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`replication_links` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.ReplicationLink"]: - """Gets a list of replication links on 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 - :return: An iterator like instance of either ReplicationLink or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ReplicationLink] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - cls: ClsType[_models.ReplicationLinkListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ReplicationLinkListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, server_name: str, database_name: str, link_id: str, **kwargs: Any - ) -> _models.ReplicationLink: - """Gets a replication link. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 link_id: The name of the replication link. Required. - :type link_id: str - :return: ReplicationLink or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ReplicationLink - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[_models.ReplicationLink] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - link_id=link_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ReplicationLink", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - link_id: str, - parameters: Union[_models.ReplicationLink, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ReplicationLink") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - link_id=link_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - link_id: str, - parameters: _models.ReplicationLink, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ReplicationLink]: - """Updates the replication link type. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 link_id: Required. - :type link_id: str - :param parameters: Required. - :type parameters: ~azure.mgmt.sql.models.ReplicationLink - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ReplicationLink or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ReplicationLink] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - link_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ReplicationLink]: - """Updates the replication link type. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 link_id: Required. - :type link_id: str - :param parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ReplicationLink or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ReplicationLink] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - link_id: str, - parameters: Union[_models.ReplicationLink, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ReplicationLink]: - """Updates the replication link type. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 link_id: Required. - :type link_id: str - :param parameters: Is either a ReplicationLink type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ReplicationLink or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ReplicationLink or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ReplicationLink] - :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", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - 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) - 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, - link_id=link_id, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ReplicationLink", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ReplicationLink].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ReplicationLink]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, server_name: str, database_name: str, link_id: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - link_id=link_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, server_name: str, database_name: str, link_id: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes the replication 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 database_name: The name of the database. Required. - :type database_name: str - :param link_id: Required. - :type link_id: str - :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", "2023-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_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - link_id=link_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - link_id: str, - parameters: Union[_models.ReplicationLinkUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ReplicationLinkUpdate") - - _request = build_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - link_id=link_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - link_id: str, - parameters: _models.ReplicationLinkUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ReplicationLink]: - """Updates the replication link type. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 link_id: Required. - :type link_id: str - :param parameters: Required. - :type parameters: ~azure.mgmt.sql.models.ReplicationLinkUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ReplicationLink or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ReplicationLink] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - link_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ReplicationLink]: - """Updates the replication link type. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 link_id: Required. - :type link_id: str - :param parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ReplicationLink or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ReplicationLink] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - link_id: str, - parameters: Union[_models.ReplicationLinkUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ReplicationLink]: - """Updates the replication link type. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 link_id: Required. - :type link_id: str - :param parameters: Is either a ReplicationLinkUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ReplicationLinkUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ReplicationLink or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ReplicationLink] - :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", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - 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) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - link_id=link_id, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ReplicationLink", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ReplicationLink].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ReplicationLink]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _failover_initial( - self, resource_group_name: str, server_name: str, database_name: str, link_id: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_failover_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - link_id=link_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_failover( - self, resource_group_name: str, server_name: str, database_name: str, link_id: str, **kwargs: Any - ) -> AsyncLROPoller[_models.ReplicationLink]: - """Fails over from the current primary server to this server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 link_id: The name of the replication link. Required. - :type link_id: str - :return: An instance of AsyncLROPoller that returns either ReplicationLink or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ReplicationLink] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - 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) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._failover_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - link_id=link_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ReplicationLink", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ReplicationLink].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ReplicationLink]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _failover_allow_data_loss_initial( - self, resource_group_name: str, server_name: str, database_name: str, link_id: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_failover_allow_data_loss_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - link_id=link_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_failover_allow_data_loss( - self, resource_group_name: str, server_name: str, database_name: str, link_id: str, **kwargs: Any - ) -> AsyncLROPoller[_models.ReplicationLink]: - """Fails over from the current primary server to this server allowing 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 database_name: The name of the database. Required. - :type database_name: str - :param link_id: The name of the replication link. Required. - :type link_id: str - :return: An instance of AsyncLROPoller that returns either ReplicationLink or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ReplicationLink] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - 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) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._failover_allow_data_loss_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - link_id=link_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ReplicationLink", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ReplicationLink].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ReplicationLink]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.ReplicationLink"]: - """Gets a list of replication 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 - :return: An iterator like instance of either ReplicationLink or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ReplicationLink] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - cls: ClsType[_models.ReplicationLinkListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ReplicationLinkListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_restorable_dropped_databases_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_restorable_dropped_databases_operations.py deleted file mode 100644 index c1c5b4406c3f..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_restorable_dropped_databases_operations.py +++ /dev/null @@ -1,202 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._restorable_dropped_databases_operations import build_get_request, build_list_by_server_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class RestorableDroppedDatabasesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`restorable_dropped_databases` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.RestorableDroppedDatabase"]: - """Gets a list of restorable dropped databases. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either RestorableDroppedDatabase or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.RestorableDroppedDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.RestorableDroppedDatabaseListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RestorableDroppedDatabaseListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - server_name: str, - restorable_dropped_database_id: str, - expand: Optional[str] = None, - filter: Optional[str] = None, - **kwargs: Any - ) -> _models.RestorableDroppedDatabase: - """Gets a restorable dropped database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param restorable_dropped_database_id: Required. - :type restorable_dropped_database_id: str - :param expand: The child resources to include in the response. Default value is None. - :type expand: str - :param filter: An OData filter expression that filters elements in the collection. Default - value is None. - :type filter: str - :return: RestorableDroppedDatabase or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.RestorableDroppedDatabase - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - cls: ClsType[_models.RestorableDroppedDatabase] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - restorable_dropped_database_id=restorable_dropped_database_id, - subscription_id=self._config.subscription_id, - expand=expand, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("RestorableDroppedDatabase", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_restorable_dropped_managed_databases_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_restorable_dropped_managed_databases_operations.py deleted file mode 100644 index 9c1548d815af..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_restorable_dropped_managed_databases_operations.py +++ /dev/null @@ -1,192 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._restorable_dropped_managed_databases_operations import ( - build_get_request, - build_list_by_instance_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class RestorableDroppedManagedDatabasesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`restorable_dropped_managed_databases` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.RestorableDroppedManagedDatabase"]: - """Gets a list of restorable dropped managed databases. - - :param resource_group_name: The name of the resource group that 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 - :return: An iterator like instance of either RestorableDroppedManagedDatabase or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.RestorableDroppedManagedDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.RestorableDroppedManagedDatabaseListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RestorableDroppedManagedDatabaseListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, managed_instance_name: str, restorable_dropped_database_id: str, **kwargs: Any - ) -> _models.RestorableDroppedManagedDatabase: - """Gets a restorable dropped managed database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :return: RestorableDroppedManagedDatabase or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.RestorableDroppedManagedDatabase - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.RestorableDroppedManagedDatabase] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - restorable_dropped_database_id=restorable_dropped_database_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("RestorableDroppedManagedDatabase", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_restore_points_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_restore_points_operations.py deleted file mode 100644 index 9f8b2ee2f785..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_restore_points_operations.py +++ /dev/null @@ -1,466 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._restore_points_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_database_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class RestorePointsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`restore_points` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.RestorePoint"]: - """Gets a list of database restore points. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :return: An iterator like instance of either RestorePoint or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.RestorePoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.RestorePointListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RestorePointListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - async def _create_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.CreateDatabaseRestorePointDefinition, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "CreateDatabaseRestorePointDefinition") - - _request = build_create_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: _models.CreateDatabaseRestorePointDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.RestorePoint]: - """Creates a restore point for a data warehouse. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The definition for creating the restore point of this database. Required. - :type parameters: ~azure.mgmt.sql.models.CreateDatabaseRestorePointDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either RestorePoint or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.RestorePoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.RestorePoint]: - """Creates a restore point for a data warehouse. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The definition for creating the restore point of this database. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either RestorePoint or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.RestorePoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.CreateDatabaseRestorePointDefinition, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.RestorePoint]: - """Creates a restore point for a data warehouse. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The definition for creating the restore point of this database. Is either a - CreateDatabaseRestorePointDefinition type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.CreateDatabaseRestorePointDefinition or IO[bytes] - :return: An instance of AsyncLROPoller that returns either RestorePoint or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.RestorePoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RestorePoint] = 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( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("RestorePoint", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.RestorePoint].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.RestorePoint]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - async def get( - self, resource_group_name: str, server_name: str, database_name: str, restore_point_name: str, **kwargs: Any - ) -> _models.RestorePoint: - """Gets a restore point. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 restore_point_name: The name of the restore point. Required. - :type restore_point_name: str - :return: RestorePoint or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.RestorePoint - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.RestorePoint] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - restore_point_name=restore_point_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("RestorePoint", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( - self, resource_group_name: str, server_name: str, database_name: str, restore_point_name: str, **kwargs: Any - ) -> None: - """Deletes a restore point. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 restore_point_name: The name of the restore point. Required. - :type restore_point_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - restore_point_name=restore_point_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sensitivity_labels_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sensitivity_labels_operations.py deleted file mode 100644 index 5ff9daa0b4f8..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sensitivity_labels_operations.py +++ /dev/null @@ -1,861 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Literal, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._sensitivity_labels_operations import ( - build_create_or_update_request, - build_delete_request, - build_disable_recommendation_request, - build_enable_recommendation_request, - build_get_request, - build_list_current_by_database_request, - build_list_recommended_by_database_request, - build_update_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class SensitivityLabelsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`sensitivity_labels` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_current_by_database( - self, - resource_group_name: str, - server_name: str, - database_name: str, - skip_token: Optional[str] = None, - count: Optional[bool] = None, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncItemPaged["_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 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 - :return: An iterator like instance of either SensitivityLabel or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SensitivityLabel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SensitivityLabelListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - skip_token=skip_token, - count=count, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @overload - async def update( - self, - resource_group_name: str, - server_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 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 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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: IO[bytes], - *, - 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 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 parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.SensitivityLabelUpdateList, IO[bytes]], - **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 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 parameters: Is either a SensitivityLabelUpdateList type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.SensitivityLabelUpdateList or IO[bytes] - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @distributed_trace - def list_recommended_by_database( - self, - resource_group_name: str, - server_name: str, - database_name: str, - skip_token: Optional[str] = None, - include_disabled_recommendations: Optional[bool] = None, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncItemPaged["_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 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 - :return: An iterator like instance of either SensitivityLabel or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SensitivityLabel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SensitivityLabelListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - skip_token=skip_token, - include_disabled_recommendations=include_disabled_recommendations, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace_async - async def enable_recommendation( - 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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_enable_recommendation_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - schema_name=schema_name, - table_name=table_name, - column_name=column_name, - subscription_id=self._config.subscription_id, - sensitivity_label_source=sensitivity_label_source, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @distributed_trace_async - async def disable_recommendation( - 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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_disable_recommendation_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - schema_name=schema_name, - table_name=table_name, - column_name=column_name, - subscription_id=self._config.subscription_id, - sensitivity_label_source=sensitivity_label_source, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - server_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - sensitivity_label_source: Union[str, _models.SensitivityLabelSource], - **kwargs: Any - ) -> _models.SensitivityLabel: - """Gets the sensitivity label of a given column. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :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 - :return: SensitivityLabel or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SensitivityLabel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SensitivityLabel] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - schema_name=schema_name, - table_name=table_name, - column_name=column_name, - sensitivity_label_source=sensitivity_label_source, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("SensitivityLabel", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - parameters: _models.SensitivityLabel, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SensitivityLabel: - """Creates or updates the sensitivity label of a given column. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :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 - :return: SensitivityLabel or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SensitivityLabel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SensitivityLabel: - """Creates or updates the sensitivity label of a given column. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :param parameters: The column sensitivity label resource. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: SensitivityLabel or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SensitivityLabel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - parameters: Union[_models.SensitivityLabel, IO[bytes]], - **kwargs: Any - ) -> _models.SensitivityLabel: - """Creates or updates the sensitivity label of a given column. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :param parameters: The column sensitivity label resource. Is either a SensitivityLabel type or - a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.SensitivityLabel or IO[bytes] - :return: SensitivityLabel or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SensitivityLabel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 {}) - - sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SensitivityLabel] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SensitivityLabel") - - _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, - headers=_headers, - params=_params, - ) - _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, 201]: - 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( - self, - resource_group_name: str, - server_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - **kwargs: Any - ) -> None: - """Deletes the sensitivity label of a given column. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - 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, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore 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 deleted file mode 100644 index 3b165eefa14c..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_advanced_threat_protection_settings_operations.py +++ /dev/null @@ -1,417 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._server_advanced_threat_protection_settings_operations import ( - build_create_or_update_request, - build_get_request, - build_list_by_server_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ServerAdvancedThreatProtectionSettingsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`server_advanced_threat_protection_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.ServerAdvancedThreatProtection"]: - """Get a list of the server's Advanced Threat Protection states. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either ServerAdvancedThreatProtection or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerAdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.LogicalServerAdvancedThreatProtectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("LogicalServerAdvancedThreatProtectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - server_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - **kwargs: Any - ) -> _models.ServerAdvancedThreatProtection: - """Get a server's Advanced Threat Protection state. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. - "Default" Required. - :type advanced_threat_protection_name: str or - ~azure.mgmt.sql.models.AdvancedThreatProtectionName - :return: ServerAdvancedThreatProtection or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerAdvancedThreatProtection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.ServerAdvancedThreatProtection] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - advanced_threat_protection_name=advanced_threat_protection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ServerAdvancedThreatProtection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: Union[_models.ServerAdvancedThreatProtection, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2021-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ServerAdvancedThreatProtection") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - advanced_threat_protection_name=advanced_threat_protection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: _models.ServerAdvancedThreatProtection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerAdvancedThreatProtection]: - """Creates or updates an Advanced Threat Protection state. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. - "Default" Required. - :type advanced_threat_protection_name: str or - ~azure.mgmt.sql.models.AdvancedThreatProtectionName - :param parameters: The server Advanced Threat Protection state. Required. - :type parameters: ~azure.mgmt.sql.models.ServerAdvancedThreatProtection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ServerAdvancedThreatProtection or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerAdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerAdvancedThreatProtection]: - """Creates or updates an Advanced Threat Protection state. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. - "Default" Required. - :type advanced_threat_protection_name: str or - ~azure.mgmt.sql.models.AdvancedThreatProtectionName - :param parameters: The server Advanced Threat Protection state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ServerAdvancedThreatProtection or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerAdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: Union[_models.ServerAdvancedThreatProtection, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerAdvancedThreatProtection]: - """Creates or updates an Advanced Threat Protection state. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. - "Default" Required. - :type advanced_threat_protection_name: str or - ~azure.mgmt.sql.models.AdvancedThreatProtectionName - :param parameters: The server Advanced Threat Protection state. Is either a - ServerAdvancedThreatProtection type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ServerAdvancedThreatProtection or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ServerAdvancedThreatProtection or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerAdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - 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) - 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, - advanced_threat_protection_name=advanced_threat_protection_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ServerAdvancedThreatProtection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ServerAdvancedThreatProtection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ServerAdvancedThreatProtection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_advisors_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_advisors_operations.py deleted file mode 100644 index f2c38e2ec2dd..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_advisors_operations.py +++ /dev/null @@ -1,318 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -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 ..._utils.serialization import Deserializer, Serializer -from ...operations._server_advisors_operations import ( - build_get_request, - build_list_by_server_request, - build_update_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ServerAdvisorsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`server_advisors` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def list_by_server( - self, resource_group_name: str, server_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> List[_models.Advisor]: - """Gets a list of server advisors. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param expand: The child resources to include in the response. Default value is None. - :type expand: str - :return: list of Advisor or the result of cls(response) - :rtype: list[~azure.mgmt.sql.models.Advisor] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[List[_models.Advisor]] = 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, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("[Advisor]", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get( - self, resource_group_name: str, server_name: str, advisor_name: str, **kwargs: Any - ) -> _models.Advisor: - """Gets a server advisor. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param advisor_name: The name of the Server Advisor. Required. - :type advisor_name: str - :return: Advisor or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.Advisor - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.Advisor] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - advisor_name=advisor_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("Advisor", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def update( - self, - resource_group_name: str, - server_name: str, - advisor_name: str, - parameters: _models.Advisor, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Advisor: - """Updates a server advisor. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param advisor_name: The name of the Server Advisor. Required. - :type advisor_name: str - :param parameters: The requested advisor resource state. Required. - :type parameters: ~azure.mgmt.sql.models.Advisor - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Advisor or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.Advisor - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - server_name: str, - advisor_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Advisor: - """Updates a server advisor. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param advisor_name: The name of the Server Advisor. Required. - :type advisor_name: str - :param parameters: The requested advisor resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: Advisor or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.Advisor - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - server_name: str, - advisor_name: str, - parameters: Union[_models.Advisor, IO[bytes]], - **kwargs: Any - ) -> _models.Advisor: - """Updates a server advisor. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param advisor_name: The name of the Server Advisor. Required. - :type advisor_name: str - :param parameters: The requested advisor resource state. Is either a Advisor type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.Advisor or IO[bytes] - :return: Advisor or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.Advisor - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "Advisor") - - _request = build_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - advisor_name=advisor_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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("Advisor", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_automatic_tuning_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_automatic_tuning_operations.py deleted file mode 100644 index 8dacd9c56128..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_automatic_tuning_operations.py +++ /dev/null @@ -1,239 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -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 ..._utils.serialization import Deserializer, Serializer -from ...operations._server_automatic_tuning_operations import build_get_request, build_update_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ServerAutomaticTuningOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`server_automatic_tuning` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, **kwargs: Any) -> _models.ServerAutomaticTuning: - """Retrieves server automatic tuning options. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: ServerAutomaticTuning or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerAutomaticTuning - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerAutomaticTuning] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ServerAutomaticTuning", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def update( - self, - resource_group_name: str, - server_name: str, - parameters: _models.ServerAutomaticTuning, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ServerAutomaticTuning: - """Update automatic tuning options on server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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: The requested automatic tuning resource state. Required. - :type parameters: ~azure.mgmt.sql.models.ServerAutomaticTuning - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ServerAutomaticTuning or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerAutomaticTuning - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ServerAutomaticTuning: - """Update automatic tuning options on server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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: The requested automatic tuning resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ServerAutomaticTuning or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerAutomaticTuning - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerAutomaticTuning, IO[bytes]], - **kwargs: Any - ) -> _models.ServerAutomaticTuning: - """Update automatic tuning options on server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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: The requested automatic tuning resource state. Is either a - ServerAutomaticTuning type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ServerAutomaticTuning or IO[bytes] - :return: ServerAutomaticTuning or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerAutomaticTuning - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ServerAutomaticTuning") - - _request = build_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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("ServerAutomaticTuning", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_azure_ad_administrators_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_azure_ad_administrators_operations.py deleted file mode 100644 index 43640999bad8..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_azure_ad_administrators_operations.py +++ /dev/null @@ -1,529 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._server_azure_ad_administrators_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_server_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ServerAzureADAdministratorsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`server_azure_ad_administrators` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - administrator_name: Union[str, _models.AdministratorName], - **kwargs: Any - ) -> _models.ServerAzureADAdministrator: - """Gets a Azure Active Directory administrator. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param administrator_name: The name of server active directory administrator. "ActiveDirectory" - Required. - :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName - :return: ServerAzureADAdministrator or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerAzureADAdministrator - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerAzureADAdministrator] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - administrator_name=administrator_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ServerAzureADAdministrator", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - administrator_name: Union[str, _models.AdministratorName], - parameters: Union[_models.ServerAzureADAdministrator, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ServerAzureADAdministrator") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - administrator_name=administrator_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - administrator_name: Union[str, _models.AdministratorName], - parameters: _models.ServerAzureADAdministrator, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerAzureADAdministrator]: - """Creates or updates an existing Azure Active Directory administrator. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param administrator_name: The name of server active directory administrator. "ActiveDirectory" - Required. - :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName - :param parameters: The requested Azure Active Directory administrator Resource state. Required. - :type parameters: ~azure.mgmt.sql.models.ServerAzureADAdministrator - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ServerAzureADAdministrator or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerAzureADAdministrator] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - administrator_name: Union[str, _models.AdministratorName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerAzureADAdministrator]: - """Creates or updates an existing Azure Active Directory administrator. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param administrator_name: The name of server active directory administrator. "ActiveDirectory" - Required. - :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName - :param parameters: The requested Azure Active Directory administrator Resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ServerAzureADAdministrator or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerAzureADAdministrator] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - administrator_name: Union[str, _models.AdministratorName], - parameters: Union[_models.ServerAzureADAdministrator, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerAzureADAdministrator]: - """Creates or updates an existing Azure Active Directory administrator. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param administrator_name: The name of server active directory administrator. "ActiveDirectory" - Required. - :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName - :param parameters: The requested Azure Active Directory administrator Resource state. Is either - a ServerAzureADAdministrator type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ServerAzureADAdministrator or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ServerAzureADAdministrator or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerAzureADAdministrator] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ServerAzureADAdministrator] = 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, - administrator_name=administrator_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ServerAzureADAdministrator", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ServerAzureADAdministrator].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ServerAzureADAdministrator]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, - resource_group_name: str, - server_name: str, - administrator_name: Union[str, _models.AdministratorName], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - administrator_name=administrator_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, - resource_group_name: str, - server_name: str, - administrator_name: Union[str, _models.AdministratorName], - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes the Azure Active Directory administrator with the given name. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param administrator_name: The name of server active directory administrator. "ActiveDirectory" - Required. - :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - administrator_name=administrator_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either ServerAzureADAdministrator or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerAzureADAdministrator] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.AdministratorListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index e5a57a8258ed..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_azure_ad_only_authentications_operations.py +++ /dev/null @@ -1,538 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._server_azure_ad_only_authentications_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_server_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ServerAzureADOnlyAuthenticationsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`server_azure_ad_only_authentications` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - authentication_name: Union[str, _models.AuthenticationName], - **kwargs: Any - ) -> _models.ServerAzureADOnlyAuthentication: - """Gets a specific Azure Active Directory only authentication property. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param authentication_name: The name of server azure active directory only authentication. - "Default" Required. - :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName - :return: ServerAzureADOnlyAuthentication or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerAzureADOnlyAuthentication] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - authentication_name=authentication_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ServerAzureADOnlyAuthentication", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - authentication_name: Union[str, _models.AuthenticationName], - parameters: Union[_models.ServerAzureADOnlyAuthentication, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ServerAzureADOnlyAuthentication") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - authentication_name=authentication_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - authentication_name: Union[str, _models.AuthenticationName], - parameters: _models.ServerAzureADOnlyAuthentication, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerAzureADOnlyAuthentication]: - """Sets Server Active Directory only authentication property or updates an existing server Active - Directory only authentication property. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param authentication_name: The name of server azure active directory only authentication. - "Default" Required. - :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName - :param parameters: The required parameters for creating or updating an Active Directory only - authentication property. Required. - :type parameters: ~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ServerAzureADOnlyAuthentication or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - authentication_name: Union[str, _models.AuthenticationName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerAzureADOnlyAuthentication]: - """Sets Server Active Directory only authentication property or updates an existing server Active - Directory only authentication property. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param authentication_name: The name of server azure active directory only authentication. - "Default" Required. - :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName - :param parameters: The required parameters for creating or updating an Active Directory only - authentication property. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ServerAzureADOnlyAuthentication or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - authentication_name: Union[str, _models.AuthenticationName], - parameters: Union[_models.ServerAzureADOnlyAuthentication, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerAzureADOnlyAuthentication]: - """Sets Server Active Directory only authentication property or updates an existing server Active - Directory only authentication property. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param authentication_name: The name of server azure active directory only authentication. - "Default" Required. - :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName - :param parameters: The required parameters for creating or updating an Active Directory only - authentication property. Is either a ServerAzureADOnlyAuthentication type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ServerAzureADOnlyAuthentication or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ServerAzureADOnlyAuthentication] = 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, - authentication_name=authentication_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ServerAzureADOnlyAuthentication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ServerAzureADOnlyAuthentication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ServerAzureADOnlyAuthentication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, - resource_group_name: str, - server_name: str, - authentication_name: Union[str, _models.AuthenticationName], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - authentication_name=authentication_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, - resource_group_name: str, - server_name: str, - authentication_name: Union[str, _models.AuthenticationName], - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an existing server Active Directory only authentication property. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param authentication_name: The name of server azure active directory only authentication. - "Default" Required. - :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - authentication_name=authentication_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either ServerAzureADOnlyAuthentication or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.AzureADOnlyAuthListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index d7be53ff4673..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_blob_auditing_policies_operations.py +++ /dev/null @@ -1,391 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Literal, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._server_blob_auditing_policies_operations import ( - build_create_or_update_request, - build_get_request, - build_list_by_server_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ServerBlobAuditingPoliciesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`server_blob_auditing_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.ServerBlobAuditingPolicy"]: - """Lists auditing settings of 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 - :return: An iterator like instance of either ServerBlobAuditingPolicy or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerBlobAuditingPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.ServerBlobAuditingPolicyListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ServerBlobAuditingPolicyListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, resource_group_name: str, server_name: str, **kwargs: Any) -> _models.ServerBlobAuditingPolicy: - """Gets a server's blob auditing policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: ServerBlobAuditingPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerBlobAuditingPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 {}) - - blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.ServerBlobAuditingPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - blob_auditing_policy_name=blob_auditing_policy_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ServerBlobAuditingPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerBlobAuditingPolicy, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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 {}) - - blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ServerBlobAuditingPolicy") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - blob_auditing_policy_name=blob_auditing_policy_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - parameters: _models.ServerBlobAuditingPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerBlobAuditingPolicy]: - """Creates or updates a server's blob auditing policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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: Properties of blob auditing policy. Required. - :type parameters: ~azure.mgmt.sql.models.ServerBlobAuditingPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ServerBlobAuditingPolicy or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerBlobAuditingPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerBlobAuditingPolicy]: - """Creates or updates a server's blob auditing policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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: Properties of blob auditing policy. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ServerBlobAuditingPolicy or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerBlobAuditingPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerBlobAuditingPolicy, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerBlobAuditingPolicy]: - """Creates or updates a server's blob auditing policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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: Properties of blob auditing policy. Is either a ServerBlobAuditingPolicy - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ServerBlobAuditingPolicy or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ServerBlobAuditingPolicy or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerBlobAuditingPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - 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) - 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, - parameters=parameters, - blob_auditing_policy_name=blob_auditing_policy_name, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ServerBlobAuditingPolicy", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ServerBlobAuditingPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ServerBlobAuditingPolicy]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 38bc81958980..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_communication_links_operations.py +++ /dev/null @@ -1,458 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._server_communication_links_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_server_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -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: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def delete( - 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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - communication_link_name=communication_link_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @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 - :return: ServerCommunicationLink or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerCommunicationLink - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.ServerCommunicationLink] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - communication_link_name=communication_link_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - communication_link_name: str, - parameters: Union[_models.ServerCommunicationLink, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ServerCommunicationLink") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - communication_link_name=communication_link_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ServerCommunicationLink or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ServerCommunicationLink or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerCommunicationLink] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ServerCommunicationLink] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - server_name=server_name, - communication_link_name=communication_link_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ServerCommunicationLink", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ServerCommunicationLink].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ServerCommunicationLink]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either ServerCommunicationLink or the result of - cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerCommunicationLink] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.ServerCommunicationLinkListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 220808483d70..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_configuration_options_operations.py +++ /dev/null @@ -1,414 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._server_configuration_options_operations import ( - build_create_or_update_request, - build_get_request, - build_list_by_managed_instance_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ServerConfigurationOptionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`server_configuration_options` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.ServerConfigurationOption"]: - """Gets a list of managed instance server configuration options. - - :param resource_group_name: The name of the resource group that 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 - :return: An iterator like instance of either ServerConfigurationOption or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerConfigurationOption] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.ServerConfigurationOptionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ServerConfigurationOptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - managed_instance_name: str, - server_configuration_option_name: Union[str, _models.ServerConfigurationOptionName], - **kwargs: Any - ) -> _models.ServerConfigurationOption: - """Gets managed instance server configuration option. - - :param resource_group_name: The name of the resource group that 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 server_configuration_option_name: The name of the server configuration option. - "allowPolybaseExport" Required. - :type server_configuration_option_name: str or - ~azure.mgmt.sql.models.ServerConfigurationOptionName - :return: ServerConfigurationOption or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerConfigurationOption - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - cls: ClsType[_models.ServerConfigurationOption] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - server_configuration_option_name=server_configuration_option_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ServerConfigurationOption", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - server_configuration_option_name: Union[str, _models.ServerConfigurationOptionName], - parameters: Union[_models.ServerConfigurationOption, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ServerConfigurationOption") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - server_configuration_option_name=server_configuration_option_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - server_configuration_option_name: Union[str, _models.ServerConfigurationOptionName], - parameters: _models.ServerConfigurationOption, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerConfigurationOption]: - """Updates managed instance server configuration option. - - :param resource_group_name: The name of the resource group that 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 server_configuration_option_name: The name of the server configuration option. - "allowPolybaseExport" Required. - :type server_configuration_option_name: str or - ~azure.mgmt.sql.models.ServerConfigurationOptionName - :param parameters: Server configuration option parameters. Required. - :type parameters: ~azure.mgmt.sql.models.ServerConfigurationOption - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ServerConfigurationOption or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerConfigurationOption] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - server_configuration_option_name: Union[str, _models.ServerConfigurationOptionName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerConfigurationOption]: - """Updates managed instance server configuration option. - - :param resource_group_name: The name of the resource group that 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 server_configuration_option_name: The name of the server configuration option. - "allowPolybaseExport" Required. - :type server_configuration_option_name: str or - ~azure.mgmt.sql.models.ServerConfigurationOptionName - :param parameters: Server configuration option parameters. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ServerConfigurationOption or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerConfigurationOption] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - server_configuration_option_name: Union[str, _models.ServerConfigurationOptionName], - parameters: Union[_models.ServerConfigurationOption, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerConfigurationOption]: - """Updates managed instance server configuration option. - - :param resource_group_name: The name of the resource group that 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 server_configuration_option_name: The name of the server configuration option. - "allowPolybaseExport" Required. - :type server_configuration_option_name: str or - ~azure.mgmt.sql.models.ServerConfigurationOptionName - :param parameters: Server configuration option parameters. Is either a - ServerConfigurationOption type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ServerConfigurationOption or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ServerConfigurationOption or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerConfigurationOption] - :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", "2022-08-01-preview")) - 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) - 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, - managed_instance_name=managed_instance_name, - server_configuration_option_name=server_configuration_option_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ServerConfigurationOption", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ServerConfigurationOption].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ServerConfigurationOption]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 23fdebd0a5ca..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_connection_policies_operations.py +++ /dev/null @@ -1,405 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._server_connection_policies_operations import ( - build_create_or_update_request, - build_get_request, - build_list_by_server_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ServerConnectionPoliciesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`server_connection_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - connection_policy_name: Union[str, _models.ConnectionPolicyName], - **kwargs: Any - ) -> _models.ServerConnectionPolicy: - """Gets a server connection policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param connection_policy_name: The name of the connection policy. "default" Required. - :type connection_policy_name: str or ~azure.mgmt.sql.models.ConnectionPolicyName - :return: ServerConnectionPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerConnectionPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.ServerConnectionPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - connection_policy_name=connection_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ServerConnectionPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - connection_policy_name: Union[str, _models.ConnectionPolicyName], - parameters: Union[_models.ServerConnectionPolicy, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ServerConnectionPolicy") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - connection_policy_name=connection_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - connection_policy_name: Union[str, _models.ConnectionPolicyName], - parameters: _models.ServerConnectionPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerConnectionPolicy]: - """Updates a server 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 - :param connection_policy_name: The name of the connection policy. "default" Required. - :type connection_policy_name: str or ~azure.mgmt.sql.models.ConnectionPolicyName - :param parameters: The required parameters for updating a server connection policy. Required. - :type parameters: ~azure.mgmt.sql.models.ServerConnectionPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ServerConnectionPolicy or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerConnectionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - connection_policy_name: Union[str, _models.ConnectionPolicyName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerConnectionPolicy]: - """Updates a server 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 - :param connection_policy_name: The name of the connection policy. "default" Required. - :type connection_policy_name: str or ~azure.mgmt.sql.models.ConnectionPolicyName - :param parameters: The required parameters for updating a server connection policy. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ServerConnectionPolicy or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerConnectionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - connection_policy_name: Union[str, _models.ConnectionPolicyName], - parameters: Union[_models.ServerConnectionPolicy, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerConnectionPolicy]: - """Updates a server 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 - :param connection_policy_name: The name of the connection policy. "default" Required. - :type connection_policy_name: str or ~azure.mgmt.sql.models.ConnectionPolicyName - :param parameters: The required parameters for updating a server connection policy. Is either a - ServerConnectionPolicy type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ServerConnectionPolicy or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ServerConnectionPolicy or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerConnectionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ServerConnectionPolicy] = 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, - connection_policy_name=connection_policy_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ServerConnectionPolicy", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ServerConnectionPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ServerConnectionPolicy]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either ServerConnectionPolicy or the result of - cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerConnectionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.ServerConnectionPolicyListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 7f9e1561a427..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_dev_ops_audit_settings_operations.py +++ /dev/null @@ -1,409 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._server_dev_ops_audit_settings_operations import ( - build_create_or_update_request, - build_get_request, - build_list_by_server_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ServerDevOpsAuditSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`server_dev_ops_audit_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.ServerDevOpsAuditingSettings"]: - """Lists DevOps audit settings of 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 - :return: An iterator like instance of either ServerDevOpsAuditingSettings or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerDevOpsAuditingSettings] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) - cls: ClsType[_models.ServerDevOpsAuditSettingsListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ServerDevOpsAuditSettingsListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - server_name: str, - dev_ops_auditing_settings_name: Union[str, _models.DevOpsAuditingSettingsName], - **kwargs: Any - ) -> _models.ServerDevOpsAuditingSettings: - """Gets a server's DevOps audit settings. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param dev_ops_auditing_settings_name: "Default" Required. - :type dev_ops_auditing_settings_name: str or ~azure.mgmt.sql.models.DevOpsAuditingSettingsName - :return: ServerDevOpsAuditingSettings or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerDevOpsAuditingSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-02-01-preview")) - cls: ClsType[_models.ServerDevOpsAuditingSettings] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - dev_ops_auditing_settings_name=dev_ops_auditing_settings_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ServerDevOpsAuditingSettings", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - dev_ops_auditing_settings_name: Union[str, _models.DevOpsAuditingSettingsName], - parameters: Union[_models.ServerDevOpsAuditingSettings, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2022-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ServerDevOpsAuditingSettings") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - dev_ops_auditing_settings_name=dev_ops_auditing_settings_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - dev_ops_auditing_settings_name: Union[str, _models.DevOpsAuditingSettingsName], - parameters: _models.ServerDevOpsAuditingSettings, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerDevOpsAuditingSettings]: - """Creates or updates a server's DevOps audit settings. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param dev_ops_auditing_settings_name: "Default" Required. - :type dev_ops_auditing_settings_name: str or ~azure.mgmt.sql.models.DevOpsAuditingSettingsName - :param parameters: Properties of DevOps audit settings. Required. - :type parameters: ~azure.mgmt.sql.models.ServerDevOpsAuditingSettings - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ServerDevOpsAuditingSettings or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerDevOpsAuditingSettings] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - dev_ops_auditing_settings_name: Union[str, _models.DevOpsAuditingSettingsName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerDevOpsAuditingSettings]: - """Creates or updates a server's DevOps audit settings. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param dev_ops_auditing_settings_name: "Default" Required. - :type dev_ops_auditing_settings_name: str or ~azure.mgmt.sql.models.DevOpsAuditingSettingsName - :param parameters: Properties of DevOps audit settings. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ServerDevOpsAuditingSettings or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerDevOpsAuditingSettings] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - dev_ops_auditing_settings_name: Union[str, _models.DevOpsAuditingSettingsName], - parameters: Union[_models.ServerDevOpsAuditingSettings, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerDevOpsAuditingSettings]: - """Creates or updates a server's DevOps audit settings. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param dev_ops_auditing_settings_name: "Default" Required. - :type dev_ops_auditing_settings_name: str or ~azure.mgmt.sql.models.DevOpsAuditingSettingsName - :param parameters: Properties of DevOps audit settings. Is either a - ServerDevOpsAuditingSettings type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ServerDevOpsAuditingSettings or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ServerDevOpsAuditingSettings or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerDevOpsAuditingSettings] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) - 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) - 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, - dev_ops_auditing_settings_name=dev_ops_auditing_settings_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ServerDevOpsAuditingSettings", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.ServerDevOpsAuditingSettings].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ServerDevOpsAuditingSettings]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 91c8cec484e0..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_dns_aliases_operations.py +++ /dev/null @@ -1,624 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._server_dns_aliases_operations import ( - build_acquire_request, - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_server_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ServerDnsAliasesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`server_dns_aliases` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, dns_alias_name: str, **kwargs: Any - ) -> _models.ServerDnsAlias: - """Gets a server DNS alias. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param dns_alias_name: The name of the server dns alias. Required. - :type dns_alias_name: str - :return: ServerDnsAlias or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerDnsAlias - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerDnsAlias] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - dns_alias_name=dns_alias_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ServerDnsAlias", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, resource_group_name: str, server_name: str, dns_alias_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - dns_alias_name=dns_alias_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_create_or_update( - self, resource_group_name: str, server_name: str, dns_alias_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.ServerDnsAlias]: - """Creates a server DNS alias. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param dns_alias_name: The name of the server dns alias. Required. - :type dns_alias_name: str - :return: An instance of AsyncLROPoller that returns either ServerDnsAlias or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerDnsAlias] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerDnsAlias] = 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, - dns_alias_name=dns_alias_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ServerDnsAlias", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ServerDnsAlias].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ServerDnsAlias]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, server_name: str, dns_alias_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - dns_alias_name=dns_alias_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, server_name: str, dns_alias_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes the server DNS alias with the given name. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param dns_alias_name: The name of the server dns alias. Required. - :type dns_alias_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - dns_alias_name=dns_alias_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either ServerDnsAlias or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerDnsAlias] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerDnsAliasListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - async def _acquire_initial( - self, - resource_group_name: str, - server_name: str, - dns_alias_name: str, - parameters: Union[_models.ServerDnsAliasAcquisition, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ServerDnsAliasAcquisition") - - _request = build_acquire_request( - resource_group_name=resource_group_name, - server_name=server_name, - dns_alias_name=dns_alias_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_acquire( - self, - resource_group_name: str, - server_name: str, - dns_alias_name: str, - parameters: _models.ServerDnsAliasAcquisition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerDnsAlias]: - """Acquires server DNS alias from another server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param dns_alias_name: The name of the server dns alias. Required. - :type dns_alias_name: str - :param parameters: Required. - :type parameters: ~azure.mgmt.sql.models.ServerDnsAliasAcquisition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ServerDnsAlias or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerDnsAlias] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_acquire( - self, - resource_group_name: str, - server_name: str, - dns_alias_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerDnsAlias]: - """Acquires server DNS alias from another server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param dns_alias_name: The name of the server dns alias. Required. - :type dns_alias_name: str - :param parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ServerDnsAlias or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerDnsAlias] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_acquire( - self, - resource_group_name: str, - server_name: str, - dns_alias_name: str, - parameters: Union[_models.ServerDnsAliasAcquisition, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerDnsAlias]: - """Acquires server DNS alias from another server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param dns_alias_name: The name of the server dns alias. Required. - :type dns_alias_name: str - :param parameters: Is either a ServerDnsAliasAcquisition type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ServerDnsAliasAcquisition or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ServerDnsAlias or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerDnsAlias] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ServerDnsAlias] = 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._acquire_initial( - resource_group_name=resource_group_name, - server_name=server_name, - dns_alias_name=dns_alias_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ServerDnsAlias", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ServerDnsAlias].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ServerDnsAlias]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_keys_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_keys_operations.py deleted file mode 100644 index 0e1a37bde6af..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_keys_operations.py +++ /dev/null @@ -1,517 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._server_keys_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_server_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ServerKeysOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`server_keys` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.ServerKey"]: - """Gets a list of server keys. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either ServerKey or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerKey] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerKeyListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ServerKeyListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, resource_group_name: str, server_name: str, key_name: str, **kwargs: Any) -> _models.ServerKey: - """Gets a server key. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param key_name: The name of the server key to be retrieved. Required. - :type key_name: str - :return: ServerKey or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerKey - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerKey] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - key_name=key_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ServerKey", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - key_name: str, - parameters: Union[_models.ServerKey, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ServerKey") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - key_name=key_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - key_name: str, - parameters: _models.ServerKey, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerKey]: - """Creates or updates a server key. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param key_name: The name of the server key to be operated on (updated or created). The key - name is required to be in the format of 'vault_key_version'. For example, if the keyId is - https://YourVaultName.vault.azure.net/keys/YourKeyName/YourKeyVersion, then the server key name - should be formatted as: YourVaultName_YourKeyName_YourKeyVersion. Required. - :type key_name: str - :param parameters: The requested server key resource state. Required. - :type parameters: ~azure.mgmt.sql.models.ServerKey - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ServerKey or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerKey] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - key_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerKey]: - """Creates or updates a server key. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param key_name: The name of the server key to be operated on (updated or created). The key - name is required to be in the format of 'vault_key_version'. For example, if the keyId is - https://YourVaultName.vault.azure.net/keys/YourKeyName/YourKeyVersion, then the server key name - should be formatted as: YourVaultName_YourKeyName_YourKeyVersion. Required. - :type key_name: str - :param parameters: The requested server key resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ServerKey or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerKey] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - key_name: str, - parameters: Union[_models.ServerKey, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerKey]: - """Creates or updates a server key. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param key_name: The name of the server key to be operated on (updated or created). The key - name is required to be in the format of 'vault_key_version'. For example, if the keyId is - https://YourVaultName.vault.azure.net/keys/YourKeyName/YourKeyVersion, then the server key name - should be formatted as: YourVaultName_YourKeyName_YourKeyVersion. Required. - :type key_name: str - :param parameters: The requested server key resource state. Is either a ServerKey type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ServerKey or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ServerKey or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerKey] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ServerKey] = 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, - key_name=key_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ServerKey", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ServerKey].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ServerKey]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, server_name: str, key_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - key_name=key_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, server_name: str, key_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes the server key with the given name. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param key_name: The name of the server key to be deleted. Required. - :type key_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - key_name=key_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_operations_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_operations_operations.py deleted file mode 100644 index ebe1319a818a..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_operations_operations.py +++ /dev/null @@ -1,126 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._server_operations_operations import build_list_by_server_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ServerOperationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`server_operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.ServerOperation"]: - """Gets a list of operations performed on the server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either ServerOperation or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerOperation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerOperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ServerOperationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_security_alert_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_security_alert_policies_operations.py deleted file mode 100644 index 7160dfcae642..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_security_alert_policies_operations.py +++ /dev/null @@ -1,406 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._server_security_alert_policies_operations import ( - build_create_or_update_request, - build_get_request, - build_list_by_server_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ServerSecurityAlertPoliciesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`server_security_alert_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - **kwargs: Any - ) -> _models.ServerSecurityAlertPolicy: - """Get a server's security alert policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :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 - :return: ServerSecurityAlertPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerSecurityAlertPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerSecurityAlertPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - security_alert_policy_name=security_alert_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ServerSecurityAlertPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - parameters: Union[_models.ServerSecurityAlertPolicy, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ServerSecurityAlertPolicy") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - security_alert_policy_name=security_alert_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - parameters: _models.ServerSecurityAlertPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerSecurityAlertPolicy]: - """Creates or updates a threat detection policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :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 - :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. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ServerSecurityAlertPolicy or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerSecurityAlertPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerSecurityAlertPolicy]: - """Creates or updates a threat detection policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :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 - :param parameters: The server security alert policy. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ServerSecurityAlertPolicy or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerSecurityAlertPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - parameters: Union[_models.ServerSecurityAlertPolicy, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerSecurityAlertPolicy]: - """Creates or updates a threat detection policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :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 - :param parameters: The server security alert policy. Is either a ServerSecurityAlertPolicy type - or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ServerSecurityAlertPolicy or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ServerSecurityAlertPolicy or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerSecurityAlertPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ServerSecurityAlertPolicy] = 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, - security_alert_policy_name=security_alert_policy_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ServerSecurityAlertPolicy", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ServerSecurityAlertPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ServerSecurityAlertPolicy]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either ServerSecurityAlertPolicy or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerSecurityAlertPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.LogicalServerSecurityAlertPolicyListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index d5042a0e8f51..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_trust_certificates_operations.py +++ /dev/null @@ -1,512 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._server_trust_certificates_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_instance_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ServerTrustCertificatesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`server_trust_certificates` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.ServerTrustCertificate"]: - """Gets a list of server trust certificates that were uploaded from box to the given Sql Managed - Instance. - - :param resource_group_name: The name of the resource group that 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 - :return: An iterator like instance of either ServerTrustCertificate or the result of - cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerTrustCertificate] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.ServerTrustCertificatesListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ServerTrustCertificatesListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, managed_instance_name: str, certificate_name: str, **kwargs: Any - ) -> _models.ServerTrustCertificate: - """Gets a server trust certificate that was uploaded from box to Sql Managed Instance. - - :param resource_group_name: The name of the resource group that 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 certificate_name: Name of of the certificate to get. Required. - :type certificate_name: str - :return: ServerTrustCertificate or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerTrustCertificate - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.ServerTrustCertificate] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - certificate_name=certificate_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ServerTrustCertificate", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - certificate_name: str, - parameters: Union[_models.ServerTrustCertificate, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2021-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ServerTrustCertificate") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - certificate_name=certificate_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - certificate_name: str, - parameters: _models.ServerTrustCertificate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerTrustCertificate]: - """Uploads a server trust certificate from box to Sql Managed Instance. - - :param resource_group_name: The name of the resource group that 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 certificate_name: Name of of the certificate to upload. Required. - :type certificate_name: str - :param parameters: The server trust certificate info. Required. - :type parameters: ~azure.mgmt.sql.models.ServerTrustCertificate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ServerTrustCertificate or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerTrustCertificate] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - certificate_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerTrustCertificate]: - """Uploads a server trust certificate from box to Sql Managed Instance. - - :param resource_group_name: The name of the resource group that 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 certificate_name: Name of of the certificate to upload. Required. - :type certificate_name: str - :param parameters: The server trust certificate info. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ServerTrustCertificate or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerTrustCertificate] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - certificate_name: str, - parameters: Union[_models.ServerTrustCertificate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerTrustCertificate]: - """Uploads a server trust certificate from box to Sql Managed Instance. - - :param resource_group_name: The name of the resource group that 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 certificate_name: Name of of the certificate to upload. Required. - :type certificate_name: str - :param parameters: The server trust certificate info. Is either a ServerTrustCertificate type - or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ServerTrustCertificate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ServerTrustCertificate or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerTrustCertificate] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - 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) - 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, - managed_instance_name=managed_instance_name, - certificate_name=certificate_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ServerTrustCertificate", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ServerTrustCertificate].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ServerTrustCertificate]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, managed_instance_name: str, certificate_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - certificate_name=certificate_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, managed_instance_name: str, certificate_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a server trust certificate that was uploaded from box to Sql Managed Instance. - - :param resource_group_name: The name of the resource group that 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 certificate_name: Name of of the certificate to delete. Required. - :type certificate_name: str - :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", "2021-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( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - certificate_name=certificate_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index 9ce670c6605d..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_trust_groups_operations.py +++ /dev/null @@ -1,583 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._server_trust_groups_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_instance_request, - build_list_by_location_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ServerTrustGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`server_trust_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get( - self, resource_group_name: str, location_name: str, server_trust_group_name: str, **kwargs: Any - ) -> _models.ServerTrustGroup: - """Gets a server trust group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param server_trust_group_name: The name of the server trust group. Required. - :type server_trust_group_name: str - :return: ServerTrustGroup or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerTrustGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerTrustGroup] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - location_name=location_name, - server_trust_group_name=server_trust_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ServerTrustGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - location_name: str, - server_trust_group_name: str, - parameters: Union[_models.ServerTrustGroup, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ServerTrustGroup") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - location_name=location_name, - server_trust_group_name=server_trust_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - location_name: str, - server_trust_group_name: str, - parameters: _models.ServerTrustGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerTrustGroup]: - """Creates or updates a server trust group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param server_trust_group_name: The name of the server trust group. Required. - :type server_trust_group_name: str - :param parameters: The server trust group parameters. Required. - :type parameters: ~azure.mgmt.sql.models.ServerTrustGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ServerTrustGroup or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerTrustGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - location_name: str, - server_trust_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerTrustGroup]: - """Creates or updates a server trust group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param server_trust_group_name: The name of the server trust group. Required. - :type server_trust_group_name: str - :param parameters: The server trust group parameters. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ServerTrustGroup or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerTrustGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - location_name: str, - server_trust_group_name: str, - parameters: Union[_models.ServerTrustGroup, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerTrustGroup]: - """Creates or updates a server trust group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param server_trust_group_name: The name of the server trust group. Required. - :type server_trust_group_name: str - :param parameters: The server trust group parameters. Is either a ServerTrustGroup type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ServerTrustGroup or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ServerTrustGroup or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerTrustGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ServerTrustGroup] = 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, - location_name=location_name, - server_trust_group_name=server_trust_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ServerTrustGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ServerTrustGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ServerTrustGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, location_name: str, server_trust_group_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - location_name=location_name, - server_trust_group_name=server_trust_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, location_name: str, server_trust_group_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes 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 - :param server_trust_group_name: The name of the server trust group. Required. - :type server_trust_group_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - location_name=location_name, - server_trust_group_name=server_trust_group_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_by_location( - self, resource_group_name: str, location_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either ServerTrustGroup or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerTrustGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerTrustGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace - def list_by_instance( - self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.ServerTrustGroup"]: - """Gets a server trust groups by instance 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 managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :return: An iterator like instance of either ServerTrustGroup or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerTrustGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerTrustGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 2e66005e2bf0..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_usages_operations.py +++ /dev/null @@ -1,126 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._server_usages_operations import build_list_by_server_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ServerUsagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`server_usages` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.ServerUsage"]: - """Returns 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. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either ServerUsage or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerUsage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.ServerUsageListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ServerUsageListResult", pipeline_response) - 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) 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 deleted file mode 100644 index cc77298d2b23..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_vulnerability_assessments_operations.py +++ /dev/null @@ -1,415 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._server_vulnerability_assessments_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_server_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ServerVulnerabilityAssessmentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`server_vulnerability_assessments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **kwargs: Any - ) -> _models.ServerVulnerabilityAssessment: - """Gets the server's vulnerability assessment. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server for which the vulnerability assessment is defined. - Required. - :type server_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 - :return: ServerVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerVulnerabilityAssessment] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ServerVulnerabilityAssessment", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: _models.ServerVulnerabilityAssessment, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ServerVulnerabilityAssessment: - """Creates or updates the server's vulnerability assessment. Learn more about setting SQL - vulnerability assessment with managed identity - - https://docs.microsoft.com/azure/azure-sql/database/sql-database-vulnerability-assessment-storage. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server for which the vulnerability assessment is defined. - Required. - :type server_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 parameters: The requested resource. Required. - :type parameters: ~azure.mgmt.sql.models.ServerVulnerabilityAssessment - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ServerVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ServerVulnerabilityAssessment: - """Creates or updates the server's vulnerability assessment. Learn more about setting SQL - vulnerability assessment with managed identity - - https://docs.microsoft.com/azure/azure-sql/database/sql-database-vulnerability-assessment-storage. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server for which the vulnerability assessment is defined. - Required. - :type server_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 parameters: The requested resource. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ServerVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: Union[_models.ServerVulnerabilityAssessment, IO[bytes]], - **kwargs: Any - ) -> _models.ServerVulnerabilityAssessment: - """Creates or updates the server's vulnerability assessment. Learn more about setting SQL - vulnerability assessment with managed identity - - https://docs.microsoft.com/azure/azure-sql/database/sql-database-vulnerability-assessment-storage. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server for which the vulnerability assessment is defined. - Required. - :type server_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 parameters: The requested resource. Is either a ServerVulnerabilityAssessment type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ServerVulnerabilityAssessment or IO[bytes] - :return: ServerVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ServerVulnerabilityAssessment") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ServerVulnerabilityAssessment", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **kwargs: Any - ) -> None: - """Removes the server's vulnerability assessment. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server for which the vulnerability assessment is defined. - Required. - :type server_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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either ServerVulnerabilityAssessment or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerVulnerabilityAssessment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 9d882620819f..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_servers_operations.py +++ /dev/null @@ -1,1179 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._servers_operations import ( - build_check_name_availability_request, - build_create_or_update_request, - build_delete_request, - build_get_request, - build_import_database_request, - build_list_by_resource_group_request, - build_list_request, - build_refresh_status_request, - build_update_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class ServersOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`servers` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def check_name_availability( - self, parameters: _models.CheckNameAvailabilityRequest, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CheckNameAvailabilityResponse: - """Determines whether a resource can be created with the specified name. - - :param parameters: The name availability request parameters. Required. - :type parameters: ~azure.mgmt.sql.models.CheckNameAvailabilityRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CheckNameAvailabilityResponse or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.CheckNameAvailabilityResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def check_name_availability( - self, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CheckNameAvailabilityResponse: - """Determines whether a resource can be created with the specified name. - - :param parameters: The name availability request parameters. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: CheckNameAvailabilityResponse or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.CheckNameAvailabilityResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def check_name_availability( - self, parameters: Union[_models.CheckNameAvailabilityRequest, IO[bytes]], **kwargs: Any - ) -> _models.CheckNameAvailabilityResponse: - """Determines whether a resource can be created with the specified name. - - :param parameters: The name availability request parameters. Is either a - CheckNameAvailabilityRequest type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.CheckNameAvailabilityRequest or IO[bytes] - :return: CheckNameAvailabilityResponse or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.CheckNameAvailabilityResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "CheckNameAvailabilityRequest") - - _request = build_check_name_availability_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckNameAvailabilityResponse", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list(self, expand: Optional[str] = None, **kwargs: Any) -> AsyncItemPaged["_models.Server"]: - """Gets a list of all servers in the subscription. - - :param expand: The child resources to include in the response. Default value is None. - :type expand: str - :return: An iterator like instance of either Server or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - cls: ClsType[_models.ServerListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ServerListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.Server"]: - """Gets a list of servers in a resource groups. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param expand: The child resources to include in the response. Default value is None. - :type expand: str - :return: An iterator like instance of either Server or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - cls: ClsType[_models.ServerListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ServerListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, server_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> _models.Server: - """Gets a server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param expand: The child resources to include in the response. Default value is None. - :type expand: str - :return: Server or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.Server - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - cls: ClsType[_models.Server] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Server", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, resource_group_name: str, server_name: str, parameters: Union[_models.Server, IO[bytes]], **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "Server") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - parameters: _models.Server, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Server]: - """Creates or updates a server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: The requested server resource state. Required. - :type parameters: ~azure.mgmt.sql.models.Server - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Server or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Server]: - """Creates or updates a server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: The requested server resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Server or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, resource_group_name: str, server_name: str, parameters: Union[_models.Server, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.Server]: - """Creates or updates a server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: The requested server resource state. Is either a Server type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.sql.models.Server or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Server or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - 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) - 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, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Server", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Server].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Server]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial(self, resource_group_name: str, server_name: str, **kwargs: Any) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete(self, resource_group_name: str, server_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Deletes 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 - :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", "2024-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( - resource_group_name=resource_group_name, - server_name=server_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ServerUpdate") - - _request = build_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - server_name: str, - parameters: _models.ServerUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Server]: - """Updates a server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: The requested server resource state. Required. - :type parameters: ~azure.mgmt.sql.models.ServerUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Server or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Server]: - """Updates a server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: The requested server resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Server or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Server]: - """Updates a server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: The requested server resource state. Is either a ServerUpdate type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ServerUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Server or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - 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) - 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( - resource_group_name=resource_group_name, - server_name=server_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Server", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Server].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Server]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _import_database_initial( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ImportNewDatabaseDefinition, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "ImportNewDatabaseDefinition") - - _request = build_import_database_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_import_database( - self, - resource_group_name: str, - server_name: str, - parameters: _models.ImportNewDatabaseDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ImportExportOperationResult]: - """Imports a bacpac into a new database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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: The database import request parameters. Required. - :type parameters: ~azure.mgmt.sql.models.ImportNewDatabaseDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ImportExportOperationResult or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_import_database( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ImportExportOperationResult]: - """Imports a bacpac into a new database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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: The database import request parameters. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ImportExportOperationResult or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_import_database( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ImportNewDatabaseDefinition, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ImportExportOperationResult]: - """Imports a bacpac into a new database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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: The database import request parameters. Is either a - ImportNewDatabaseDefinition type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ImportNewDatabaseDefinition or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ImportExportOperationResult or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - 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) - 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._import_database_initial( - resource_group_name=resource_group_name, - server_name=server_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ImportExportOperationResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ImportExportOperationResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ImportExportOperationResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _refresh_status_initial( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_refresh_status_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_refresh_status( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.RefreshExternalGovernanceStatusOperationResult]: - """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 server_name: The name of the server. Required. - :type server_name: str - :return: An instance of AsyncLROPoller that returns either - RefreshExternalGovernanceStatusOperationResult or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.RefreshExternalGovernanceStatusOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - 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) - 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, - server_name=server_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize( - "RefreshExternalGovernanceStatusOperationResult", pipeline_response.http_response - ) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.RefreshExternalGovernanceStatusOperationResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.RefreshExternalGovernanceStatusOperationResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_service_objectives_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_service_objectives_operations.py deleted file mode 100644 index bf20c3cc892b..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_service_objectives_operations.py +++ /dev/null @@ -1,187 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._service_objectives_operations import build_get_request, build_list_by_server_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -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: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - :return: ServiceObjective or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServiceObjective - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.ServiceObjective] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - service_objective_name=service_objective_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either ServiceObjective or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServiceObjective] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.ServiceObjectiveListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 080d0abc42eb..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_agent_operations.py +++ /dev/null @@ -1,240 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -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 ..._utils.serialization import Deserializer, Serializer -from ...operations._sql_agent_operations import build_create_or_update_request, build_get_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class SqlAgentOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`sql_agent` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get( - self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> _models.SqlAgentConfiguration: - """Gets current instance sql agent configuration. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :return: SqlAgentConfiguration or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SqlAgentConfiguration - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SqlAgentConfiguration] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("SqlAgentConfiguration", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - parameters: _models.SqlAgentConfiguration, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SqlAgentConfiguration: - """Puts new sql agent configuration to instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 parameters: Required. - :type parameters: ~azure.mgmt.sql.models.SqlAgentConfiguration - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SqlAgentConfiguration or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SqlAgentConfiguration - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SqlAgentConfiguration: - """Puts new sql agent configuration to instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: SqlAgentConfiguration or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SqlAgentConfiguration - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - parameters: Union[_models.SqlAgentConfiguration, IO[bytes]], - **kwargs: Any - ) -> _models.SqlAgentConfiguration: - """Puts new sql agent configuration to instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 parameters: Is either a SqlAgentConfiguration type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.SqlAgentConfiguration or IO[bytes] - :return: SqlAgentConfiguration or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SqlAgentConfiguration - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SqlAgentConfiguration") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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("SqlAgentConfiguration", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 0bf4f77131ff..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_baseline_operations.py +++ /dev/null @@ -1,221 +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 collections.abc import MutableMapping -from typing import Any, Callable, Literal, Optional, TypeVar, Union - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._sql_vulnerability_assessment_baseline_operations import ( - build_get_request, - build_list_by_sql_vulnerability_assessment_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class SqlVulnerabilityAssessmentBaselineOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`sql_vulnerability_assessment_baseline` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_sql_vulnerability_assessment( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **kwargs: Any - ) -> AsyncItemPaged["_models.DatabaseSqlVulnerabilityAssessmentBaselineSet"]: - """Gets a list of database's sql vulnerability assessment rule baselines. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_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 - :return: An iterator like instance of either DatabaseSqlVulnerabilityAssessmentBaselineSet or - the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentBaselineSetListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_sql_vulnerability_assessment_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - system_database_name=system_database_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize( - "DatabaseSqlVulnerabilityAssessmentBaselineSetListResult", pipeline_response - ) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - **kwargs: Any - ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: - """Gets a list of database's sql vulnerability assessment rule baselines. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :return: DatabaseSqlVulnerabilityAssessmentBaselineSet or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentBaselineSet] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - baseline_name=baseline_name, - subscription_id=self._config.subscription_id, - system_database_name=system_database_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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( - "DatabaseSqlVulnerabilityAssessmentBaselineSet", pipeline_response.http_response - ) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 32fc47a66730..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_baselines_operations.py +++ /dev/null @@ -1,215 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Literal, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -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 ..._utils.serialization import Deserializer, Serializer -from ...operations._sql_vulnerability_assessment_baselines_operations import build_create_or_update_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class SqlVulnerabilityAssessmentBaselinesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`sql_vulnerability_assessment_baselines` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - parameters: _models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: - """Add a database's vulnerability assessment rule baseline 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 server_name: The name of the server. Required. - :type server_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :param parameters: The requested rule baseline resource. Required. - :type parameters: - ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseSqlVulnerabilityAssessmentBaselineSet or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: - """Add a database's vulnerability assessment rule baseline 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 server_name: The name of the server. Required. - :type server_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :param parameters: The requested rule baseline resource. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseSqlVulnerabilityAssessmentBaselineSet or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - parameters: Union[_models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput, IO[bytes]], - **kwargs: Any - ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: - """Add a database's vulnerability assessment rule baseline 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 server_name: The name of the server. Required. - :type server_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :param parameters: The requested rule baseline resource. Is either a - DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput type or a IO[bytes] type. Required. - :type parameters: - ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput or IO[bytes] - :return: DatabaseSqlVulnerabilityAssessmentBaselineSet or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - baseline_name=baseline_name, - subscription_id=self._config.subscription_id, - system_database_name=system_database_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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( - "DatabaseSqlVulnerabilityAssessmentBaselineSet", pipeline_response.http_response - ) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index c41a29b6a007..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_execute_scan_operations.py +++ /dev/null @@ -1,183 +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 collections.abc import MutableMapping -from typing import Any, AsyncIterator, Callable, Literal, Optional, TypeVar, Union, cast - -from azure.core import AsyncPipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -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 ..._utils.serialization import Deserializer, Serializer -from ...operations._sql_vulnerability_assessment_execute_scan_operations import build_execute_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class SqlVulnerabilityAssessmentExecuteScanOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`sql_vulnerability_assessment_execute_scan` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - async def _execute_initial( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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 {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_execute_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - system_database_name=system_database_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_execute( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **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 vulnerability_assessment_name: The name of the vulnerability assessment. "default" - Required. - :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName - :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 {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - 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._execute_initial( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - system_database_name=system_database_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index dbac66dd7252..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_rule_baseline_operations.py +++ /dev/null @@ -1,401 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Literal, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._sql_vulnerability_assessment_rule_baseline_operations import ( - build_create_or_update_request, - build_get_request, - build_list_by_baseline_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class SqlVulnerabilityAssessmentRuleBaselineOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`sql_vulnerability_assessment_rule_baseline` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_baseline( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - **kwargs: Any - ) -> AsyncItemPaged["_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline"]: - """Gets a system database's sql vulnerability assessment rule baseline. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :return: An iterator like instance of either DatabaseSqlVulnerabilityAssessmentRuleBaseline or - the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_baseline_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - baseline_name=baseline_name, - subscription_id=self._config.subscription_id, - system_database_name=system_database_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize( - "DatabaseSqlVulnerabilityAssessmentRuleBaselineListResult", pipeline_response - ) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - rule_id: str, - **kwargs: Any - ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: - """Gets a system database's sql vulnerability assessment rule baseline. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :param rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - baseline_name=baseline_name, - rule_id=rule_id, - subscription_id=self._config.subscription_id, - system_database_name=system_database_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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( - "DatabaseSqlVulnerabilityAssessmentRuleBaseline", pipeline_response.http_response - ) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - rule_id: str, - parameters: _models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :param rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :param parameters: The requested rule baseline resource. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - rule_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :param rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :param parameters: The requested rule baseline resource. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - rule_id: str, - parameters: Union[_models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput, IO[bytes]], - **kwargs: Any - ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :param rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :param parameters: The requested rule baseline resource. Is either a - DatabaseSqlVulnerabilityAssessmentRuleBaselineInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput or - IO[bytes] - :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DatabaseSqlVulnerabilityAssessmentRuleBaselineInput") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - baseline_name=baseline_name, - rule_id=rule_id, - subscription_id=self._config.subscription_id, - system_database_name=system_database_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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( - "DatabaseSqlVulnerabilityAssessmentRuleBaseline", pipeline_response.http_response - ) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index de384381ca92..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_rule_baselines_operations.py +++ /dev/null @@ -1,126 +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 collections.abc import MutableMapping -from typing import Any, Callable, Literal, Optional, TypeVar, Union - -from azure.core import AsyncPipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -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 ..._utils.serialization import Deserializer, Serializer -from ...operations._sql_vulnerability_assessment_rule_baselines_operations import build_delete_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class SqlVulnerabilityAssessmentRuleBaselinesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`sql_vulnerability_assessment_rule_baselines` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def delete( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - rule_id: str, - **kwargs: Any - ) -> None: - """Removes the database's vulnerability assessment rule baseline. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :param rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - baseline_name=baseline_name, - rule_id=rule_id, - subscription_id=self._config.subscription_id, - system_database_name=system_database_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore 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 deleted file mode 100644 index 68bf49112f30..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_scan_result_operations.py +++ /dev/null @@ -1,229 +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 collections.abc import MutableMapping -from typing import Any, Callable, Literal, Optional, TypeVar, Union - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._sql_vulnerability_assessment_scan_result_operations import ( - build_get_request, - build_list_by_scan_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class SqlVulnerabilityAssessmentScanResultOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`sql_vulnerability_assessment_scan_result` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_scan( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], - scan_id: str, - **kwargs: Any - ) -> AsyncItemPaged["_models.SqlVulnerabilityAssessmentScanResults"]: - """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. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" - Required. - :type vulnerability_assessment_name: str or - ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentName - :param scan_id: The scan id of the SQL Vulnerability Assessment scan to retrieve result from. - Required. - :type scan_id: str - :return: An iterator like instance of either SqlVulnerabilityAssessmentScanResults or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanResults] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[_models.SQLVulnerabilityAssessmentScanListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_scan_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - scan_id=scan_id, - subscription_id=self._config.subscription_id, - system_database_name=system_database_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SQLVulnerabilityAssessmentScanListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], - scan_id: str, - scan_result_id: str, - **kwargs: Any - ) -> _models.SqlVulnerabilityAssessmentScanResults: - """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. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" - Required. - :type vulnerability_assessment_name: str or - ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentName - :param scan_id: The scan id of the SQL Vulnerability Assessment scan to retrieve result from. - Required. - :type scan_id: str - :param scan_result_id: The scan result id of the specific result to retrieve. Required. - :type scan_result_id: str - :return: SqlVulnerabilityAssessmentScanResults or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[_models.SqlVulnerabilityAssessmentScanResults] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - scan_id=scan_id, - scan_result_id=scan_result_id, - subscription_id=self._config.subscription_id, - system_database_name=system_database_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("SqlVulnerabilityAssessmentScanResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 37c10aea5fb5..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_scans_operations.py +++ /dev/null @@ -1,217 +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 collections.abc import MutableMapping -from typing import Any, Callable, Literal, Optional, TypeVar, Union - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._sql_vulnerability_assessment_scans_operations import ( - build_get_request, - build_list_by_sql_vulnerability_assessments_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class SqlVulnerabilityAssessmentScansOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`sql_vulnerability_assessment_scans` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_sql_vulnerability_assessments( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **kwargs: Any - ) -> AsyncItemPaged["_models.SqlVulnerabilityAssessmentScanRecord"]: - """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 server_name: The name of the server. Required. - :type server_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 - :return: An iterator like instance of either SqlVulnerabilityAssessmentScanRecord or the result - of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanRecord] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[_models.SqlVulnerabilityAssessmentScanRecordListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_sql_vulnerability_assessments_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - system_database_name=system_database_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SqlVulnerabilityAssessmentScanRecordListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - scan_id: str, - **kwargs: Any - ) -> _models.SqlVulnerabilityAssessmentScanRecord: - """Get a system database vulnerability assessment scan record. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_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: Required. - :type scan_id: str - :return: SqlVulnerabilityAssessmentScanRecord or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanRecord - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[_models.SqlVulnerabilityAssessmentScanRecord] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - scan_id=scan_id, - subscription_id=self._config.subscription_id, - system_database_name=system_database_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("SqlVulnerabilityAssessmentScanRecord", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index f7b827e0b94d..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessments_operations.py +++ /dev/null @@ -1,114 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar, Union - -from azure.core import AsyncPipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -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 ..._utils.serialization import Deserializer, Serializer -from ...operations._sql_vulnerability_assessments_operations import build_delete_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class SqlVulnerabilityAssessmentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`sql_vulnerability_assessments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def delete( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **kwargs: Any - ) -> None: - """Removes SQL Vulnerability Assessment. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" - Required. - :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore 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 deleted file mode 100644 index fc57b748316c..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessments_settings_operations.py +++ /dev/null @@ -1,343 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._sql_vulnerability_assessments_settings_operations import ( - build_create_or_update_request, - build_get_request, - build_list_by_server_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class SqlVulnerabilityAssessmentsSettingsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`sql_vulnerability_assessments_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.SqlVulnerabilityAssessment"]: - """Lists SQL 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 - :return: An iterator like instance of either SqlVulnerabilityAssessment or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SqlVulnerabilityAssessment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[_models.SqlVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SqlVulnerabilityAssessmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], - **kwargs: Any - ) -> _models.SqlVulnerabilityAssessment: - """Gets SQL Vulnerability Assessment 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 vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" - Required. - :type vulnerability_assessment_name: str or - ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentName - :return: SqlVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-11-01-preview")) - cls: ClsType[_models.SqlVulnerabilityAssessment] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("SqlVulnerabilityAssessment", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: _models.SqlVulnerabilityAssessment, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SqlVulnerabilityAssessment: - """Creates or updates SQL Vulnerability Assessment 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 vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" - Required. - :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName - :param parameters: The requested resource. Required. - :type parameters: ~azure.mgmt.sql.models.SqlVulnerabilityAssessment - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SqlVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SqlVulnerabilityAssessment: - """Creates or updates SQL Vulnerability Assessment 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 vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" - Required. - :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName - :param parameters: The requested resource. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: SqlVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: Union[_models.SqlVulnerabilityAssessment, IO[bytes]], - **kwargs: Any - ) -> _models.SqlVulnerabilityAssessment: - """Creates or updates SQL Vulnerability Assessment 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 vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" - Required. - :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName - :param parameters: The requested resource. Is either a SqlVulnerabilityAssessment type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.SqlVulnerabilityAssessment or IO[bytes] - :return: SqlVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SqlVulnerabilityAssessment") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SqlVulnerabilityAssessment", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 3010f8adf613..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_start_stop_managed_instance_schedules_operations.py +++ /dev/null @@ -1,404 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._start_stop_managed_instance_schedules_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_instance_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class StartStopManagedInstanceSchedulesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`start_stop_managed_instance_schedules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.StartStopManagedInstanceSchedule"]: - """Lists the managed instance's Start/Stop schedules. - - :param resource_group_name: The name of the resource group that 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 - :return: An iterator like instance of either StartStopManagedInstanceSchedule or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.StartStopManagedInstanceSchedule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.StartStopManagedInstanceScheduleListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("StartStopManagedInstanceScheduleListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - managed_instance_name: str, - start_stop_schedule_name: Union[str, _models.StartStopScheduleName], - **kwargs: Any - ) -> _models.StartStopManagedInstanceSchedule: - """Gets the managed instance's Start/Stop schedule. - - :param resource_group_name: The name of the resource group that 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 start_stop_schedule_name: Name of the managed instance Start/Stop schedule. "default" - Required. - :type start_stop_schedule_name: str or ~azure.mgmt.sql.models.StartStopScheduleName - :return: StartStopManagedInstanceSchedule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.StartStopManagedInstanceSchedule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - cls: ClsType[_models.StartStopManagedInstanceSchedule] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - start_stop_schedule_name=start_stop_schedule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("StartStopManagedInstanceSchedule", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - start_stop_schedule_name: Union[str, _models.StartStopScheduleName], - parameters: _models.StartStopManagedInstanceSchedule, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.StartStopManagedInstanceSchedule: - """Creates or updates the managed instance's Start/Stop schedule. - - :param resource_group_name: The name of the resource group that 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 start_stop_schedule_name: Name of the managed instance Start/Stop schedule. "default" - Required. - :type start_stop_schedule_name: str or ~azure.mgmt.sql.models.StartStopScheduleName - :param parameters: The requested managed instance Start/Stop schedule. Required. - :type parameters: ~azure.mgmt.sql.models.StartStopManagedInstanceSchedule - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: StartStopManagedInstanceSchedule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.StartStopManagedInstanceSchedule - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - start_stop_schedule_name: Union[str, _models.StartStopScheduleName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.StartStopManagedInstanceSchedule: - """Creates or updates the managed instance's Start/Stop schedule. - - :param resource_group_name: The name of the resource group that 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 start_stop_schedule_name: Name of the managed instance Start/Stop schedule. "default" - Required. - :type start_stop_schedule_name: str or ~azure.mgmt.sql.models.StartStopScheduleName - :param parameters: The requested managed instance Start/Stop schedule. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: StartStopManagedInstanceSchedule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.StartStopManagedInstanceSchedule - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - start_stop_schedule_name: Union[str, _models.StartStopScheduleName], - parameters: Union[_models.StartStopManagedInstanceSchedule, IO[bytes]], - **kwargs: Any - ) -> _models.StartStopManagedInstanceSchedule: - """Creates or updates the managed instance's Start/Stop schedule. - - :param resource_group_name: The name of the resource group that 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 start_stop_schedule_name: Name of the managed instance Start/Stop schedule. "default" - Required. - :type start_stop_schedule_name: str or ~azure.mgmt.sql.models.StartStopScheduleName - :param parameters: The requested managed instance Start/Stop schedule. Is either a - StartStopManagedInstanceSchedule type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.StartStopManagedInstanceSchedule or IO[bytes] - :return: StartStopManagedInstanceSchedule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.StartStopManagedInstanceSchedule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "StartStopManagedInstanceSchedule") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - start_stop_schedule_name=start_stop_schedule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("StartStopManagedInstanceSchedule", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( - self, - resource_group_name: str, - managed_instance_name: str, - start_stop_schedule_name: Union[str, _models.StartStopScheduleName], - **kwargs: Any - ) -> None: - """Deletes the managed instance's Start/Stop schedule. - - :param resource_group_name: The name of the resource group that 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 start_stop_schedule_name: Name of the managed instance Start/Stop schedule. "default" - Required. - :type start_stop_schedule_name: str or ~azure.mgmt.sql.models.StartStopScheduleName - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-08-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, - start_stop_schedule_name=start_stop_schedule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_subscription_usages_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_subscription_usages_operations.py deleted file mode 100644 index 044b11e21400..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_subscription_usages_operations.py +++ /dev/null @@ -1,175 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._subscription_usages_operations import build_get_request, build_list_by_location_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class SubscriptionUsagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`subscription_usages` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_location(self, location_name: str, **kwargs: Any) -> AsyncItemPaged["_models.SubscriptionUsage"]: - """Gets all subscription usage metrics in a given location. - - :param location_name: The name of the region where the resource is located. Required. - :type location_name: str - :return: An iterator like instance of either SubscriptionUsage or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SubscriptionUsage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SubscriptionUsageListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SubscriptionUsageListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, location_name: str, usage_name: str, **kwargs: Any) -> _models.SubscriptionUsage: - """Gets a subscription usage metric. - - :param location_name: The name of the region where the resource is located. Required. - :type location_name: str - :param usage_name: Name of usage metric to return. Required. - :type usage_name: str - :return: SubscriptionUsage or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SubscriptionUsage - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SubscriptionUsage] = kwargs.pop("cls", None) - - _request = build_get_request( - location_name=location_name, - usage_name=usage_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("SubscriptionUsage", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 55e3dda45ebc..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_synapse_link_workspaces_operations.py +++ /dev/null @@ -1,130 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._synapse_link_workspaces_operations import build_list_by_database_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class SynapseLinkWorkspacesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`synapse_link_workspaces` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.SynapseLinkWorkspace"]: - """Gets all synapselink workspaces 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 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 - :return: An iterator like instance of either SynapseLinkWorkspace or the result of - cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SynapseLinkWorkspace] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - cls: ClsType[_models.SynapseLinkWorkspaceListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SynapseLinkWorkspaceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) 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 deleted file mode 100644 index 47b63fcffc3c..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sync_agents_operations.py +++ /dev/null @@ -1,648 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._sync_agents_operations import ( - build_create_or_update_request, - build_delete_request, - build_generate_key_request, - build_get_request, - build_list_by_server_request, - build_list_linked_databases_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class SyncAgentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`sync_agents` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, sync_agent_name: str, **kwargs: Any - ) -> _models.SyncAgent: - """Gets a sync agent. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param sync_agent_name: The name of the sync agent. Required. - :type sync_agent_name: str - :return: SyncAgent or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SyncAgent - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncAgent] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - sync_agent_name=sync_agent_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("SyncAgent", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - sync_agent_name: str, - parameters: Union[_models.SyncAgent, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "SyncAgent") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - sync_agent_name=sync_agent_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - sync_agent_name: str, - parameters: _models.SyncAgent, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.SyncAgent]: - """Creates or updates a sync agent. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param sync_agent_name: The name of the sync agent. Required. - :type sync_agent_name: str - :param parameters: The requested sync agent resource state. Required. - :type parameters: ~azure.mgmt.sql.models.SyncAgent - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either SyncAgent or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncAgent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - sync_agent_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.SyncAgent]: - """Creates or updates a sync agent. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param sync_agent_name: The name of the sync agent. Required. - :type sync_agent_name: str - :param parameters: The requested sync agent resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either SyncAgent or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncAgent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - sync_agent_name: str, - parameters: Union[_models.SyncAgent, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.SyncAgent]: - """Creates or updates a sync agent. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param sync_agent_name: The name of the sync agent. Required. - :type sync_agent_name: str - :param parameters: The requested sync agent resource state. Is either a SyncAgent type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.SyncAgent or IO[bytes] - :return: An instance of AsyncLROPoller that returns either SyncAgent or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncAgent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SyncAgent] = 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, - sync_agent_name=sync_agent_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SyncAgent", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.SyncAgent].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.SyncAgent]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, server_name: str, sync_agent_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - sync_agent_name=sync_agent_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, server_name: str, sync_agent_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a sync agent. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param sync_agent_name: The name of the sync agent. Required. - :type sync_agent_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - sync_agent_name=sync_agent_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either SyncAgent or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncAgent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncAgentListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace_async - async def generate_key( - self, resource_group_name: str, server_name: str, sync_agent_name: str, **kwargs: Any - ) -> _models.SyncAgentKeyProperties: - """Generates a sync agent key. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param sync_agent_name: The name of the sync agent. Required. - :type sync_agent_name: str - :return: SyncAgentKeyProperties or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SyncAgentKeyProperties - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncAgentKeyProperties] = kwargs.pop("cls", None) - - _request = build_generate_key_request( - resource_group_name=resource_group_name, - server_name=server_name, - sync_agent_name=sync_agent_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("SyncAgentKeyProperties", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_linked_databases( - self, resource_group_name: str, server_name: str, sync_agent_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.SyncAgentLinkedDatabase"]: - """Lists databases linked to a sync agent. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param sync_agent_name: The name of the sync agent. Required. - :type sync_agent_name: str - :return: An iterator like instance of either SyncAgentLinkedDatabase or the result of - cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncAgentLinkedDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncAgentLinkedDatabaseListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_linked_databases_request( - resource_group_name=resource_group_name, - server_name=server_name, - sync_agent_name=sync_agent_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SyncAgentLinkedDatabaseListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sync_groups_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sync_groups_operations.py deleted file mode 100644 index b174069b8b45..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sync_groups_operations.py +++ /dev/null @@ -1,1239 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._sync_groups_operations import ( - build_cancel_sync_request, - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_database_request, - build_list_hub_schemas_request, - build_list_logs_request, - build_list_sync_database_ids_request, - build_refresh_hub_schema_request, - build_trigger_sync_request, - build_update_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class SyncGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`sync_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_sync_database_ids( - self, location_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.SyncDatabaseIdProperties"]: - """Gets a collection of sync database ids. - - :param location_name: The name of the region where the resource is located. Required. - :type location_name: str - :return: An iterator like instance of either SyncDatabaseIdProperties or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncDatabaseIdProperties] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncDatabaseIdListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_sync_database_ids_request( - location_name=location_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SyncDatabaseIdListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - async def _refresh_hub_schema_initial( - self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._refresh_hub_schema_initial( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_hub_schemas( - self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.SyncFullSchemaProperties"]: - """Gets a collection of hub database schemas. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database on which the sync group is hosted. Required. - :type database_name: str - :param sync_group_name: The name of the sync group. Required. - :type sync_group_name: str - :return: An iterator like instance of either SyncFullSchemaProperties or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncFullSchemaProperties] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncFullSchemaPropertiesListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @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 - ) -> AsyncItemPaged["_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 - :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", "2020-11-01-preview")) - cls: ClsType[_models.SyncGroupLogListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace_async - async def cancel_sync( - 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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_cancel_sync_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - sync_group_name=sync_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @distributed_trace_async - async def trigger_sync( - 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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_trigger_sync_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - sync_group_name=sync_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @distributed_trace_async - async def get( - self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any - ) -> _models.SyncGroup: - """Gets a sync group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database on which the sync group is hosted. Required. - :type database_name: str - :param sync_group_name: The name of the sync group. Required. - :type sync_group_name: str - :return: SyncGroup or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SyncGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncGroup] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - sync_group_name=sync_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - 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[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - parameters: Union[_models.SyncGroup, IO[bytes]], - **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. Is either a SyncGroup type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.SyncGroup or IO[bytes] - :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", "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) - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SyncGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.SyncGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.SyncGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any - ) -> 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. - :type resource_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 - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - parameters: Union[_models.SyncGroup, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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. Is either a SyncGroup type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.SyncGroup or IO[bytes] - :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", "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) - 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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SyncGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.SyncGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.SyncGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either SyncGroup or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SyncGroupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sync_members_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sync_members_operations.py deleted file mode 100644 index 42dd0f0f0c23..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sync_members_operations.py +++ /dev/null @@ -1,1032 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._sync_members_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_sync_group_request, - build_list_member_schemas_request, - build_refresh_member_schema_request, - build_update_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class SyncMembersOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`sync_members` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - sync_group_name: str, - sync_member_name: str, - **kwargs: Any - ) -> _models.SyncMember: - """Gets a sync member. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :return: SyncMember or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SyncMember - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncMember] = 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, - sync_member_name=sync_member_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("SyncMember", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - sync_member_name: str, - parameters: Union[_models.SyncMember, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "SyncMember") - - _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, - sync_member_name=sync_member_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - sync_member_name: str, - parameters: _models.SyncMember, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.SyncMember]: - """Creates or updates a sync member. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :param parameters: The requested sync member resource state. Required. - :type parameters: ~azure.mgmt.sql.models.SyncMember - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either SyncMember or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncMember] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - sync_member_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.SyncMember]: - """Creates or updates a sync member. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :param parameters: The requested sync member resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either SyncMember or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncMember] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - sync_member_name: str, - parameters: Union[_models.SyncMember, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.SyncMember]: - """Creates or updates a sync member. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :param parameters: The requested sync member resource state. Is either a SyncMember type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.SyncMember or IO[bytes] - :return: An instance of AsyncLROPoller that returns either SyncMember or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncMember] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SyncMember] = 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, - sync_member_name=sync_member_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SyncMember", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.SyncMember].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.SyncMember]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - sync_member_name: str, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - sync_member_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a sync member. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - sync_group_name=sync_group_name, - sync_member_name=sync_member_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - sync_member_name: str, - parameters: Union[_models.SyncMember, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "SyncMember") - - _request = build_update_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - sync_member_name: str, - parameters: _models.SyncMember, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.SyncMember]: - """Updates an existing sync member. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :param parameters: The requested sync member resource state. Required. - :type parameters: ~azure.mgmt.sql.models.SyncMember - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either SyncMember or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncMember] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - sync_member_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.SyncMember]: - """Updates an existing sync member. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :param parameters: The requested sync member resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either SyncMember or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncMember] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - sync_member_name: str, - parameters: Union[_models.SyncMember, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.SyncMember]: - """Updates an existing sync member. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :param parameters: The requested sync member resource state. Is either a SyncMember type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.SyncMember or IO[bytes] - :return: An instance of AsyncLROPoller that returns either SyncMember or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncMember] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SyncMember] = 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( - 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, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SyncMember", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.SyncMember].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.SyncMember]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_by_sync_group( - self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either SyncMember or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncMember] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncMemberListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @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 - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either SyncFullSchemaProperties or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncFullSchemaProperties] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncFullSchemaPropertiesListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - async def _refresh_member_schema_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - sync_member_name: str, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_refresh_member_schema_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_refresh_member_schema( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - sync_member_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Refreshes 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 - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._refresh_member_schema_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - sync_group_name=sync_group_name, - sync_member_name=sync_member_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_tde_certificates_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_tde_certificates_operations.py deleted file mode 100644 index 48ff54c5e5b9..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_tde_certificates_operations.py +++ /dev/null @@ -1,243 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -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 ..._utils.serialization import Deserializer, Serializer -from ...operations._tde_certificates_operations import build_create_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class TdeCertificatesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`tde_certificates` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - async def _create_initial( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.TdeCertificate, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "TdeCertificate") - - _request = build_create_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create( - self, - resource_group_name: str, - server_name: str, - parameters: _models.TdeCertificate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Creates a TDE certificate for a given server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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: The requested TDE certificate to be created or updated. Required. - :type parameters: ~azure.mgmt.sql.models.TdeCertificate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Creates a TDE certificate for a given server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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: The requested TDE certificate to be created or updated. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.TdeCertificate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Creates a TDE certificate for a given server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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: The requested TDE certificate to be created or updated. Is either a - TdeCertificate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.TdeCertificate or IO[bytes] - :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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[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._create_initial( - resource_group_name=resource_group_name, - server_name=server_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_time_zones_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_time_zones_operations.py deleted file mode 100644 index fb2bc11fcabb..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_time_zones_operations.py +++ /dev/null @@ -1,175 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._time_zones_operations import build_get_request, build_list_by_location_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class TimeZonesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`time_zones` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_location(self, location_name: str, **kwargs: Any) -> AsyncItemPaged["_models.TimeZone"]: - """Gets a list of managed instance time zones by location. - - :param location_name: Required. - :type location_name: str - :return: An iterator like instance of either TimeZone or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.TimeZone] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.TimeZoneListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("TimeZoneListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, location_name: str, time_zone_id: str, **kwargs: Any) -> _models.TimeZone: - """Gets a managed instance time zone. - - :param location_name: Required. - :type location_name: str - :param time_zone_id: Required. - :type time_zone_id: str - :return: TimeZone or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.TimeZone - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.TimeZone] = kwargs.pop("cls", None) - - _request = build_get_request( - location_name=location_name, - time_zone_id=time_zone_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("TimeZone", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_transparent_data_encryptions_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_transparent_data_encryptions_operations.py deleted file mode 100644 index e85f7b9d4fbf..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_transparent_data_encryptions_operations.py +++ /dev/null @@ -1,438 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._transparent_data_encryptions_operations import ( - build_create_or_update_request, - build_get_request, - build_list_by_database_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class TransparentDataEncryptionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`transparent_data_encryptions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> AsyncItemPaged["_models.LogicalDatabaseTransparentDataEncryption"]: - """Gets a list of the logical database's transparent data encryption. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the logical database for which the transparent data - encryption is defined. Required. - :type database_name: str - :return: An iterator like instance of either LogicalDatabaseTransparentDataEncryption or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.LogicalDatabaseTransparentDataEncryptionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("LogicalDatabaseTransparentDataEncryptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - server_name: str, - database_name: str, - tde_name: Union[str, _models.TransparentDataEncryptionName], - **kwargs: Any - ) -> _models.LogicalDatabaseTransparentDataEncryption: - """Gets a logical database's transparent data encryption. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the logical database for which the transparent data - encryption is defined. Required. - :type database_name: str - :param tde_name: The name of the transparent data encryption configuration. "current" Required. - :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName - :return: LogicalDatabaseTransparentDataEncryption or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - cls: ClsType[_models.LogicalDatabaseTransparentDataEncryption] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - tde_name=tde_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("LogicalDatabaseTransparentDataEncryption", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - tde_name: Union[str, _models.TransparentDataEncryptionName], - parameters: Union[_models.LogicalDatabaseTransparentDataEncryption, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "LogicalDatabaseTransparentDataEncryption") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - tde_name=tde_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - tde_name: Union[str, _models.TransparentDataEncryptionName], - parameters: _models.LogicalDatabaseTransparentDataEncryption, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.LogicalDatabaseTransparentDataEncryption]: - """Updates a logical database's transparent data encryption configuration. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the logical database for which the security alert policy is - defined. Required. - :type database_name: str - :param tde_name: The name of the transparent data encryption configuration. "current" Required. - :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName - :param parameters: The database transparent data encryption. Required. - :type parameters: ~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either - LogicalDatabaseTransparentDataEncryption or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - tde_name: Union[str, _models.TransparentDataEncryptionName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.LogicalDatabaseTransparentDataEncryption]: - """Updates a logical database's transparent data encryption configuration. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the logical database for which the security alert policy is - defined. Required. - :type database_name: str - :param tde_name: The name of the transparent data encryption configuration. "current" Required. - :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName - :param parameters: The database transparent data encryption. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either - LogicalDatabaseTransparentDataEncryption or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - tde_name: Union[str, _models.TransparentDataEncryptionName], - parameters: Union[_models.LogicalDatabaseTransparentDataEncryption, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.LogicalDatabaseTransparentDataEncryption]: - """Updates a logical database's transparent data encryption configuration. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the logical database for which the security alert policy is - defined. Required. - :type database_name: str - :param tde_name: The name of the transparent data encryption configuration. "current" Required. - :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName - :param parameters: The database transparent data encryption. Is either a - LogicalDatabaseTransparentDataEncryption type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption or IO[bytes] - :return: An instance of AsyncLROPoller that returns either - LogicalDatabaseTransparentDataEncryption or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption] - :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", "2022-08-01-preview")) - 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) - 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, - tde_name=tde_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize( - "LogicalDatabaseTransparentDataEncryption", pipeline_response.http_response - ) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.LogicalDatabaseTransparentDataEncryption].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.LogicalDatabaseTransparentDataEncryption]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 04e09943b289..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_usages_operations.py +++ /dev/null @@ -1,130 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -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.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._usages_operations import build_list_by_instance_pool_request -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class UsagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`usages` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_instance_pool( - self, resource_group_name: str, instance_pool_name: str, expand_children: Optional[bool] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.Usage"]: - """Gets all instance pool usage 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 instance_pool_name: The name of the instance pool to be retrieved. Required. - :type instance_pool_name: str - :param expand_children: Optional request parameter to include managed instance usages within - the instance pool. Default value is None. - :type expand_children: bool - :return: An iterator like instance of either Usage or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.Usage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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_pool_request( - resource_group_name=resource_group_name, - instance_pool_name=instance_pool_name, - subscription_id=self._config.subscription_id, - expand_children=expand_children, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("UsageListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_virtual_clusters_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_virtual_clusters_operations.py deleted file mode 100644 index 10d19bec2dde..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_virtual_clusters_operations.py +++ /dev/null @@ -1,663 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._virtual_clusters_operations import ( - build_delete_request, - build_get_request, - build_list_by_resource_group_request, - build_list_request, - build_update_dns_servers_request, - build_update_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class VirtualClustersOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`virtual_clusters` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_models.VirtualCluster"]: - """Gets a list of all virtualClusters in the subscription. - - :return: An iterator like instance of either VirtualCluster or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.VirtualCluster] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - cls: ClsType[_models.VirtualClusterListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualClusterListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, **kwargs: Any - ) -> AsyncItemPaged["_models.VirtualCluster"]: - """Gets a list of virtual clusters in a resource group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :return: An iterator like instance of either VirtualCluster or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.VirtualCluster] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - cls: ClsType[_models.VirtualClusterListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualClusterListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, resource_group_name: str, virtual_cluster_name: str, **kwargs: Any) -> _models.VirtualCluster: - """Gets a virtual cluster. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param virtual_cluster_name: The name of the virtual cluster. Required. - :type virtual_cluster_name: str - :return: VirtualCluster or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.VirtualCluster - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-05-01-preview")) - cls: ClsType[_models.VirtualCluster] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - virtual_cluster_name=virtual_cluster_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("VirtualCluster", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _delete_initial( - self, resource_group_name: str, virtual_cluster_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2022-05-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - virtual_cluster_name=virtual_cluster_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, virtual_cluster_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a virtual cluster. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param virtual_cluster_name: The name of the virtual cluster. Required. - :type virtual_cluster_name: str - :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", "2022-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_initial( - resource_group_name=resource_group_name, - virtual_cluster_name=virtual_cluster_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - virtual_cluster_name: str, - parameters: Union[_models.VirtualClusterUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2022-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "VirtualClusterUpdate") - - _request = build_update_request( - resource_group_name=resource_group_name, - virtual_cluster_name=virtual_cluster_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - virtual_cluster_name: str, - parameters: _models.VirtualClusterUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualCluster]: - """Updates an existing virtual cluster. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param virtual_cluster_name: The name of the virtual cluster. Required. - :type virtual_cluster_name: str - :param parameters: The requested virtual cluster resource state. Required. - :type parameters: ~azure.mgmt.sql.models.VirtualClusterUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualCluster or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.VirtualCluster] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - virtual_cluster_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualCluster]: - """Updates an existing virtual cluster. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param virtual_cluster_name: The name of the virtual cluster. Required. - :type virtual_cluster_name: str - :param parameters: The requested virtual cluster resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualCluster or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.VirtualCluster] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - virtual_cluster_name: str, - parameters: Union[_models.VirtualClusterUpdate, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualCluster]: - """Updates an existing virtual cluster. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param virtual_cluster_name: The name of the virtual cluster. Required. - :type virtual_cluster_name: str - :param parameters: The requested virtual cluster resource state. Is either a - VirtualClusterUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.VirtualClusterUpdate or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualCluster or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.VirtualCluster] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - 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) - 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( - resource_group_name=resource_group_name, - virtual_cluster_name=virtual_cluster_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualCluster", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.VirtualCluster].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.VirtualCluster]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_dns_servers_initial( - self, resource_group_name: str, virtual_cluster_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2022-05-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_update_dns_servers_request( - resource_group_name=resource_group_name, - virtual_cluster_name=virtual_cluster_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_update_dns_servers( - self, resource_group_name: str, virtual_cluster_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.UpdateVirtualClusterDnsServersOperation]: - """Synchronizes the DNS server settings used by the managed instances inside the given virtual - cluster. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param virtual_cluster_name: The name of the virtual cluster. Required. - :type virtual_cluster_name: str - :return: An instance of AsyncLROPoller that returns either - UpdateVirtualClusterDnsServersOperation or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.UpdateVirtualClusterDnsServersOperation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - 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) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_dns_servers_initial( - resource_group_name=resource_group_name, - virtual_cluster_name=virtual_cluster_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("UpdateVirtualClusterDnsServersOperation", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.UpdateVirtualClusterDnsServersOperation].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.UpdateVirtualClusterDnsServersOperation]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_virtual_network_rules_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_virtual_network_rules_operations.py deleted file mode 100644 index 146d69ad7b5c..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_virtual_network_rules_operations.py +++ /dev/null @@ -1,510 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._virtual_network_rules_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_server_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class VirtualNetworkRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`virtual_network_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, virtual_network_rule_name: str, **kwargs: Any - ) -> _models.VirtualNetworkRule: - """Gets a virtual network rule. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param virtual_network_rule_name: The name of the virtual network rule. Required. - :type virtual_network_rule_name: str - :return: VirtualNetworkRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.VirtualNetworkRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.VirtualNetworkRule] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - virtual_network_rule_name=virtual_network_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("VirtualNetworkRule", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - virtual_network_rule_name: str, - parameters: Union[_models.VirtualNetworkRule, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "VirtualNetworkRule") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - virtual_network_rule_name=virtual_network_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - virtual_network_rule_name: str, - parameters: _models.VirtualNetworkRule, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualNetworkRule]: - """Creates or updates an existing virtual network rule. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param virtual_network_rule_name: The name of the virtual network rule. Required. - :type virtual_network_rule_name: str - :param parameters: The requested virtual Network Rule Resource state. Required. - :type parameters: ~azure.mgmt.sql.models.VirtualNetworkRule - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualNetworkRule or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.VirtualNetworkRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - virtual_network_rule_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualNetworkRule]: - """Creates or updates an existing virtual network rule. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param virtual_network_rule_name: The name of the virtual network rule. Required. - :type virtual_network_rule_name: str - :param parameters: The requested virtual Network Rule Resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either VirtualNetworkRule or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.VirtualNetworkRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - virtual_network_rule_name: str, - parameters: Union[_models.VirtualNetworkRule, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualNetworkRule]: - """Creates or updates an existing virtual network rule. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param virtual_network_rule_name: The name of the virtual network rule. Required. - :type virtual_network_rule_name: str - :param parameters: The requested virtual Network Rule Resource state. Is either a - VirtualNetworkRule type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.VirtualNetworkRule or IO[bytes] - :return: An instance of AsyncLROPoller that returns either VirtualNetworkRule or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.VirtualNetworkRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualNetworkRule] = 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, - virtual_network_rule_name=virtual_network_rule_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualNetworkRule", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.VirtualNetworkRule].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.VirtualNetworkRule]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, server_name: str, virtual_network_rule_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - virtual_network_rule_name=virtual_network_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, server_name: str, virtual_network_rule_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes the virtual network rule with the given name. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param virtual_network_rule_name: The name of the virtual network rule. Required. - :type virtual_network_rule_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - virtual_network_rule_name=virtual_network_rule_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either VirtualNetworkRule or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.VirtualNetworkRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.VirtualNetworkRuleListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 7a32cff5ccfc..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_workload_classifiers_operations.py +++ /dev/null @@ -1,581 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._workload_classifiers_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_workload_group_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class WorkloadClassifiersOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`workload_classifiers` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - workload_group_name: str, - workload_classifier_name: str, - **kwargs: Any - ) -> _models.WorkloadClassifier: - """Gets a workload classifier. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 classifier - from. Required. - :type workload_group_name: str - :param workload_classifier_name: The name of the workload classifier. Required. - :type workload_classifier_name: str - :return: WorkloadClassifier or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.WorkloadClassifier - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.WorkloadClassifier] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - workload_group_name=workload_group_name, - workload_classifier_name=workload_classifier_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("WorkloadClassifier", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - workload_group_name: str, - workload_classifier_name: str, - parameters: Union[_models.WorkloadClassifier, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "WorkloadClassifier") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - workload_group_name=workload_group_name, - workload_classifier_name=workload_classifier_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - workload_group_name: str, - workload_classifier_name: str, - parameters: _models.WorkloadClassifier, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.WorkloadClassifier]: - """Creates or updates a workload classifier. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 classifier - from. Required. - :type workload_group_name: str - :param workload_classifier_name: The name of the workload classifier to create/update. - Required. - :type workload_classifier_name: str - :param parameters: The properties of the workload classifier. Required. - :type parameters: ~azure.mgmt.sql.models.WorkloadClassifier - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either WorkloadClassifier or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.WorkloadClassifier] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - workload_group_name: str, - workload_classifier_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.WorkloadClassifier]: - """Creates or updates a workload classifier. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 classifier - from. Required. - :type workload_group_name: str - :param workload_classifier_name: The name of the workload classifier to create/update. - Required. - :type workload_classifier_name: str - :param parameters: The properties of the workload classifier. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either WorkloadClassifier or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.WorkloadClassifier] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - workload_group_name: str, - workload_classifier_name: str, - parameters: Union[_models.WorkloadClassifier, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.WorkloadClassifier]: - """Creates or updates a workload classifier. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 classifier - from. Required. - :type workload_group_name: str - :param workload_classifier_name: The name of the workload classifier to create/update. - Required. - :type workload_classifier_name: str - :param parameters: The properties of the workload classifier. Is either a WorkloadClassifier - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.WorkloadClassifier or IO[bytes] - :return: An instance of AsyncLROPoller that returns either WorkloadClassifier or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.WorkloadClassifier] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.WorkloadClassifier] = 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, - workload_group_name=workload_group_name, - workload_classifier_name=workload_classifier_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("WorkloadClassifier", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.WorkloadClassifier].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.WorkloadClassifier]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - workload_group_name: str, - workload_classifier_name: str, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - workload_group_name=workload_group_name, - workload_classifier_name=workload_classifier_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, - resource_group_name: str, - server_name: str, - database_name: str, - workload_group_name: str, - workload_classifier_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a workload classifier. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 classifier - from. Required. - :type workload_group_name: str - :param workload_classifier_name: The name of the workload classifier to delete. Required. - :type workload_classifier_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - workload_group_name=workload_group_name, - workload_classifier_name=workload_classifier_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_by_workload_group( - self, resource_group_name: str, server_name: str, database_name: str, workload_group_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either WorkloadClassifier or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.WorkloadClassifier] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.WorkloadClassifierListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 79c54c9236b0..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_workload_groups_operations.py +++ /dev/null @@ -1,532 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._workload_groups_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_database_request, -) -from .._configuration import SqlManagementClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class WorkloadGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`workload_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, workload_group_name: str, **kwargs: Any - ) -> _models.WorkloadGroup: - """Gets a workload group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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. Required. - :type workload_group_name: str - :return: WorkloadGroup or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.WorkloadGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.WorkloadGroup] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - workload_group_name=workload_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("WorkloadGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - workload_group_name: str, - parameters: Union[_models.WorkloadGroup, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, "WorkloadGroup") - - _request = build_create_or_update_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await 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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - workload_group_name: str, - parameters: _models.WorkloadGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.WorkloadGroup]: - """Creates or updates 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. Required. - :type workload_group_name: str - :param parameters: The requested workload group state. Required. - :type parameters: ~azure.mgmt.sql.models.WorkloadGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either WorkloadGroup or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.WorkloadGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - workload_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.WorkloadGroup]: - """Creates or updates 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. Required. - :type workload_group_name: str - :param parameters: The requested workload group state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either WorkloadGroup or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.WorkloadGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - workload_group_name: str, - parameters: Union[_models.WorkloadGroup, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.WorkloadGroup]: - """Creates or updates 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. Required. - :type workload_group_name: str - :param parameters: The requested workload group state. Is either a WorkloadGroup type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.WorkloadGroup or IO[bytes] - :return: An instance of AsyncLROPoller that returns either WorkloadGroup or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.WorkloadGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.WorkloadGroup] = 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, - workload_group_name=workload_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("WorkloadGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.WorkloadGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.WorkloadGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, server_name: str, database_name: str, workload_group_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, server_name: str, database_name: str, workload_group_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes 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 to delete. Required. - :type workload_group_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - workload_group_name=workload_group_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> AsyncItemPaged["_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 - :return: An iterator like instance of either WorkloadGroup or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.WorkloadGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.WorkloadGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 dd7ea514048c..b18af86403f0 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -14,15 +14,18 @@ from ._patch import * # pylint: disable=unused-wildcard-import -from ._models_py3 import ( # type: ignore - AdministratorListResult, +from ._models import ( # type: ignore + AdministratorProperties, + AdvancedThreatProtectionProperties, Advisor, + AdvisorProperties, AutoPauseDelayTimeRange, AutomaticTuningOptions, AutomaticTuningServerOptions, - AzureADOnlyAuthListResult, + AutomaticTuningServerProperties, + AzureADOnlyAuthProperties, BackupShortTermRetentionPolicy, - BackupShortTermRetentionPolicyListResult, + BackupShortTermRetentionPolicyProperties, Baseline, BaselineAdjustedResult, BenchmarkReference, @@ -32,73 +35,78 @@ CheckNameAvailabilityResponse, CompleteDatabaseRestoreDefinition, CopyLongTermRetentionBackupParameters, + CopyLongTermRetentionBackupParametersProperties, CreateDatabaseRestorePointDefinition, DataMaskingPolicy, + DataMaskingPolicyProperties, DataMaskingRule, - DataMaskingRuleListResult, + DataMaskingRuleProperties, + DataSyncParticipantIdentity, + DataSyncParticipantUserAssignedIdentity, DataWarehouseUserActivities, - DataWarehouseUserActivitiesListResult, + DataWarehouseUserActivitiesProperties, Database, DatabaseAdvancedThreatProtection, - DatabaseAdvancedThreatProtectionListResult, DatabaseAutomaticTuning, + DatabaseAutomaticTuningProperties, DatabaseBlobAuditingPolicy, - DatabaseBlobAuditingPolicyListResult, + DatabaseBlobAuditingPolicyProperties, DatabaseColumn, - DatabaseColumnListResult, + DatabaseColumnProperties, DatabaseExtensions, + DatabaseExtensionsProperties, DatabaseIdentity, DatabaseKey, - DatabaseListResult, DatabaseOperation, - DatabaseOperationListResult, + DatabaseOperationProperties, + DatabaseProperties, DatabaseSchema, - DatabaseSchemaListResult, - DatabaseSecurityAlertListResult, DatabaseSecurityAlertPolicy, DatabaseSqlVulnerabilityAssessmentBaselineSet, - DatabaseSqlVulnerabilityAssessmentBaselineSetListResult, + DatabaseSqlVulnerabilityAssessmentBaselineSetProperties, DatabaseSqlVulnerabilityAssessmentRuleBaseline, DatabaseSqlVulnerabilityAssessmentRuleBaselineInput, + DatabaseSqlVulnerabilityAssessmentRuleBaselineInputProperties, DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput, - DatabaseSqlVulnerabilityAssessmentRuleBaselineListResult, + DatabaseSqlVulnerabilityAssessmentRuleBaselineListInputProperties, + DatabaseSqlVulnerabilityAssessmentRuleBaselineProperties, DatabaseTable, - DatabaseTableListResult, + DatabaseTableProperties, DatabaseUpdate, + DatabaseUpdateProperties, DatabaseUsage, - DatabaseUsageListResult, + DatabaseUsageProperties, DatabaseUserIdentity, DatabaseVulnerabilityAssessment, - DatabaseVulnerabilityAssessmentListResult, + DatabaseVulnerabilityAssessmentProperties, DatabaseVulnerabilityAssessmentRuleBaseline, DatabaseVulnerabilityAssessmentRuleBaselineItem, + DatabaseVulnerabilityAssessmentRuleBaselineProperties, + DatabaseVulnerabilityAssessmentScanExportProperties, DatabaseVulnerabilityAssessmentScansExport, DeletedServer, - DeletedServerListResult, + DeletedServerProperties, DistributedAvailabilityGroup, DistributedAvailabilityGroupDatabase, + DistributedAvailabilityGroupProperties, DistributedAvailabilityGroupSetRole, DistributedAvailabilityGroupsFailoverRequest, - DistributedAvailabilityGroupsListResult, EditionCapability, ElasticPool, - ElasticPoolActivity, - ElasticPoolActivityListResult, - ElasticPoolDatabaseActivity, - ElasticPoolDatabaseActivityListResult, ElasticPoolEditionCapability, - ElasticPoolListResult, ElasticPoolOperation, - ElasticPoolOperationListResult, + ElasticPoolOperationProperties, ElasticPoolPerDatabaseMaxPerformanceLevelCapability, ElasticPoolPerDatabaseMinPerformanceLevelCapability, ElasticPoolPerDatabaseSettings, ElasticPoolPerformanceLevelCapability, + ElasticPoolProperties, ElasticPoolUpdate, + ElasticPoolUpdateProperties, EncryptionProtector, - EncryptionProtectorListResult, + EncryptionProtectorProperties, EndpointCertificate, - EndpointCertificateListResult, + EndpointCertificateProperties, EndpointDependency, EndpointDetail, ErrorAdditionalInfo, @@ -106,187 +114,191 @@ ErrorResponse, ExportDatabaseDefinition, ExtendedDatabaseBlobAuditingPolicy, - ExtendedDatabaseBlobAuditingPolicyListResult, + ExtendedDatabaseBlobAuditingPolicyProperties, ExtendedServerBlobAuditingPolicy, - ExtendedServerBlobAuditingPolicyListResult, + ExtendedServerBlobAuditingPolicyProperties, FailoverGroup, - FailoverGroupListResult, + FailoverGroupProperties, FailoverGroupReadOnlyEndpoint, FailoverGroupReadWriteEndpoint, FailoverGroupUpdate, + FailoverGroupUpdateProperties, FirewallRule, FirewallRuleList, - FirewallRuleListResult, + FreeLimitExhaustionBehaviorCapability, GeoBackupPolicy, - GeoBackupPolicyListResult, + GeoBackupPolicyProperties, IPv6FirewallRule, - IPv6FirewallRuleListResult, + IPv6ServerFirewallRuleProperties, ImportExistingDatabaseDefinition, - ImportExportExtensionsOperationListResult, ImportExportExtensionsOperationResult, + ImportExportExtensionsOperationResultProperties, ImportExportOperationResult, + ImportExportOperationResultProperties, ImportNewDatabaseDefinition, InstanceFailoverGroup, - InstanceFailoverGroupListResult, + InstanceFailoverGroupProperties, InstanceFailoverGroupReadOnlyEndpoint, InstanceFailoverGroupReadWriteEndpoint, InstancePool, InstancePoolEditionCapability, InstancePoolFamilyCapability, - InstancePoolListResult, + InstancePoolOperation, + InstancePoolOperationProperties, + InstancePoolProperties, InstancePoolUpdate, InstancePoolVcoresCapability, Job, JobAgent, - JobAgentListResult, + JobAgentEditionCapability, + JobAgentIdentity, + JobAgentProperties, + JobAgentServiceLevelObjectiveCapability, JobAgentUpdate, + JobAgentUserAssignedIdentity, + JobAgentVersionCapability, JobCredential, - JobCredentialListResult, + JobCredentialProperties, JobExecution, - JobExecutionListResult, + JobExecutionProperties, JobExecutionTarget, - JobListResult, JobPrivateEndpoint, - JobPrivateEndpointListResult, + JobPrivateEndpointProperties, + JobProperties, JobSchedule, JobStep, JobStepAction, JobStepExecutionOptions, - JobStepListResult, JobStepOutput, + JobStepProperties, JobTarget, JobTargetGroup, - JobTargetGroupListResult, + JobTargetGroupProperties, JobVersion, - JobVersionListResult, LedgerDigestUploads, - LedgerDigestUploadsListResult, + LedgerDigestUploadsProperties, LicenseTypeCapability, LocationCapabilities, LogSizeCapability, LogicalDatabaseTransparentDataEncryption, - LogicalDatabaseTransparentDataEncryptionListResult, - LogicalServerAdvancedThreatProtectionListResult, - LogicalServerSecurityAlertPolicyListResult, LongTermRetentionBackup, - LongTermRetentionBackupListResult, LongTermRetentionBackupOperationResult, + LongTermRetentionBackupProperties, + LongTermRetentionOperationResultProperties, LongTermRetentionPolicy, - LongTermRetentionPolicyListResult, + LongTermRetentionPolicyProperties, MaintenanceConfigurationCapability, MaintenanceWindowOptions, + MaintenanceWindowOptionsProperties, MaintenanceWindowTimeRange, MaintenanceWindows, + MaintenanceWindowsProperties, ManagedBackupShortTermRetentionPolicy, - ManagedBackupShortTermRetentionPolicyListResult, + ManagedBackupShortTermRetentionPolicyProperties, ManagedDatabase, ManagedDatabaseAdvancedThreatProtection, - ManagedDatabaseAdvancedThreatProtectionListResult, - ManagedDatabaseListResult, + ManagedDatabaseExtendedAccessibilityInfo, ManagedDatabaseMoveDefinition, - ManagedDatabaseMoveOperationListResult, ManagedDatabaseMoveOperationResult, + ManagedDatabaseMoveOperationResultProperties, + ManagedDatabaseProperties, ManagedDatabaseRestoreDetailsBackupSetProperties, + ManagedDatabaseRestoreDetailsProperties, ManagedDatabaseRestoreDetailsResult, ManagedDatabaseRestoreDetailsUnrestorableFileProperties, ManagedDatabaseSecurityAlertPolicy, - ManagedDatabaseSecurityAlertPolicyListResult, ManagedDatabaseStartMoveDefinition, ManagedDatabaseUpdate, ManagedInstance, ManagedInstanceAdministrator, - ManagedInstanceAdministratorListResult, + ManagedInstanceAdministratorProperties, ManagedInstanceAdvancedThreatProtection, - ManagedInstanceAdvancedThreatProtectionListResult, - ManagedInstanceAzureADOnlyAuthListResult, + ManagedInstanceAzureADOnlyAuthProperties, ManagedInstanceAzureADOnlyAuthentication, ManagedInstanceDtc, - ManagedInstanceDtcListResult, + ManagedInstanceDtcProperties, ManagedInstanceDtcSecuritySettings, ManagedInstanceDtcTransactionManagerCommunicationSettings, ManagedInstanceEditionCapability, ManagedInstanceEncryptionProtector, - ManagedInstanceEncryptionProtectorListResult, + ManagedInstanceEncryptionProtectorProperties, ManagedInstanceExternalAdministrator, ManagedInstanceFamilyCapability, ManagedInstanceKey, - ManagedInstanceKeyListResult, - ManagedInstanceListResult, + ManagedInstanceKeyProperties, ManagedInstanceLongTermRetentionBackup, - ManagedInstanceLongTermRetentionBackupListResult, + ManagedInstanceLongTermRetentionBackupProperties, ManagedInstanceLongTermRetentionPolicy, - ManagedInstanceLongTermRetentionPolicyListResult, + ManagedInstanceLongTermRetentionPolicyProperties, ManagedInstanceMaintenanceConfigurationCapability, ManagedInstanceOperation, - ManagedInstanceOperationListResult, ManagedInstanceOperationParametersPair, + ManagedInstanceOperationProperties, ManagedInstanceOperationSteps, ManagedInstancePairInfo, ManagedInstancePecProperty, ManagedInstancePrivateEndpointConnection, - ManagedInstancePrivateEndpointConnectionListResult, ManagedInstancePrivateEndpointConnectionProperties, ManagedInstancePrivateEndpointProperty, ManagedInstancePrivateLink, - ManagedInstancePrivateLinkListResult, ManagedInstancePrivateLinkProperties, ManagedInstancePrivateLinkServiceConnectionStateProperty, + ManagedInstanceProperties, ManagedInstanceQuery, - ManagedInstanceQueryStatistics, ManagedInstanceUpdate, + ManagedInstanceValidateAzureKeyVaultEncryptionKeyRequest, ManagedInstanceVcoresCapability, ManagedInstanceVersionCapability, ManagedInstanceVulnerabilityAssessment, - ManagedInstanceVulnerabilityAssessmentListResult, + ManagedInstanceVulnerabilityAssessmentProperties, ManagedLedgerDigestUploads, - ManagedLedgerDigestUploadsListResult, + ManagedLedgerDigestUploadsProperties, ManagedServerDnsAlias, ManagedServerDnsAliasAcquisition, ManagedServerDnsAliasCreation, - ManagedServerDnsAliasListResult, + ManagedServerDnsAliasProperties, ManagedServerSecurityAlertPolicy, - ManagedServerSecurityAlertPolicyListResult, ManagedTransparentDataEncryption, - ManagedTransparentDataEncryptionListResult, + ManagedTransparentDataEncryptionProperties, + MaxLimitRangeCapability, MaxSizeCapability, MaxSizeRangeCapability, - Metric, - MetricAvailability, - MetricDefinition, - MetricDefinitionListResult, - MetricListResult, - MetricName, - MetricValue, MinCapacityCapability, + NSPConfigAccessRule, + NSPConfigAccessRuleProperties, + NSPConfigAssociation, + NSPConfigNetworkSecurityPerimeterRule, + NSPConfigPerimeter, + NSPConfigProfile, + NSPProvisioningIssue, + NSPProvisioningIssueProperties, Name, NetworkIsolationSettings, + NetworkSecurityPerimeterConfiguration, + NetworkSecurityPerimeterConfigurationProperties, Operation, OperationDisplay, - OperationImpact, - OperationListResult, OutboundEnvironmentEndpoint, - OutboundEnvironmentEndpointCollection, OutboundFirewallRule, - OutboundFirewallRuleListResult, + OutboundFirewallRuleProperties, PartnerInfo, PartnerRegionInfo, + PerDatabaseAutoPauseDelayTimeRange, PerformanceLevelCapability, PhaseDetails, PrivateEndpointConnection, - PrivateEndpointConnectionListResult, PrivateEndpointConnectionProperties, PrivateEndpointConnectionRequestStatus, PrivateEndpointProperty, PrivateLinkResource, - PrivateLinkResourceListResult, PrivateLinkResourceProperties, PrivateLinkServiceConnectionStateProperty, ProxyResource, ProxyResourceWithWritableName, QueryCheck, QueryMetricInterval, - QueryMetricIntervalAutoGenerated, QueryMetricProperties, + QueryProperties, QueryStatistics, QueryStatisticsProperties, ReadScaleCapability, @@ -295,148 +307,152 @@ RecommendedActionImpactRecord, RecommendedActionImplementationInfo, RecommendedActionMetricInfo, + RecommendedActionProperties, RecommendedActionStateInfo, RecommendedSensitivityLabelUpdate, RecommendedSensitivityLabelUpdateList, + RecommendedSensitivityLabelUpdateProperties, RecoverableDatabase, - RecoverableDatabaseListResult, + RecoverableDatabaseProperties, RecoverableManagedDatabase, - RecoverableManagedDatabaseListResult, + RecoverableManagedDatabaseProperties, RefreshExternalGovernanceStatusOperationResult, RefreshExternalGovernanceStatusOperationResultMI, + RefreshExternalGovernanceStatusOperationResultProperties, + RefreshExternalGovernanceStatusOperationResultPropertiesMI, Remediation, ReplicationLink, - ReplicationLinkListResult, + ReplicationLinkProperties, ReplicationLinkUpdate, + ReplicationLinkUpdateProperties, Resource, ResourceIdentity, ResourceMoveDefinition, ResourceWithWritableName, RestorableDroppedDatabase, - RestorableDroppedDatabaseListResult, + RestorableDroppedDatabaseProperties, RestorableDroppedManagedDatabase, - RestorableDroppedManagedDatabaseListResult, + RestorableDroppedManagedDatabaseProperties, RestorePoint, - RestorePointListResult, - SQLVulnerabilityAssessmentScanListResult, + RestorePointProperties, ScheduleItem, + SecurityAlertPolicyProperties, + SecurityAlertsPolicyProperties, SecurityEvent, - SecurityEventCollection, + SecurityEventProperties, SecurityEventSqlInjectionAdditionalProperties, - SecurityEventsFilterParameters, SensitivityLabel, - SensitivityLabelListResult, + SensitivityLabelProperties, SensitivityLabelUpdate, SensitivityLabelUpdateList, + SensitivityLabelUpdateProperties, Server, ServerAdvancedThreatProtection, ServerAutomaticTuning, ServerAzureADAdministrator, ServerAzureADOnlyAuthentication, ServerBlobAuditingPolicy, - ServerBlobAuditingPolicyListResult, - ServerCommunicationLink, - ServerCommunicationLinkListResult, + ServerBlobAuditingPolicyProperties, ServerConfigurationOption, - ServerConfigurationOptionListResult, + ServerConfigurationOptionProperties, ServerConnectionPolicy, - ServerConnectionPolicyListResult, - ServerDevOpsAuditSettingsListResult, + ServerConnectionPolicyProperties, + ServerDevOpsAuditSettingsProperties, ServerDevOpsAuditingSettings, ServerDnsAlias, ServerDnsAliasAcquisition, - ServerDnsAliasListResult, + ServerDnsAliasProperties, ServerExternalAdministrator, + ServerFirewallRuleProperties, ServerInfo, ServerKey, - ServerKeyListResult, - ServerListResult, + ServerKeyProperties, ServerOperation, - ServerOperationListResult, + ServerOperationProperties, ServerPrivateEndpointConnection, + ServerProperties, ServerSecurityAlertPolicy, ServerTrustCertificate, - ServerTrustCertificatesListResult, + ServerTrustCertificateProperties, ServerTrustGroup, - ServerTrustGroupListResult, + ServerTrustGroupProperties, ServerUpdate, ServerUsage, - ServerUsageListResult, + ServerUsageProperties, ServerVersionCapability, ServerVulnerabilityAssessment, - ServerVulnerabilityAssessmentListResult, - ServiceObjective, + ServerVulnerabilityAssessmentProperties, ServiceObjectiveCapability, - ServiceObjectiveListResult, ServicePrincipal, Sku, - SloUsageMetric, SqlAgentConfiguration, + SqlAgentConfigurationProperties, SqlVulnerabilityAssessment, - SqlVulnerabilityAssessmentListResult, + SqlVulnerabilityAssessmentPolicyProperties, SqlVulnerabilityAssessmentScanError, SqlVulnerabilityAssessmentScanRecord, - SqlVulnerabilityAssessmentScanRecordListResult, + SqlVulnerabilityAssessmentScanRecordProperties, + SqlVulnerabilityAssessmentScanResultProperties, SqlVulnerabilityAssessmentScanResults, StartStopManagedInstanceSchedule, - StartStopManagedInstanceScheduleListResult, + StartStopManagedInstanceScheduleProperties, StorageCapability, SubscriptionUsage, - SubscriptionUsageListResult, + SubscriptionUsageProperties, SynapseLinkWorkspace, SynapseLinkWorkspaceInfoProperties, - SynapseLinkWorkspaceListResult, + SynapseLinkWorkspaceProperties, SyncAgent, SyncAgentKeyProperties, SyncAgentLinkedDatabase, - SyncAgentLinkedDatabaseListResult, - SyncAgentListResult, - SyncDatabaseIdListResult, + SyncAgentLinkedDatabaseProperties, + SyncAgentProperties, SyncDatabaseIdProperties, SyncFullSchemaProperties, - SyncFullSchemaPropertiesListResult, SyncFullSchemaTable, SyncFullSchemaTableColumn, SyncGroup, - SyncGroupListResult, - SyncGroupLogListResult, SyncGroupLogProperties, + SyncGroupProperties, SyncGroupSchema, SyncGroupSchemaTable, SyncGroupSchemaTableColumn, SyncMember, - SyncMemberListResult, + SyncMemberProperties, SystemData, TdeCertificate, + TdeCertificateProperties, TimeZone, - TimeZoneListResult, + TimeZoneProperties, TopQueries, - TopQueriesListResult, TrackedResource, + TransparentDataEncryptionProperties, UpdateLongTermRetentionBackupParameters, + UpdateLongTermRetentionBackupParametersProperties, UpdateVirtualClusterDnsServersOperation, UpsertManagedServerOperationParameters, - UpsertManagedServerOperationStep, + UpsertManagedServerOperationStepWithEstimatesAndDuration, Usage, - UsageListResult, UserIdentity, VaRule, VirtualCluster, - VirtualClusterListResult, + VirtualClusterDnsServersProperties, + VirtualClusterProperties, VirtualClusterUpdate, VirtualNetworkRule, - VirtualNetworkRuleListResult, + VirtualNetworkRuleProperties, VulnerabilityAssessmentRecurringScansProperties, VulnerabilityAssessmentScanError, VulnerabilityAssessmentScanRecord, - VulnerabilityAssessmentScanRecordListResult, + VulnerabilityAssessmentScanRecordProperties, WorkloadClassifier, - WorkloadClassifierListResult, + WorkloadClassifierProperties, WorkloadGroup, - WorkloadGroupListResult, + WorkloadGroupProperties, + ZonePinningCapability, ) -from ._sql_management_client_enums import ( # type: ignore +from ._enums import ( # type: ignore AdministratorName, AdministratorType, AdvancedThreatProtectionName, @@ -463,14 +479,18 @@ CapabilityStatus, CatalogCollationType, CheckNameAvailabilityReason, + CheckNameAvailabilityResourceType, + ClientClassificationSource, ColumnDataType, ConnectionPolicyName, CreateMode, CreatedByType, DNSRefreshOperationStatus, DataMaskingFunction, + DataMaskingPolicyName, DataMaskingRuleState, DataMaskingState, + DataSyncParticipantIdentityType, DataWarehouseUserActivityName, DatabaseIdentityType, DatabaseKeyType, @@ -485,23 +505,25 @@ ElasticPoolLicenseType, ElasticPoolState, EncryptionProtectorName, + ErrorType, ExternalGovernanceStatus, FailoverGroupDatabasesSecondaryType, FailoverGroupReplicationRole, FailoverModeType, FailoverType, FreeLimitExhaustionBehavior, - FreemiumType, GeoBackupPolicyName, GeoBackupPolicyState, HybridSecondaryUsage, HybridSecondaryUsageDetected, IdentityType, ImplementationMethod, + InaccessibilityReason, InstanceFailoverGroupReplicationRole, InstancePoolLicenseType, InstanceRole, IsRetryable, + JobAgentIdentityType, JobAgentState, JobExecutionLifecycle, JobScheduleType, @@ -536,7 +558,7 @@ PauseDelayTimeUnit, PerformanceLevelUnit, Phase, - PrimaryAggregationType, + PricingModel, PrincipalType, PrivateEndpointProvisioningState, PrivateLinkServiceConnectionStateActionsRequire, @@ -581,7 +603,6 @@ ServerPublicNetworkAccessFlag, ServerTrustGroupPropertiesTrustScopesItem, ServerWorkspaceFeature, - ServiceObjectiveName, ServicePrincipalType, SetLegalHoldImmutability, ShortTermRetentionPolicyName, @@ -603,29 +624,32 @@ TimeBasedImmutability, TimeBasedImmutabilityMode, TransparentDataEncryptionName, + TransparentDataEncryptionScanState, TransparentDataEncryptionState, - UnitDefinitionType, - UnitType, - UpsertManagedServerOperationStepStatus, + UpsertManagedServerOperationStepWithEstimatesAndDurationStatus, VirtualNetworkRuleState, VulnerabilityAssessmentName, VulnerabilityAssessmentPolicyBaselineName, VulnerabilityAssessmentScanState, VulnerabilityAssessmentScanTriggerType, + VulnerabilityAssessmentSystemDatabaseName, ) from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ - "AdministratorListResult", + "AdministratorProperties", + "AdvancedThreatProtectionProperties", "Advisor", + "AdvisorProperties", "AutoPauseDelayTimeRange", "AutomaticTuningOptions", "AutomaticTuningServerOptions", - "AzureADOnlyAuthListResult", + "AutomaticTuningServerProperties", + "AzureADOnlyAuthProperties", "BackupShortTermRetentionPolicy", - "BackupShortTermRetentionPolicyListResult", + "BackupShortTermRetentionPolicyProperties", "Baseline", "BaselineAdjustedResult", "BenchmarkReference", @@ -635,73 +659,78 @@ "CheckNameAvailabilityResponse", "CompleteDatabaseRestoreDefinition", "CopyLongTermRetentionBackupParameters", + "CopyLongTermRetentionBackupParametersProperties", "CreateDatabaseRestorePointDefinition", "DataMaskingPolicy", + "DataMaskingPolicyProperties", "DataMaskingRule", - "DataMaskingRuleListResult", + "DataMaskingRuleProperties", + "DataSyncParticipantIdentity", + "DataSyncParticipantUserAssignedIdentity", "DataWarehouseUserActivities", - "DataWarehouseUserActivitiesListResult", + "DataWarehouseUserActivitiesProperties", "Database", "DatabaseAdvancedThreatProtection", - "DatabaseAdvancedThreatProtectionListResult", "DatabaseAutomaticTuning", + "DatabaseAutomaticTuningProperties", "DatabaseBlobAuditingPolicy", - "DatabaseBlobAuditingPolicyListResult", + "DatabaseBlobAuditingPolicyProperties", "DatabaseColumn", - "DatabaseColumnListResult", + "DatabaseColumnProperties", "DatabaseExtensions", + "DatabaseExtensionsProperties", "DatabaseIdentity", "DatabaseKey", - "DatabaseListResult", "DatabaseOperation", - "DatabaseOperationListResult", + "DatabaseOperationProperties", + "DatabaseProperties", "DatabaseSchema", - "DatabaseSchemaListResult", - "DatabaseSecurityAlertListResult", "DatabaseSecurityAlertPolicy", "DatabaseSqlVulnerabilityAssessmentBaselineSet", - "DatabaseSqlVulnerabilityAssessmentBaselineSetListResult", + "DatabaseSqlVulnerabilityAssessmentBaselineSetProperties", "DatabaseSqlVulnerabilityAssessmentRuleBaseline", "DatabaseSqlVulnerabilityAssessmentRuleBaselineInput", + "DatabaseSqlVulnerabilityAssessmentRuleBaselineInputProperties", "DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput", - "DatabaseSqlVulnerabilityAssessmentRuleBaselineListResult", + "DatabaseSqlVulnerabilityAssessmentRuleBaselineListInputProperties", + "DatabaseSqlVulnerabilityAssessmentRuleBaselineProperties", "DatabaseTable", - "DatabaseTableListResult", + "DatabaseTableProperties", "DatabaseUpdate", + "DatabaseUpdateProperties", "DatabaseUsage", - "DatabaseUsageListResult", + "DatabaseUsageProperties", "DatabaseUserIdentity", "DatabaseVulnerabilityAssessment", - "DatabaseVulnerabilityAssessmentListResult", + "DatabaseVulnerabilityAssessmentProperties", "DatabaseVulnerabilityAssessmentRuleBaseline", "DatabaseVulnerabilityAssessmentRuleBaselineItem", + "DatabaseVulnerabilityAssessmentRuleBaselineProperties", + "DatabaseVulnerabilityAssessmentScanExportProperties", "DatabaseVulnerabilityAssessmentScansExport", "DeletedServer", - "DeletedServerListResult", + "DeletedServerProperties", "DistributedAvailabilityGroup", "DistributedAvailabilityGroupDatabase", + "DistributedAvailabilityGroupProperties", "DistributedAvailabilityGroupSetRole", "DistributedAvailabilityGroupsFailoverRequest", - "DistributedAvailabilityGroupsListResult", "EditionCapability", "ElasticPool", - "ElasticPoolActivity", - "ElasticPoolActivityListResult", - "ElasticPoolDatabaseActivity", - "ElasticPoolDatabaseActivityListResult", "ElasticPoolEditionCapability", - "ElasticPoolListResult", "ElasticPoolOperation", - "ElasticPoolOperationListResult", + "ElasticPoolOperationProperties", "ElasticPoolPerDatabaseMaxPerformanceLevelCapability", "ElasticPoolPerDatabaseMinPerformanceLevelCapability", "ElasticPoolPerDatabaseSettings", "ElasticPoolPerformanceLevelCapability", + "ElasticPoolProperties", "ElasticPoolUpdate", + "ElasticPoolUpdateProperties", "EncryptionProtector", - "EncryptionProtectorListResult", + "EncryptionProtectorProperties", "EndpointCertificate", - "EndpointCertificateListResult", + "EndpointCertificateProperties", "EndpointDependency", "EndpointDetail", "ErrorAdditionalInfo", @@ -709,187 +738,191 @@ "ErrorResponse", "ExportDatabaseDefinition", "ExtendedDatabaseBlobAuditingPolicy", - "ExtendedDatabaseBlobAuditingPolicyListResult", + "ExtendedDatabaseBlobAuditingPolicyProperties", "ExtendedServerBlobAuditingPolicy", - "ExtendedServerBlobAuditingPolicyListResult", + "ExtendedServerBlobAuditingPolicyProperties", "FailoverGroup", - "FailoverGroupListResult", + "FailoverGroupProperties", "FailoverGroupReadOnlyEndpoint", "FailoverGroupReadWriteEndpoint", "FailoverGroupUpdate", + "FailoverGroupUpdateProperties", "FirewallRule", "FirewallRuleList", - "FirewallRuleListResult", + "FreeLimitExhaustionBehaviorCapability", "GeoBackupPolicy", - "GeoBackupPolicyListResult", + "GeoBackupPolicyProperties", "IPv6FirewallRule", - "IPv6FirewallRuleListResult", + "IPv6ServerFirewallRuleProperties", "ImportExistingDatabaseDefinition", - "ImportExportExtensionsOperationListResult", "ImportExportExtensionsOperationResult", + "ImportExportExtensionsOperationResultProperties", "ImportExportOperationResult", + "ImportExportOperationResultProperties", "ImportNewDatabaseDefinition", "InstanceFailoverGroup", - "InstanceFailoverGroupListResult", + "InstanceFailoverGroupProperties", "InstanceFailoverGroupReadOnlyEndpoint", "InstanceFailoverGroupReadWriteEndpoint", "InstancePool", "InstancePoolEditionCapability", "InstancePoolFamilyCapability", - "InstancePoolListResult", + "InstancePoolOperation", + "InstancePoolOperationProperties", + "InstancePoolProperties", "InstancePoolUpdate", "InstancePoolVcoresCapability", "Job", "JobAgent", - "JobAgentListResult", + "JobAgentEditionCapability", + "JobAgentIdentity", + "JobAgentProperties", + "JobAgentServiceLevelObjectiveCapability", "JobAgentUpdate", + "JobAgentUserAssignedIdentity", + "JobAgentVersionCapability", "JobCredential", - "JobCredentialListResult", + "JobCredentialProperties", "JobExecution", - "JobExecutionListResult", + "JobExecutionProperties", "JobExecutionTarget", - "JobListResult", "JobPrivateEndpoint", - "JobPrivateEndpointListResult", + "JobPrivateEndpointProperties", + "JobProperties", "JobSchedule", "JobStep", "JobStepAction", "JobStepExecutionOptions", - "JobStepListResult", "JobStepOutput", + "JobStepProperties", "JobTarget", "JobTargetGroup", - "JobTargetGroupListResult", + "JobTargetGroupProperties", "JobVersion", - "JobVersionListResult", "LedgerDigestUploads", - "LedgerDigestUploadsListResult", + "LedgerDigestUploadsProperties", "LicenseTypeCapability", "LocationCapabilities", "LogSizeCapability", "LogicalDatabaseTransparentDataEncryption", - "LogicalDatabaseTransparentDataEncryptionListResult", - "LogicalServerAdvancedThreatProtectionListResult", - "LogicalServerSecurityAlertPolicyListResult", "LongTermRetentionBackup", - "LongTermRetentionBackupListResult", "LongTermRetentionBackupOperationResult", + "LongTermRetentionBackupProperties", + "LongTermRetentionOperationResultProperties", "LongTermRetentionPolicy", - "LongTermRetentionPolicyListResult", + "LongTermRetentionPolicyProperties", "MaintenanceConfigurationCapability", "MaintenanceWindowOptions", + "MaintenanceWindowOptionsProperties", "MaintenanceWindowTimeRange", "MaintenanceWindows", + "MaintenanceWindowsProperties", "ManagedBackupShortTermRetentionPolicy", - "ManagedBackupShortTermRetentionPolicyListResult", + "ManagedBackupShortTermRetentionPolicyProperties", "ManagedDatabase", "ManagedDatabaseAdvancedThreatProtection", - "ManagedDatabaseAdvancedThreatProtectionListResult", - "ManagedDatabaseListResult", + "ManagedDatabaseExtendedAccessibilityInfo", "ManagedDatabaseMoveDefinition", - "ManagedDatabaseMoveOperationListResult", "ManagedDatabaseMoveOperationResult", + "ManagedDatabaseMoveOperationResultProperties", + "ManagedDatabaseProperties", "ManagedDatabaseRestoreDetailsBackupSetProperties", + "ManagedDatabaseRestoreDetailsProperties", "ManagedDatabaseRestoreDetailsResult", "ManagedDatabaseRestoreDetailsUnrestorableFileProperties", "ManagedDatabaseSecurityAlertPolicy", - "ManagedDatabaseSecurityAlertPolicyListResult", "ManagedDatabaseStartMoveDefinition", "ManagedDatabaseUpdate", "ManagedInstance", "ManagedInstanceAdministrator", - "ManagedInstanceAdministratorListResult", + "ManagedInstanceAdministratorProperties", "ManagedInstanceAdvancedThreatProtection", - "ManagedInstanceAdvancedThreatProtectionListResult", - "ManagedInstanceAzureADOnlyAuthListResult", + "ManagedInstanceAzureADOnlyAuthProperties", "ManagedInstanceAzureADOnlyAuthentication", "ManagedInstanceDtc", - "ManagedInstanceDtcListResult", + "ManagedInstanceDtcProperties", "ManagedInstanceDtcSecuritySettings", "ManagedInstanceDtcTransactionManagerCommunicationSettings", "ManagedInstanceEditionCapability", "ManagedInstanceEncryptionProtector", - "ManagedInstanceEncryptionProtectorListResult", + "ManagedInstanceEncryptionProtectorProperties", "ManagedInstanceExternalAdministrator", "ManagedInstanceFamilyCapability", "ManagedInstanceKey", - "ManagedInstanceKeyListResult", - "ManagedInstanceListResult", + "ManagedInstanceKeyProperties", "ManagedInstanceLongTermRetentionBackup", - "ManagedInstanceLongTermRetentionBackupListResult", + "ManagedInstanceLongTermRetentionBackupProperties", "ManagedInstanceLongTermRetentionPolicy", - "ManagedInstanceLongTermRetentionPolicyListResult", + "ManagedInstanceLongTermRetentionPolicyProperties", "ManagedInstanceMaintenanceConfigurationCapability", "ManagedInstanceOperation", - "ManagedInstanceOperationListResult", "ManagedInstanceOperationParametersPair", + "ManagedInstanceOperationProperties", "ManagedInstanceOperationSteps", "ManagedInstancePairInfo", "ManagedInstancePecProperty", "ManagedInstancePrivateEndpointConnection", - "ManagedInstancePrivateEndpointConnectionListResult", "ManagedInstancePrivateEndpointConnectionProperties", "ManagedInstancePrivateEndpointProperty", "ManagedInstancePrivateLink", - "ManagedInstancePrivateLinkListResult", "ManagedInstancePrivateLinkProperties", "ManagedInstancePrivateLinkServiceConnectionStateProperty", + "ManagedInstanceProperties", "ManagedInstanceQuery", - "ManagedInstanceQueryStatistics", "ManagedInstanceUpdate", + "ManagedInstanceValidateAzureKeyVaultEncryptionKeyRequest", "ManagedInstanceVcoresCapability", "ManagedInstanceVersionCapability", "ManagedInstanceVulnerabilityAssessment", - "ManagedInstanceVulnerabilityAssessmentListResult", + "ManagedInstanceVulnerabilityAssessmentProperties", "ManagedLedgerDigestUploads", - "ManagedLedgerDigestUploadsListResult", + "ManagedLedgerDigestUploadsProperties", "ManagedServerDnsAlias", "ManagedServerDnsAliasAcquisition", "ManagedServerDnsAliasCreation", - "ManagedServerDnsAliasListResult", + "ManagedServerDnsAliasProperties", "ManagedServerSecurityAlertPolicy", - "ManagedServerSecurityAlertPolicyListResult", "ManagedTransparentDataEncryption", - "ManagedTransparentDataEncryptionListResult", + "ManagedTransparentDataEncryptionProperties", + "MaxLimitRangeCapability", "MaxSizeCapability", "MaxSizeRangeCapability", - "Metric", - "MetricAvailability", - "MetricDefinition", - "MetricDefinitionListResult", - "MetricListResult", - "MetricName", - "MetricValue", "MinCapacityCapability", + "NSPConfigAccessRule", + "NSPConfigAccessRuleProperties", + "NSPConfigAssociation", + "NSPConfigNetworkSecurityPerimeterRule", + "NSPConfigPerimeter", + "NSPConfigProfile", + "NSPProvisioningIssue", + "NSPProvisioningIssueProperties", "Name", "NetworkIsolationSettings", + "NetworkSecurityPerimeterConfiguration", + "NetworkSecurityPerimeterConfigurationProperties", "Operation", "OperationDisplay", - "OperationImpact", - "OperationListResult", "OutboundEnvironmentEndpoint", - "OutboundEnvironmentEndpointCollection", "OutboundFirewallRule", - "OutboundFirewallRuleListResult", + "OutboundFirewallRuleProperties", "PartnerInfo", "PartnerRegionInfo", + "PerDatabaseAutoPauseDelayTimeRange", "PerformanceLevelCapability", "PhaseDetails", "PrivateEndpointConnection", - "PrivateEndpointConnectionListResult", "PrivateEndpointConnectionProperties", "PrivateEndpointConnectionRequestStatus", "PrivateEndpointProperty", "PrivateLinkResource", - "PrivateLinkResourceListResult", "PrivateLinkResourceProperties", "PrivateLinkServiceConnectionStateProperty", "ProxyResource", "ProxyResourceWithWritableName", "QueryCheck", "QueryMetricInterval", - "QueryMetricIntervalAutoGenerated", "QueryMetricProperties", + "QueryProperties", "QueryStatistics", "QueryStatisticsProperties", "ReadScaleCapability", @@ -898,145 +931,149 @@ "RecommendedActionImpactRecord", "RecommendedActionImplementationInfo", "RecommendedActionMetricInfo", + "RecommendedActionProperties", "RecommendedActionStateInfo", "RecommendedSensitivityLabelUpdate", "RecommendedSensitivityLabelUpdateList", + "RecommendedSensitivityLabelUpdateProperties", "RecoverableDatabase", - "RecoverableDatabaseListResult", + "RecoverableDatabaseProperties", "RecoverableManagedDatabase", - "RecoverableManagedDatabaseListResult", + "RecoverableManagedDatabaseProperties", "RefreshExternalGovernanceStatusOperationResult", "RefreshExternalGovernanceStatusOperationResultMI", + "RefreshExternalGovernanceStatusOperationResultProperties", + "RefreshExternalGovernanceStatusOperationResultPropertiesMI", "Remediation", "ReplicationLink", - "ReplicationLinkListResult", + "ReplicationLinkProperties", "ReplicationLinkUpdate", + "ReplicationLinkUpdateProperties", "Resource", "ResourceIdentity", "ResourceMoveDefinition", "ResourceWithWritableName", "RestorableDroppedDatabase", - "RestorableDroppedDatabaseListResult", + "RestorableDroppedDatabaseProperties", "RestorableDroppedManagedDatabase", - "RestorableDroppedManagedDatabaseListResult", + "RestorableDroppedManagedDatabaseProperties", "RestorePoint", - "RestorePointListResult", - "SQLVulnerabilityAssessmentScanListResult", + "RestorePointProperties", "ScheduleItem", + "SecurityAlertPolicyProperties", + "SecurityAlertsPolicyProperties", "SecurityEvent", - "SecurityEventCollection", + "SecurityEventProperties", "SecurityEventSqlInjectionAdditionalProperties", - "SecurityEventsFilterParameters", "SensitivityLabel", - "SensitivityLabelListResult", + "SensitivityLabelProperties", "SensitivityLabelUpdate", "SensitivityLabelUpdateList", + "SensitivityLabelUpdateProperties", "Server", "ServerAdvancedThreatProtection", "ServerAutomaticTuning", "ServerAzureADAdministrator", "ServerAzureADOnlyAuthentication", "ServerBlobAuditingPolicy", - "ServerBlobAuditingPolicyListResult", - "ServerCommunicationLink", - "ServerCommunicationLinkListResult", + "ServerBlobAuditingPolicyProperties", "ServerConfigurationOption", - "ServerConfigurationOptionListResult", + "ServerConfigurationOptionProperties", "ServerConnectionPolicy", - "ServerConnectionPolicyListResult", - "ServerDevOpsAuditSettingsListResult", + "ServerConnectionPolicyProperties", + "ServerDevOpsAuditSettingsProperties", "ServerDevOpsAuditingSettings", "ServerDnsAlias", "ServerDnsAliasAcquisition", - "ServerDnsAliasListResult", + "ServerDnsAliasProperties", "ServerExternalAdministrator", + "ServerFirewallRuleProperties", "ServerInfo", "ServerKey", - "ServerKeyListResult", - "ServerListResult", + "ServerKeyProperties", "ServerOperation", - "ServerOperationListResult", + "ServerOperationProperties", "ServerPrivateEndpointConnection", + "ServerProperties", "ServerSecurityAlertPolicy", "ServerTrustCertificate", - "ServerTrustCertificatesListResult", + "ServerTrustCertificateProperties", "ServerTrustGroup", - "ServerTrustGroupListResult", + "ServerTrustGroupProperties", "ServerUpdate", "ServerUsage", - "ServerUsageListResult", + "ServerUsageProperties", "ServerVersionCapability", "ServerVulnerabilityAssessment", - "ServerVulnerabilityAssessmentListResult", - "ServiceObjective", + "ServerVulnerabilityAssessmentProperties", "ServiceObjectiveCapability", - "ServiceObjectiveListResult", "ServicePrincipal", "Sku", - "SloUsageMetric", "SqlAgentConfiguration", + "SqlAgentConfigurationProperties", "SqlVulnerabilityAssessment", - "SqlVulnerabilityAssessmentListResult", + "SqlVulnerabilityAssessmentPolicyProperties", "SqlVulnerabilityAssessmentScanError", "SqlVulnerabilityAssessmentScanRecord", - "SqlVulnerabilityAssessmentScanRecordListResult", + "SqlVulnerabilityAssessmentScanRecordProperties", + "SqlVulnerabilityAssessmentScanResultProperties", "SqlVulnerabilityAssessmentScanResults", "StartStopManagedInstanceSchedule", - "StartStopManagedInstanceScheduleListResult", + "StartStopManagedInstanceScheduleProperties", "StorageCapability", "SubscriptionUsage", - "SubscriptionUsageListResult", + "SubscriptionUsageProperties", "SynapseLinkWorkspace", "SynapseLinkWorkspaceInfoProperties", - "SynapseLinkWorkspaceListResult", + "SynapseLinkWorkspaceProperties", "SyncAgent", "SyncAgentKeyProperties", "SyncAgentLinkedDatabase", - "SyncAgentLinkedDatabaseListResult", - "SyncAgentListResult", - "SyncDatabaseIdListResult", + "SyncAgentLinkedDatabaseProperties", + "SyncAgentProperties", "SyncDatabaseIdProperties", "SyncFullSchemaProperties", - "SyncFullSchemaPropertiesListResult", "SyncFullSchemaTable", "SyncFullSchemaTableColumn", "SyncGroup", - "SyncGroupListResult", - "SyncGroupLogListResult", "SyncGroupLogProperties", + "SyncGroupProperties", "SyncGroupSchema", "SyncGroupSchemaTable", "SyncGroupSchemaTableColumn", "SyncMember", - "SyncMemberListResult", + "SyncMemberProperties", "SystemData", "TdeCertificate", + "TdeCertificateProperties", "TimeZone", - "TimeZoneListResult", + "TimeZoneProperties", "TopQueries", - "TopQueriesListResult", "TrackedResource", + "TransparentDataEncryptionProperties", "UpdateLongTermRetentionBackupParameters", + "UpdateLongTermRetentionBackupParametersProperties", "UpdateVirtualClusterDnsServersOperation", "UpsertManagedServerOperationParameters", - "UpsertManagedServerOperationStep", + "UpsertManagedServerOperationStepWithEstimatesAndDuration", "Usage", - "UsageListResult", "UserIdentity", "VaRule", "VirtualCluster", - "VirtualClusterListResult", + "VirtualClusterDnsServersProperties", + "VirtualClusterProperties", "VirtualClusterUpdate", "VirtualNetworkRule", - "VirtualNetworkRuleListResult", + "VirtualNetworkRuleProperties", "VulnerabilityAssessmentRecurringScansProperties", "VulnerabilityAssessmentScanError", "VulnerabilityAssessmentScanRecord", - "VulnerabilityAssessmentScanRecordListResult", + "VulnerabilityAssessmentScanRecordProperties", "WorkloadClassifier", - "WorkloadClassifierListResult", + "WorkloadClassifierProperties", "WorkloadGroup", - "WorkloadGroupListResult", + "WorkloadGroupProperties", + "ZonePinningCapability", "AdministratorName", "AdministratorType", "AdvancedThreatProtectionName", @@ -1063,14 +1100,18 @@ "CapabilityStatus", "CatalogCollationType", "CheckNameAvailabilityReason", + "CheckNameAvailabilityResourceType", + "ClientClassificationSource", "ColumnDataType", "ConnectionPolicyName", "CreateMode", "CreatedByType", "DNSRefreshOperationStatus", "DataMaskingFunction", + "DataMaskingPolicyName", "DataMaskingRuleState", "DataMaskingState", + "DataSyncParticipantIdentityType", "DataWarehouseUserActivityName", "DatabaseIdentityType", "DatabaseKeyType", @@ -1085,23 +1126,25 @@ "ElasticPoolLicenseType", "ElasticPoolState", "EncryptionProtectorName", + "ErrorType", "ExternalGovernanceStatus", "FailoverGroupDatabasesSecondaryType", "FailoverGroupReplicationRole", "FailoverModeType", "FailoverType", "FreeLimitExhaustionBehavior", - "FreemiumType", "GeoBackupPolicyName", "GeoBackupPolicyState", "HybridSecondaryUsage", "HybridSecondaryUsageDetected", "IdentityType", "ImplementationMethod", + "InaccessibilityReason", "InstanceFailoverGroupReplicationRole", "InstancePoolLicenseType", "InstanceRole", "IsRetryable", + "JobAgentIdentityType", "JobAgentState", "JobExecutionLifecycle", "JobScheduleType", @@ -1136,7 +1179,7 @@ "PauseDelayTimeUnit", "PerformanceLevelUnit", "Phase", - "PrimaryAggregationType", + "PricingModel", "PrincipalType", "PrivateEndpointProvisioningState", "PrivateLinkServiceConnectionStateActionsRequire", @@ -1181,7 +1224,6 @@ "ServerPublicNetworkAccessFlag", "ServerTrustGroupPropertiesTrustScopesItem", "ServerWorkspaceFeature", - "ServiceObjectiveName", "ServicePrincipalType", "SetLegalHoldImmutability", "ShortTermRetentionPolicyName", @@ -1203,15 +1245,15 @@ "TimeBasedImmutability", "TimeBasedImmutabilityMode", "TransparentDataEncryptionName", + "TransparentDataEncryptionScanState", "TransparentDataEncryptionState", - "UnitDefinitionType", - "UnitType", - "UpsertManagedServerOperationStepStatus", + "UpsertManagedServerOperationStepWithEstimatesAndDurationStatus", "VirtualNetworkRuleState", "VulnerabilityAssessmentName", "VulnerabilityAssessmentPolicyBaselineName", "VulnerabilityAssessmentScanState", "VulnerabilityAssessmentScanTriggerType", + "VulnerabilityAssessmentSystemDatabaseName", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() 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/_enums.py similarity index 71% rename from sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_sql_management_client_enums.py rename to sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_enums.py index ba8731c058ec..36154f03ffbf 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/_enums.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -12,21 +12,24 @@ class AdministratorName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """AdministratorName.""" + """Type of AdministratorName.""" ACTIVE_DIRECTORY = "ActiveDirectory" + """ActiveDirectory.""" class AdministratorType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of the sever administrator.""" ACTIVE_DIRECTORY = "ActiveDirectory" + """ActiveDirectory.""" class AdvancedThreatProtectionName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """AdvancedThreatProtectionName.""" + """Type of AdvancedThreatProtectionName.""" DEFAULT = "Default" + """Default.""" class AdvancedThreatProtectionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -35,8 +38,11 @@ class AdvancedThreatProtectionState(str, Enum, metaclass=CaseInsensitiveEnumMeta """ NEW = "New" + """New.""" ENABLED = "Enabled" + """Enabled.""" DISABLED = "Disabled" + """Disabled.""" class AdvisorStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -45,40 +51,55 @@ class AdvisorStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ GA = "GA" + """GA.""" PUBLIC_PREVIEW = "PublicPreview" + """PublicPreview.""" LIMITED_PUBLIC_PREVIEW = "LimitedPublicPreview" + """LimitedPublicPreview.""" PRIVATE_PREVIEW = "PrivatePreview" + """PrivatePreview.""" class AggregationFunctionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """AggregationFunctionType.""" + """Type of AggregationFunctionType.""" AVG = "avg" + """avg.""" MIN = "min" + """min.""" MAX = "max" + """max.""" STDEV = "stdev" + """stdev.""" SUM = "sum" + """sum.""" class AlwaysEncryptedEnclaveType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Type of enclave requested on the elastic pool.""" + """Type of enclave requested on the database i.e. Default or VBS enclaves.""" DEFAULT = "Default" + """Default.""" VBS = "VBS" + """VBS.""" class AuthenticationName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """AuthenticationName.""" + """Type of AuthenticationName.""" DEFAULT = "Default" + """Default.""" class AuthMetadataLookupModes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The managed instance's authentication metadata lookup mode.""" AZURE_AD = "AzureAD" + """AzureAD.""" PAIRED = "Paired" + """Paired.""" WINDOWS = "Windows" + """Windows.""" class AutoExecuteStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -87,8 +108,11 @@ class AutoExecuteStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ ENABLED = "Enabled" + """Enabled.""" DISABLED = "Disabled" + """Disabled.""" DEFAULT = "Default" + """Default.""" class AutoExecuteStatusInheritedFrom(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -99,93 +123,131 @@ class AutoExecuteStatusInheritedFrom(str, Enum, metaclass=CaseInsensitiveEnumMet """ DEFAULT = "Default" + """Default.""" SUBSCRIPTION = "Subscription" + """Subscription.""" SERVER = "Server" + """Server.""" ELASTIC_POOL = "ElasticPool" + """ElasticPool.""" DATABASE = "Database" + """Database.""" class AutomaticTuningDisabledReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Reason description if desired and actual state are different.""" DEFAULT = "Default" + """Default.""" DISABLED = "Disabled" + """Disabled.""" AUTO_CONFIGURED = "AutoConfigured" + """AutoConfigured.""" INHERITED_FROM_SERVER = "InheritedFromServer" + """InheritedFromServer.""" QUERY_STORE_OFF = "QueryStoreOff" + """QueryStoreOff.""" QUERY_STORE_READ_ONLY = "QueryStoreReadOnly" + """QueryStoreReadOnly.""" NOT_SUPPORTED = "NotSupported" + """NotSupported.""" class AutomaticTuningMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Automatic tuning desired state.""" INHERIT = "Inherit" + """Inherit.""" CUSTOM = "Custom" + """Custom.""" AUTO = "Auto" + """Auto.""" UNSPECIFIED = "Unspecified" + """Unspecified.""" class AutomaticTuningOptionModeActual(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Automatic tuning option actual state.""" OFF = "Off" + """Off.""" ON = "On" + """On.""" class AutomaticTuningOptionModeDesired(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Automatic tuning option desired state.""" OFF = "Off" + """Off.""" ON = "On" + """On.""" DEFAULT = "Default" + """Default.""" class AutomaticTuningServerMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Automatic tuning desired state.""" CUSTOM = "Custom" + """Custom.""" AUTO = "Auto" + """Auto.""" UNSPECIFIED = "Unspecified" + """Unspecified.""" class AutomaticTuningServerReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Reason description if desired and actual state are different.""" DEFAULT = "Default" + """Default.""" DISABLED = "Disabled" + """Disabled.""" AUTO_CONFIGURED = "AutoConfigured" + """AutoConfigured.""" class AvailabilityZoneType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the availability zone the pool's primary replica is pinned to.""" + """Specifies the availability zone the database is pinned to.""" NO_PREFERENCE = "NoPreference" + """NoPreference.""" ONE = "1" + """1.""" TWO = "2" + """2.""" THREE = "3" + """3.""" class BackupStorageAccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The BackupStorageAccessTier for the LTR backup.""" HOT = "Hot" + """Hot.""" ARCHIVE = "Archive" + """Archive.""" class BackupStorageRedundancy(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The storage redundancy type of the backup.""" + """The storage account type used to store backups for this database.""" GEO = "Geo" + """Geo.""" LOCAL = "Local" + """Local.""" ZONE = "Zone" + """Zone.""" GEO_ZONE = "GeoZone" + """GeoZone.""" class BaselineName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """BaselineName.""" + """Type of BaselineName.""" DEFAULT = "default" + """default.""" class BlobAuditingPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -194,33 +256,48 @@ class BlobAuditingPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ ENABLED = "Enabled" + """Enabled.""" DISABLED = "Disabled" + """Disabled.""" class CapabilityGroup(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """CapabilityGroup.""" + """Type of CapabilityGroup.""" SUPPORTED_EDITIONS = "supportedEditions" + """supportedEditions.""" SUPPORTED_ELASTIC_POOL_EDITIONS = "supportedElasticPoolEditions" + """supportedElasticPoolEditions.""" SUPPORTED_MANAGED_INSTANCE_VERSIONS = "supportedManagedInstanceVersions" + """supportedManagedInstanceVersions.""" SUPPORTED_INSTANCE_POOL_EDITIONS = "supportedInstancePoolEditions" + """supportedInstancePoolEditions.""" SUPPORTED_MANAGED_INSTANCE_EDITIONS = "supportedManagedInstanceEditions" + """supportedManagedInstanceEditions.""" + SUPPORTED_JOB_AGENT_VERSIONS = "supportedJobAgentVersions" + """supportedJobAgentVersions.""" class CapabilityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the capability.""" VISIBLE = "Visible" + """Visible.""" AVAILABLE = "Available" + """Available.""" DEFAULT = "Default" + """Default.""" DISABLED = "Disabled" + """Disabled.""" class CatalogCollationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Collation of the metadata catalog.""" DATABASE_DEFAULT = "DATABASE_DEFAULT" + """DATABASE_DEFAULT.""" SQL_LATIN1_GENERAL_CP1_CI_AS = "SQL_Latin1_General_CP1_CI_AS" + """SQL_Latin1_General_CP1_CI_AS.""" class CheckNameAvailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -229,62 +306,122 @@ class CheckNameAvailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ INVALID = "Invalid" + """Invalid.""" ALREADY_EXISTS = "AlreadyExists" + """AlreadyExists.""" + + +class CheckNameAvailabilityResourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of CheckNameAvailabilityResourceType.""" + + MICROSOFT_SQL_SERVERS = "Microsoft.Sql/servers" + """Microsoft.Sql/servers.""" + + +class ClientClassificationSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of ClientClassificationSource.""" + + NONE = "None" + """None.""" + NATIVE = "Native" + """Native.""" + RECOMMENDED = "Recommended" + """Recommended.""" + MIP = "MIP" + """MIP.""" class ColumnDataType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The column data type.""" IMAGE = "image" + """image.""" TEXT = "text" + """text.""" UNIQUEIDENTIFIER = "uniqueidentifier" + """uniqueidentifier.""" DATE = "date" + """date.""" TIME = "time" + """time.""" DATETIME2 = "datetime2" + """datetime2.""" DATETIMEOFFSET = "datetimeoffset" + """datetimeoffset.""" TINYINT = "tinyint" + """tinyint.""" SMALLINT = "smallint" + """smallint.""" INT = "int" + """int.""" SMALLDATETIME = "smalldatetime" + """smalldatetime.""" REAL = "real" + """real.""" MONEY = "money" + """money.""" DATETIME = "datetime" + """datetime.""" FLOAT = "float" + """float.""" SQL_VARIANT = "sql_variant" + """sql_variant.""" NTEXT = "ntext" + """ntext.""" BIT = "bit" + """bit.""" DECIMAL = "decimal" + """decimal.""" NUMERIC = "numeric" + """numeric.""" SMALLMONEY = "smallmoney" + """smallmoney.""" BIGINT = "bigint" + """bigint.""" HIERARCHYID = "hierarchyid" + """hierarchyid.""" GEOMETRY = "geometry" + """geometry.""" GEOGRAPHY = "geography" + """geography.""" VARBINARY = "varbinary" + """varbinary.""" VARCHAR = "varchar" + """varchar.""" BINARY = "binary" + """binary.""" CHAR = "char" + """char.""" TIMESTAMP = "timestamp" + """timestamp.""" NVARCHAR = "nvarchar" + """nvarchar.""" NCHAR = "nchar" + """nchar.""" XML = "xml" + """xml.""" SYSNAME = "sysname" - INT_ENUM = "int" + """sysname.""" class ConnectionPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ConnectionPolicyName.""" + """Type of ConnectionPolicyName.""" DEFAULT = "default" + """default.""" class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource.""" + """The kind of entity that created the resource.""" USER = "User" + """The entity was created by a user.""" APPLICATION = "Application" + """The entity was created by an application.""" MANAGED_IDENTITY = "ManagedIdentity" + """The entity was created by a managed identity.""" KEY = "Key" + """The entity was created by a key.""" class CreateMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -320,28 +457,41 @@ class CreateMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ DEFAULT = "Default" + """Default.""" COPY = "Copy" + """Copy.""" SECONDARY = "Secondary" + """Secondary.""" POINT_IN_TIME_RESTORE = "PointInTimeRestore" + """PointInTimeRestore.""" RESTORE = "Restore" + """Restore.""" RECOVERY = "Recovery" + """Recovery.""" RESTORE_EXTERNAL_BACKUP = "RestoreExternalBackup" + """RestoreExternalBackup.""" RESTORE_EXTERNAL_BACKUP_SECONDARY = "RestoreExternalBackupSecondary" + """RestoreExternalBackupSecondary.""" RESTORE_LONG_TERM_RETENTION_BACKUP = "RestoreLongTermRetentionBackup" + """RestoreLongTermRetentionBackup.""" ONLINE_SECONDARY = "OnlineSecondary" + """OnlineSecondary.""" class DatabaseIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The identity type.""" NONE = "None" + """None.""" USER_ASSIGNED = "UserAssigned" + """UserAssigned.""" class DatabaseKeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The database key type. Only supported value is 'AzureKeyVault'.""" AZURE_KEY_VAULT = "AzureKeyVault" + """AzureKeyVault.""" class DatabaseLicenseType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -350,7 +500,9 @@ class DatabaseLicenseType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ LICENSE_INCLUDED = "LicenseIncluded" + """LicenseIncluded.""" BASE_PRICE = "BasePrice" + """BasePrice.""" class DatabaseReadScale(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -360,55 +512,97 @@ class DatabaseReadScale(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ ENABLED = "Enabled" + """Enabled.""" DISABLED = "Disabled" + """Disabled.""" class DatabaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """DatabaseState.""" + """Type of DatabaseState.""" ALL = "All" + """All.""" LIVE = "Live" + """Live.""" DELETED = "Deleted" + """Deleted.""" class DatabaseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the database.""" ONLINE = "Online" + """Online.""" RESTORING = "Restoring" + """Restoring.""" RECOVERY_PENDING = "RecoveryPending" + """RecoveryPending.""" RECOVERING = "Recovering" + """Recovering.""" SUSPECT = "Suspect" + """Suspect.""" OFFLINE = "Offline" + """Offline.""" STANDBY = "Standby" + """Standby.""" SHUTDOWN = "Shutdown" + """Shutdown.""" EMERGENCY_MODE = "EmergencyMode" + """EmergencyMode.""" AUTO_CLOSED = "AutoClosed" + """AutoClosed.""" COPYING = "Copying" + """Copying.""" CREATING = "Creating" + """Creating.""" INACCESSIBLE = "Inaccessible" + """Inaccessible.""" OFFLINE_SECONDARY = "OfflineSecondary" + """OfflineSecondary.""" PAUSING = "Pausing" + """Pausing.""" PAUSED = "Paused" + """Paused.""" RESUMING = "Resuming" + """Resuming.""" SCALING = "Scaling" + """Scaling.""" OFFLINE_CHANGING_DW_PERFORMANCE_TIERS = "OfflineChangingDwPerformanceTiers" + """OfflineChangingDwPerformanceTiers.""" ONLINE_CHANGING_DW_PERFORMANCE_TIERS = "OnlineChangingDwPerformanceTiers" + """OnlineChangingDwPerformanceTiers.""" DISABLED = "Disabled" + """Disabled.""" STOPPING = "Stopping" + """Stopping.""" STOPPED = "Stopped" + """Stopped.""" STARTING = "Starting" + """Starting.""" class DataMaskingFunction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The masking function that is used for the data masking rule.""" DEFAULT = "Default" + """Default.""" CCN = "CCN" + """CCN.""" EMAIL = "Email" + """Email.""" NUMBER = "Number" + """Number.""" SSN = "SSN" + """SSN.""" TEXT = "Text" + """Text.""" + + +class DataMaskingPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of DataMaskingPolicyName.""" + + DEFAULT = "Default" + """Default.""" class DataMaskingRuleState(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -418,39 +612,65 @@ class DataMaskingRuleState(str, Enum, metaclass=CaseInsensitiveEnumMeta): the provided value of ruleState. """ - DISABLED = "Disabled" ENABLED = "Enabled" + """Enabled.""" + DISABLED = "Disabled" + """Disabled.""" class DataMaskingState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The state of the data masking policy.""" - DISABLED = "Disabled" ENABLED = "Enabled" + """Enabled.""" + DISABLED = "Disabled" + """Disabled.""" + + +class DataSyncParticipantIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of DataSyncParticipantIdentityType.""" + + NONE = "None" + """None.""" + SYSTEM_ASSIGNED = "SystemAssigned" + """SystemAssigned.""" + USER_ASSIGNED = "UserAssigned" + """UserAssigned.""" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssignedUserAssigned" + """SystemAssignedUserAssigned.""" class DataWarehouseUserActivityName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """DataWarehouseUserActivityName.""" + """Type of DataWarehouseUserActivityName.""" CURRENT = "current" + """current.""" class DayOfWeek(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Day of maintenance window.""" SUNDAY = "Sunday" + """Sunday.""" MONDAY = "Monday" + """Monday.""" TUESDAY = "Tuesday" + """Tuesday.""" WEDNESDAY = "Wednesday" + """Wednesday.""" THURSDAY = "Thursday" + """Thursday.""" FRIDAY = "Friday" + """Friday.""" SATURDAY = "Saturday" + """Saturday.""" class DevOpsAuditingSettingsName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """DevOpsAuditingSettingsName.""" + """Type of DevOpsAuditingSettingsName.""" DEFAULT = "Default" + """Default.""" class DiffBackupIntervalInHours(int, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -460,63 +680,90 @@ class DiffBackupIntervalInHours(int, Enum, metaclass=CaseInsensitiveEnumMeta): """ TWELVE = 12 + """12.""" TWENTY_FOUR = 24 + """24.""" class DNSRefreshOperationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the DNS refresh operation.""" SUCCEEDED = "Succeeded" + """Succeeded.""" FAILED = "Failed" + """Failed.""" IN_PROGRESS = "InProgress" + """InProgress.""" class DtcName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """DtcName.""" + """Type of DtcName.""" CURRENT = "current" + """current.""" class ElasticPoolLicenseType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The license type to apply for this elastic pool.""" LICENSE_INCLUDED = "LicenseIncluded" + """LicenseIncluded.""" BASE_PRICE = "BasePrice" + """BasePrice.""" class ElasticPoolState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The state of the elastic pool.""" CREATING = "Creating" + """Creating.""" READY = "Ready" + """Ready.""" DISABLED = "Disabled" + """Disabled.""" class EncryptionProtectorName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """EncryptionProtectorName.""" + """Type of EncryptionProtectorName.""" CURRENT = "current" + """current.""" + + +class ErrorType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Error type (e.g. None, User).""" + + NONE = "None" + """None.""" + USER = "User" + """User.""" class ExternalGovernanceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Status of external governance.""" ENABLED = "Enabled" + """Enabled.""" DISABLED = "Disabled" + """Disabled.""" class FailoverGroupDatabasesSecondaryType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Databases secondary type on partner server.""" GEO = "Geo" + """Geo.""" STANDBY = "Standby" + """Standby.""" class FailoverGroupReplicationRole(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Local replication role of the failover group instance.""" PRIMARY = "Primary" + """Primary.""" SECONDARY = "Secondary" + """Secondary.""" class FailoverModeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -525,14 +772,18 @@ class FailoverModeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ NONE = "None" + """None.""" MANUAL = "Manual" + """Manual.""" class FailoverType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The failover type, can be ForcedAllowDataLoss or Planned.""" FORCED_ALLOW_DATA_LOSS = "ForcedAllowDataLoss" + """ForcedAllowDataLoss.""" PLANNED = "Planned" + """Planned.""" class FreeLimitExhaustionBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -546,27 +797,25 @@ class FreeLimitExhaustionBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ AUTO_PAUSE = "AutoPause" + """AutoPause.""" BILL_OVER_USAGE = "BillOverUsage" - - -class FreemiumType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Weather or not Managed Instance is freemium.""" - - REGULAR = "Regular" - FREEMIUM = "Freemium" + """BillOverUsage.""" class GeoBackupPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """GeoBackupPolicyName.""" + """Type of GeoBackupPolicyName.""" DEFAULT = "Default" + """Default.""" class GeoBackupPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The state of the geo backup policy.""" - DISABLED = "Disabled" ENABLED = "Enabled" + """Enabled.""" + DISABLED = "Disabled" + """Disabled.""" class HybridSecondaryUsage(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -575,7 +824,9 @@ class HybridSecondaryUsage(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ ACTIVE = "Active" + """Active.""" PASSIVE = "Passive" + """Passive.""" class HybridSecondaryUsageDetected(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -585,7 +836,9 @@ class HybridSecondaryUsageDetected(str, Enum, metaclass=CaseInsensitiveEnumMeta) """ ACTIVE = "Active" + """Active.""" PASSIVE = "Passive" + """Passive.""" class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -594,9 +847,13 @@ class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ NONE = "None" + """None.""" SYSTEM_ASSIGNED = "SystemAssigned" + """SystemAssigned.""" USER_ASSIGNED = "UserAssigned" + """UserAssigned.""" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" + """SystemAssigned,UserAssigned.""" class ImplementationMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -605,14 +862,31 @@ class ImplementationMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ T_SQL = "TSql" + """TSql.""" AZURE_POWER_SHELL = "AzurePowerShell" + """AzurePowerShell.""" + + +class InaccessibilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Root cause kind. Allowed values are “TransparentDataEncryption”, “DatabaseReplication”, and + “Unknown”. + """ + + UNKNOWN = "Unknown" + """Unknown.""" + TRANSPARENT_DATA_ENCRYPTION = "TransparentDataEncryption" + """TransparentDataEncryption.""" + DATABASE_REPLICATION = "DatabaseReplication" + """DatabaseReplication.""" class InstanceFailoverGroupReplicationRole(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Local replication role of the failover group instance.""" PRIMARY = "Primary" + """Primary.""" SECONDARY = "Secondary" + """Secondary.""" class InstancePoolLicenseType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -621,14 +895,18 @@ class InstancePoolLicenseType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ LICENSE_INCLUDED = "LicenseIncluded" + """LicenseIncluded.""" BASE_PRICE = "BasePrice" + """BasePrice.""" class InstanceRole(str, Enum, metaclass=CaseInsensitiveEnumMeta): """New role of managed instance in a distributed availability group, can be Primary or Secondary.""" PRIMARY = "Primary" + """Primary.""" SECONDARY = "Secondary" + """Secondary.""" class IsRetryable(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -637,110 +915,163 @@ class IsRetryable(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ YES = "Yes" + """Yes.""" NO = "No" + """No.""" + + +class JobAgentIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The job agent identity type.""" + + NONE = "None" + """None.""" + SYSTEM_ASSIGNED = "SystemAssigned" + """SystemAssigned.""" + USER_ASSIGNED = "UserAssigned" + """UserAssigned.""" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssignedUserAssigned" + """SystemAssignedUserAssigned.""" class JobAgentState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The state of the job agent.""" CREATING = "Creating" + """Creating.""" READY = "Ready" + """Ready.""" UPDATING = "Updating" + """Updating.""" DELETING = "Deleting" + """Deleting.""" DISABLED = "Disabled" + """Disabled.""" class JobExecutionLifecycle(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The detailed state of the job execution.""" CREATED = "Created" + """Created.""" IN_PROGRESS = "InProgress" + """InProgress.""" WAITING_FOR_CHILD_JOB_EXECUTIONS = "WaitingForChildJobExecutions" + """WaitingForChildJobExecutions.""" WAITING_FOR_RETRY = "WaitingForRetry" + """WaitingForRetry.""" SUCCEEDED = "Succeeded" + """Succeeded.""" SUCCEEDED_WITH_SKIPPED = "SucceededWithSkipped" + """SucceededWithSkipped.""" FAILED = "Failed" + """Failed.""" TIMED_OUT = "TimedOut" + """TimedOut.""" CANCELED = "Canceled" + """Canceled.""" SKIPPED = "Skipped" + """Skipped.""" class JobScheduleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Schedule interval type.""" ONCE = "Once" + """Once.""" RECURRING = "Recurring" + """Recurring.""" class JobStepActionSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The source of the action to execute.""" INLINE = "Inline" + """Inline.""" class JobStepActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of action being executed by the job step.""" T_SQL = "TSql" + """TSql.""" class JobStepOutputType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The output destination type.""" SQL_DATABASE = "SqlDatabase" + """SqlDatabase.""" class JobTargetGroupMembershipType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Whether the target is included or excluded from the group.""" INCLUDE = "Include" + """Include.""" EXCLUDE = "Exclude" + """Exclude.""" class JobTargetType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of the target.""" TARGET_GROUP = "TargetGroup" + """TargetGroup.""" SQL_DATABASE = "SqlDatabase" + """SqlDatabase.""" SQL_ELASTIC_POOL = "SqlElasticPool" + """SqlElasticPool.""" SQL_SHARD_MAP = "SqlShardMap" + """SqlShardMap.""" SQL_SERVER = "SqlServer" + """SqlServer.""" class LedgerDigestUploadsName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """LedgerDigestUploadsName.""" + """Type of LedgerDigestUploadsName.""" CURRENT = "current" + """current.""" class LedgerDigestUploadsState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the state of ledger digest upload.""" ENABLED = "Enabled" + """Enabled.""" DISABLED = "Disabled" + """Disabled.""" class LinkRole(str, Enum, metaclass=CaseInsensitiveEnumMeta): """SQL server side link role.""" PRIMARY = "Primary" + """Primary.""" SECONDARY = "Secondary" + """Secondary.""" class LogSizeUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The units that the limit is expressed in.""" MEGABYTES = "Megabytes" + """Megabytes.""" GIGABYTES = "Gigabytes" + """Gigabytes.""" TERABYTES = "Terabytes" + """Terabytes.""" PETABYTES = "Petabytes" + """Petabytes.""" PERCENT = "Percent" + """Percent.""" class LongTermRetentionPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """LongTermRetentionPolicyName.""" + """Type of LongTermRetentionPolicyName.""" DEFAULT = "default" + """default.""" class ManagedDatabaseCreateMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -755,40 +1086,62 @@ class ManagedDatabaseCreateMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ DEFAULT = "Default" + """Default.""" RESTORE_EXTERNAL_BACKUP = "RestoreExternalBackup" + """RestoreExternalBackup.""" POINT_IN_TIME_RESTORE = "PointInTimeRestore" + """PointInTimeRestore.""" RECOVERY = "Recovery" + """Recovery.""" RESTORE_LONG_TERM_RETENTION_BACKUP = "RestoreLongTermRetentionBackup" + """RestoreLongTermRetentionBackup.""" class ManagedDatabaseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Status of the database.""" ONLINE = "Online" + """Online.""" OFFLINE = "Offline" + """Offline.""" SHUTDOWN = "Shutdown" + """Shutdown.""" CREATING = "Creating" + """Creating.""" INACCESSIBLE = "Inaccessible" + """Inaccessible.""" RESTORING = "Restoring" + """Restoring.""" UPDATING = "Updating" + """Updating.""" STOPPING = "Stopping" + """Stopping.""" STOPPED = "Stopped" + """Stopped.""" STARTING = "Starting" + """Starting.""" DB_MOVING = "DbMoving" + """DbMoving.""" DB_COPYING = "DbCopying" + """DbCopying.""" class ManagedInstanceAdministratorType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of the managed instance administrator.""" ACTIVE_DIRECTORY = "ActiveDirectory" + """ActiveDirectory.""" class ManagedInstanceDatabaseFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the internal format of instance databases specific to the SQL engine version.""" ALWAYS_UP_TO_DATE = "AlwaysUpToDate" + """AlwaysUpToDate.""" SQL_SERVER2022 = "SQLServer2022" + """SQLServer2022.""" + SQL_SERVER2025 = "SQLServer2025" + """SQLServer2025.""" class ManagedInstanceLicenseType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -797,34 +1150,45 @@ class ManagedInstanceLicenseType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ LICENSE_INCLUDED = "LicenseIncluded" + """LicenseIncluded.""" BASE_PRICE = "BasePrice" + """BasePrice.""" -class ManagedInstanceLongTermRetentionPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ManagedInstanceLongTermRetentionPolicyName.""" +class ManagedInstanceLongTermRetentionPolicyName( # pylint: disable=name-too-long + str, Enum, metaclass=CaseInsensitiveEnumMeta +): + """Type of ManagedInstanceLongTermRetentionPolicyName.""" DEFAULT = "default" + """default.""" class ManagedInstanceProxyOverride(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Connection type used for connecting to the instance.""" PROXY = "Proxy" + """Proxy.""" REDIRECT = "Redirect" + """Redirect.""" DEFAULT = "Default" + """Default.""" class ManagedLedgerDigestUploadsName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ManagedLedgerDigestUploadsName.""" + """Type of ManagedLedgerDigestUploadsName.""" CURRENT = "current" + """current.""" class ManagedLedgerDigestUploadsState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the state of ledger digest upload.""" ENABLED = "Enabled" + """Enabled.""" DISABLED = "Disabled" + """Disabled.""" class ManagedServerCreateMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -837,174 +1201,241 @@ class ManagedServerCreateMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ DEFAULT = "Default" + """Default.""" POINT_IN_TIME_RESTORE = "PointInTimeRestore" + """PointInTimeRestore.""" class ManagedShortTermRetentionPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ManagedShortTermRetentionPolicyName.""" + """Type of ManagedShortTermRetentionPolicyName.""" DEFAULT = "default" + """default.""" class ManagementOperationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The operation state.""" PENDING = "Pending" + """Pending.""" IN_PROGRESS = "InProgress" + """InProgress.""" SUCCEEDED = "Succeeded" + """Succeeded.""" FAILED = "Failed" + """Failed.""" CANCEL_IN_PROGRESS = "CancelInProgress" + """CancelInProgress.""" CANCELLED = "Cancelled" + """Cancelled.""" class MaxSizeUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The units that the limit is expressed in.""" MEGABYTES = "Megabytes" + """Megabytes.""" GIGABYTES = "Gigabytes" + """Gigabytes.""" TERABYTES = "Terabytes" + """Terabytes.""" PETABYTES = "Petabytes" + """Petabytes.""" class MetricType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """MetricType.""" + """Type of MetricType.""" CPU = "cpu" + """cpu.""" IO = "io" + """io.""" LOG_IO = "logIo" + """logIo.""" DURATION = "duration" + """duration.""" DTU = "dtu" + """dtu.""" class MinimalTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Minimal TLS version. Allowed values: 'None', 1.0', '1.1', '1.2', '1.3'.""" NONE = "None" + """None.""" ONE0 = "1.0" + """1.0.""" ONE1 = "1.1" + """1.1.""" ONE2 = "1.2" + """1.2.""" ONE3 = "1.3" + """1.3.""" class MoveOperationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Operation mode.""" MOVE = "Move" + """Move.""" COPY = "Copy" + """Copy.""" class OperationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Operation Mode.""" + """Operation mode of the operation: Import, Export, or PolybaseImport.""" POLYBASE_IMPORT = "PolybaseImport" + """PolybaseImport.""" + IMPORT = "Import" + """Import.""" + EXPORT = "Export" + """Export.""" class OperationOrigin(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The intended executor of the operation.""" USER = "user" + """user.""" SYSTEM = "system" + """system.""" class PauseDelayTimeUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Unit of time that delay is expressed in.""" MINUTES = "Minutes" + """Minutes.""" class PerformanceLevelUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Unit type used to measure performance level.""" DTU = "DTU" + """DTU.""" V_CORES = "VCores" + """VCores.""" class Phase(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The operation phase.""" LOG_TRANSITION_IN_PROGRESS = "LogTransitionInProgress" + """LogTransitionInProgress.""" COPYING = "Copying" + """Copying.""" BUILDING_HYPERSCALE_COMPONENTS = "BuildingHyperscaleComponents" + """BuildingHyperscaleComponents.""" CATCHUP = "Catchup" + """Catchup.""" WAITING_FOR_CUTOVER = "WaitingForCutover" + """WaitingForCutover.""" CUTOVER_IN_PROGRESS = "CutoverInProgress" + """CutoverInProgress.""" -class PrimaryAggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The primary aggregation type defining how metric values are displayed.""" +class PricingModel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Pricing model of Managed Instance.""" - NONE = "None" - AVERAGE = "Average" - COUNT = "Count" - MINIMUM = "Minimum" - MAXIMUM = "Maximum" - TOTAL = "Total" + REGULAR = "Regular" + """Regular.""" + FREEMIUM = "Freemium" + """Freemium.""" class PrincipalType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Principal Type of the sever administrator.""" USER = "User" + """User.""" GROUP = "Group" + """Group.""" APPLICATION = "Application" + """Application.""" class PrivateEndpointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """State of the private endpoint connection.""" APPROVING = "Approving" + """Approving.""" READY = "Ready" + """Ready.""" DROPPING = "Dropping" + """Dropping.""" FAILED = "Failed" + """Failed.""" REJECTING = "Rejecting" + """Rejecting.""" -class PrivateLinkServiceConnectionStateActionsRequire(str, Enum, metaclass=CaseInsensitiveEnumMeta): +class PrivateLinkServiceConnectionStateActionsRequire( # pylint: disable=name-too-long + str, Enum, metaclass=CaseInsensitiveEnumMeta +): """The actions required for private link service connection.""" NONE = "None" + """None.""" class PrivateLinkServiceConnectionStateStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The private link service connection status.""" APPROVED = "Approved" + """Approved.""" PENDING = "Pending" + """Pending.""" REJECTED = "Rejected" + """Rejected.""" DISCONNECTED = "Disconnected" + """Disconnected.""" class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ARM provisioning state of the job execution.""" CREATED = "Created" + """Created.""" IN_PROGRESS = "InProgress" + """InProgress.""" SUCCEEDED = "Succeeded" + """Succeeded.""" FAILED = "Failed" + """Failed.""" CANCELED = "Canceled" + """Canceled.""" class QueryMetricUnitType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The unit of the metric.""" PERCENTAGE = "percentage" + """percentage.""" KB = "KB" + """KB.""" MICROSECONDS = "microseconds" + """microseconds.""" COUNT = "count" + """count.""" class QueryTimeGrainType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Interval type (length).""" PT1_H = "PT1H" + """PT1H.""" P1_D = "P1D" + """P1D.""" class ReadOnlyEndpointFailoverPolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Failover policy of the read-only endpoint for the failover group.""" DISABLED = "Disabled" + """Disabled.""" ENABLED = "Enabled" + """Enabled.""" class ReadWriteEndpointFailoverPolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -1013,7 +1444,9 @@ class ReadWriteEndpointFailoverPolicy(str, Enum, metaclass=CaseInsensitiveEnumMe """ MANUAL = "Manual" + """Manual.""" AUTOMATIC = "Automatic" + """Automatic.""" class RecommendedActionCurrentState(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -1030,152 +1463,212 @@ class RecommendedActionCurrentState(str, Enum, metaclass=CaseInsensitiveEnumMeta """ ACTIVE = "Active" + """Active.""" PENDING = "Pending" + """Pending.""" EXECUTING = "Executing" + """Executing.""" VERIFYING = "Verifying" + """Verifying.""" PENDING_REVERT = "PendingRevert" + """PendingRevert.""" REVERT_CANCELLED = "RevertCancelled" + """RevertCancelled.""" REVERTING = "Reverting" + """Reverting.""" REVERTED = "Reverted" + """Reverted.""" IGNORED = "Ignored" + """Ignored.""" EXPIRED = "Expired" + """Expired.""" MONITORING = "Monitoring" + """Monitoring.""" RESOLVED = "Resolved" + """Resolved.""" SUCCESS = "Success" + """Success.""" ERROR = "Error" + """Error.""" class RecommendedActionInitiatedBy(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets if approval for applying this recommended action was given by user/system.""" USER = "User" + """User.""" SYSTEM = "System" + """System.""" class RecommendedSensitivityLabelUpdateKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """RecommendedSensitivityLabelUpdateKind.""" + """Type of RecommendedSensitivityLabelUpdateKind.""" ENABLE = "enable" + """enable.""" DISABLE = "disable" + """disable.""" class ReplicaConnectedState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Link connected state.""" DISCONNECTED = "DISCONNECTED" + """DISCONNECTED.""" CONNECTED = "CONNECTED" + """CONNECTED.""" class ReplicaSynchronizationHealth(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Link health state.""" NOT_HEALTHY = "NOT_HEALTHY" + """NOT_HEALTHY.""" PARTIALLY_HEALTHY = "PARTIALLY_HEALTHY" + """PARTIALLY_HEALTHY.""" HEALTHY = "HEALTHY" + """HEALTHY.""" class ReplicationLinkType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Link type (GEO, NAMED, STANDBY). Update operation does not support NAMED.""" GEO = "GEO" + """GEO.""" NAMED = "NAMED" + """NAMED.""" STANDBY = "STANDBY" + """STANDBY.""" class ReplicationModeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Replication mode of the link.""" ASYNC = "Async" + """Async.""" SYNC = "Sync" - ASYNC_ENUM = "Async" + """Sync.""" class ReplicationRole(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Local replication role.""" PRIMARY = "Primary" + """Primary.""" SECONDARY = "Secondary" + """Secondary.""" NON_READABLE_SECONDARY = "NonReadableSecondary" + """NonReadableSecondary.""" SOURCE = "Source" + """Source.""" COPY = "Copy" + """Copy.""" class ReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Replication state (PENDING, SEEDING, CATCHUP, SUSPENDED).""" PENDING = "PENDING" + """PENDING.""" SEEDING = "SEEDING" + """SEEDING.""" CATCH_UP = "CATCH_UP" + """CATCH_UP.""" SUSPENDED = "SUSPENDED" + """SUSPENDED.""" class ReplicaType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ReplicaType.""" + """Type of ReplicaType.""" PRIMARY = "Primary" + """Primary.""" READABLE_SECONDARY = "ReadableSecondary" + """ReadableSecondary.""" class RestoreDetailsName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """RestoreDetailsName.""" + """Type of RestoreDetailsName.""" DEFAULT = "Default" + """Default.""" class RestorePointType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of restore point.""" CONTINUOUS = "CONTINUOUS" + """CONTINUOUS.""" DISCRETE = "DISCRETE" + """DISCRETE.""" class RoleChangeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of the role change, can be Planned or Forced.""" FORCED = "Forced" + """Forced.""" PLANNED = "Planned" + """Planned.""" class RuleSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): """SQL Vulnerability Assessment rule severity.""" HIGH = "High" + """High.""" MEDIUM = "Medium" + """Medium.""" LOW = "Low" + """Low.""" INFORMATIONAL = "Informational" + """Informational.""" OBSOLETE = "Obsolete" + """Obsolete.""" class RuleStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """SQL Vulnerability Assessment baseline status.""" NON_FINDING = "NonFinding" + """NonFinding.""" FINDING = "Finding" + """Finding.""" INTERNAL_ERROR = "InternalError" + """InternalError.""" class RuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """SQL Vulnerability Assessment rule type.""" BINARY = "Binary" + """Binary.""" BASELINE_EXPECTED = "BaselineExpected" + """BaselineExpected.""" POSITIVE_LIST = "PositiveList" + """PositiveList.""" NEGATIVE_LIST = "NegativeList" + """NegativeList.""" class SampleName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The name of the sample schema to apply when creating this database.""" ADVENTURE_WORKS_LT = "AdventureWorksLT" + """AdventureWorksLT.""" WIDE_WORLD_IMPORTERS_STD = "WideWorldImportersStd" + """WideWorldImportersStd.""" WIDE_WORLD_IMPORTERS_FULL = "WideWorldImportersFull" + """WideWorldImportersFull.""" class SecondaryInstanceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of the geo-secondary instance. Set 'Standby' if the instance is used as a DR option only.""" GEO = "Geo" + """Geo.""" STANDBY = "Standby" + """Standby.""" class SecondaryType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -1184,14 +1677,18 @@ class SecondaryType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ GEO = "Geo" + """Geo.""" NAMED = "Named" + """Named.""" STANDBY = "Standby" + """Standby.""" class SecurityAlertPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """SecurityAlertPolicyName.""" + """Type of SecurityAlertPolicyName.""" DEFAULT = "Default" + """Default.""" class SecurityAlertPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -1200,8 +1697,11 @@ class SecurityAlertPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ NEW = "New" + """New.""" ENABLED = "Enabled" + """Enabled.""" DISABLED = "Disabled" + """Disabled.""" class SecurityAlertsPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -1210,74 +1710,98 @@ class SecurityAlertsPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ ENABLED = "Enabled" + """Enabled.""" DISABLED = "Disabled" + """Disabled.""" class SecurityEventType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of the security event.""" UNDEFINED = "Undefined" + """Undefined.""" SQL_INJECTION_VULNERABILITY = "SqlInjectionVulnerability" + """SqlInjectionVulnerability.""" SQL_INJECTION_EXPLOIT = "SqlInjectionExploit" + """SqlInjectionExploit.""" class SeedingModeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Database seeding mode – can be Automatic (default), or Manual for supported scenarios.""" AUTOMATIC = "Automatic" + """Automatic.""" MANUAL = "Manual" + """Manual.""" class SensitivityLabelRank(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """SensitivityLabelRank.""" + """Type of SensitivityLabelRank.""" NONE = "None" + """None.""" LOW = "Low" + """Low.""" MEDIUM = "Medium" + """Medium.""" HIGH = "High" + """High.""" CRITICAL = "Critical" + """Critical.""" class SensitivityLabelSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """SensitivityLabelSource.""" + """Type of SensitivityLabelSource.""" CURRENT = "current" + """current.""" RECOMMENDED = "recommended" + """recommended.""" class SensitivityLabelUpdateKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """SensitivityLabelUpdateKind.""" + """Type of SensitivityLabelUpdateKind.""" SET = "set" + """set.""" REMOVE = "remove" + """remove.""" class ServerConfigurationOptionName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ServerConfigurationOptionName.""" + """Type of ServerConfigurationOptionName.""" ALLOW_POLYBASE_EXPORT = "allowPolybaseExport" + """allowPolybaseExport.""" class ServerConnectionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The server connection type.""" DEFAULT = "Default" + """Default.""" REDIRECT = "Redirect" + """Redirect.""" PROXY = "Proxy" + """Proxy.""" class ServerCreateMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Create mode for server, only valid values for this are Normal and Restore.""" NORMAL = "Normal" + """Normal.""" RESTORE = "Restore" + """Restore.""" class ServerKeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The encryption protector type like 'ServiceManaged', 'AzureKeyVault'.""" SERVICE_MANAGED = "ServiceManaged" + """ServiceManaged.""" AZURE_KEY_VAULT = "AzureKeyVault" + """AzureKeyVault.""" class ServerNetworkAccessFlag(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -1286,7 +1810,9 @@ class ServerNetworkAccessFlag(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ ENABLED = "Enabled" + """Enabled.""" DISABLED = "Disabled" + """Disabled.""" class ServerPublicNetworkAccessFlag(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -1295,15 +1821,22 @@ class ServerPublicNetworkAccessFlag(str, Enum, metaclass=CaseInsensitiveEnumMeta """ ENABLED = "Enabled" + """Enabled.""" DISABLED = "Disabled" + """Disabled.""" SECURED_BY_PERIMETER = "SecuredByPerimeter" + """SecuredByPerimeter.""" -class ServerTrustGroupPropertiesTrustScopesItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ServerTrustGroupPropertiesTrustScopesItem.""" +class ServerTrustGroupPropertiesTrustScopesItem( # pylint: disable=name-too-long + str, Enum, metaclass=CaseInsensitiveEnumMeta +): + """Type of ServerTrustGroupPropertiesTrustScopesItem.""" GLOBAL_TRANSACTIONS = "GlobalTransactions" + """GlobalTransactions.""" SERVICE_BROKER = "ServiceBroker" + """ServiceBroker.""" class ServerWorkspaceFeature(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -1312,84 +1845,18 @@ class ServerWorkspaceFeature(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ CONNECTED = "Connected" + """Connected.""" 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" + """Disconnected.""" class ServicePrincipalType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Service principal type.""" NONE = "None" + """None.""" SYSTEM_ASSIGNED = "SystemAssigned" + """SystemAssigned.""" class SetLegalHoldImmutability(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -1398,26 +1865,32 @@ class SetLegalHoldImmutability(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ ENABLED = "Enabled" + """Enabled.""" DISABLED = "Disabled" + """Disabled.""" class ShortTermRetentionPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ShortTermRetentionPolicyName.""" + """Type of ShortTermRetentionPolicyName.""" DEFAULT = "default" + """default.""" class SqlAgentConfigurationPropertiesState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The state of Sql Agent.""" ENABLED = "Enabled" + """Enabled.""" DISABLED = "Disabled" + """Disabled.""" class SqlVulnerabilityAssessmentName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """SqlVulnerabilityAssessmentName.""" + """Type of SqlVulnerabilityAssessmentName.""" DEFAULT = "default" + """default.""" class SqlVulnerabilityAssessmentState(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -1426,118 +1899,173 @@ class SqlVulnerabilityAssessmentState(str, Enum, metaclass=CaseInsensitiveEnumMe """ ENABLED = "Enabled" + """Enabled.""" DISABLED = "Disabled" + """Disabled.""" class StartStopScheduleName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """StartStopScheduleName.""" + """Type of StartStopScheduleName.""" DEFAULT = "default" + """default.""" class StorageCapabilityStorageAccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The storage account type for the database's backups.""" GRS = "GRS" + """GRS.""" LRS = "LRS" + """LRS.""" ZRS = "ZRS" + """ZRS.""" + GZRS = "GZRS" + """GZRS.""" class StorageKeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Storage key type.""" + """Storage key type: StorageAccessKey, SharedAccessKey or ManagedIdentity.""" SHARED_ACCESS_KEY = "SharedAccessKey" + """SharedAccessKey.""" STORAGE_ACCESS_KEY = "StorageAccessKey" + """StorageAccessKey.""" MANAGED_IDENTITY = "ManagedIdentity" + """ManagedIdentity.""" class SyncAgentState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """State of the sync agent.""" ONLINE = "Online" + """Online.""" OFFLINE = "Offline" + """Offline.""" NEVER_CONNECTED = "NeverConnected" + """NeverConnected.""" class SyncConflictResolutionPolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Conflict resolution policy of the sync group.""" HUB_WIN = "HubWin" + """HubWin.""" MEMBER_WIN = "MemberWin" + """MemberWin.""" class SyncDirection(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Sync direction of the sync member.""" BIDIRECTIONAL = "Bidirectional" + """Bidirectional.""" ONE_WAY_MEMBER_TO_HUB = "OneWayMemberToHub" + """OneWayMemberToHub.""" ONE_WAY_HUB_TO_MEMBER = "OneWayHubToMember" + """OneWayHubToMember.""" class SyncGroupLogType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of the sync group log.""" ALL = "All" + """All.""" ERROR = "Error" + """Error.""" WARNING = "Warning" + """Warning.""" SUCCESS = "Success" + """Success.""" class SyncGroupState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Sync state of the sync group.""" NOT_READY = "NotReady" + """NotReady.""" ERROR = "Error" + """Error.""" WARNING = "Warning" + """Warning.""" PROGRESSING = "Progressing" + """Progressing.""" GOOD = "Good" + """Good.""" class SyncGroupsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """SyncGroupsType.""" + """Type of SyncGroupsType.""" ALL = "All" + """All.""" ERROR = "Error" + """Error.""" WARNING = "Warning" + """Warning.""" SUCCESS = "Success" + """Success.""" class SyncMemberDbType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of the sync agent linked database.""" AZURE_SQL_DATABASE = "AzureSqlDatabase" + """AzureSqlDatabase.""" SQL_SERVER_DATABASE = "SqlServerDatabase" + """SqlServerDatabase.""" class SyncMemberState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Sync state of the sync member.""" SYNC_IN_PROGRESS = "SyncInProgress" + """SyncInProgress.""" SYNC_SUCCEEDED = "SyncSucceeded" + """SyncSucceeded.""" SYNC_FAILED = "SyncFailed" + """SyncFailed.""" DISABLED_TOMBSTONE_CLEANUP = "DisabledTombstoneCleanup" + """DisabledTombstoneCleanup.""" DISABLED_BACKUP_RESTORE = "DisabledBackupRestore" + """DisabledBackupRestore.""" SYNC_SUCCEEDED_WITH_WARNINGS = "SyncSucceededWithWarnings" + """SyncSucceededWithWarnings.""" SYNC_CANCELLING = "SyncCancelling" + """SyncCancelling.""" SYNC_CANCELLED = "SyncCancelled" + """SyncCancelled.""" UN_PROVISIONED = "UnProvisioned" + """UnProvisioned.""" PROVISIONING = "Provisioning" + """Provisioning.""" PROVISIONED = "Provisioned" + """Provisioned.""" PROVISION_FAILED = "ProvisionFailed" + """ProvisionFailed.""" DE_PROVISIONING = "DeProvisioning" + """DeProvisioning.""" DE_PROVISIONED = "DeProvisioned" + """DeProvisioned.""" DE_PROVISION_FAILED = "DeProvisionFailed" + """DeProvisionFailed.""" REPROVISIONING = "Reprovisioning" + """Reprovisioning.""" REPROVISION_FAILED = "ReprovisionFailed" + """ReprovisionFailed.""" UN_REPROVISIONED = "UnReprovisioned" + """UnReprovisioned.""" class TableTemporalType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The table temporal type.""" NON_TEMPORAL_TABLE = "NonTemporalTable" + """NonTemporalTable.""" HISTORY_TABLE = "HistoryTable" + """HistoryTable.""" SYSTEM_VERSIONED_TEMPORAL_TABLE = "SystemVersionedTemporalTable" + """SystemVersionedTemporalTable.""" class TimeBasedImmutability(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -1547,97 +2075,133 @@ class TimeBasedImmutability(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ ENABLED = "Enabled" + """Enabled.""" DISABLED = "Disabled" + """Disabled.""" class TimeBasedImmutabilityMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The time-based immutability mode. Only applicable if time-based immutability is enabled.""" LOCKED = "Locked" + """Locked.""" UNLOCKED = "Unlocked" + """Unlocked.""" class TransparentDataEncryptionName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """TransparentDataEncryptionName.""" + """Type of TransparentDataEncryptionName.""" CURRENT = "current" + """current.""" + + +class TransparentDataEncryptionScanState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies the encryption scan state of the transparent data encryption.""" + + NONE = "None" + """None.""" + RESUME = "Resume" + """Resume.""" + RUNNING = "Running" + """Running.""" + SUSPEND = "Suspend" + """Suspend.""" + ABORTED = "Aborted" + """Aborted.""" + COMPLETED = "Completed" + """Completed.""" class TransparentDataEncryptionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the state of the transparent data encryption.""" ENABLED = "Enabled" + """Enabled.""" DISABLED = "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.""" +class UpsertManagedServerOperationStepWithEstimatesAndDurationStatus( # pylint: disable=name-too-long + str, Enum, metaclass=CaseInsensitiveEnumMeta +): + """Type of UpsertManagedServerOperationStepWithEstimatesAndDurationStatus.""" NOT_STARTED = "NotStarted" + """NotStarted.""" IN_PROGRESS = "InProgress" + """InProgress.""" SLOWED_DOWN = "SlowedDown" + """SlowedDown.""" COMPLETED = "Completed" + """Completed.""" FAILED = "Failed" + """Failed.""" CANCELED = "Canceled" + """Canceled.""" class VirtualNetworkRuleState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Virtual Network Rule State.""" INITIALIZING = "Initializing" + """Initializing.""" IN_PROGRESS = "InProgress" + """InProgress.""" READY = "Ready" + """Ready.""" FAILED = "Failed" + """Failed.""" DELETING = "Deleting" + """Deleting.""" UNKNOWN = "Unknown" + """Unknown.""" class VulnerabilityAssessmentName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """VulnerabilityAssessmentName.""" + """Type of VulnerabilityAssessmentName.""" DEFAULT = "default" + """default.""" -class VulnerabilityAssessmentPolicyBaselineName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """VulnerabilityAssessmentPolicyBaselineName.""" +class VulnerabilityAssessmentPolicyBaselineName( # pylint: disable=name-too-long + str, Enum, metaclass=CaseInsensitiveEnumMeta +): + """Type of VulnerabilityAssessmentPolicyBaselineName.""" MASTER = "master" + """master.""" DEFAULT = "default" + """default.""" class VulnerabilityAssessmentScanState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The scan status.""" PASSED = "Passed" + """Passed.""" FAILED = "Failed" + """Failed.""" FAILED_TO_RUN = "FailedToRun" + """FailedToRun.""" IN_PROGRESS = "InProgress" + """InProgress.""" class VulnerabilityAssessmentScanTriggerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The scan trigger type.""" ON_DEMAND = "OnDemand" + """OnDemand.""" RECURRING = "Recurring" + """Recurring.""" + + +class VulnerabilityAssessmentSystemDatabaseName( # pylint: disable=name-too-long + str, Enum, metaclass=CaseInsensitiveEnumMeta +): + """Type of VulnerabilityAssessmentSystemDatabaseName.""" + + MASTER = "master" + """master.""" diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_models.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_models.py new file mode 100644 index 000000000000..596df25250fa --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_models.py @@ -0,0 +1,25285 @@ +# pylint: disable=line-too-long,useless-suppression,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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=useless-super-delegation + +import datetime +from typing import Any, Mapping, Optional, TYPE_CHECKING, Union, overload + +from .._utils.model_base import Model as _Model, rest_field + +if TYPE_CHECKING: + from .. import models as _models + + +class AdministratorProperties(_Model): + """Properties of a active directory administrator. + + :ivar administrator_type: Type of the sever administrator. "ActiveDirectory" + :vartype administrator_type: str or ~azure.mgmt.sql.models.AdministratorType + :ivar login: Login name of the server administrator. Required. + :vartype login: str + :ivar sid: SID (object ID) of the server administrator. Required. + :vartype sid: str + :ivar tenant_id: Tenant ID of the administrator. + :vartype tenant_id: str + :ivar azure_ad_only_authentication: Azure Active Directory only Authentication enabled. + :vartype azure_ad_only_authentication: bool + """ + + administrator_type: Optional[Union[str, "_models.AdministratorType"]] = rest_field( + name="administratorType", visibility=["read", "create", "update", "delete", "query"] + ) + """Type of the sever administrator. \"ActiveDirectory\"""" + login: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Login name of the server administrator. Required.""" + sid: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """SID (object ID) of the server administrator. Required.""" + tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read", "create", "update", "delete", "query"]) + """Tenant ID of the administrator.""" + azure_ad_only_authentication: Optional[bool] = rest_field(name="azureADOnlyAuthentication", visibility=["read"]) + """Azure Active Directory only Authentication enabled.""" + + @overload + def __init__( + self, + *, + login: str, + sid: str, + administrator_type: Optional[Union[str, "_models.AdministratorType"]] = None, + tenant_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AdvancedThreatProtectionProperties(_Model): + """Properties of an Advanced Threat Protection state. + + :ivar state: Specifies the state of the Advanced Threat Protection, whether it is enabled or + disabled or a state has not been applied yet on the specific database or server. Required. + Known values are: "New", "Enabled", and "Disabled". + :vartype state: str or ~azure.mgmt.sql.models.AdvancedThreatProtectionState + :ivar creation_time: Specifies the UTC creation time of the policy. + :vartype creation_time: ~datetime.datetime + """ + + state: Union[str, "_models.AdvancedThreatProtectionState"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the state of the Advanced Threat Protection, whether it is enabled or disabled or a + state has not been applied yet on the specific database or server. Required. Known values are: + \"New\", \"Enabled\", and \"Disabled\".""" + creation_time: Optional[datetime.datetime] = rest_field(name="creationTime", visibility=["read"], format="rfc3339") + """Specifies the UTC creation time of the policy.""" + + @overload + def __init__( + self, + *, + state: Union[str, "_models.AdvancedThreatProtectionState"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Resource(_Model): + """Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.""" + name: Optional[str] = rest_field(visibility=["read"]) + """The name of the resource.""" + type: Optional[str] = rest_field(visibility=["read"]) + """The type of the resource. E.g. \"Microsoft.Compute/virtualMachines\" or + \"Microsoft.Storage/storageAccounts\".""" + system_data: Optional["_models.SystemData"] = rest_field(name="systemData", visibility=["read"]) + """Azure Resource Manager metadata containing createdBy and modifiedBy information.""" + + +class ProxyResource(Resource): + """Proxy Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + """ + + +class Advisor(ProxyResource): + """Database, Server or Elastic Pool Advisor. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.AdvisorProperties + :ivar kind: Resource kind. + :vartype kind: str + :ivar location: Resource location. + :vartype location: str + """ + + properties: Optional["_models.AdvisorProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + kind: Optional[str] = rest_field(visibility=["read"]) + """Resource kind.""" + location: Optional[str] = rest_field(visibility=["read"]) + """Resource location.""" + + __flattened_items = [ + "advisor_status", + "auto_execute_status", + "auto_execute_status_inherited_from", + "recommendations_status", + "last_checked", + "recommended_actions", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.AdvisorProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class AdvisorProperties(_Model): + """Properties for a Database, Server or Elastic Pool Advisor. + + :ivar advisor_status: Gets the status of availability of this advisor to customers. Possible + values are 'GA', 'PublicPreview', 'LimitedPublicPreview' and 'PrivatePreview'. Known values + are: "GA", "PublicPreview", "LimitedPublicPreview", and "PrivatePreview". + :vartype advisor_status: str or ~azure.mgmt.sql.models.AdvisorStatus + :ivar auto_execute_status: Gets the auto-execute status (whether to let the system execute the + recommendations) of this advisor. Possible values are 'Enabled' and 'Disabled'. Required. Known + values are: "Enabled", "Disabled", and "Default". + :vartype auto_execute_status: str or ~azure.mgmt.sql.models.AutoExecuteStatus + :ivar auto_execute_status_inherited_from: Gets the resource from which current value of + auto-execute status is inherited. Auto-execute status can be set on (and inherited from) + different levels in the resource hierarchy. Possible values are 'Subscription', 'Server', + 'ElasticPool', 'Database' and 'Default' (when status is not explicitly set on any level). Known + values are: "Default", "Subscription", "Server", "ElasticPool", and "Database". + :vartype auto_execute_status_inherited_from: str or + ~azure.mgmt.sql.models.AutoExecuteStatusInheritedFrom + :ivar recommendations_status: Gets that status of recommendations for this advisor and reason + for not having any recommendations. Possible values include, but are not limited to, 'Ok' + (Recommendations available),LowActivity (not enough workload to analyze), 'DbSeemsTuned' + (Database is doing well), etc. + :vartype recommendations_status: str + :ivar last_checked: Gets the time when the current resource was analyzed for recommendations by + this advisor. + :vartype last_checked: ~datetime.datetime + :ivar recommended_actions: Gets the recommended actions for this advisor. + :vartype recommended_actions: list[~azure.mgmt.sql.models.RecommendedAction] + """ + + advisor_status: Optional[Union[str, "_models.AdvisorStatus"]] = rest_field( + name="advisorStatus", visibility=["read"] + ) + """Gets the status of availability of this advisor to customers. Possible values are 'GA', + 'PublicPreview', 'LimitedPublicPreview' and 'PrivatePreview'. Known values are: \"GA\", + \"PublicPreview\", \"LimitedPublicPreview\", and \"PrivatePreview\".""" + auto_execute_status: Union[str, "_models.AutoExecuteStatus"] = rest_field( + name="autoExecuteStatus", visibility=["read", "create", "update", "delete", "query"] + ) + """Gets the auto-execute status (whether to let the system execute the recommendations) of this + advisor. Possible values are 'Enabled' and 'Disabled'. Required. Known values are: \"Enabled\", + \"Disabled\", and \"Default\".""" + auto_execute_status_inherited_from: Optional[Union[str, "_models.AutoExecuteStatusInheritedFrom"]] = rest_field( + name="autoExecuteStatusInheritedFrom", visibility=["read"] + ) + """Gets the resource from which current value of auto-execute status is inherited. Auto-execute + status can be set on (and inherited from) different levels in the resource hierarchy. Possible + values are 'Subscription', 'Server', 'ElasticPool', 'Database' and 'Default' (when status is + not explicitly set on any level). Known values are: \"Default\", \"Subscription\", \"Server\", + \"ElasticPool\", and \"Database\".""" + recommendations_status: Optional[str] = rest_field(name="recommendationsStatus", visibility=["read"]) + """Gets that status of recommendations for this advisor and reason for not having any + recommendations. Possible values include, but are not limited to, 'Ok' (Recommendations + available),LowActivity (not enough workload to analyze), 'DbSeemsTuned' (Database is doing + well), etc.""" + last_checked: Optional[datetime.datetime] = rest_field(name="lastChecked", visibility=["read"], format="rfc3339") + """Gets the time when the current resource was analyzed for recommendations by this advisor.""" + recommended_actions: Optional[list["_models.RecommendedAction"]] = rest_field( + name="recommendedActions", visibility=["read"] + ) + """Gets the recommended actions for this advisor.""" + + @overload + def __init__( + self, + *, + auto_execute_status: Union[str, "_models.AutoExecuteStatus"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AutomaticTuningOptions(_Model): + """Automatic tuning properties for individual advisors. + + :ivar desired_state: Automatic tuning option desired state. Known values are: "Off", "On", and + "Default". + :vartype desired_state: str or ~azure.mgmt.sql.models.AutomaticTuningOptionModeDesired + :ivar actual_state: Automatic tuning option actual state. Known values are: "Off" and "On". + :vartype actual_state: str or ~azure.mgmt.sql.models.AutomaticTuningOptionModeActual + :ivar reason_code: Reason code if desired and actual state are different. + :vartype reason_code: int + :ivar reason_desc: Reason description if desired and actual state are different. Known values + are: "Default", "Disabled", "AutoConfigured", "InheritedFromServer", "QueryStoreOff", + "QueryStoreReadOnly", and "NotSupported". + :vartype reason_desc: str or ~azure.mgmt.sql.models.AutomaticTuningDisabledReason + """ + + desired_state: Optional[Union[str, "_models.AutomaticTuningOptionModeDesired"]] = rest_field( + name="desiredState", visibility=["read", "create", "update", "delete", "query"] + ) + """Automatic tuning option desired state. Known values are: \"Off\", \"On\", and \"Default\".""" + actual_state: Optional[Union[str, "_models.AutomaticTuningOptionModeActual"]] = rest_field( + name="actualState", visibility=["read"] + ) + """Automatic tuning option actual state. Known values are: \"Off\" and \"On\".""" + reason_code: Optional[int] = rest_field(name="reasonCode", visibility=["read"]) + """Reason code if desired and actual state are different.""" + reason_desc: Optional[Union[str, "_models.AutomaticTuningDisabledReason"]] = rest_field( + name="reasonDesc", visibility=["read"] + ) + """Reason description if desired and actual state are different. Known values are: \"Default\", + \"Disabled\", \"AutoConfigured\", \"InheritedFromServer\", \"QueryStoreOff\", + \"QueryStoreReadOnly\", and \"NotSupported\".""" + + @overload + def __init__( + self, + *, + desired_state: Optional[Union[str, "_models.AutomaticTuningOptionModeDesired"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AutomaticTuningServerOptions(_Model): + """Automatic tuning properties for individual advisors. + + :ivar desired_state: Automatic tuning option desired state. Known values are: "Off", "On", and + "Default". + :vartype desired_state: str or ~azure.mgmt.sql.models.AutomaticTuningOptionModeDesired + :ivar actual_state: Automatic tuning option actual state. Known values are: "Off" and "On". + :vartype actual_state: str or ~azure.mgmt.sql.models.AutomaticTuningOptionModeActual + :ivar reason_code: Reason code if desired and actual state are different. + :vartype reason_code: int + :ivar reason_desc: Reason description if desired and actual state are different. Known values + are: "Default", "Disabled", and "AutoConfigured". + :vartype reason_desc: str or ~azure.mgmt.sql.models.AutomaticTuningServerReason + """ + + desired_state: Optional[Union[str, "_models.AutomaticTuningOptionModeDesired"]] = rest_field( + name="desiredState", visibility=["read", "create", "update", "delete", "query"] + ) + """Automatic tuning option desired state. Known values are: \"Off\", \"On\", and \"Default\".""" + actual_state: Optional[Union[str, "_models.AutomaticTuningOptionModeActual"]] = rest_field( + name="actualState", visibility=["read"] + ) + """Automatic tuning option actual state. Known values are: \"Off\" and \"On\".""" + reason_code: Optional[int] = rest_field(name="reasonCode", visibility=["read"]) + """Reason code if desired and actual state are different.""" + reason_desc: Optional[Union[str, "_models.AutomaticTuningServerReason"]] = rest_field( + name="reasonDesc", visibility=["read"] + ) + """Reason description if desired and actual state are different. Known values are: \"Default\", + \"Disabled\", and \"AutoConfigured\".""" + + @overload + def __init__( + self, + *, + desired_state: Optional[Union[str, "_models.AutomaticTuningOptionModeDesired"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AutomaticTuningServerProperties(_Model): + """Server-level Automatic Tuning properties. + + :ivar desired_state: Automatic tuning desired state. Known values are: "Custom", "Auto", and + "Unspecified". + :vartype desired_state: str or ~azure.mgmt.sql.models.AutomaticTuningServerMode + :ivar actual_state: Automatic tuning actual state. Known values are: "Custom", "Auto", and + "Unspecified". + :vartype actual_state: str or ~azure.mgmt.sql.models.AutomaticTuningServerMode + :ivar options: Automatic tuning options definition. + :vartype options: dict[str, ~azure.mgmt.sql.models.AutomaticTuningServerOptions] + """ + + desired_state: Optional[Union[str, "_models.AutomaticTuningServerMode"]] = rest_field( + name="desiredState", visibility=["read", "create", "update", "delete", "query"] + ) + """Automatic tuning desired state. Known values are: \"Custom\", \"Auto\", and \"Unspecified\".""" + actual_state: Optional[Union[str, "_models.AutomaticTuningServerMode"]] = rest_field( + name="actualState", visibility=["read"] + ) + """Automatic tuning actual state. Known values are: \"Custom\", \"Auto\", and \"Unspecified\".""" + options: Optional[dict[str, "_models.AutomaticTuningServerOptions"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Automatic tuning options definition.""" + + @overload + def __init__( + self, + *, + desired_state: Optional[Union[str, "_models.AutomaticTuningServerMode"]] = None, + options: Optional[dict[str, "_models.AutomaticTuningServerOptions"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AutoPauseDelayTimeRange(_Model): + """Supported auto pause delay time range. + + :ivar min_value: Minimum value. + :vartype min_value: int + :ivar max_value: Maximum value. + :vartype max_value: int + :ivar step_size: Step value for discrete values between the minimum value and the maximum + value. + :vartype step_size: int + :ivar default: Default value is no value is provided. + :vartype default: int + :ivar unit: Unit of time that delay is expressed in. "Minutes" + :vartype unit: str or ~azure.mgmt.sql.models.PauseDelayTimeUnit + :ivar do_not_pause_value: Value that is used to not pause (infinite delay before pause). + :vartype do_not_pause_value: int + """ + + min_value: Optional[int] = rest_field(name="minValue", visibility=["read"]) + """Minimum value.""" + max_value: Optional[int] = rest_field(name="maxValue", visibility=["read"]) + """Maximum value.""" + step_size: Optional[int] = rest_field(name="stepSize", visibility=["read"]) + """Step value for discrete values between the minimum value and the maximum value.""" + default: Optional[int] = rest_field(visibility=["read"]) + """Default value is no value is provided.""" + unit: Optional[Union[str, "_models.PauseDelayTimeUnit"]] = rest_field(visibility=["read"]) + """Unit of time that delay is expressed in. \"Minutes\"""" + do_not_pause_value: Optional[int] = rest_field(name="doNotPauseValue", visibility=["read"]) + """Value that is used to not pause (infinite delay before pause).""" + + +class AzureADOnlyAuthProperties(_Model): + """Properties of a active directory only authentication. + + :ivar azure_ad_only_authentication: Azure Active Directory only Authentication enabled. + Required. + :vartype azure_ad_only_authentication: bool + """ + + azure_ad_only_authentication: bool = rest_field( + name="azureADOnlyAuthentication", visibility=["read", "create", "update", "delete", "query"] + ) + """Azure Active Directory only Authentication enabled. Required.""" + + @overload + def __init__( + self, + *, + azure_ad_only_authentication: bool, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BackupShortTermRetentionPolicy(ProxyResource): + """A short term retention policy. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.BackupShortTermRetentionPolicyProperties + """ + + properties: Optional["_models.BackupShortTermRetentionPolicyProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["retention_days", "diff_backup_interval_in_hours"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.BackupShortTermRetentionPolicyProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class BackupShortTermRetentionPolicyProperties(_Model): + """Properties of a short term retention policy. + + :ivar retention_days: The backup retention period in days. This is how many days Point-in-Time + Restore will be supported. + :vartype retention_days: int + :ivar diff_backup_interval_in_hours: The differential backup interval in hours. This is how + many interval hours between each differential backup will be supported. This is only applicable + to live databases but not dropped databases. Known values are: 12 and 24. + :vartype diff_backup_interval_in_hours: int or ~azure.mgmt.sql.models.DiffBackupIntervalInHours + """ + + retention_days: Optional[int] = rest_field( + name="retentionDays", visibility=["read", "create", "update", "delete", "query"] + ) + """The backup retention period in days. This is how many days Point-in-Time Restore will be + supported.""" + diff_backup_interval_in_hours: Optional[Union[int, "_models.DiffBackupIntervalInHours"]] = rest_field( + name="diffBackupIntervalInHours", visibility=["read", "create", "update", "delete", "query"] + ) + """The differential backup interval in hours. This is how many interval hours between each + differential backup will be supported. This is only applicable to live databases but not + dropped databases. Known values are: 12 and 24.""" + + @overload + def __init__( + self, + *, + retention_days: Optional[int] = None, + diff_backup_interval_in_hours: Optional[Union[int, "_models.DiffBackupIntervalInHours"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Baseline(_Model): + """SQL Vulnerability Assessment baseline Details. + + :ivar expected_results: SQL Vulnerability Assessment baseline expected results. + :vartype expected_results: list[list[str]] + :ivar updated_time: SQL Vulnerability Assessment baseline update time (UTC). + :vartype updated_time: ~datetime.datetime + """ + + expected_results: Optional[list[list[str]]] = rest_field(name="expectedResults", visibility=["read"]) + """SQL Vulnerability Assessment baseline expected results.""" + updated_time: Optional[datetime.datetime] = rest_field(name="updatedTime", visibility=["read"], format="rfc3339") + """SQL Vulnerability Assessment baseline update time (UTC).""" + + +class BaselineAdjustedResult(_Model): + """SQL Vulnerability Assessment baseline adjusted results. + + :ivar baseline: SQL Vulnerability Assessment baseline details. + :vartype baseline: ~azure.mgmt.sql.models.Baseline + :ivar status: SQL Vulnerability Assessment baseline status. Known values are: "NonFinding", + "Finding", and "InternalError". + :vartype status: str or ~azure.mgmt.sql.models.RuleStatus + :ivar results_not_in_baseline: SQL Vulnerability Assessment results that are not in baseline. + :vartype results_not_in_baseline: list[list[str]] + :ivar results_only_in_baseline: SQL Vulnerability Assessment results that are in baseline. + :vartype results_only_in_baseline: list[list[str]] + """ + + baseline: Optional["_models.Baseline"] = rest_field(visibility=["read"]) + """SQL Vulnerability Assessment baseline details.""" + status: Optional[Union[str, "_models.RuleStatus"]] = rest_field(visibility=["read"]) + """SQL Vulnerability Assessment baseline status. Known values are: \"NonFinding\", \"Finding\", + and \"InternalError\".""" + results_not_in_baseline: Optional[list[list[str]]] = rest_field(name="resultsNotInBaseline", visibility=["read"]) + """SQL Vulnerability Assessment results that are not in baseline.""" + results_only_in_baseline: Optional[list[list[str]]] = rest_field(name="resultsOnlyInBaseline", visibility=["read"]) + """SQL Vulnerability Assessment results that are in baseline.""" + + +class BenchmarkReference(_Model): + """SQL Vulnerability Assessment benchmark reference. + + :ivar benchmark: SQL Vulnerability Assessment benchmark name. + :vartype benchmark: str + :ivar reference: SQL Vulnerability Assessment benchmark reference. + :vartype reference: str + """ + + benchmark: Optional[str] = rest_field(visibility=["read"]) + """SQL Vulnerability Assessment benchmark name.""" + reference: Optional[str] = rest_field(visibility=["read"]) + """SQL Vulnerability Assessment benchmark reference.""" + + +class CertificateInfo(_Model): + """Certificate information. + + :ivar certificate_name: The certificate name. + :vartype certificate_name: str + :ivar expiry_date: The certificate expiry date. + :vartype expiry_date: ~datetime.datetime + """ + + certificate_name: Optional[str] = rest_field(name="certificateName", visibility=["read"]) + """The certificate name.""" + expiry_date: Optional[datetime.datetime] = rest_field(name="expiryDate", visibility=["read"], format="rfc3339") + """The certificate expiry date.""" + + +class ChangeLongTermRetentionBackupAccessTierParameters(_Model): # pylint: disable=name-too-long + """Contains the information necessary to change long term retention backup access tier and related + operation mode. + + :ivar backup_storage_access_tier: The long term retention backup storage access tier. Required. + :vartype backup_storage_access_tier: str + :ivar operation_mode: The operation mode when updating ltr backup storage access tier. + Required. + :vartype operation_mode: str + """ + + backup_storage_access_tier: str = rest_field( + name="backupStorageAccessTier", visibility=["read", "create", "update", "delete", "query"] + ) + """The long term retention backup storage access tier. Required.""" + operation_mode: str = rest_field(name="operationMode", visibility=["read", "create", "update", "delete", "query"]) + """The operation mode when updating ltr backup storage access tier. Required.""" + + @overload + def __init__( + self, + *, + backup_storage_access_tier: str, + operation_mode: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CheckNameAvailabilityRequest(_Model): + """A request to check whether the specified name for a resource is available. + + :ivar name: Required. + :vartype name: str + :ivar type: Required. "Microsoft.Sql/servers" + :vartype type: str or ~azure.mgmt.sql.models.CheckNameAvailabilityResourceType + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + type: Union[str, "_models.CheckNameAvailabilityResourceType"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Required. \"Microsoft.Sql/servers\"""" + + @overload + def __init__( + self, + *, + name: str, + type: Union[str, "_models.CheckNameAvailabilityResourceType"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CheckNameAvailabilityResponse(_Model): + """The result of a name availability check. + + :ivar name: The name whose availability was checked. + :vartype name: str + :ivar available: True if the name is available, otherwise false. + :vartype available: bool + :ivar reason: The reason code explaining why the name is unavailable. Will be undefined if the + name is available. Known values are: "Invalid" and "AlreadyExists". + :vartype reason: str or ~azure.mgmt.sql.models.CheckNameAvailabilityReason + :ivar message: A message explaining why the name is unavailable. Will be undefined if the name + is available. + :vartype message: str + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """The name whose availability was checked.""" + available: Optional[bool] = rest_field(visibility=["read"]) + """True if the name is available, otherwise false.""" + reason: Optional[Union[str, "_models.CheckNameAvailabilityReason"]] = rest_field(visibility=["read"]) + """The reason code explaining why the name is unavailable. Will be undefined if the name is + available. Known values are: \"Invalid\" and \"AlreadyExists\".""" + message: Optional[str] = rest_field(visibility=["read"]) + """A message explaining why the name is unavailable. Will be undefined if the name is available.""" + + +class CompleteDatabaseRestoreDefinition(_Model): + """Contains the information necessary to perform a complete database restore operation. + + :ivar last_backup_name: The last backup name to apply. Required. + :vartype last_backup_name: str + """ + + last_backup_name: str = rest_field( + name="lastBackupName", visibility=["read", "create", "update", "delete", "query"] + ) + """The last backup name to apply. Required.""" + + @overload + def __init__( + self, + *, + last_backup_name: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CopyLongTermRetentionBackupParameters(_Model): + """Contains the information necessary to perform long term retention backup copy operation. + + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.CopyLongTermRetentionBackupParametersProperties + """ + + properties: Optional["_models.CopyLongTermRetentionBackupParametersProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "target_subscription_id", + "target_resource_group", + "target_server_resource_id", + "target_server_fully_qualified_domain_name", + "target_database_name", + "target_backup_storage_redundancy", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.CopyLongTermRetentionBackupParametersProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class CopyLongTermRetentionBackupParametersProperties(_Model): # pylint: disable=name-too-long + """Contains the properties to perform long term retention backup copy operation. + + :ivar target_subscription_id: The subscription that owns the target server. + :vartype target_subscription_id: str + :ivar target_resource_group: The resource group that owns the target server. + :vartype target_resource_group: str + :ivar target_server_resource_id: The resource Id of the target server that owns the database. + :vartype target_server_resource_id: str + :ivar target_server_fully_qualified_domain_name: The fully qualified domain name of the target + server. + :vartype target_server_fully_qualified_domain_name: str + :ivar target_database_name: The name of the database owns the copied backup. + :vartype target_database_name: str + :ivar target_backup_storage_redundancy: The storage redundancy type of the copied backup. Known + values are: "Geo", "Local", "Zone", and "GeoZone". + :vartype target_backup_storage_redundancy: str or + ~azure.mgmt.sql.models.BackupStorageRedundancy + """ + + target_subscription_id: Optional[str] = rest_field(name="targetSubscriptionId", visibility=["create"]) + """The subscription that owns the target server.""" + target_resource_group: Optional[str] = rest_field(name="targetResourceGroup", visibility=["create"]) + """The resource group that owns the target server.""" + target_server_resource_id: Optional[str] = rest_field(name="targetServerResourceId", visibility=["create"]) + """The resource Id of the target server that owns the database.""" + target_server_fully_qualified_domain_name: Optional[str] = rest_field( + name="targetServerFullyQualifiedDomainName", visibility=["create"] + ) + """The fully qualified domain name of the target server.""" + target_database_name: Optional[str] = rest_field(name="targetDatabaseName", visibility=["create"]) + """The name of the database owns the copied backup.""" + target_backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = rest_field( + name="targetBackupStorageRedundancy", visibility=["create"] + ) + """The storage redundancy type of the copied backup. Known values are: \"Geo\", \"Local\", + \"Zone\", and \"GeoZone\".""" + + @overload + def __init__( + self, + *, + target_subscription_id: Optional[str] = None, + target_resource_group: Optional[str] = None, + target_server_resource_id: Optional[str] = None, + target_server_fully_qualified_domain_name: Optional[str] = None, + target_database_name: Optional[str] = None, + target_backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CreateDatabaseRestorePointDefinition(_Model): + """Contains the information necessary to perform a create database restore point operation. + + :ivar restore_point_label: The restore point label to apply. Required. + :vartype restore_point_label: str + """ + + restore_point_label: str = rest_field( + name="restorePointLabel", visibility=["read", "create", "update", "delete", "query"] + ) + """The restore point label to apply. Required.""" + + @overload + def __init__( + self, + *, + restore_point_label: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class TrackedResource(Resource): + """Tracked Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + """ + + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource tags.""" + location: str = rest_field(visibility=["read", "create"]) + """The geo-location where the resource lives. Required.""" + + @overload + def __init__( + self, + *, + location: str, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Database(TrackedResource): + """A database resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.DatabaseProperties + :ivar sku: The database SKU. + + The list of SKUs may vary by region and support offer. To determine the SKUs (including the SKU + name, tier/edition, family, and capacity) that are available to your subscription in an Azure + region, use the ``Capabilities_ListByLocation`` REST API or one of the following commands: + + + + .. code-block:: azurecli + + az sql db list-editions -l -o table + + + + .. code-block:: powershell + + Get-AzSqlServerServiceObjective -Location . + :vartype sku: ~azure.mgmt.sql.models.Sku + :ivar kind: Kind of database. This is metadata used for the Azure portal experience. + :vartype kind: str + :ivar managed_by: Resource that manages the database. + :vartype managed_by: str + :ivar identity: The Azure Active Directory identity of the database. + :vartype identity: ~azure.mgmt.sql.models.DatabaseIdentity + """ + + properties: Optional["_models.DatabaseProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + sku: Optional["_models.Sku"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The database SKU. + + The list of SKUs may vary by region and support offer. To determine the SKUs (including the SKU + name, tier/edition, family, and capacity) that are available to your subscription in an Azure + region, use the ``Capabilities_ListByLocation`` REST API or one of the following commands: + + + + .. code-block:: azurecli + + az sql db list-editions -l -o table + + + + .. code-block:: powershell + + Get-AzSqlServerServiceObjective -Location .""" + kind: Optional[str] = rest_field(visibility=["read"]) + """Kind of database. This is metadata used for the Azure portal experience.""" + managed_by: Optional[str] = rest_field(name="managedBy", visibility=["read"]) + """Resource that manages the database.""" + identity: Optional["_models.DatabaseIdentity"] = rest_field(visibility=["read", "create"]) + """The Azure Active Directory identity of the database.""" + + __flattened_items = [ + "create_mode", + "collation", + "max_size_bytes", + "sample_name", + "elastic_pool_id", + "source_database_id", + "status", + "database_id", + "creation_date", + "current_service_objective_name", + "requested_service_objective_name", + "default_secondary_location", + "failover_group_id", + "restore_point_in_time", + "source_database_deletion_date", + "recovery_services_recovery_point_id", + "long_term_retention_backup_resource_id", + "recoverable_database_id", + "restorable_dropped_database_id", + "catalog_collation", + "zone_redundant", + "license_type", + "max_log_size_bytes", + "earliest_restore_date", + "read_scale", + "high_availability_replica_count", + "secondary_type", + "current_sku", + "auto_pause_delay", + "current_backup_storage_redundancy", + "requested_backup_storage_redundancy", + "min_capacity", + "paused_date", + "resumed_date", + "maintenance_configuration_id", + "is_ledger_on", + "is_infra_encryption_enabled", + "federated_client_id", + "keys_property", + "encryption_protector", + "preferred_enclave_type", + "use_free_limit", + "free_limit_exhaustion_behavior", + "source_resource_id", + "manual_cutover", + "perform_cutover", + "availability_zone", + "encryption_protector_auto_rotation", + "provisioning_state", + ] + + @overload + def __init__( + self, + *, + location: str, + tags: Optional[dict[str, str]] = None, + properties: Optional["_models.DatabaseProperties"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.DatabaseIdentity"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class DatabaseAdvancedThreatProtection(ProxyResource): + """A database Advanced Threat Protection. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.AdvancedThreatProtectionProperties + """ + + properties: Optional["_models.AdvancedThreatProtectionProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["state", "creation_time"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.AdvancedThreatProtectionProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class DatabaseAutomaticTuning(ProxyResource): + """Database-level Automatic Tuning. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.DatabaseAutomaticTuningProperties + """ + + properties: Optional["_models.DatabaseAutomaticTuningProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["desired_state", "actual_state", "options"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.DatabaseAutomaticTuningProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class DatabaseAutomaticTuningProperties(_Model): + """Database-level Automatic Tuning properties. + + :ivar desired_state: Automatic tuning desired state. Known values are: "Inherit", "Custom", + "Auto", and "Unspecified". + :vartype desired_state: str or ~azure.mgmt.sql.models.AutomaticTuningMode + :ivar actual_state: Automatic tuning actual state. Known values are: "Inherit", "Custom", + "Auto", and "Unspecified". + :vartype actual_state: str or ~azure.mgmt.sql.models.AutomaticTuningMode + :ivar options: Automatic tuning options definition. + :vartype options: dict[str, ~azure.mgmt.sql.models.AutomaticTuningOptions] + """ + + desired_state: Optional[Union[str, "_models.AutomaticTuningMode"]] = rest_field( + name="desiredState", visibility=["read", "create", "update", "delete", "query"] + ) + """Automatic tuning desired state. Known values are: \"Inherit\", \"Custom\", \"Auto\", and + \"Unspecified\".""" + actual_state: Optional[Union[str, "_models.AutomaticTuningMode"]] = rest_field( + name="actualState", visibility=["read"] + ) + """Automatic tuning actual state. Known values are: \"Inherit\", \"Custom\", \"Auto\", and + \"Unspecified\".""" + options: Optional[dict[str, "_models.AutomaticTuningOptions"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Automatic tuning options definition.""" + + @overload + def __init__( + self, + *, + desired_state: Optional[Union[str, "_models.AutomaticTuningMode"]] = None, + options: Optional[dict[str, "_models.AutomaticTuningOptions"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DatabaseBlobAuditingPolicy(ProxyResource): + """A database blob auditing policy. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.DatabaseBlobAuditingPolicyProperties + :ivar kind: Resource kind. + :vartype kind: str + """ + + properties: Optional["_models.DatabaseBlobAuditingPolicyProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + kind: Optional[str] = rest_field(visibility=["read"]) + """Resource kind.""" + + __flattened_items = [ + "retention_days", + "audit_actions_and_groups", + "is_storage_secondary_key_in_use", + "is_azure_monitor_target_enabled", + "queue_delay_ms", + "is_managed_identity_in_use", + "state", + "storage_endpoint", + "storage_account_access_key", + "storage_account_subscription_id", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.DatabaseBlobAuditingPolicyProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class DatabaseBlobAuditingPolicyProperties(_Model): + """Properties of a database blob auditing policy. + + :ivar retention_days: Specifies the number of days to keep in the audit logs in the storage + account. + :vartype retention_days: int + :ivar audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. + + The recommended set of action groups to use is the following combination - this will audit all + the queries and stored procedures executed against the database, as well as successful and + failed logins: + + BATCH_COMPLETED_GROUP, + SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, + FAILED_DATABASE_AUTHENTICATION_GROUP. + + This above combination is also the set that is configured by default when enabling auditing + from the Azure portal. + + The supported action groups to audit are (note: choose only specific groups that cover your + auditing needs. Using unnecessary groups could lead to very large quantities of audit records): + + APPLICATION_ROLE_CHANGE_PASSWORD_GROUP + BACKUP_RESTORE_GROUP + DATABASE_LOGOUT_GROUP + DATABASE_OBJECT_CHANGE_GROUP + DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP + DATABASE_OBJECT_PERMISSION_CHANGE_GROUP + DATABASE_OPERATION_GROUP + DATABASE_PERMISSION_CHANGE_GROUP + DATABASE_PRINCIPAL_CHANGE_GROUP + DATABASE_PRINCIPAL_IMPERSONATION_GROUP + DATABASE_ROLE_MEMBER_CHANGE_GROUP + FAILED_DATABASE_AUTHENTICATION_GROUP + SCHEMA_OBJECT_ACCESS_GROUP + SCHEMA_OBJECT_CHANGE_GROUP + SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP + SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP + SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP + USER_CHANGE_PASSWORD_GROUP + BATCH_STARTED_GROUP + BATCH_COMPLETED_GROUP + DBCC_GROUP + DATABASE_OWNERSHIP_CHANGE_GROUP + DATABASE_CHANGE_GROUP + LEDGER_OPERATION_GROUP + + These are groups that cover all sql statements and stored procedures executed against the + database, and should not be used in combination with other groups as this will result in + duplicate audit logs. + + For more information, see `Database-Level Audit Action Groups + `_. + + For Database auditing policy, specific Actions can also be specified (note that Actions cannot + be specified for Server auditing policy). The supported actions to audit are: + SELECT + UPDATE + INSERT + DELETE + EXECUTE + RECEIVE + REFERENCES + + The general form for defining an action to be audited is: + {action} ON {object} BY {principal} + + Note that in the above format can refer to an object like a table, view, or stored + procedure, or an entire database or schema. For the latter cases, the forms DATABASE::{db_name} + and SCHEMA::{schema_name} are used, respectively. + + For example: + SELECT on dbo.myTable by public + SELECT on DATABASE::myDatabase by public + SELECT on SCHEMA::mySchema by public + + For more information, see `Database-Level Audit Actions + `_. + :vartype audit_actions_and_groups: list[str] + :ivar is_storage_secondary_key_in_use: Specifies whether storageAccountAccessKey value is the + storage's secondary key. + :vartype is_storage_secondary_key_in_use: bool + :ivar is_azure_monitor_target_enabled: Specifies whether audit events are sent to Azure + Monitor. + In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and + 'IsAzureMonitorTargetEnabled' as true. + + When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' + diagnostic logs category on the database should be also created. + Note that for server level audit you should use the 'master' database as {databaseName}. + + Diagnostic Settings URI format: + PUT + `https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + `_ + + For more information, see `Diagnostic Settings REST API + `_ + or `Diagnostic Settings PowerShell `_. + :vartype is_azure_monitor_target_enabled: bool + :ivar queue_delay_ms: Specifies the amount of time in milliseconds that can elapse before audit + actions are forced to be processed. The default minimum value is 1000 (1 second). The maximum + is 2,147,483,647. + :vartype queue_delay_ms: int + :ivar is_managed_identity_in_use: Specifies whether Managed Identity is used to access blob + storage. + :vartype is_managed_identity_in_use: bool + :ivar state: Specifies the state of the audit. If state is Enabled, storageEndpoint or + isAzureMonitorTargetEnabled are required. Required. Known values are: "Enabled" and "Disabled". + :vartype state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState + :ivar storage_endpoint: Specifies the blob storage endpoint (e.g. + `https://MyAccount.blob.core.windows.net `_). If state + is Enabled, storageEndpoint or isAzureMonitorTargetEnabled is required. + :vartype storage_endpoint: str + :ivar storage_account_access_key: Specifies the identifier key of the auditing storage account. + If state is Enabled and storageEndpoint is specified, not specifying the + storageAccountAccessKey will use SQL server system-assigned managed identity to access the + storage. + Prerequisites for using managed identity authentication: + + 1. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). + 2. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data + Contributor' RBAC role to the server identity. + For more information, see [Auditing to storage using Managed Identity + authentication](https://go.microsoft.com/fwlink/?linkid=2114355). + :vartype storage_account_access_key: str + :ivar storage_account_subscription_id: Specifies the blob storage subscription Id. + :vartype storage_account_subscription_id: str + """ + + retention_days: Optional[int] = rest_field( + name="retentionDays", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the number of days to keep in the audit logs in the storage account.""" + audit_actions_and_groups: Optional[list[str]] = rest_field( + name="auditActionsAndGroups", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the Actions-Groups and Actions to audit. + + The recommended set of action groups to use is the following combination - this will audit all + the queries and stored procedures executed against the database, as well as successful and + failed logins: + + BATCH_COMPLETED_GROUP, + SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, + FAILED_DATABASE_AUTHENTICATION_GROUP. + + This above combination is also the set that is configured by default when enabling auditing + from the Azure portal. + + The supported action groups to audit are (note: choose only specific groups that cover your + auditing needs. Using unnecessary groups could lead to very large quantities of audit records): + + APPLICATION_ROLE_CHANGE_PASSWORD_GROUP + BACKUP_RESTORE_GROUP + DATABASE_LOGOUT_GROUP + DATABASE_OBJECT_CHANGE_GROUP + DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP + DATABASE_OBJECT_PERMISSION_CHANGE_GROUP + DATABASE_OPERATION_GROUP + DATABASE_PERMISSION_CHANGE_GROUP + DATABASE_PRINCIPAL_CHANGE_GROUP + DATABASE_PRINCIPAL_IMPERSONATION_GROUP + DATABASE_ROLE_MEMBER_CHANGE_GROUP + FAILED_DATABASE_AUTHENTICATION_GROUP + SCHEMA_OBJECT_ACCESS_GROUP + SCHEMA_OBJECT_CHANGE_GROUP + SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP + SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP + SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP + USER_CHANGE_PASSWORD_GROUP + BATCH_STARTED_GROUP + BATCH_COMPLETED_GROUP + DBCC_GROUP + DATABASE_OWNERSHIP_CHANGE_GROUP + DATABASE_CHANGE_GROUP + LEDGER_OPERATION_GROUP + + These are groups that cover all sql statements and stored procedures executed against the + database, and should not be used in combination with other groups as this will result in + duplicate audit logs. + + For more information, see `Database-Level Audit Action Groups + `_. + + For Database auditing policy, specific Actions can also be specified (note that Actions cannot + be specified for Server auditing policy). The supported actions to audit are: + SELECT + UPDATE + INSERT + DELETE + EXECUTE + RECEIVE + REFERENCES + + The general form for defining an action to be audited is: + {action} ON {object} BY {principal} + + Note that in the above format can refer to an object like a table, view, or stored + procedure, or an entire database or schema. For the latter cases, the forms DATABASE::{db_name} + and SCHEMA::{schema_name} are used, respectively. + + For example: + SELECT on dbo.myTable by public + SELECT on DATABASE::myDatabase by public + SELECT on SCHEMA::mySchema by public + + For more information, see `Database-Level Audit Actions + `_.""" + is_storage_secondary_key_in_use: Optional[bool] = rest_field( + name="isStorageSecondaryKeyInUse", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies whether storageAccountAccessKey value is the storage's secondary key.""" + is_azure_monitor_target_enabled: Optional[bool] = rest_field( + name="isAzureMonitorTargetEnabled", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies whether audit events are sent to Azure Monitor. + In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and + 'IsAzureMonitorTargetEnabled' as true. + + When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' + diagnostic logs category on the database should be also created. + Note that for server level audit you should use the 'master' database as {databaseName}. + + Diagnostic Settings URI format: + PUT + `https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + `_ + + For more information, see `Diagnostic Settings REST API + `_ + or `Diagnostic Settings PowerShell `_.""" + queue_delay_ms: Optional[int] = rest_field( + name="queueDelayMs", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the amount of time in milliseconds that can elapse before audit actions are forced to + be processed. The default minimum value is 1000 (1 second). The maximum is 2,147,483,647.""" + is_managed_identity_in_use: Optional[bool] = rest_field( + name="isManagedIdentityInUse", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies whether Managed Identity is used to access blob storage.""" + state: Union[str, "_models.BlobAuditingPolicyState"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the state of the audit. If state is Enabled, storageEndpoint or + isAzureMonitorTargetEnabled are required. Required. Known values are: \"Enabled\" and + \"Disabled\".""" + storage_endpoint: Optional[str] = rest_field( + name="storageEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the blob storage endpoint (e.g. `https://MyAccount.blob.core.windows.net + `_). If state is Enabled, storageEndpoint or + isAzureMonitorTargetEnabled is required.""" + storage_account_access_key: Optional[str] = rest_field( + name="storageAccountAccessKey", visibility=["create", "update"] + ) + """Specifies the identifier key of the auditing storage account. + If state is Enabled and storageEndpoint is specified, not specifying the + storageAccountAccessKey will use SQL server system-assigned managed identity to access the + storage. + Prerequisites for using managed identity authentication: + + 1. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). + 2. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data + Contributor' RBAC role to the server identity. + For more information, see [Auditing to storage using Managed Identity + authentication](https://go.microsoft.com/fwlink/?linkid=2114355).""" + storage_account_subscription_id: Optional[str] = rest_field( + name="storageAccountSubscriptionId", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the blob storage subscription Id.""" + + @overload + def __init__( + self, + *, + state: Union[str, "_models.BlobAuditingPolicyState"], + retention_days: Optional[int] = None, + audit_actions_and_groups: Optional[list[str]] = None, + is_storage_secondary_key_in_use: Optional[bool] = None, + is_azure_monitor_target_enabled: Optional[bool] = None, + queue_delay_ms: Optional[int] = None, + is_managed_identity_in_use: Optional[bool] = None, + storage_endpoint: Optional[str] = None, + storage_account_access_key: Optional[str] = None, + storage_account_subscription_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DatabaseColumn(ProxyResource): + """A database column resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.DatabaseColumnProperties + """ + + properties: Optional["_models.DatabaseColumnProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["column_type", "temporal_type", "memory_optimized", "is_computed"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.DatabaseColumnProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class DatabaseColumnProperties(_Model): + """Database column properties. + + :ivar column_type: The column data type. Known values are: "image", "text", "uniqueidentifier", + "date", "time", "datetime2", "datetimeoffset", "tinyint", "smallint", "int", "smalldatetime", + "real", "money", "datetime", "float", "sql_variant", "ntext", "bit", "decimal", "numeric", + "smallmoney", "bigint", "hierarchyid", "geometry", "geography", "varbinary", "varchar", + "binary", "char", "timestamp", "nvarchar", "nchar", "xml", and "sysname". + :vartype column_type: str or ~azure.mgmt.sql.models.ColumnDataType + :ivar temporal_type: The table temporal type. Known values are: "NonTemporalTable", + "HistoryTable", and "SystemVersionedTemporalTable". + :vartype temporal_type: str or ~azure.mgmt.sql.models.TableTemporalType + :ivar memory_optimized: Whether or not the column belongs to a memory optimized table. + :vartype memory_optimized: bool + :ivar is_computed: Whether or not the column is computed. + :vartype is_computed: bool + """ + + column_type: Optional[Union[str, "_models.ColumnDataType"]] = rest_field( + name="columnType", visibility=["read", "create", "update", "delete", "query"] + ) + """The column data type. Known values are: \"image\", \"text\", \"uniqueidentifier\", \"date\", + \"time\", \"datetime2\", \"datetimeoffset\", \"tinyint\", \"smallint\", \"int\", + \"smalldatetime\", \"real\", \"money\", \"datetime\", \"float\", \"sql_variant\", \"ntext\", + \"bit\", \"decimal\", \"numeric\", \"smallmoney\", \"bigint\", \"hierarchyid\", \"geometry\", + \"geography\", \"varbinary\", \"varchar\", \"binary\", \"char\", \"timestamp\", \"nvarchar\", + \"nchar\", \"xml\", and \"sysname\".""" + temporal_type: Optional[Union[str, "_models.TableTemporalType"]] = rest_field( + name="temporalType", visibility=["read", "create", "update", "delete", "query"] + ) + """The table temporal type. Known values are: \"NonTemporalTable\", \"HistoryTable\", and + \"SystemVersionedTemporalTable\".""" + memory_optimized: Optional[bool] = rest_field( + name="memoryOptimized", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether or not the column belongs to a memory optimized table.""" + is_computed: Optional[bool] = rest_field( + name="isComputed", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether or not the column is computed.""" + + @overload + def __init__( + self, + *, + column_type: Optional[Union[str, "_models.ColumnDataType"]] = None, + temporal_type: Optional[Union[str, "_models.TableTemporalType"]] = None, + memory_optimized: Optional[bool] = None, + is_computed: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DatabaseExtensions(ProxyResource): + """An Import, Export, or PolybaseImport resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.DatabaseExtensionsProperties + """ + + properties: Optional["_models.DatabaseExtensionsProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "operation_mode", + "storage_key_type", + "storage_key", + "storage_uri", + "administrator_login", + "administrator_login_password", + "authentication_type", + "database_edition", + "service_objective_name", + "max_size_bytes", + "network_isolation", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.DatabaseExtensionsProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class DatabaseExtensionsProperties(_Model): + """Contains the database information after a successful Import, Export, or PolybaseImport. + + :ivar operation_mode: Operation mode of the operation: Import, Export, or PolybaseImport. + Required. Known values are: "PolybaseImport", "Import", and "Export". + :vartype operation_mode: str or ~azure.mgmt.sql.models.OperationMode + :ivar storage_key_type: Storage key type: StorageAccessKey, SharedAccessKey or ManagedIdentity. + Required. Known values are: "SharedAccessKey", "StorageAccessKey", and "ManagedIdentity". + :vartype storage_key_type: str or ~azure.mgmt.sql.models.StorageKeyType + :ivar storage_key: Storage key for the storage account. If StorageKeyType is ManagedIdentity, + this field should specify the Managed Identity's resource ID. Required. + :vartype storage_key: str + :ivar storage_uri: Storage Uri for the storage account. Required. + :vartype storage_uri: str + :ivar administrator_login: Administrator login name. If AuthenticationType is ManagedIdentity, + this field should specify the Managed Identity's resource ID. + :vartype administrator_login: str + :ivar administrator_login_password: Administrator login password. If AuthenticationType is + ManagedIdentity, this field should not be specified. + :vartype administrator_login_password: str + :ivar authentication_type: Authentication type used to access the SQL: Sql, ADPassword or + ManagedIdentity. + :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 + """ + + operation_mode: Union[str, "_models.OperationMode"] = rest_field(name="operationMode", visibility=["create"]) + """Operation mode of the operation: Import, Export, or PolybaseImport. Required. Known values are: + \"PolybaseImport\", \"Import\", and \"Export\".""" + storage_key_type: Union[str, "_models.StorageKeyType"] = rest_field(name="storageKeyType", visibility=["create"]) + """Storage key type: StorageAccessKey, SharedAccessKey or ManagedIdentity. Required. Known values + are: \"SharedAccessKey\", \"StorageAccessKey\", and \"ManagedIdentity\".""" + storage_key: str = rest_field(name="storageKey", visibility=["create"]) + """Storage key for the storage account. If StorageKeyType is ManagedIdentity, this field should + specify the Managed Identity's resource ID. Required.""" + storage_uri: str = rest_field(name="storageUri", visibility=["create"]) + """Storage Uri for the storage account. Required.""" + administrator_login: Optional[str] = rest_field(name="administratorLogin", visibility=["create"]) + """Administrator login name. If AuthenticationType is ManagedIdentity, this field should specify + the Managed Identity's resource ID.""" + administrator_login_password: Optional[str] = rest_field(name="administratorLoginPassword", visibility=["create"]) + """Administrator login password. If AuthenticationType is ManagedIdentity, this field should not + be specified.""" + authentication_type: Optional[str] = rest_field(name="authenticationType", visibility=["create"]) + """Authentication type used to access the SQL: Sql, ADPassword or ManagedIdentity.""" + database_edition: Optional[str] = rest_field(name="databaseEdition", visibility=["create"]) + """Database edition for the newly created database in the case of an import operation.""" + service_objective_name: Optional[str] = rest_field(name="serviceObjectiveName", visibility=["create"]) + """Database service level objective for the newly created database in the case of an import + operation.""" + max_size_bytes: Optional[str] = rest_field(name="maxSizeBytes", visibility=["create"]) + """Database max size in bytes for the newly created database in the case of an import operation.""" + network_isolation: Optional["_models.NetworkIsolationSettings"] = rest_field( + name="networkIsolation", visibility=["create"] + ) + """Optional resource information to enable network isolation for request.""" + + @overload + def __init__( + self, + *, + operation_mode: Union[str, "_models.OperationMode"], + storage_key_type: Union[str, "_models.StorageKeyType"], + storage_key: str, + storage_uri: str, + 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, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DatabaseIdentity(_Model): + """Azure Active Directory identity configuration for a resource. + + :ivar type: The identity type. Known values are: "None" and "UserAssigned". + :vartype type: str or ~azure.mgmt.sql.models.DatabaseIdentityType + :ivar tenant_id: The Azure Active Directory tenant id. + :vartype tenant_id: str + :ivar user_assigned_identities: The resource ids of the user assigned identities to use. + :vartype user_assigned_identities: dict[str, ~azure.mgmt.sql.models.DatabaseUserIdentity] + """ + + type: Optional[Union[str, "_models.DatabaseIdentityType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The identity type. Known values are: \"None\" and \"UserAssigned\".""" + tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read"]) + """The Azure Active Directory tenant id.""" + user_assigned_identities: Optional[dict[str, "_models.DatabaseUserIdentity"]] = rest_field( + name="userAssignedIdentities", visibility=["read", "create", "update", "delete", "query"] + ) + """The resource ids of the user assigned identities to use.""" + + @overload + def __init__( + self, + *, + type: Optional[Union[str, "_models.DatabaseIdentityType"]] = None, + user_assigned_identities: Optional[dict[str, "_models.DatabaseUserIdentity"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DatabaseKey(_Model): + """Database level key used for encryption at rest. + + :ivar type: The database key type. Only supported value is 'AzureKeyVault'. "AzureKeyVault" + :vartype type: str or ~azure.mgmt.sql.models.DatabaseKeyType + :ivar thumbprint: Thumbprint of the database key. + :vartype thumbprint: str + :ivar creation_date: The database key creation date. + :vartype creation_date: ~datetime.datetime + :ivar subregion: Subregion of the server key. + :vartype subregion: str + :ivar key_version: The database key's version. + :vartype key_version: str + """ + + type: Optional[Union[str, "_models.DatabaseKeyType"]] = rest_field(visibility=["read"]) + """The database key type. Only supported value is 'AzureKeyVault'. \"AzureKeyVault\"""" + thumbprint: Optional[str] = rest_field(visibility=["read"]) + """Thumbprint of the database key.""" + creation_date: Optional[datetime.datetime] = rest_field(name="creationDate", visibility=["read"], format="rfc3339") + """The database key creation date.""" + subregion: Optional[str] = rest_field(visibility=["read"]) + """Subregion of the server key.""" + key_version: Optional[str] = rest_field(name="keyVersion", visibility=["read"]) + """The database key's version.""" + + +class DatabaseOperation(ProxyResource): + """A database operation. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.DatabaseOperationProperties + """ + + properties: Optional["_models.DatabaseOperationProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "database_name", + "operation", + "operation_friendly_name", + "percent_complete", + "server_name", + "start_time", + "state", + "error_code", + "error_description", + "error_severity", + "is_user_error", + "estimated_completion_time", + "description", + "is_cancellable", + "operation_phase_details", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.DatabaseOperationProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class DatabaseOperationProperties(_Model): + """The properties of a database operation. + + :ivar database_name: The name of the database the operation is being performed on. + :vartype database_name: str + :ivar operation: The name of operation. + :vartype operation: str + :ivar operation_friendly_name: The friendly name of operation. + :vartype operation_friendly_name: str + :ivar percent_complete: The percentage of the operation completed. + :vartype percent_complete: int + :ivar server_name: The name of the server. + :vartype server_name: str + :ivar start_time: The operation start time. + :vartype start_time: ~datetime.datetime + :ivar state: The operation state. Known values are: "Pending", "InProgress", "Succeeded", + "Failed", "CancelInProgress", and "Cancelled". + :vartype state: str or ~azure.mgmt.sql.models.ManagementOperationState + :ivar error_code: The operation error code. + :vartype error_code: int + :ivar error_description: The operation error description. + :vartype error_description: str + :ivar error_severity: The operation error severity. + :vartype error_severity: int + :ivar is_user_error: Whether or not the error is a user error. + :vartype is_user_error: bool + :ivar estimated_completion_time: The estimated completion time of the operation. + :vartype estimated_completion_time: ~datetime.datetime + :ivar description: The operation description. + :vartype description: str + :ivar is_cancellable: Whether the operation can be cancelled. + :vartype is_cancellable: bool + :ivar operation_phase_details: The operation phase details. + :vartype operation_phase_details: ~azure.mgmt.sql.models.PhaseDetails + """ + + database_name: Optional[str] = rest_field(name="databaseName", visibility=["read"]) + """The name of the database the operation is being performed on.""" + operation: Optional[str] = rest_field(visibility=["read"]) + """The name of operation.""" + operation_friendly_name: Optional[str] = rest_field(name="operationFriendlyName", visibility=["read"]) + """The friendly name of operation.""" + percent_complete: Optional[int] = rest_field(name="percentComplete", visibility=["read"]) + """The percentage of the operation completed.""" + server_name: Optional[str] = rest_field(name="serverName", visibility=["read"]) + """The name of the server.""" + start_time: Optional[datetime.datetime] = rest_field(name="startTime", visibility=["read"], format="rfc3339") + """The operation start time.""" + state: Optional[Union[str, "_models.ManagementOperationState"]] = rest_field(visibility=["read"]) + """The operation state. Known values are: \"Pending\", \"InProgress\", \"Succeeded\", \"Failed\", + \"CancelInProgress\", and \"Cancelled\".""" + error_code: Optional[int] = rest_field(name="errorCode", visibility=["read"]) + """The operation error code.""" + error_description: Optional[str] = rest_field(name="errorDescription", visibility=["read"]) + """The operation error description.""" + error_severity: Optional[int] = rest_field(name="errorSeverity", visibility=["read"]) + """The operation error severity.""" + is_user_error: Optional[bool] = rest_field(name="isUserError", visibility=["read"]) + """Whether or not the error is a user error.""" + estimated_completion_time: Optional[datetime.datetime] = rest_field( + name="estimatedCompletionTime", visibility=["read"], format="rfc3339" + ) + """The estimated completion time of the operation.""" + description: Optional[str] = rest_field(visibility=["read"]) + """The operation description.""" + is_cancellable: Optional[bool] = rest_field(name="isCancellable", visibility=["read"]) + """Whether the operation can be cancelled.""" + operation_phase_details: Optional["_models.PhaseDetails"] = rest_field( + name="operationPhaseDetails", visibility=["read"] + ) + """The operation phase details.""" + + +class DatabaseProperties(_Model): + """The database's properties. + + :ivar create_mode: Specifies the mode of database creation. + + Default: regular database creation. + + Copy: creates a database as a copy of an existing database. sourceDatabaseId must be specified + as the resource ID of the source database. + + Secondary: creates a database as a secondary replica of an existing database. sourceDatabaseId + must be specified as the resource ID of the existing primary database. + + PointInTimeRestore: Creates a database by restoring a point in time backup of an existing + database. sourceDatabaseId must be specified as the resource ID of the existing database, and + restorePointInTime must be specified. + + Recovery: Creates a database by restoring a geo-replicated backup. sourceDatabaseId must be + specified as the recoverable database resource ID to restore. + + Restore: Creates a database by restoring a backup of a deleted database. sourceDatabaseId must + be specified. If sourceDatabaseId is the database's original resource ID, then + sourceDatabaseDeletionDate must be specified. Otherwise sourceDatabaseId must be the restorable + dropped database resource ID and sourceDatabaseDeletionDate is ignored. restorePointInTime may + also be specified to restore from an earlier point in time. + + RestoreLongTermRetentionBackup: Creates a database by restoring from a long term retention + vault. recoveryServicesRecoveryPointResourceId must be specified as the recovery point resource + ID. + + Copy, Secondary, and RestoreLongTermRetentionBackup are not supported for DataWarehouse + edition. Known values are: "Default", "Copy", "Secondary", "PointInTimeRestore", "Restore", + "Recovery", "RestoreExternalBackup", "RestoreExternalBackupSecondary", + "RestoreLongTermRetentionBackup", and "OnlineSecondary". + :vartype create_mode: str or ~azure.mgmt.sql.models.CreateMode + :ivar collation: The collation of the database. + :vartype collation: str + :ivar max_size_bytes: The max size of the database expressed in bytes. + :vartype max_size_bytes: int + :ivar sample_name: The name of the sample schema to apply when creating this database. Known + values are: "AdventureWorksLT", "WideWorldImportersStd", and "WideWorldImportersFull". + :vartype sample_name: str or ~azure.mgmt.sql.models.SampleName + :ivar elastic_pool_id: The resource identifier of the elastic pool containing this database. + :vartype elastic_pool_id: str + :ivar source_database_id: The resource identifier of the source database associated with create + operation of this database. + :vartype source_database_id: str + :ivar status: The status of the database. Known values are: "Online", "Restoring", + "RecoveryPending", "Recovering", "Suspect", "Offline", "Standby", "Shutdown", "EmergencyMode", + "AutoClosed", "Copying", "Creating", "Inaccessible", "OfflineSecondary", "Pausing", "Paused", + "Resuming", "Scaling", "OfflineChangingDwPerformanceTiers", "OnlineChangingDwPerformanceTiers", + "Disabled", "Stopping", "Stopped", and "Starting". + :vartype status: str or ~azure.mgmt.sql.models.DatabaseStatus + :ivar database_id: The ID of the database. + :vartype database_id: str + :ivar creation_date: The creation date of the database (ISO8601 format). + :vartype creation_date: ~datetime.datetime + :ivar current_service_objective_name: The current service level objective name of the database. + :vartype current_service_objective_name: str + :ivar requested_service_objective_name: The requested service level objective name of the + database. + :vartype requested_service_objective_name: str + :ivar default_secondary_location: The default secondary region for this database. + :vartype default_secondary_location: str + :ivar failover_group_id: Failover Group resource identifier that this database belongs to. + :vartype failover_group_id: str + :ivar restore_point_in_time: Specifies the point in time (ISO8601 format) of the source + database that will be restored to create the new database. + :vartype restore_point_in_time: ~datetime.datetime + :ivar source_database_deletion_date: Specifies the time that the database was deleted. + :vartype source_database_deletion_date: ~datetime.datetime + :ivar recovery_services_recovery_point_id: The resource identifier of the recovery point + associated with create operation of this database. + :vartype recovery_services_recovery_point_id: str + :ivar long_term_retention_backup_resource_id: The resource identifier of the long term + retention backup associated with create operation of this database. + :vartype long_term_retention_backup_resource_id: str + :ivar recoverable_database_id: The resource identifier of the recoverable database associated + with create operation of this database. + :vartype recoverable_database_id: str + :ivar restorable_dropped_database_id: The resource identifier of the restorable dropped + database associated with create operation of this database. + :vartype restorable_dropped_database_id: str + :ivar catalog_collation: Collation of the metadata catalog. Known values are: + "DATABASE_DEFAULT" and "SQL_Latin1_General_CP1_CI_AS". + :vartype catalog_collation: str or ~azure.mgmt.sql.models.CatalogCollationType + :ivar zone_redundant: Whether or not this database is zone redundant, which means the replicas + of this database will be spread across multiple availability zones. + :vartype zone_redundant: bool + :ivar license_type: The license type to apply for this database. ``LicenseIncluded`` if you + need a license, or ``BasePrice`` if you have a license and are eligible for the Azure Hybrid + Benefit. Known values are: "LicenseIncluded" and "BasePrice". + :vartype license_type: str or ~azure.mgmt.sql.models.DatabaseLicenseType + :ivar max_log_size_bytes: The max log size for this database. + :vartype max_log_size_bytes: int + :ivar earliest_restore_date: This records the earliest start date and time that restore is + available for this database (ISO8601 format). + :vartype earliest_restore_date: ~datetime.datetime + :ivar read_scale: The state of read-only routing. If enabled, connections that have application + intent set to readonly in their connection string may be routed to a readonly secondary replica + in the same region. Not applicable to a Hyperscale database within an elastic pool. Known + values are: "Enabled" and "Disabled". + :vartype read_scale: str or ~azure.mgmt.sql.models.DatabaseReadScale + :ivar high_availability_replica_count: The number of secondary replicas associated with the + Business Critical, Premium, or Hyperscale edition database that are used to provide high + availability. Not applicable to a Hyperscale database within an elastic pool. + :vartype high_availability_replica_count: int + :ivar secondary_type: The secondary type of the database if it is a secondary. Valid values + are Geo, Named and Standby. Known values are: "Geo", "Named", and "Standby". + :vartype secondary_type: str or ~azure.mgmt.sql.models.SecondaryType + :ivar current_sku: The name and tier of the SKU. + :vartype current_sku: ~azure.mgmt.sql.models.Sku + :ivar auto_pause_delay: Time in minutes after which database is automatically paused. A value + of -1 means that automatic pause is disabled. + :vartype auto_pause_delay: int + :ivar current_backup_storage_redundancy: The storage account type used to store backups for + this database. Known values are: "Geo", "Local", "Zone", and "GeoZone". + :vartype current_backup_storage_redundancy: str or + ~azure.mgmt.sql.models.BackupStorageRedundancy + :ivar requested_backup_storage_redundancy: The storage account type to be used to store backups + for this database. Known values are: "Geo", "Local", "Zone", and "GeoZone". + :vartype requested_backup_storage_redundancy: str or + ~azure.mgmt.sql.models.BackupStorageRedundancy + :ivar min_capacity: Minimal capacity that database will always have allocated, if not paused. + :vartype min_capacity: float + :ivar paused_date: The date when database was paused by user configuration or action(ISO8601 + format). Null if the database is ready. + :vartype paused_date: ~datetime.datetime + :ivar resumed_date: The date when database was resumed by user action or database login + (ISO8601 format). Null if the database is paused. + :vartype resumed_date: ~datetime.datetime + :ivar maintenance_configuration_id: Maintenance configuration id assigned to the database. This + configuration defines the period when the maintenance updates will occur. + :vartype maintenance_configuration_id: str + :ivar is_ledger_on: Whether or not this database is a ledger database, which means all tables + in the database are ledger tables. Note: the value of this property cannot be changed after the + database has been created. + :vartype is_ledger_on: bool + :ivar is_infra_encryption_enabled: Infra encryption is enabled for this database. + :vartype is_infra_encryption_enabled: bool + :ivar federated_client_id: The Client id used for cross tenant per database CMK scenario. + :vartype federated_client_id: str + :ivar keys_property: The resource ids of the user assigned identities to use. + :vartype keys_property: dict[str, ~azure.mgmt.sql.models.DatabaseKey] + :ivar encryption_protector: The azure key vault URI of the database if it's configured with per + Database Customer Managed Keys. + :vartype encryption_protector: str + :ivar preferred_enclave_type: Type of enclave requested on the database i.e. Default or VBS + enclaves. Known values are: "Default" and "VBS". + :vartype preferred_enclave_type: str or ~azure.mgmt.sql.models.AlwaysEncryptedEnclaveType + :ivar use_free_limit: Whether or not the database uses free monthly limits. Allowed on one + database in a subscription. + :vartype use_free_limit: bool + :ivar free_limit_exhaustion_behavior: Specifies the behavior when monthly free limits are + exhausted for the free database. + + AutoPause: The database will be auto paused upon exhaustion of free limits for remainder of the + month. + + BillForUsage: The database will continue to be online upon exhaustion of free limits and any + overage will be billed. Known values are: "AutoPause" and "BillOverUsage". + :vartype free_limit_exhaustion_behavior: str or + ~azure.mgmt.sql.models.FreeLimitExhaustionBehavior + :ivar source_resource_id: The resource identifier of the source associated with the create + operation of this database. + + This property is only supported for DataWarehouse edition and allows to restore across + subscriptions. + + When sourceResourceId is specified, sourceDatabaseId, recoverableDatabaseId, + restorableDroppedDatabaseId and sourceDatabaseDeletionDate must not be specified and CreateMode + must be PointInTimeRestore, Restore or Recover. + + When createMode is PointInTimeRestore, sourceResourceId must be the resource ID of the existing + database or existing sql pool, and restorePointInTime must be specified. + + When createMode is Restore, sourceResourceId must be the resource ID of restorable dropped + database or restorable dropped sql pool. + + When createMode is Recover, sourceResourceId must be the resource ID of recoverable database or + recoverable sql pool. + + When source subscription belongs to a different tenant than target subscription, + “x-ms-authorization-auxiliary” header must contain authentication token for the source tenant. + For more details about “x-ms-authorization-auxiliary” header see + `https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/authenticate-multi-tenant + `_. + :vartype source_resource_id: str + :ivar manual_cutover: Whether or not customer controlled manual cutover needs to be done during + Update Database operation to Hyperscale tier. + + This property is only applicable when scaling database from Business Critical/General + Purpose/Premium/Standard tier to Hyperscale tier. + + When manualCutover is specified, the scaling operation will wait for user input to trigger + cutover to Hyperscale database. + + To trigger cutover, please provide 'performCutover' parameter when the Scaling operation is in + Waiting state. + :vartype manual_cutover: bool + :ivar perform_cutover: To trigger customer controlled manual cutover during the wait state + while Scaling operation is in progress. + + This property parameter is only applicable for scaling operations that are initiated along with + 'manualCutover' parameter. + + This property is only applicable when scaling database from Business Critical/General + Purpose/Premium/Standard tier to Hyperscale tier is already in progress. + + When performCutover is specified, the scaling operation will trigger cutover and perform + role-change to Hyperscale database. + :vartype perform_cutover: bool + :ivar availability_zone: Specifies the availability zone the database is pinned to. Known + values are: "NoPreference", "1", "2", and "3". + :vartype availability_zone: str or ~azure.mgmt.sql.models.AvailabilityZoneType + :ivar encryption_protector_auto_rotation: The flag to enable or disable auto rotation of + database encryption protector AKV key. + :vartype encryption_protector_auto_rotation: bool + :ivar provisioning_state: Specifies the provisioning state for this resource. + :vartype provisioning_state: str + """ + + create_mode: Optional[Union[str, "_models.CreateMode"]] = rest_field(name="createMode", visibility=["create"]) + """Specifies the mode of database creation. + + Default: regular database creation. + + Copy: creates a database as a copy of an existing database. sourceDatabaseId must be specified + as the resource ID of the source database. + + Secondary: creates a database as a secondary replica of an existing database. sourceDatabaseId + must be specified as the resource ID of the existing primary database. + + PointInTimeRestore: Creates a database by restoring a point in time backup of an existing + database. sourceDatabaseId must be specified as the resource ID of the existing database, and + restorePointInTime must be specified. + + Recovery: Creates a database by restoring a geo-replicated backup. sourceDatabaseId must be + specified as the recoverable database resource ID to restore. + + Restore: Creates a database by restoring a backup of a deleted database. sourceDatabaseId must + be specified. If sourceDatabaseId is the database's original resource ID, then + sourceDatabaseDeletionDate must be specified. Otherwise sourceDatabaseId must be the restorable + dropped database resource ID and sourceDatabaseDeletionDate is ignored. restorePointInTime may + also be specified to restore from an earlier point in time. + + RestoreLongTermRetentionBackup: Creates a database by restoring from a long term retention + vault. recoveryServicesRecoveryPointResourceId must be specified as the recovery point resource + ID. + + Copy, Secondary, and RestoreLongTermRetentionBackup are not supported for DataWarehouse + edition. Known values are: \"Default\", \"Copy\", \"Secondary\", \"PointInTimeRestore\", + \"Restore\", \"Recovery\", \"RestoreExternalBackup\", \"RestoreExternalBackupSecondary\", + \"RestoreLongTermRetentionBackup\", and \"OnlineSecondary\".""" + collation: Optional[str] = rest_field(visibility=["read", "create"]) + """The collation of the database.""" + max_size_bytes: Optional[int] = rest_field( + name="maxSizeBytes", visibility=["read", "create", "update", "delete", "query"] + ) + """The max size of the database expressed in bytes.""" + sample_name: Optional[Union[str, "_models.SampleName"]] = rest_field(name="sampleName", visibility=["create"]) + """The name of the sample schema to apply when creating this database. Known values are: + \"AdventureWorksLT\", \"WideWorldImportersStd\", and \"WideWorldImportersFull\".""" + elastic_pool_id: Optional[str] = rest_field( + name="elasticPoolId", visibility=["read", "create", "update", "delete", "query"] + ) + """The resource identifier of the elastic pool containing this database.""" + source_database_id: Optional[str] = rest_field(name="sourceDatabaseId", visibility=["create"]) + """The resource identifier of the source database associated with create operation of this + database.""" + status: Optional[Union[str, "_models.DatabaseStatus"]] = rest_field(visibility=["read"]) + """The status of the database. Known values are: \"Online\", \"Restoring\", \"RecoveryPending\", + \"Recovering\", \"Suspect\", \"Offline\", \"Standby\", \"Shutdown\", \"EmergencyMode\", + \"AutoClosed\", \"Copying\", \"Creating\", \"Inaccessible\", \"OfflineSecondary\", \"Pausing\", + \"Paused\", \"Resuming\", \"Scaling\", \"OfflineChangingDwPerformanceTiers\", + \"OnlineChangingDwPerformanceTiers\", \"Disabled\", \"Stopping\", \"Stopped\", and + \"Starting\".""" + database_id: Optional[str] = rest_field(name="databaseId", visibility=["read"]) + """The ID of the database.""" + creation_date: Optional[datetime.datetime] = rest_field(name="creationDate", visibility=["read"], format="rfc3339") + """The creation date of the database (ISO8601 format).""" + current_service_objective_name: Optional[str] = rest_field(name="currentServiceObjectiveName", visibility=["read"]) + """The current service level objective name of the database.""" + requested_service_objective_name: Optional[str] = rest_field( + name="requestedServiceObjectiveName", visibility=["read"] + ) + """The requested service level objective name of the database.""" + default_secondary_location: Optional[str] = rest_field(name="defaultSecondaryLocation", visibility=["read"]) + """The default secondary region for this database.""" + failover_group_id: Optional[str] = rest_field(name="failoverGroupId", visibility=["read"]) + """Failover Group resource identifier that this database belongs to.""" + restore_point_in_time: Optional[datetime.datetime] = rest_field( + name="restorePointInTime", visibility=["create"], format="rfc3339" + ) + """Specifies the point in time (ISO8601 format) of the source database that will be restored to + create the new database.""" + source_database_deletion_date: Optional[datetime.datetime] = rest_field( + name="sourceDatabaseDeletionDate", visibility=["create"], format="rfc3339" + ) + """Specifies the time that the database was deleted.""" + recovery_services_recovery_point_id: Optional[str] = rest_field( + name="recoveryServicesRecoveryPointId", visibility=["create"] + ) + """The resource identifier of the recovery point associated with create operation of this + database.""" + long_term_retention_backup_resource_id: Optional[str] = rest_field( + name="longTermRetentionBackupResourceId", visibility=["create"] + ) + """The resource identifier of the long term retention backup associated with create operation of + this database.""" + recoverable_database_id: Optional[str] = rest_field(name="recoverableDatabaseId", visibility=["create"]) + """The resource identifier of the recoverable database associated with create operation of this + database.""" + restorable_dropped_database_id: Optional[str] = rest_field( + name="restorableDroppedDatabaseId", visibility=["create"] + ) + """The resource identifier of the restorable dropped database associated with create operation of + this database.""" + catalog_collation: Optional[Union[str, "_models.CatalogCollationType"]] = rest_field( + name="catalogCollation", visibility=["read", "create"] + ) + """Collation of the metadata catalog. Known values are: \"DATABASE_DEFAULT\" and + \"SQL_Latin1_General_CP1_CI_AS\".""" + zone_redundant: Optional[bool] = rest_field( + name="zoneRedundant", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether or not this database is zone redundant, which means the replicas of this database will + be spread across multiple availability zones.""" + license_type: Optional[Union[str, "_models.DatabaseLicenseType"]] = rest_field( + name="licenseType", visibility=["read", "create", "update", "delete", "query"] + ) + """The license type to apply for this database. ``LicenseIncluded`` if you need a license, or + ``BasePrice`` if you have a license and are eligible for the Azure Hybrid Benefit. Known values + are: \"LicenseIncluded\" and \"BasePrice\".""" + max_log_size_bytes: Optional[int] = rest_field(name="maxLogSizeBytes", visibility=["read"]) + """The max log size for this database.""" + earliest_restore_date: Optional[datetime.datetime] = rest_field( + name="earliestRestoreDate", visibility=["read"], format="rfc3339" + ) + """This records the earliest start date and time that restore is available for this database + (ISO8601 format).""" + read_scale: Optional[Union[str, "_models.DatabaseReadScale"]] = rest_field( + name="readScale", visibility=["read", "update"] + ) + """The state of read-only routing. If enabled, connections that have application intent set to + readonly in their connection string may be routed to a readonly secondary replica in the same + region. Not applicable to a Hyperscale database within an elastic pool. Known values are: + \"Enabled\" and \"Disabled\".""" + high_availability_replica_count: Optional[int] = rest_field( + name="highAvailabilityReplicaCount", visibility=["read", "create", "update", "delete", "query"] + ) + """The number of secondary replicas associated with the Business Critical, Premium, or Hyperscale + edition database that are used to provide high availability. Not applicable to a Hyperscale + database within an elastic pool.""" + secondary_type: Optional[Union[str, "_models.SecondaryType"]] = rest_field( + name="secondaryType", visibility=["read", "create", "update", "delete", "query"] + ) + """The secondary type of the database if it is a secondary. Valid values are Geo, Named and + Standby. Known values are: \"Geo\", \"Named\", and \"Standby\".""" + current_sku: Optional["_models.Sku"] = rest_field(name="currentSku", visibility=["read"]) + """The name and tier of the SKU.""" + auto_pause_delay: Optional[int] = rest_field( + name="autoPauseDelay", visibility=["read", "create", "update", "delete", "query"] + ) + """Time in minutes after which database is automatically paused. A value of -1 means that + automatic pause is disabled.""" + current_backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = rest_field( + name="currentBackupStorageRedundancy", visibility=["read"] + ) + """The storage account type used to store backups for this database. Known values are: \"Geo\", + \"Local\", \"Zone\", and \"GeoZone\".""" + requested_backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = rest_field( + name="requestedBackupStorageRedundancy", visibility=["read", "create", "update", "delete", "query"] + ) + """The storage account type to be used to store backups for this database. Known values are: + \"Geo\", \"Local\", \"Zone\", and \"GeoZone\".""" + min_capacity: Optional[float] = rest_field( + name="minCapacity", visibility=["read", "create", "update", "delete", "query"] + ) + """Minimal capacity that database will always have allocated, if not paused.""" + paused_date: Optional[datetime.datetime] = rest_field(name="pausedDate", visibility=["read"], format="rfc3339") + """The date when database was paused by user configuration or action(ISO8601 format). Null if the + database is ready.""" + resumed_date: Optional[datetime.datetime] = rest_field(name="resumedDate", visibility=["read"], format="rfc3339") + """The date when database was resumed by user action or database login (ISO8601 format). Null if + the database is paused.""" + maintenance_configuration_id: Optional[str] = rest_field( + name="maintenanceConfigurationId", visibility=["read", "create", "update", "delete", "query"] + ) + """Maintenance configuration id assigned to the database. This configuration defines the period + when the maintenance updates will occur.""" + is_ledger_on: Optional[bool] = rest_field( + name="isLedgerOn", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether or not this database is a ledger database, which means all tables in the database are + ledger tables. Note: the value of this property cannot be changed after the database has been + created.""" + is_infra_encryption_enabled: Optional[bool] = rest_field(name="isInfraEncryptionEnabled", visibility=["read"]) + """Infra encryption is enabled for this database.""" + federated_client_id: Optional[str] = rest_field( + name="federatedClientId", visibility=["read", "create", "update", "delete", "query"] + ) + """The Client id used for cross tenant per database CMK scenario.""" + keys_property: Optional[dict[str, "_models.DatabaseKey"]] = rest_field( + name="keys", visibility=["read", "create", "update", "delete", "query"], original_tsp_name="keys" + ) + """The resource ids of the user assigned identities to use.""" + encryption_protector: Optional[str] = rest_field( + name="encryptionProtector", visibility=["read", "create", "update", "delete", "query"] + ) + """The azure key vault URI of the database if it's configured with per Database Customer Managed + Keys.""" + preferred_enclave_type: Optional[Union[str, "_models.AlwaysEncryptedEnclaveType"]] = rest_field( + name="preferredEnclaveType", visibility=["read", "create", "update", "delete", "query"] + ) + """Type of enclave requested on the database i.e. Default or VBS enclaves. Known values are: + \"Default\" and \"VBS\".""" + use_free_limit: Optional[bool] = rest_field( + name="useFreeLimit", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether or not the database uses free monthly limits. Allowed on one database in a + subscription.""" + free_limit_exhaustion_behavior: Optional[Union[str, "_models.FreeLimitExhaustionBehavior"]] = rest_field( + name="freeLimitExhaustionBehavior", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the behavior when monthly free limits are exhausted for the free database. + + AutoPause: The database will be auto paused upon exhaustion of free limits for remainder of the + month. + + BillForUsage: The database will continue to be online upon exhaustion of free limits and any + overage will be billed. Known values are: \"AutoPause\" and \"BillOverUsage\".""" + source_resource_id: Optional[str] = rest_field(name="sourceResourceId", visibility=["create"]) + """The resource identifier of the source associated with the create operation of this database. + + This property is only supported for DataWarehouse edition and allows to restore across + subscriptions. + + When sourceResourceId is specified, sourceDatabaseId, recoverableDatabaseId, + restorableDroppedDatabaseId and sourceDatabaseDeletionDate must not be specified and CreateMode + must be PointInTimeRestore, Restore or Recover. + + When createMode is PointInTimeRestore, sourceResourceId must be the resource ID of the existing + database or existing sql pool, and restorePointInTime must be specified. + + When createMode is Restore, sourceResourceId must be the resource ID of restorable dropped + database or restorable dropped sql pool. + + When createMode is Recover, sourceResourceId must be the resource ID of recoverable database or + recoverable sql pool. + + When source subscription belongs to a different tenant than target subscription, + “x-ms-authorization-auxiliary” header must contain authentication token for the source tenant. + For more details about “x-ms-authorization-auxiliary” header see + `https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/authenticate-multi-tenant + `_.""" + manual_cutover: Optional[bool] = rest_field( + name="manualCutover", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether or not customer controlled manual cutover needs to be done during Update Database + operation to Hyperscale tier. + + This property is only applicable when scaling database from Business Critical/General + Purpose/Premium/Standard tier to Hyperscale tier. + + When manualCutover is specified, the scaling operation will wait for user input to trigger + cutover to Hyperscale database. + + To trigger cutover, please provide 'performCutover' parameter when the Scaling operation is in + Waiting state.""" + perform_cutover: Optional[bool] = rest_field( + name="performCutover", visibility=["read", "create", "update", "delete", "query"] + ) + """To trigger customer controlled manual cutover during the wait state while Scaling operation is + in progress. + + This property parameter is only applicable for scaling operations that are initiated along with + 'manualCutover' parameter. + + This property is only applicable when scaling database from Business Critical/General + Purpose/Premium/Standard tier to Hyperscale tier is already in progress. + + When performCutover is specified, the scaling operation will trigger cutover and perform + role-change to Hyperscale database.""" + availability_zone: Optional[Union[str, "_models.AvailabilityZoneType"]] = rest_field( + name="availabilityZone", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the availability zone the database is pinned to. Known values are: \"NoPreference\", + \"1\", \"2\", and \"3\".""" + encryption_protector_auto_rotation: Optional[bool] = rest_field( + name="encryptionProtectorAutoRotation", visibility=["read", "create", "update", "delete", "query"] + ) + """The flag to enable or disable auto rotation of database encryption protector AKV key.""" + provisioning_state: Optional[str] = rest_field(name="provisioningState", visibility=["read"]) + """Specifies the provisioning state for this resource.""" + + @overload + def __init__( # pylint: disable=too-many-locals + self, + *, + create_mode: Optional[Union[str, "_models.CreateMode"]] = None, + collation: Optional[str] = None, + max_size_bytes: Optional[int] = None, + sample_name: Optional[Union[str, "_models.SampleName"]] = None, + elastic_pool_id: Optional[str] = None, + source_database_id: Optional[str] = None, + restore_point_in_time: Optional[datetime.datetime] = None, + source_database_deletion_date: Optional[datetime.datetime] = None, + recovery_services_recovery_point_id: Optional[str] = None, + long_term_retention_backup_resource_id: Optional[str] = None, + recoverable_database_id: Optional[str] = None, + restorable_dropped_database_id: Optional[str] = None, + catalog_collation: Optional[Union[str, "_models.CatalogCollationType"]] = None, + zone_redundant: Optional[bool] = None, + license_type: Optional[Union[str, "_models.DatabaseLicenseType"]] = None, + read_scale: Optional[Union[str, "_models.DatabaseReadScale"]] = None, + high_availability_replica_count: Optional[int] = None, + secondary_type: Optional[Union[str, "_models.SecondaryType"]] = None, + auto_pause_delay: Optional[int] = None, + requested_backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = None, + min_capacity: Optional[float] = None, + maintenance_configuration_id: Optional[str] = None, + is_ledger_on: Optional[bool] = None, + federated_client_id: Optional[str] = None, + keys_property: Optional[dict[str, "_models.DatabaseKey"]] = None, + encryption_protector: Optional[str] = None, + preferred_enclave_type: Optional[Union[str, "_models.AlwaysEncryptedEnclaveType"]] = None, + use_free_limit: Optional[bool] = None, + free_limit_exhaustion_behavior: Optional[Union[str, "_models.FreeLimitExhaustionBehavior"]] = None, + source_resource_id: Optional[str] = None, + manual_cutover: Optional[bool] = None, + perform_cutover: Optional[bool] = None, + availability_zone: Optional[Union[str, "_models.AvailabilityZoneType"]] = None, + encryption_protector_auto_rotation: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DatabaseSchema(ProxyResource): + """A database schema resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + """ + + +class DatabaseSecurityAlertPolicy(ProxyResource): + """A database security alert policy. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.SecurityAlertsPolicyProperties + """ + + properties: Optional["_models.SecurityAlertsPolicyProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "state", + "disabled_alerts", + "email_addresses", + "email_account_admins", + "storage_endpoint", + "storage_account_access_key", + "retention_days", + "creation_time", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.SecurityAlertsPolicyProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class DatabaseSqlVulnerabilityAssessmentBaselineSet(ProxyResource): # pylint: disable=name-too-long + """A database sql vulnerability assessment baseline set. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: + ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSetProperties + """ + + properties: Optional["_models.DatabaseSqlVulnerabilityAssessmentBaselineSetProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["results"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.DatabaseSqlVulnerabilityAssessmentBaselineSetProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class DatabaseSqlVulnerabilityAssessmentBaselineSetProperties(_Model): # pylint: disable=name-too-long + """Properties of a database Sql Vulnerability Assessment baseline set. + + :ivar results: The baseline set result. Required. + :vartype results: dict[str, list[list[str]]] + """ + + results: dict[str, list[list[str]]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The baseline set result. Required.""" + + @overload + def __init__( + self, + *, + results: dict[str, list[list[str]]], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DatabaseSqlVulnerabilityAssessmentRuleBaseline(ProxyResource): # pylint: disable=name-too-long + """A database sql vulnerability assessment rule baseline. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: + ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineProperties + """ + + properties: Optional["_models.DatabaseSqlVulnerabilityAssessmentRuleBaselineProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["results"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.DatabaseSqlVulnerabilityAssessmentRuleBaselineProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class DatabaseSqlVulnerabilityAssessmentRuleBaselineInput(ProxyResource): # pylint: disable=name-too-long + """A database sql vulnerability assessment rule baseline input. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: + ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInputProperties + """ + + properties: Optional["_models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInputProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["latest_scan", "results"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInputProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class DatabaseSqlVulnerabilityAssessmentRuleBaselineInputProperties(_Model): # pylint: disable=name-too-long + """Properties of a database Sql Vulnerability Assessment rule baseline. + + :ivar latest_scan: The latest scan flag. Required. + :vartype latest_scan: bool + :ivar results: The rule baseline result. Required. + :vartype results: list[list[str]] + """ + + latest_scan: bool = rest_field(name="latestScan", visibility=["read", "create", "update", "delete", "query"]) + """The latest scan flag. Required.""" + results: list[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The rule baseline result. Required.""" + + @overload + def __init__( + self, + *, + latest_scan: bool, + results: list[list[str]], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput(ProxyResource): # pylint: disable=name-too-long + """A database sql vulnerability assessment rule baseline list input. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: + ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInputProperties + """ + + properties: Optional["_models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInputProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["latest_scan", "results"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInputProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class DatabaseSqlVulnerabilityAssessmentRuleBaselineListInputProperties(_Model): # pylint: disable=name-too-long + """Properties of a database Sql Vulnerability Assessment rule baseline. + + :ivar latest_scan: The latest scan flag. Required. + :vartype latest_scan: bool + :ivar results: The rule baseline result list. Required. + :vartype results: dict[str, list[list[str]]] + """ + + latest_scan: bool = rest_field(name="latestScan", visibility=["read", "create", "update", "delete", "query"]) + """The latest scan flag. Required.""" + results: dict[str, list[list[str]]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The rule baseline result list. Required.""" + + @overload + def __init__( + self, + *, + latest_scan: bool, + results: dict[str, list[list[str]]], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DatabaseSqlVulnerabilityAssessmentRuleBaselineProperties(_Model): # pylint: disable=name-too-long + """Properties of a database Sql Vulnerability Assessment rule baseline. + + :ivar results: The rule baseline result. Required. + :vartype results: list[list[str]] + """ + + results: list[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The rule baseline result. Required.""" + + @overload + def __init__( + self, + *, + results: list[list[str]], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DatabaseTable(ProxyResource): + """A database table resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.DatabaseTableProperties + """ + + properties: Optional["_models.DatabaseTableProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["temporal_type", "memory_optimized"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.DatabaseTableProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class DatabaseTableProperties(_Model): + """Database table properties. + + :ivar temporal_type: The table temporal type. Known values are: "NonTemporalTable", + "HistoryTable", and "SystemVersionedTemporalTable". + :vartype temporal_type: str or ~azure.mgmt.sql.models.TableTemporalType + :ivar memory_optimized: Whether or not the table is memory optimized. + :vartype memory_optimized: bool + """ + + temporal_type: Optional[Union[str, "_models.TableTemporalType"]] = rest_field( + name="temporalType", visibility=["read", "create", "update", "delete", "query"] + ) + """The table temporal type. Known values are: \"NonTemporalTable\", \"HistoryTable\", and + \"SystemVersionedTemporalTable\".""" + memory_optimized: Optional[bool] = rest_field( + name="memoryOptimized", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether or not the table is memory optimized.""" + + @overload + def __init__( + self, + *, + temporal_type: Optional[Union[str, "_models.TableTemporalType"]] = None, + memory_optimized: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DatabaseUpdate(_Model): + """A database update resource. + + :ivar sku: The name and tier of the SKU. + :vartype sku: ~azure.mgmt.sql.models.Sku + :ivar identity: Database identity. + :vartype identity: ~azure.mgmt.sql.models.DatabaseIdentity + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.DatabaseUpdateProperties + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + sku: Optional["_models.Sku"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name and tier of the SKU.""" + identity: Optional["_models.DatabaseIdentity"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Database identity.""" + properties: Optional["_models.DatabaseUpdateProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource tags.""" + + __flattened_items = [ + "create_mode", + "collation", + "max_size_bytes", + "sample_name", + "elastic_pool_id", + "source_database_id", + "status", + "database_id", + "creation_date", + "current_service_objective_name", + "requested_service_objective_name", + "default_secondary_location", + "failover_group_id", + "restore_point_in_time", + "source_database_deletion_date", + "recovery_services_recovery_point_id", + "long_term_retention_backup_resource_id", + "recoverable_database_id", + "restorable_dropped_database_id", + "catalog_collation", + "zone_redundant", + "license_type", + "max_log_size_bytes", + "earliest_restore_date", + "read_scale", + "high_availability_replica_count", + "secondary_type", + "current_sku", + "auto_pause_delay", + "current_backup_storage_redundancy", + "requested_backup_storage_redundancy", + "min_capacity", + "paused_date", + "resumed_date", + "maintenance_configuration_id", + "is_ledger_on", + "is_infra_encryption_enabled", + "federated_client_id", + "keys_property", + "encryption_protector", + "preferred_enclave_type", + "use_free_limit", + "free_limit_exhaustion_behavior", + "manual_cutover", + "perform_cutover", + "encryption_protector_auto_rotation", + "provisioning_state", + ] + + @overload + def __init__( + self, + *, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.DatabaseIdentity"] = None, + properties: Optional["_models.DatabaseUpdateProperties"] = None, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class DatabaseUpdateProperties(_Model): + """A database update properties. + + :ivar create_mode: Specifies the mode of database creation. + + Default: regular database creation. + + Copy: creates a database as a copy of an existing database. sourceDatabaseId must be specified + as the resource ID of the source database. + + Secondary: creates a database as a secondary replica of an existing database. sourceDatabaseId + must be specified as the resource ID of the existing primary database. + + PointInTimeRestore: Creates a database by restoring a point in time backup of an existing + database. sourceDatabaseId must be specified as the resource ID of the existing database, and + restorePointInTime must be specified. + + Recovery: Creates a database by restoring a geo-replicated backup. sourceDatabaseId must be + specified as the recoverable database resource ID to restore. + + Restore: Creates a database by restoring a backup of a deleted database. sourceDatabaseId must + be specified. If sourceDatabaseId is the database's original resource ID, then + sourceDatabaseDeletionDate must be specified. Otherwise sourceDatabaseId must be the restorable + dropped database resource ID and sourceDatabaseDeletionDate is ignored. restorePointInTime may + also be specified to restore from an earlier point in time. + + RestoreLongTermRetentionBackup: Creates a database by restoring from a long term retention + vault. recoveryServicesRecoveryPointResourceId must be specified as the recovery point resource + ID. + + Copy, Secondary, and RestoreLongTermRetentionBackup are not supported for DataWarehouse + edition. Known values are: "Default", "Copy", "Secondary", "PointInTimeRestore", "Restore", + "Recovery", "RestoreExternalBackup", "RestoreExternalBackupSecondary", + "RestoreLongTermRetentionBackup", and "OnlineSecondary". + :vartype create_mode: str or ~azure.mgmt.sql.models.CreateMode + :ivar collation: The collation of the database. + :vartype collation: str + :ivar max_size_bytes: The max size of the database expressed in bytes. + :vartype max_size_bytes: int + :ivar sample_name: The name of the sample schema to apply when creating this database. Known + values are: "AdventureWorksLT", "WideWorldImportersStd", and "WideWorldImportersFull". + :vartype sample_name: str or ~azure.mgmt.sql.models.SampleName + :ivar elastic_pool_id: The resource identifier of the elastic pool containing this database. + :vartype elastic_pool_id: str + :ivar source_database_id: The resource identifier of the source database associated with create + operation of this database. + :vartype source_database_id: str + :ivar status: The status of the database. Known values are: "Online", "Restoring", + "RecoveryPending", "Recovering", "Suspect", "Offline", "Standby", "Shutdown", "EmergencyMode", + "AutoClosed", "Copying", "Creating", "Inaccessible", "OfflineSecondary", "Pausing", "Paused", + "Resuming", "Scaling", "OfflineChangingDwPerformanceTiers", "OnlineChangingDwPerformanceTiers", + "Disabled", "Stopping", "Stopped", and "Starting". + :vartype status: str or ~azure.mgmt.sql.models.DatabaseStatus + :ivar database_id: The ID of the database. + :vartype database_id: str + :ivar creation_date: The creation date of the database (ISO8601 format). + :vartype creation_date: ~datetime.datetime + :ivar current_service_objective_name: The current service level objective name of the database. + :vartype current_service_objective_name: str + :ivar requested_service_objective_name: The requested service level objective name of the + database. + :vartype requested_service_objective_name: str + :ivar default_secondary_location: The default secondary region for this database. + :vartype default_secondary_location: str + :ivar failover_group_id: Failover Group resource identifier that this database belongs to. + :vartype failover_group_id: str + :ivar restore_point_in_time: Specifies the point in time (ISO8601 format) of the source + database that will be restored to create the new database. + :vartype restore_point_in_time: ~datetime.datetime + :ivar source_database_deletion_date: Specifies the time that the database was deleted. + :vartype source_database_deletion_date: ~datetime.datetime + :ivar recovery_services_recovery_point_id: The resource identifier of the recovery point + associated with create operation of this database. + :vartype recovery_services_recovery_point_id: str + :ivar long_term_retention_backup_resource_id: The resource identifier of the long term + retention backup associated with create operation of this database. + :vartype long_term_retention_backup_resource_id: str + :ivar recoverable_database_id: The resource identifier of the recoverable database associated + with create operation of this database. + :vartype recoverable_database_id: str + :ivar restorable_dropped_database_id: The resource identifier of the restorable dropped + database associated with create operation of this database. + :vartype restorable_dropped_database_id: str + :ivar catalog_collation: Collation of the metadata catalog. Known values are: + "DATABASE_DEFAULT" and "SQL_Latin1_General_CP1_CI_AS". + :vartype catalog_collation: str or ~azure.mgmt.sql.models.CatalogCollationType + :ivar zone_redundant: Whether or not this database is zone redundant, which means the replicas + of this database will be spread across multiple availability zones. + :vartype zone_redundant: bool + :ivar license_type: The license type to apply for this database. ``LicenseIncluded`` if you + need a license, or ``BasePrice`` if you have a license and are eligible for the Azure Hybrid + Benefit. Known values are: "LicenseIncluded" and "BasePrice". + :vartype license_type: str or ~azure.mgmt.sql.models.DatabaseLicenseType + :ivar max_log_size_bytes: The max log size for this database. + :vartype max_log_size_bytes: int + :ivar earliest_restore_date: This records the earliest start date and time that restore is + available for this database (ISO8601 format). + :vartype earliest_restore_date: ~datetime.datetime + :ivar read_scale: The state of read-only routing. If enabled, connections that have application + intent set to readonly in their connection string may be routed to a readonly secondary replica + in the same region. Not applicable to a Hyperscale database within an elastic pool. Known + values are: "Enabled" and "Disabled". + :vartype read_scale: str or ~azure.mgmt.sql.models.DatabaseReadScale + :ivar high_availability_replica_count: The number of secondary replicas associated with the + Business Critical, Premium, or Hyperscale edition database that are used to provide high + availability. Not applicable to a Hyperscale database within an elastic pool. + :vartype high_availability_replica_count: int + :ivar secondary_type: The secondary type of the database if it is a secondary. Valid values + are Geo, Named and Standby. Known values are: "Geo", "Named", and "Standby". + :vartype secondary_type: str or ~azure.mgmt.sql.models.SecondaryType + :ivar current_sku: The name and tier of the SKU. + :vartype current_sku: ~azure.mgmt.sql.models.Sku + :ivar auto_pause_delay: Time in minutes after which database is automatically paused. A value + of -1 means that automatic pause is disabled. + :vartype auto_pause_delay: int + :ivar current_backup_storage_redundancy: The storage account type used to store backups for + this database. Known values are: "Geo", "Local", "Zone", and "GeoZone". + :vartype current_backup_storage_redundancy: str or + ~azure.mgmt.sql.models.BackupStorageRedundancy + :ivar requested_backup_storage_redundancy: The storage account type to be used to store backups + for this database. Known values are: "Geo", "Local", "Zone", and "GeoZone". + :vartype requested_backup_storage_redundancy: str or + ~azure.mgmt.sql.models.BackupStorageRedundancy + :ivar min_capacity: Minimal capacity that database will always have allocated, if not paused. + :vartype min_capacity: float + :ivar paused_date: The date when database was paused by user configuration or action(ISO8601 + format). Null if the database is ready. + :vartype paused_date: ~datetime.datetime + :ivar resumed_date: The date when database was resumed by user action or database login + (ISO8601 format). Null if the database is paused. + :vartype resumed_date: ~datetime.datetime + :ivar maintenance_configuration_id: Maintenance configuration id assigned to the database. This + configuration defines the period when the maintenance updates will occur. + :vartype maintenance_configuration_id: str + :ivar is_ledger_on: Whether or not this database is a ledger database, which means all tables + in the database are ledger tables. Note: the value of this property cannot be changed after the + database has been created. + :vartype is_ledger_on: bool + :ivar is_infra_encryption_enabled: Infra encryption is enabled for this database. + :vartype is_infra_encryption_enabled: bool + :ivar federated_client_id: The Client id used for cross tenant per database CMK scenario. + :vartype federated_client_id: str + :ivar keys_property: The resource ids of the user assigned identities to use. + :vartype keys_property: dict[str, ~azure.mgmt.sql.models.DatabaseKey] + :ivar encryption_protector: The azure key vault URI of the database if it's configured with per + Database Customer Managed Keys. + :vartype encryption_protector: str + :ivar preferred_enclave_type: Type of enclave requested on the database i.e. Default or VBS + enclaves. Known values are: "Default" and "VBS". + :vartype preferred_enclave_type: str or ~azure.mgmt.sql.models.AlwaysEncryptedEnclaveType + :ivar use_free_limit: Whether or not the database uses free monthly limits. Allowed on one + database in a subscription. + :vartype use_free_limit: bool + :ivar free_limit_exhaustion_behavior: Specifies the behavior when monthly free limits are + exhausted for the free database. + + AutoPause: The database will be auto paused upon exhaustion of free limits for remainder of the + month. + + BillForUsage: The database will continue to be online upon exhaustion of free limits and any + overage will be billed. Known values are: "AutoPause" and "BillOverUsage". + :vartype free_limit_exhaustion_behavior: str or + ~azure.mgmt.sql.models.FreeLimitExhaustionBehavior + :ivar manual_cutover: Whether or not customer controlled manual cutover needs to be done during + Update Database operation to Hyperscale tier. + + This property is only applicable when scaling database from Business Critical/General + Purpose/Premium/Standard tier to Hyperscale tier. + + When manualCutover is specified, the scaling operation will wait for user input to trigger + cutover to Hyperscale database. + + To trigger cutover, please provide 'performCutover' parameter when the Scaling operation is in + Waiting state. + :vartype manual_cutover: bool + :ivar perform_cutover: To trigger customer controlled manual cutover during the wait state + while Scaling operation is in progress. + + This property parameter is only applicable for scaling operations that are initiated along with + 'manualCutover' parameter. + + This property is only applicable when scaling database from Business Critical/General + Purpose/Premium/Standard tier to Hyperscale tier is already in progress. + + When performCutover is specified, the scaling operation will trigger cutover and perform + role-change to Hyperscale database. + :vartype perform_cutover: bool + :ivar encryption_protector_auto_rotation: The flag to enable or disable auto rotation of + database encryption protector AKV key. + :vartype encryption_protector_auto_rotation: bool + :ivar provisioning_state: Specifies the provisioning state for this resource. + :vartype provisioning_state: str + """ + + create_mode: Optional[Union[str, "_models.CreateMode"]] = rest_field(name="createMode", visibility=["create"]) + """Specifies the mode of database creation. + + Default: regular database creation. + + Copy: creates a database as a copy of an existing database. sourceDatabaseId must be specified + as the resource ID of the source database. + + Secondary: creates a database as a secondary replica of an existing database. sourceDatabaseId + must be specified as the resource ID of the existing primary database. + + PointInTimeRestore: Creates a database by restoring a point in time backup of an existing + database. sourceDatabaseId must be specified as the resource ID of the existing database, and + restorePointInTime must be specified. + + Recovery: Creates a database by restoring a geo-replicated backup. sourceDatabaseId must be + specified as the recoverable database resource ID to restore. + + Restore: Creates a database by restoring a backup of a deleted database. sourceDatabaseId must + be specified. If sourceDatabaseId is the database's original resource ID, then + sourceDatabaseDeletionDate must be specified. Otherwise sourceDatabaseId must be the restorable + dropped database resource ID and sourceDatabaseDeletionDate is ignored. restorePointInTime may + also be specified to restore from an earlier point in time. + + RestoreLongTermRetentionBackup: Creates a database by restoring from a long term retention + vault. recoveryServicesRecoveryPointResourceId must be specified as the recovery point resource + ID. + + Copy, Secondary, and RestoreLongTermRetentionBackup are not supported for DataWarehouse + edition. Known values are: \"Default\", \"Copy\", \"Secondary\", \"PointInTimeRestore\", + \"Restore\", \"Recovery\", \"RestoreExternalBackup\", \"RestoreExternalBackupSecondary\", + \"RestoreLongTermRetentionBackup\", and \"OnlineSecondary\".""" + collation: Optional[str] = rest_field(visibility=["read", "create"]) + """The collation of the database.""" + max_size_bytes: Optional[int] = rest_field( + name="maxSizeBytes", visibility=["read", "create", "update", "delete", "query"] + ) + """The max size of the database expressed in bytes.""" + sample_name: Optional[Union[str, "_models.SampleName"]] = rest_field(name="sampleName", visibility=["create"]) + """The name of the sample schema to apply when creating this database. Known values are: + \"AdventureWorksLT\", \"WideWorldImportersStd\", and \"WideWorldImportersFull\".""" + elastic_pool_id: Optional[str] = rest_field( + name="elasticPoolId", visibility=["read", "create", "update", "delete", "query"] + ) + """The resource identifier of the elastic pool containing this database.""" + source_database_id: Optional[str] = rest_field(name="sourceDatabaseId", visibility=["create"]) + """The resource identifier of the source database associated with create operation of this + database.""" + status: Optional[Union[str, "_models.DatabaseStatus"]] = rest_field(visibility=["read"]) + """The status of the database. Known values are: \"Online\", \"Restoring\", \"RecoveryPending\", + \"Recovering\", \"Suspect\", \"Offline\", \"Standby\", \"Shutdown\", \"EmergencyMode\", + \"AutoClosed\", \"Copying\", \"Creating\", \"Inaccessible\", \"OfflineSecondary\", \"Pausing\", + \"Paused\", \"Resuming\", \"Scaling\", \"OfflineChangingDwPerformanceTiers\", + \"OnlineChangingDwPerformanceTiers\", \"Disabled\", \"Stopping\", \"Stopped\", and + \"Starting\".""" + database_id: Optional[str] = rest_field(name="databaseId", visibility=["read"]) + """The ID of the database.""" + creation_date: Optional[datetime.datetime] = rest_field(name="creationDate", visibility=["read"], format="rfc3339") + """The creation date of the database (ISO8601 format).""" + current_service_objective_name: Optional[str] = rest_field(name="currentServiceObjectiveName", visibility=["read"]) + """The current service level objective name of the database.""" + requested_service_objective_name: Optional[str] = rest_field( + name="requestedServiceObjectiveName", visibility=["read"] + ) + """The requested service level objective name of the database.""" + default_secondary_location: Optional[str] = rest_field(name="defaultSecondaryLocation", visibility=["read"]) + """The default secondary region for this database.""" + failover_group_id: Optional[str] = rest_field(name="failoverGroupId", visibility=["read"]) + """Failover Group resource identifier that this database belongs to.""" + restore_point_in_time: Optional[datetime.datetime] = rest_field( + name="restorePointInTime", visibility=["create"], format="rfc3339" + ) + """Specifies the point in time (ISO8601 format) of the source database that will be restored to + create the new database.""" + source_database_deletion_date: Optional[datetime.datetime] = rest_field( + name="sourceDatabaseDeletionDate", visibility=["create"], format="rfc3339" + ) + """Specifies the time that the database was deleted.""" + recovery_services_recovery_point_id: Optional[str] = rest_field( + name="recoveryServicesRecoveryPointId", visibility=["create"] + ) + """The resource identifier of the recovery point associated with create operation of this + database.""" + long_term_retention_backup_resource_id: Optional[str] = rest_field( + name="longTermRetentionBackupResourceId", visibility=["create"] + ) + """The resource identifier of the long term retention backup associated with create operation of + this database.""" + recoverable_database_id: Optional[str] = rest_field(name="recoverableDatabaseId", visibility=["create"]) + """The resource identifier of the recoverable database associated with create operation of this + database.""" + restorable_dropped_database_id: Optional[str] = rest_field( + name="restorableDroppedDatabaseId", visibility=["create"] + ) + """The resource identifier of the restorable dropped database associated with create operation of + this database.""" + catalog_collation: Optional[Union[str, "_models.CatalogCollationType"]] = rest_field( + name="catalogCollation", visibility=["read", "create"] + ) + """Collation of the metadata catalog. Known values are: \"DATABASE_DEFAULT\" and + \"SQL_Latin1_General_CP1_CI_AS\".""" + zone_redundant: Optional[bool] = rest_field( + name="zoneRedundant", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether or not this database is zone redundant, which means the replicas of this database will + be spread across multiple availability zones.""" + license_type: Optional[Union[str, "_models.DatabaseLicenseType"]] = rest_field( + name="licenseType", visibility=["read", "create", "update", "delete", "query"] + ) + """The license type to apply for this database. ``LicenseIncluded`` if you need a license, or + ``BasePrice`` if you have a license and are eligible for the Azure Hybrid Benefit. Known values + are: \"LicenseIncluded\" and \"BasePrice\".""" + max_log_size_bytes: Optional[int] = rest_field(name="maxLogSizeBytes", visibility=["read"]) + """The max log size for this database.""" + earliest_restore_date: Optional[datetime.datetime] = rest_field( + name="earliestRestoreDate", visibility=["read"], format="rfc3339" + ) + """This records the earliest start date and time that restore is available for this database + (ISO8601 format).""" + read_scale: Optional[Union[str, "_models.DatabaseReadScale"]] = rest_field( + name="readScale", visibility=["read", "update"] + ) + """The state of read-only routing. If enabled, connections that have application intent set to + readonly in their connection string may be routed to a readonly secondary replica in the same + region. Not applicable to a Hyperscale database within an elastic pool. Known values are: + \"Enabled\" and \"Disabled\".""" + high_availability_replica_count: Optional[int] = rest_field( + name="highAvailabilityReplicaCount", visibility=["read", "create", "update", "delete", "query"] + ) + """The number of secondary replicas associated with the Business Critical, Premium, or Hyperscale + edition database that are used to provide high availability. Not applicable to a Hyperscale + database within an elastic pool.""" + secondary_type: Optional[Union[str, "_models.SecondaryType"]] = rest_field( + name="secondaryType", visibility=["read", "create", "update", "delete", "query"] + ) + """The secondary type of the database if it is a secondary. Valid values are Geo, Named and + Standby. Known values are: \"Geo\", \"Named\", and \"Standby\".""" + current_sku: Optional["_models.Sku"] = rest_field(name="currentSku", visibility=["read"]) + """The name and tier of the SKU.""" + auto_pause_delay: Optional[int] = rest_field( + name="autoPauseDelay", visibility=["read", "create", "update", "delete", "query"] + ) + """Time in minutes after which database is automatically paused. A value of -1 means that + automatic pause is disabled.""" + current_backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = rest_field( + name="currentBackupStorageRedundancy", visibility=["read"] + ) + """The storage account type used to store backups for this database. Known values are: \"Geo\", + \"Local\", \"Zone\", and \"GeoZone\".""" + requested_backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = rest_field( + name="requestedBackupStorageRedundancy", visibility=["read", "create", "update", "delete", "query"] + ) + """The storage account type to be used to store backups for this database. Known values are: + \"Geo\", \"Local\", \"Zone\", and \"GeoZone\".""" + min_capacity: Optional[float] = rest_field( + name="minCapacity", visibility=["read", "create", "update", "delete", "query"] + ) + """Minimal capacity that database will always have allocated, if not paused.""" + paused_date: Optional[datetime.datetime] = rest_field(name="pausedDate", visibility=["read"], format="rfc3339") + """The date when database was paused by user configuration or action(ISO8601 format). Null if the + database is ready.""" + resumed_date: Optional[datetime.datetime] = rest_field(name="resumedDate", visibility=["read"], format="rfc3339") + """The date when database was resumed by user action or database login (ISO8601 format). Null if + the database is paused.""" + maintenance_configuration_id: Optional[str] = rest_field( + name="maintenanceConfigurationId", visibility=["read", "create", "update", "delete", "query"] + ) + """Maintenance configuration id assigned to the database. This configuration defines the period + when the maintenance updates will occur.""" + is_ledger_on: Optional[bool] = rest_field( + name="isLedgerOn", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether or not this database is a ledger database, which means all tables in the database are + ledger tables. Note: the value of this property cannot be changed after the database has been + created.""" + is_infra_encryption_enabled: Optional[bool] = rest_field(name="isInfraEncryptionEnabled", visibility=["read"]) + """Infra encryption is enabled for this database.""" + federated_client_id: Optional[str] = rest_field( + name="federatedClientId", visibility=["read", "create", "update", "delete", "query"] + ) + """The Client id used for cross tenant per database CMK scenario.""" + keys_property: Optional[dict[str, "_models.DatabaseKey"]] = rest_field( + name="keys", visibility=["read", "create", "update", "delete", "query"], original_tsp_name="keys" + ) + """The resource ids of the user assigned identities to use.""" + encryption_protector: Optional[str] = rest_field( + name="encryptionProtector", visibility=["read", "create", "update", "delete", "query"] + ) + """The azure key vault URI of the database if it's configured with per Database Customer Managed + Keys.""" + preferred_enclave_type: Optional[Union[str, "_models.AlwaysEncryptedEnclaveType"]] = rest_field( + name="preferredEnclaveType", visibility=["read", "create", "update", "delete", "query"] + ) + """Type of enclave requested on the database i.e. Default or VBS enclaves. Known values are: + \"Default\" and \"VBS\".""" + use_free_limit: Optional[bool] = rest_field( + name="useFreeLimit", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether or not the database uses free monthly limits. Allowed on one database in a + subscription.""" + free_limit_exhaustion_behavior: Optional[Union[str, "_models.FreeLimitExhaustionBehavior"]] = rest_field( + name="freeLimitExhaustionBehavior", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the behavior when monthly free limits are exhausted for the free database. + + AutoPause: The database will be auto paused upon exhaustion of free limits for remainder of the + month. + + BillForUsage: The database will continue to be online upon exhaustion of free limits and any + overage will be billed. Known values are: \"AutoPause\" and \"BillOverUsage\".""" + manual_cutover: Optional[bool] = rest_field( + name="manualCutover", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether or not customer controlled manual cutover needs to be done during Update Database + operation to Hyperscale tier. + + This property is only applicable when scaling database from Business Critical/General + Purpose/Premium/Standard tier to Hyperscale tier. + + When manualCutover is specified, the scaling operation will wait for user input to trigger + cutover to Hyperscale database. + + To trigger cutover, please provide 'performCutover' parameter when the Scaling operation is in + Waiting state.""" + perform_cutover: Optional[bool] = rest_field( + name="performCutover", visibility=["read", "create", "update", "delete", "query"] + ) + """To trigger customer controlled manual cutover during the wait state while Scaling operation is + in progress. + + This property parameter is only applicable for scaling operations that are initiated along with + 'manualCutover' parameter. + + This property is only applicable when scaling database from Business Critical/General + Purpose/Premium/Standard tier to Hyperscale tier is already in progress. + + When performCutover is specified, the scaling operation will trigger cutover and perform + role-change to Hyperscale database.""" + encryption_protector_auto_rotation: Optional[bool] = rest_field( + name="encryptionProtectorAutoRotation", visibility=["read", "create", "update", "delete", "query"] + ) + """The flag to enable or disable auto rotation of database encryption protector AKV key.""" + provisioning_state: Optional[str] = rest_field(name="provisioningState", visibility=["read"]) + """Specifies the provisioning state for this resource.""" + + @overload + def __init__( # pylint: disable=too-many-locals + self, + *, + create_mode: Optional[Union[str, "_models.CreateMode"]] = None, + collation: Optional[str] = None, + max_size_bytes: Optional[int] = None, + sample_name: Optional[Union[str, "_models.SampleName"]] = None, + elastic_pool_id: Optional[str] = None, + source_database_id: Optional[str] = None, + restore_point_in_time: Optional[datetime.datetime] = None, + source_database_deletion_date: Optional[datetime.datetime] = None, + recovery_services_recovery_point_id: Optional[str] = None, + long_term_retention_backup_resource_id: Optional[str] = None, + recoverable_database_id: Optional[str] = None, + restorable_dropped_database_id: Optional[str] = None, + catalog_collation: Optional[Union[str, "_models.CatalogCollationType"]] = None, + zone_redundant: Optional[bool] = None, + license_type: Optional[Union[str, "_models.DatabaseLicenseType"]] = None, + read_scale: Optional[Union[str, "_models.DatabaseReadScale"]] = None, + high_availability_replica_count: Optional[int] = None, + secondary_type: Optional[Union[str, "_models.SecondaryType"]] = None, + auto_pause_delay: Optional[int] = None, + requested_backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = None, + min_capacity: Optional[float] = None, + maintenance_configuration_id: Optional[str] = None, + is_ledger_on: Optional[bool] = None, + federated_client_id: Optional[str] = None, + keys_property: Optional[dict[str, "_models.DatabaseKey"]] = None, + encryption_protector: Optional[str] = None, + preferred_enclave_type: Optional[Union[str, "_models.AlwaysEncryptedEnclaveType"]] = None, + use_free_limit: Optional[bool] = None, + free_limit_exhaustion_behavior: Optional[Union[str, "_models.FreeLimitExhaustionBehavior"]] = None, + manual_cutover: Optional[bool] = None, + perform_cutover: Optional[bool] = None, + encryption_protector_auto_rotation: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DatabaseUsage(ProxyResource): + """Usage metric of a database. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.DatabaseUsageProperties + """ + + properties: Optional["_models.DatabaseUsageProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["display_name", "current_value", "limit", "unit"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.DatabaseUsageProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class DatabaseUsageProperties(_Model): + """Properties of a database usage. + + :ivar display_name: User-readable name of the metric. + :vartype display_name: str + :ivar current_value: Current value of the metric. + :vartype current_value: float + :ivar limit: Boundary value of the metric. + :vartype limit: float + :ivar unit: Unit of the metric. + :vartype unit: str + """ + + display_name: Optional[str] = rest_field(name="displayName", visibility=["read"]) + """User-readable name of the metric.""" + current_value: Optional[float] = rest_field(name="currentValue", visibility=["read"]) + """Current value of the metric.""" + limit: Optional[float] = rest_field(visibility=["read"]) + """Boundary value of the metric.""" + unit: Optional[str] = rest_field(visibility=["read"]) + """Unit of the metric.""" + + +class DatabaseUserIdentity(_Model): + """Azure Active Directory identity configuration for a resource. + + :ivar principal_id: The Azure Active Directory principal id. + :vartype principal_id: str + :ivar client_id: The Azure Active Directory client id. + :vartype client_id: str + """ + + principal_id: Optional[str] = rest_field(name="principalId", visibility=["read"]) + """The Azure Active Directory principal id.""" + client_id: Optional[str] = rest_field(name="clientId", visibility=["read"]) + """The Azure Active Directory client id.""" + + +class DatabaseVulnerabilityAssessment(ProxyResource): + """A database vulnerability assessment. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentProperties + """ + + properties: Optional["_models.DatabaseVulnerabilityAssessmentProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "storage_container_path", + "storage_container_sas_key", + "storage_account_access_key", + "recurring_scans", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.DatabaseVulnerabilityAssessmentProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class DatabaseVulnerabilityAssessmentProperties(_Model): # pylint: disable=name-too-long + """Properties of a database Vulnerability Assessment. + + :ivar storage_container_path: A blob storage container path to hold the scan results (e.g. + `https://myStorage.blob.core.windows.net/VaScans/ + `_). It is required if server level + vulnerability assessment policy doesn't set. + :vartype storage_container_path: str + :ivar storage_container_sas_key: A shared access signature (SAS Key) that has write access to + the blob container specified in 'storageContainerPath' parameter. If 'storageAccountAccessKey' + isn't specified, StorageContainerSasKey is required. Applies only if the storage account is not + behind a Vnet or a firewall. + :vartype storage_container_sas_key: str + :ivar storage_account_access_key: Specifies the identifier key of the storage account for + vulnerability assessment scan results. If 'StorageContainerSasKey' isn't specified, + storageAccountAccessKey is required. Applies only if the storage account is not behind a Vnet + or a firewall. + :vartype storage_account_access_key: str + :ivar recurring_scans: The recurring scans settings. + :vartype recurring_scans: + ~azure.mgmt.sql.models.VulnerabilityAssessmentRecurringScansProperties + """ + + storage_container_path: Optional[str] = rest_field(name="storageContainerPath", visibility=["create", "update"]) + """A blob storage container path to hold the scan results (e.g. + `https://myStorage.blob.core.windows.net/VaScans/ + `_). It is required if server level + vulnerability assessment policy doesn't set.""" + storage_container_sas_key: Optional[str] = rest_field( + name="storageContainerSasKey", visibility=["create", "update"] + ) + """A shared access signature (SAS Key) that has write access to the blob container specified in + 'storageContainerPath' parameter. If 'storageAccountAccessKey' isn't specified, + StorageContainerSasKey is required. Applies only if the storage account is not behind a Vnet or + a firewall.""" + storage_account_access_key: Optional[str] = rest_field( + name="storageAccountAccessKey", visibility=["create", "update"] + ) + """Specifies the identifier key of the storage account for vulnerability assessment scan results. + If 'StorageContainerSasKey' isn't specified, storageAccountAccessKey is required. Applies only + if the storage account is not behind a Vnet or a firewall.""" + recurring_scans: Optional["_models.VulnerabilityAssessmentRecurringScansProperties"] = rest_field( + name="recurringScans", visibility=["read", "create", "update", "delete", "query"] + ) + """The recurring scans settings.""" + + @overload + def __init__( + self, + *, + storage_container_path: Optional[str] = None, + storage_container_sas_key: Optional[str] = None, + storage_account_access_key: Optional[str] = None, + recurring_scans: Optional["_models.VulnerabilityAssessmentRecurringScansProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DatabaseVulnerabilityAssessmentRuleBaseline(ProxyResource): # pylint: disable=name-too-long + """A database vulnerability assessment rule baseline. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: + ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaselineProperties + """ + + properties: Optional["_models.DatabaseVulnerabilityAssessmentRuleBaselineProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["baseline_results"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.DatabaseVulnerabilityAssessmentRuleBaselineProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class DatabaseVulnerabilityAssessmentRuleBaselineItem(_Model): # pylint: disable=name-too-long + """Properties for an Azure SQL Database Vulnerability Assessment rule baseline's result. + + :ivar result: The rule baseline result. Required. + :vartype result: list[str] + """ + + result: list[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The rule baseline result. Required.""" + + @overload + def __init__( + self, + *, + result: list[str], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DatabaseVulnerabilityAssessmentRuleBaselineProperties(_Model): # pylint: disable=name-too-long + """Properties of a database Vulnerability Assessment rule baseline. + + :ivar baseline_results: The rule baseline result. Required. + :vartype baseline_results: + list[~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaselineItem] + """ + + baseline_results: list["_models.DatabaseVulnerabilityAssessmentRuleBaselineItem"] = rest_field( + name="baselineResults", visibility=["read", "create", "update", "delete", "query"] + ) + """The rule baseline result. Required.""" + + @overload + def __init__( + self, + *, + baseline_results: list["_models.DatabaseVulnerabilityAssessmentRuleBaselineItem"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DatabaseVulnerabilityAssessmentScanExportProperties(_Model): # pylint: disable=name-too-long + """Properties of the export operation's result. + + :ivar exported_report_location: Location of the exported report (e.g. + `https://myStorage.blob.core.windows.net/VaScans/scans/serverName/databaseName/scan_scanId.xlsx + `_). + :vartype exported_report_location: str + """ + + exported_report_location: Optional[str] = rest_field(name="exportedReportLocation", visibility=["read"]) + """Location of the exported report (e.g. + `https://myStorage.blob.core.windows.net/VaScans/scans/serverName/databaseName/scan_scanId.xlsx + `_).""" + + +class DatabaseVulnerabilityAssessmentScansExport(ProxyResource): # pylint: disable=name-too-long + """A database Vulnerability Assessment scan export resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentScanExportProperties + """ + + properties: Optional["_models.DatabaseVulnerabilityAssessmentScanExportProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["exported_report_location"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.DatabaseVulnerabilityAssessmentScanExportProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class DataMaskingPolicy(ProxyResource): + """A database data masking policy. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.DataMaskingPolicyProperties + :ivar location: The location of the data masking policy. + :vartype location: str + :ivar kind: The kind of Data Masking Policy. Metadata, used for Azure portal. + :vartype kind: str + """ + + properties: Optional["_models.DataMaskingPolicyProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + location: Optional[str] = rest_field(visibility=["read"]) + """The location of the data masking policy.""" + kind: Optional[str] = rest_field(visibility=["read"]) + """The kind of Data Masking Policy. Metadata, used for Azure portal.""" + + __flattened_items = ["data_masking_state", "exempt_principals", "application_principals", "masking_level"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.DataMaskingPolicyProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class DataMaskingPolicyProperties(_Model): + """The properties of a database data masking policy. + + :ivar data_masking_state: The state of the data masking policy. Required. 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 + receive data results without masking for all of the database queries. + :vartype exempt_principals: str + :ivar application_principals: The list of the application principals. This is a legacy + parameter and is no longer used. + :vartype application_principals: str + :ivar masking_level: The masking level. This is a legacy parameter and is no longer used. + :vartype masking_level: str + """ + + data_masking_state: Union[str, "_models.DataMaskingState"] = rest_field( + name="dataMaskingState", visibility=["read", "create", "update", "delete", "query"] + ) + """The state of the data masking policy. Required. Known values are: \"Enabled\" and \"Disabled\".""" + exempt_principals: Optional[str] = rest_field( + name="exemptPrincipals", visibility=["read", "create", "update", "delete", "query"] + ) + """The list of the exempt principals. Specifies the semicolon-separated list of database users for + which the data masking policy does not apply. The specified users receive data results without + masking for all of the database queries.""" + application_principals: Optional[str] = rest_field(name="applicationPrincipals", visibility=["read"]) + """The list of the application principals. This is a legacy parameter and is no longer used.""" + masking_level: Optional[str] = rest_field(name="maskingLevel", visibility=["read"]) + """The masking level. This is a legacy parameter and is no longer used.""" + + @overload + def __init__( + self, + *, + data_masking_state: Union[str, "_models.DataMaskingState"], + exempt_principals: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DataMaskingRule(ProxyResource): + """A database data masking rule. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar location: The location of the data masking rule. + :vartype location: str + :ivar kind: The kind of Data Masking Rule. Metadata, used for Azure portal. + :vartype kind: str + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.DataMaskingRuleProperties + """ + + location: Optional[str] = rest_field(visibility=["read"]) + """The location of the data masking rule.""" + kind: Optional[str] = rest_field(visibility=["read"]) + """The kind of Data Masking Rule. Metadata, used for Azure portal.""" + properties: Optional["_models.DataMaskingRuleProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "id", + "rule_state", + "schema_name", + "table_name", + "column_name", + "alias_name", + "masking_function", + "number_from", + "number_to", + "prefix_size", + "suffix_size", + "replacement_string", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.DataMaskingRuleProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class DataMaskingRuleProperties(_Model): + """The properties of a database data masking rule. + + :ivar id: The rule Id. + :vartype id: 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: "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. Required. + :vartype schema_name: str + :ivar table_name: The table name on which the data masking rule is applied. Required. + :vartype table_name: str + :ivar column_name: The column name on which the data masking rule is applied. Required. + :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. Required. + Known values are: "Default", "CCN", "Email", "Number", "SSN", and "Text". + :vartype masking_function: str or ~azure.mgmt.sql.models.DataMaskingFunction + :ivar number_from: The numberFrom property of the masking rule. Required if maskingFunction is + set to Number, otherwise this parameter will be ignored. + :vartype number_from: str + :ivar number_to: The numberTo property of the data masking rule. Required if maskingFunction is + set to Number, otherwise this parameter will be ignored. + :vartype number_to: str + :ivar prefix_size: If maskingFunction is set to Text, the number of characters to show unmasked + in the beginning of the string. Otherwise, this parameter will be ignored. + :vartype prefix_size: str + :ivar suffix_size: If maskingFunction is set to Text, the number of characters to show unmasked + at the end of the string. Otherwise, this parameter will be ignored. + :vartype suffix_size: str + :ivar replacement_string: If maskingFunction is set to Text, the character to use for masking + the unexposed part of the string. Otherwise, this parameter will be ignored. + :vartype replacement_string: str + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """The rule Id.""" + rule_state: Optional[Union[str, "_models.DataMaskingRuleState"]] = rest_field( + name="ruleState", visibility=["read", "create", "update", "delete", "query"] + ) + """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: \"Enabled\" and \"Disabled\".""" + schema_name: str = rest_field(name="schemaName", visibility=["read", "create", "update", "delete", "query"]) + """The schema name on which the data masking rule is applied. Required.""" + table_name: str = rest_field(name="tableName", visibility=["read", "create", "update", "delete", "query"]) + """The table name on which the data masking rule is applied. Required.""" + column_name: str = rest_field(name="columnName", visibility=["read", "create", "update", "delete", "query"]) + """The column name on which the data masking rule is applied. Required.""" + alias_name: Optional[str] = rest_field(name="aliasName", visibility=["read", "create", "update", "delete", "query"]) + """The alias name. This is a legacy parameter and is no longer used.""" + masking_function: Union[str, "_models.DataMaskingFunction"] = rest_field( + name="maskingFunction", visibility=["read", "create", "update", "delete", "query"] + ) + """The masking function that is used for the data masking rule. Required. Known values are: + \"Default\", \"CCN\", \"Email\", \"Number\", \"SSN\", and \"Text\".""" + number_from: Optional[str] = rest_field( + name="numberFrom", visibility=["read", "create", "update", "delete", "query"] + ) + """The numberFrom property of the masking rule. Required if maskingFunction is set to Number, + otherwise this parameter will be ignored.""" + number_to: Optional[str] = rest_field(name="numberTo", visibility=["read", "create", "update", "delete", "query"]) + """The numberTo property of the data masking rule. Required if maskingFunction is set to Number, + otherwise this parameter will be ignored.""" + prefix_size: Optional[str] = rest_field( + name="prefixSize", visibility=["read", "create", "update", "delete", "query"] + ) + """If maskingFunction is set to Text, the number of characters to show unmasked in the beginning + of the string. Otherwise, this parameter will be ignored.""" + suffix_size: Optional[str] = rest_field( + name="suffixSize", visibility=["read", "create", "update", "delete", "query"] + ) + """If maskingFunction is set to Text, the number of characters to show unmasked at the end of the + string. Otherwise, this parameter will be ignored.""" + replacement_string: Optional[str] = rest_field( + name="replacementString", visibility=["read", "create", "update", "delete", "query"] + ) + """If maskingFunction is set to Text, the character to use for masking the unexposed part of the + string. Otherwise, this parameter will be ignored.""" + + @overload + def __init__( + self, + *, + schema_name: str, + table_name: str, + column_name: str, + masking_function: Union[str, "_models.DataMaskingFunction"], + rule_state: Optional[Union[str, "_models.DataMaskingRuleState"]] = None, + alias_name: Optional[str] = None, + number_from: Optional[str] = None, + number_to: Optional[str] = None, + prefix_size: Optional[str] = None, + suffix_size: Optional[str] = None, + replacement_string: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DataSyncParticipantIdentity(_Model): + """Azure Active Directory identity configuration for a resource. + + :ivar type: The Datasync identity type. Required. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssignedUserAssigned". + :vartype type: str or ~azure.mgmt.sql.models.DataSyncParticipantIdentityType + :ivar tenant_id: The DataSync participant identity tenant id. + :vartype tenant_id: str + :ivar user_assigned_identities: The resource ids of the user assigned identities to use. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.sql.models.DataSyncParticipantUserAssignedIdentity] + """ + + type: Union[str, "_models.DataSyncParticipantIdentityType"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The Datasync identity type. Required. Known values are: \"None\", \"SystemAssigned\", + \"UserAssigned\", and \"SystemAssignedUserAssigned\".""" + tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read", "create", "update", "delete", "query"]) + """The DataSync participant identity tenant id.""" + user_assigned_identities: Optional[dict[str, "_models.DataSyncParticipantUserAssignedIdentity"]] = rest_field( + name="userAssignedIdentities", visibility=["read", "create", "update", "delete", "query"] + ) + """The resource ids of the user assigned identities to use.""" + + @overload + def __init__( + self, + *, + type: Union[str, "_models.DataSyncParticipantIdentityType"], + tenant_id: Optional[str] = None, + user_assigned_identities: Optional[dict[str, "_models.DataSyncParticipantUserAssignedIdentity"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DataSyncParticipantUserAssignedIdentity(_Model): + """Azure Active Directory identity configuration for a resource. + + :ivar principal_id: The Azure Active Directory principal id. + :vartype principal_id: str + :ivar client_id: The Azure Active Directory client id. + :vartype client_id: str + """ + + principal_id: Optional[str] = rest_field(name="principalId", visibility=["read"]) + """The Azure Active Directory principal id.""" + client_id: Optional[str] = rest_field(name="clientId", visibility=["read"]) + """The Azure Active Directory client id.""" + + +class DataWarehouseUserActivities(ProxyResource): + """User activities of a data warehouse. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.DataWarehouseUserActivitiesProperties + """ + + properties: Optional["_models.DataWarehouseUserActivitiesProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["active_queries_count"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.DataWarehouseUserActivitiesProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class DataWarehouseUserActivitiesProperties(_Model): + """User activities of a data warehouse. This currently includes the count of running or suspended + queries. For more information, please view the sys.dm_pdw_exec_requests dynamic management view + (DMV). + + :ivar active_queries_count: Count of running and suspended queries. + :vartype active_queries_count: int + """ + + active_queries_count: Optional[int] = rest_field(name="activeQueriesCount", visibility=["read"]) + """Count of running and suspended queries.""" + + +class DeletedServer(ProxyResource): + """A deleted server. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.DeletedServerProperties + """ + + properties: Optional["_models.DeletedServerProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["version", "deletion_time", "original_id", "fully_qualified_domain_name"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.DeletedServerProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class DeletedServerProperties(_Model): + """The properties of a deleted server. + + :ivar version: The version of the deleted server. + :vartype version: str + :ivar deletion_time: The deletion time of the deleted server. + :vartype deletion_time: ~datetime.datetime + :ivar original_id: The original ID of the server before deletion. + :vartype original_id: str + :ivar fully_qualified_domain_name: The fully qualified domain name of the server. + :vartype fully_qualified_domain_name: str + """ + + version: Optional[str] = rest_field(visibility=["read"]) + """The version of the deleted server.""" + deletion_time: Optional[datetime.datetime] = rest_field(name="deletionTime", visibility=["read"], format="rfc3339") + """The deletion time of the deleted server.""" + original_id: Optional[str] = rest_field(name="originalId", visibility=["read"]) + """The original ID of the server before deletion.""" + fully_qualified_domain_name: Optional[str] = rest_field(name="fullyQualifiedDomainName", visibility=["read"]) + """The fully qualified domain name of the server.""" + + +class DistributedAvailabilityGroup(ProxyResource): + """Distributed availability group between box and Sql Managed Instance. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.DistributedAvailabilityGroupProperties + """ + + properties: Optional["_models.DistributedAvailabilityGroupProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "distributed_availability_group_name", + "distributed_availability_group_id", + "replication_mode", + "partner_link_role", + "partner_availability_group_name", + "partner_endpoint", + "instance_link_role", + "instance_availability_group_name", + "failover_mode", + "seeding_mode", + "databases", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.DistributedAvailabilityGroupProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class DistributedAvailabilityGroupDatabase(_Model): + """Database specific information. + + :ivar database_name: The name of the database in link. + :vartype database_name: str + :ivar instance_replica_id: Managed instance replica id. + :vartype instance_replica_id: str + :ivar partner_replica_id: SQL server replica id. + :vartype partner_replica_id: str + :ivar replica_state: Current link state. + :vartype replica_state: str + :ivar seeding_progress: Seeding progress. + :vartype seeding_progress: str + :ivar synchronization_health: Link health state. Known values are: "NOT_HEALTHY", + "PARTIALLY_HEALTHY", and "HEALTHY". + :vartype synchronization_health: str or ~azure.mgmt.sql.models.ReplicaSynchronizationHealth + :ivar connected_state: Link connected state. Known values are: "DISCONNECTED" and "CONNECTED". + :vartype connected_state: str or ~azure.mgmt.sql.models.ReplicaConnectedState + :ivar last_received_lsn: Last received LSN. + :vartype last_received_lsn: str + :ivar last_received_time: Last received LSN time. + :vartype last_received_time: ~datetime.datetime + :ivar last_sent_lsn: Last sent LSN. + :vartype last_sent_lsn: str + :ivar last_sent_time: Last sent LSN time. + :vartype last_sent_time: ~datetime.datetime + :ivar last_commit_lsn: Last commit LSN. + :vartype last_commit_lsn: str + :ivar last_commit_time: Last commit LSN time. + :vartype last_commit_time: ~datetime.datetime + :ivar last_hardened_lsn: Last hardened LSN. + :vartype last_hardened_lsn: str + :ivar last_hardened_time: Last hardened LSN time. + :vartype last_hardened_time: ~datetime.datetime + :ivar last_backup_lsn: Last backup LSN. + :vartype last_backup_lsn: str + :ivar last_backup_time: Last backup LSN time. + :vartype last_backup_time: ~datetime.datetime + :ivar most_recent_link_error: The most recent link connection error description. + :vartype most_recent_link_error: str + :ivar partner_auth_cert_validity: SQL server certificate validity. + :vartype partner_auth_cert_validity: ~azure.mgmt.sql.models.CertificateInfo + :ivar instance_send_replication_lag_seconds: Replication lag when Managed Instance link side is + primary. + :vartype instance_send_replication_lag_seconds: int + :ivar instance_redo_replication_lag_seconds: Redo lag when Managed Instance link side is + primary. + :vartype instance_redo_replication_lag_seconds: int + """ + + database_name: Optional[str] = rest_field( + name="databaseName", visibility=["read", "create", "update", "delete", "query"] + ) + """The name of the database in link.""" + instance_replica_id: Optional[str] = rest_field(name="instanceReplicaId", visibility=["read"]) + """Managed instance replica id.""" + partner_replica_id: Optional[str] = rest_field(name="partnerReplicaId", visibility=["read"]) + """SQL server replica id.""" + replica_state: Optional[str] = rest_field(name="replicaState", visibility=["read"]) + """Current link state.""" + seeding_progress: Optional[str] = rest_field(name="seedingProgress", visibility=["read"]) + """Seeding progress.""" + synchronization_health: Optional[Union[str, "_models.ReplicaSynchronizationHealth"]] = rest_field( + name="synchronizationHealth", visibility=["read"] + ) + """Link health state. Known values are: \"NOT_HEALTHY\", \"PARTIALLY_HEALTHY\", and \"HEALTHY\".""" + connected_state: Optional[Union[str, "_models.ReplicaConnectedState"]] = rest_field( + name="connectedState", visibility=["read"] + ) + """Link connected state. Known values are: \"DISCONNECTED\" and \"CONNECTED\".""" + last_received_lsn: Optional[str] = rest_field(name="lastReceivedLsn", visibility=["read"]) + """Last received LSN.""" + last_received_time: Optional[datetime.datetime] = rest_field( + name="lastReceivedTime", visibility=["read"], format="rfc3339" + ) + """Last received LSN time.""" + last_sent_lsn: Optional[str] = rest_field(name="lastSentLsn", visibility=["read"]) + """Last sent LSN.""" + last_sent_time: Optional[datetime.datetime] = rest_field(name="lastSentTime", visibility=["read"], format="rfc3339") + """Last sent LSN time.""" + last_commit_lsn: Optional[str] = rest_field(name="lastCommitLsn", visibility=["read"]) + """Last commit LSN.""" + last_commit_time: Optional[datetime.datetime] = rest_field( + name="lastCommitTime", visibility=["read"], format="rfc3339" + ) + """Last commit LSN time.""" + last_hardened_lsn: Optional[str] = rest_field(name="lastHardenedLsn", visibility=["read"]) + """Last hardened LSN.""" + last_hardened_time: Optional[datetime.datetime] = rest_field( + name="lastHardenedTime", visibility=["read"], format="rfc3339" + ) + """Last hardened LSN time.""" + last_backup_lsn: Optional[str] = rest_field(name="lastBackupLsn", visibility=["read"]) + """Last backup LSN.""" + last_backup_time: Optional[datetime.datetime] = rest_field( + name="lastBackupTime", visibility=["read"], format="rfc3339" + ) + """Last backup LSN time.""" + most_recent_link_error: Optional[str] = rest_field(name="mostRecentLinkError", visibility=["read"]) + """The most recent link connection error description.""" + partner_auth_cert_validity: Optional["_models.CertificateInfo"] = rest_field( + name="partnerAuthCertValidity", visibility=["read"] + ) + """SQL server certificate validity.""" + instance_send_replication_lag_seconds: Optional[int] = rest_field( + name="instanceSendReplicationLagSeconds", visibility=["read"] + ) + """Replication lag when Managed Instance link side is primary.""" + instance_redo_replication_lag_seconds: Optional[int] = rest_field( + name="instanceRedoReplicationLagSeconds", visibility=["read"] + ) + """Redo lag when Managed Instance link side is primary.""" + + @overload + def __init__( + self, + *, + database_name: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DistributedAvailabilityGroupProperties(_Model): + """The properties of a distributed availability group. + + :ivar distributed_availability_group_name: Name of the distributed availability group. + :vartype distributed_availability_group_name: str + :ivar distributed_availability_group_id: ID of the distributed availability group. + :vartype distributed_availability_group_id: str + :ivar replication_mode: Replication mode of the link. Known values are: "Async" and "Sync". + :vartype replication_mode: str or ~azure.mgmt.sql.models.ReplicationModeType + :ivar partner_link_role: SQL server side link role. Known values are: "Primary" and + "Secondary". + :vartype partner_link_role: str or ~azure.mgmt.sql.models.LinkRole + :ivar partner_availability_group_name: SQL server side availability group name. + :vartype partner_availability_group_name: str + :ivar partner_endpoint: SQL server side endpoint - IP or DNS resolvable name. + :vartype partner_endpoint: str + :ivar instance_link_role: Managed instance side link role. Known values are: "Primary" and + "Secondary". + :vartype instance_link_role: str or ~azure.mgmt.sql.models.LinkRole + :ivar instance_availability_group_name: Managed instance side availability group name. + :vartype instance_availability_group_name: str + :ivar failover_mode: The link failover mode - can be Manual if intended to be used for two-way + failover with a supported SQL Server, or None for one-way failover to Azure. Known values are: + "None" and "Manual". + :vartype failover_mode: str or ~azure.mgmt.sql.models.FailoverModeType + :ivar seeding_mode: Database seeding mode – can be Automatic (default), or Manual for supported + scenarios. Known values are: "Automatic" and "Manual". + :vartype seeding_mode: str or ~azure.mgmt.sql.models.SeedingModeType + :ivar databases: Databases in the distributed availability group. + :vartype databases: list[~azure.mgmt.sql.models.DistributedAvailabilityGroupDatabase] + """ + + distributed_availability_group_name: Optional[str] = rest_field( + name="distributedAvailabilityGroupName", visibility=["read"] + ) + """Name of the distributed availability group.""" + distributed_availability_group_id: Optional[str] = rest_field( + name="distributedAvailabilityGroupId", visibility=["read"] + ) + """ID of the distributed availability group.""" + replication_mode: Optional[Union[str, "_models.ReplicationModeType"]] = rest_field( + name="replicationMode", visibility=["read", "create", "update", "delete", "query"] + ) + """Replication mode of the link. Known values are: \"Async\" and \"Sync\".""" + partner_link_role: Optional[Union[str, "_models.LinkRole"]] = rest_field( + name="partnerLinkRole", visibility=["read"] + ) + """SQL server side link role. Known values are: \"Primary\" and \"Secondary\".""" + partner_availability_group_name: Optional[str] = rest_field( + name="partnerAvailabilityGroupName", visibility=["read", "create", "update", "delete", "query"] + ) + """SQL server side availability group name.""" + partner_endpoint: Optional[str] = rest_field( + name="partnerEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """SQL server side endpoint - IP or DNS resolvable name.""" + instance_link_role: Optional[Union[str, "_models.LinkRole"]] = rest_field( + name="instanceLinkRole", visibility=["read", "create", "update", "delete", "query"] + ) + """Managed instance side link role. Known values are: \"Primary\" and \"Secondary\".""" + instance_availability_group_name: Optional[str] = rest_field( + name="instanceAvailabilityGroupName", visibility=["read", "create", "update", "delete", "query"] + ) + """Managed instance side availability group name.""" + failover_mode: Optional[Union[str, "_models.FailoverModeType"]] = rest_field( + name="failoverMode", visibility=["read", "create", "update", "delete", "query"] + ) + """The link failover mode - can be Manual if intended to be used for two-way failover with a + supported SQL Server, or None for one-way failover to Azure. Known values are: \"None\" and + \"Manual\".""" + seeding_mode: Optional[Union[str, "_models.SeedingModeType"]] = rest_field( + name="seedingMode", visibility=["read", "create", "update", "delete", "query"] + ) + """Database seeding mode – can be Automatic (default), or Manual for supported scenarios. Known + values are: \"Automatic\" and \"Manual\".""" + databases: Optional[list["_models.DistributedAvailabilityGroupDatabase"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Databases in the distributed availability group.""" + + @overload + def __init__( + self, + *, + replication_mode: Optional[Union[str, "_models.ReplicationModeType"]] = None, + partner_availability_group_name: Optional[str] = None, + partner_endpoint: Optional[str] = None, + instance_link_role: Optional[Union[str, "_models.LinkRole"]] = None, + instance_availability_group_name: Optional[str] = None, + failover_mode: Optional[Union[str, "_models.FailoverModeType"]] = None, + seeding_mode: Optional[Union[str, "_models.SeedingModeType"]] = None, + databases: Optional[list["_models.DistributedAvailabilityGroupDatabase"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DistributedAvailabilityGroupSetRole(_Model): + """Distributed availability group failover request. + + :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 + """ + + instance_role: Union[str, "_models.InstanceRole"] = rest_field(name="instanceRole", visibility=["create", "update"]) + """New role of managed instance in a distributed availability group, can be Primary or Secondary. + Required. Known values are: \"Primary\" and \"Secondary\".""" + role_change_type: Union[str, "_models.RoleChangeType"] = rest_field( + name="roleChangeType", visibility=["create", "update"] + ) + """The type of the role change, can be Planned or Forced. Required. Known values are: \"Forced\" + and \"Planned\".""" + + @overload + def __init__( + self, + *, + instance_role: Union[str, "_models.InstanceRole"], + role_change_type: Union[str, "_models.RoleChangeType"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DistributedAvailabilityGroupsFailoverRequest(_Model): # pylint: disable=name-too-long + """Distributed availability group failover. + + :ivar failover_type: The failover type, can be ForcedAllowDataLoss or Planned. Required. Known + values are: "ForcedAllowDataLoss" and "Planned". + :vartype failover_type: str or ~azure.mgmt.sql.models.FailoverType + """ + + failover_type: Union[str, "_models.FailoverType"] = rest_field(name="failoverType", visibility=["create", "update"]) + """The failover type, can be ForcedAllowDataLoss or Planned. Required. Known values are: + \"ForcedAllowDataLoss\" and \"Planned\".""" + + @overload + def __init__( + self, + *, + failover_type: Union[str, "_models.FailoverType"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class EditionCapability(_Model): + """The edition capability. + + :ivar name: The database edition name. + :vartype name: str + :ivar supported_service_level_objectives: The list of supported service objectives for the + edition. + :vartype supported_service_level_objectives: + list[~azure.mgmt.sql.models.ServiceObjectiveCapability] + :ivar zone_redundant: Whether or not zone redundancy is supported for the edition. + :vartype zone_redundant: bool + :ivar read_scale: The read scale capability for the edition. + :vartype read_scale: ~azure.mgmt.sql.models.ReadScaleCapability + :ivar supported_storage_capabilities: The list of supported storage capabilities for this + edition. + :vartype supported_storage_capabilities: list[~azure.mgmt.sql.models.StorageCapability] + :ivar 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 + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """The database edition name.""" + supported_service_level_objectives: Optional[list["_models.ServiceObjectiveCapability"]] = rest_field( + name="supportedServiceLevelObjectives", visibility=["read"] + ) + """The list of supported service objectives for the edition.""" + zone_redundant: Optional[bool] = rest_field(name="zoneRedundant", visibility=["read"]) + """Whether or not zone redundancy is supported for the edition.""" + read_scale: Optional["_models.ReadScaleCapability"] = rest_field(name="readScale", visibility=["read"]) + """The read scale capability for the edition.""" + supported_storage_capabilities: Optional[list["_models.StorageCapability"]] = rest_field( + name="supportedStorageCapabilities", visibility=["read"] + ) + """The list of supported storage capabilities for this edition.""" + zone_pinning: Optional[bool] = rest_field(name="zonePinning", visibility=["read"]) + """Whether or not zone pinning is supported for the edition.""" + status: Optional[Union[str, "_models.CapabilityStatus"]] = rest_field(visibility=["read"]) + """The status of the capability. Known values are: \"Visible\", \"Available\", \"Default\", and + \"Disabled\".""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for the capability not being available.""" + + @overload + def __init__( + self, + *, + reason: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ElasticPool(TrackedResource): + """An elastic pool. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ElasticPoolProperties + :ivar sku: The elastic pool SKU. + + The list of SKUs may vary by region and support offer. To determine the SKUs (including the SKU + name, tier/edition, family, and capacity) that are available to your subscription in an Azure + region, use the ``Capabilities_ListByLocation`` REST API or the following command: + + + + .. code-block:: azurecli + + az sql elastic-pool list-editions -l -o table. + :vartype sku: ~azure.mgmt.sql.models.Sku + :ivar kind: Kind of elastic pool. This is metadata used for the Azure portal experience. + :vartype kind: str + """ + + properties: Optional["_models.ElasticPoolProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + sku: Optional["_models.Sku"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The elastic pool SKU. + + The list of SKUs may vary by region and support offer. To determine the SKUs (including the SKU + name, tier/edition, family, and capacity) that are available to your subscription in an Azure + region, use the ``Capabilities_ListByLocation`` REST API or the following command: + + + + .. code-block:: azurecli + + az sql elastic-pool list-editions -l -o table.""" + kind: Optional[str] = rest_field(visibility=["read"]) + """Kind of elastic pool. This is metadata used for the Azure portal experience.""" + + __flattened_items = [ + "state", + "creation_date", + "max_size_bytes", + "min_capacity", + "per_database_settings", + "zone_redundant", + "license_type", + "maintenance_configuration_id", + "high_availability_replica_count", + "auto_pause_delay", + "preferred_enclave_type", + "availability_zone", + "current_sku", + ] + + @overload + def __init__( + self, + *, + location: str, + tags: Optional[dict[str, str]] = None, + properties: Optional["_models.ElasticPoolProperties"] = None, + sku: Optional["_models.Sku"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ElasticPoolEditionCapability(_Model): + """The elastic pool edition capability. + + :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 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 + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """The elastic pool edition name.""" + supported_elastic_pool_performance_levels: Optional[list["_models.ElasticPoolPerformanceLevelCapability"]] = ( + rest_field(name="supportedElasticPoolPerformanceLevels", visibility=["read"]) + ) + """The list of supported elastic pool DTU levels for the edition.""" + zone_redundant: Optional[bool] = rest_field(name="zoneRedundant", visibility=["read"]) + """Whether or not zone redundancy is supported for the edition.""" + zone_pinning: Optional[bool] = rest_field(name="zonePinning", visibility=["read"]) + """Whether or not zone pinning is supported for the edition.""" + status: Optional[Union[str, "_models.CapabilityStatus"]] = rest_field(visibility=["read"]) + """The status of the capability. Known values are: \"Visible\", \"Available\", \"Default\", and + \"Disabled\".""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for the capability not being available.""" + + @overload + def __init__( + self, + *, + reason: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ElasticPoolOperation(ProxyResource): + """A elastic pool operation. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ElasticPoolOperationProperties + """ + + properties: Optional["_models.ElasticPoolOperationProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "elastic_pool_name", + "operation", + "operation_friendly_name", + "percent_complete", + "server_name", + "start_time", + "state", + "error_code", + "error_description", + "error_severity", + "is_user_error", + "estimated_completion_time", + "description", + "is_cancellable", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ElasticPoolOperationProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ElasticPoolOperationProperties(_Model): + """The properties of a elastic pool operation. + + :ivar elastic_pool_name: The name of the elastic pool the operation is being performed on. + :vartype elastic_pool_name: str + :ivar operation: The name of operation. + :vartype operation: str + :ivar operation_friendly_name: The friendly name of operation. + :vartype operation_friendly_name: str + :ivar percent_complete: The percentage of the operation completed. + :vartype percent_complete: int + :ivar server_name: The name of the server. + :vartype server_name: str + :ivar start_time: The operation start time. + :vartype start_time: ~datetime.datetime + :ivar state: The operation state. + :vartype state: str + :ivar error_code: The operation error code. + :vartype error_code: int + :ivar error_description: The operation error description. + :vartype error_description: str + :ivar error_severity: The operation error severity. + :vartype error_severity: int + :ivar is_user_error: Whether or not the error is a user error. + :vartype is_user_error: bool + :ivar estimated_completion_time: The estimated completion time of the operation. + :vartype estimated_completion_time: ~datetime.datetime + :ivar description: The operation description. + :vartype description: str + :ivar is_cancellable: Whether the operation can be cancelled. + :vartype is_cancellable: bool + """ + + elastic_pool_name: Optional[str] = rest_field(name="elasticPoolName", visibility=["read"]) + """The name of the elastic pool the operation is being performed on.""" + operation: Optional[str] = rest_field(visibility=["read"]) + """The name of operation.""" + operation_friendly_name: Optional[str] = rest_field(name="operationFriendlyName", visibility=["read"]) + """The friendly name of operation.""" + percent_complete: Optional[int] = rest_field(name="percentComplete", visibility=["read"]) + """The percentage of the operation completed.""" + server_name: Optional[str] = rest_field(name="serverName", visibility=["read"]) + """The name of the server.""" + start_time: Optional[datetime.datetime] = rest_field(name="startTime", visibility=["read"], format="rfc3339") + """The operation start time.""" + state: Optional[str] = rest_field(visibility=["read"]) + """The operation state.""" + error_code: Optional[int] = rest_field(name="errorCode", visibility=["read"]) + """The operation error code.""" + error_description: Optional[str] = rest_field(name="errorDescription", visibility=["read"]) + """The operation error description.""" + error_severity: Optional[int] = rest_field(name="errorSeverity", visibility=["read"]) + """The operation error severity.""" + is_user_error: Optional[bool] = rest_field(name="isUserError", visibility=["read"]) + """Whether or not the error is a user error.""" + estimated_completion_time: Optional[datetime.datetime] = rest_field( + name="estimatedCompletionTime", visibility=["read"], format="rfc3339" + ) + """The estimated completion time of the operation.""" + description: Optional[str] = rest_field(visibility=["read"]) + """The operation description.""" + is_cancellable: Optional[bool] = rest_field(name="isCancellable", visibility=["read"]) + """Whether the operation can be cancelled.""" + + +class ElasticPoolPerDatabaseMaxPerformanceLevelCapability(_Model): # pylint: disable=name-too-long + """The max per-database performance level capability. + + :ivar limit: The maximum performance level per database. + :vartype limit: float + :ivar unit: Unit type used to measure performance level. Known values are: "DTU" and "VCores". + :vartype unit: str or ~azure.mgmt.sql.models.PerformanceLevelUnit + :ivar supported_per_database_min_performance_levels: The list of supported min database + performance levels. + :vartype supported_per_database_min_performance_levels: + list[~azure.mgmt.sql.models.ElasticPoolPerDatabaseMinPerformanceLevelCapability] + :ivar status: The status of the capability. 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 + """ + + limit: Optional[float] = rest_field(visibility=["read"]) + """The maximum performance level per database.""" + unit: Optional[Union[str, "_models.PerformanceLevelUnit"]] = rest_field(visibility=["read"]) + """Unit type used to measure performance level. Known values are: \"DTU\" and \"VCores\".""" + supported_per_database_min_performance_levels: Optional[ + list["_models.ElasticPoolPerDatabaseMinPerformanceLevelCapability"] + ] = rest_field(name="supportedPerDatabaseMinPerformanceLevels", visibility=["read"]) + """The list of supported min database performance levels.""" + status: Optional[Union[str, "_models.CapabilityStatus"]] = rest_field(visibility=["read"]) + """The status of the capability. Known values are: \"Visible\", \"Available\", \"Default\", and + \"Disabled\".""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for the capability not being available.""" + + @overload + def __init__( + self, + *, + reason: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ElasticPoolPerDatabaseMinPerformanceLevelCapability(_Model): # pylint: disable=name-too-long + """The minimum per-database performance level capability. + + :ivar limit: The minimum performance level per database. + :vartype limit: float + :ivar unit: Unit type used to measure performance level. Known values are: "DTU" and "VCores". + :vartype unit: str or ~azure.mgmt.sql.models.PerformanceLevelUnit + :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 + """ + + limit: Optional[float] = rest_field(visibility=["read"]) + """The minimum performance level per database.""" + unit: Optional[Union[str, "_models.PerformanceLevelUnit"]] = rest_field(visibility=["read"]) + """Unit type used to measure performance level. Known values are: \"DTU\" and \"VCores\".""" + status: Optional[Union[str, "_models.CapabilityStatus"]] = rest_field(visibility=["read"]) + """The status of the capability. Known values are: \"Visible\", \"Available\", \"Default\", and + \"Disabled\".""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for the capability not being available.""" + + @overload + def __init__( + self, + *, + reason: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ElasticPoolPerDatabaseSettings(_Model): + """Per database settings of an elastic pool. + + :ivar min_capacity: The minimum capacity all databases are guaranteed. + :vartype min_capacity: float + :ivar max_capacity: The maximum capacity any one database can consume. + :vartype max_capacity: float + :ivar auto_pause_delay: Auto Pause Delay for per database within pool. + :vartype auto_pause_delay: int + """ + + min_capacity: Optional[float] = rest_field( + name="minCapacity", visibility=["read", "create", "update", "delete", "query"] + ) + """The minimum capacity all databases are guaranteed.""" + max_capacity: Optional[float] = rest_field( + name="maxCapacity", visibility=["read", "create", "update", "delete", "query"] + ) + """The maximum capacity any one database can consume.""" + auto_pause_delay: Optional[int] = rest_field( + name="autoPauseDelay", visibility=["read", "create", "update", "delete", "query"] + ) + """Auto Pause Delay for per database within pool.""" + + @overload + def __init__( + self, + *, + min_capacity: Optional[float] = None, + max_capacity: Optional[float] = None, + auto_pause_delay: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ElasticPoolPerformanceLevelCapability(_Model): + """The Elastic Pool performance level capability. + + :ivar performance_level: The performance level for the pool. + :vartype performance_level: ~azure.mgmt.sql.models.PerformanceLevelCapability + :ivar sku: The sku. + :vartype sku: ~azure.mgmt.sql.models.Sku + :ivar supported_license_types: List of supported license types. + :vartype supported_license_types: list[~azure.mgmt.sql.models.LicenseTypeCapability] + :ivar max_database_count: The maximum number of databases supported. + :vartype max_database_count: int + :ivar included_max_size: The included (free) max size for this performance level. + :vartype included_max_size: ~azure.mgmt.sql.models.MaxSizeCapability + :ivar supported_max_sizes: The list of supported max sizes. + :vartype supported_max_sizes: list[~azure.mgmt.sql.models.MaxSizeRangeCapability] + :ivar supported_per_database_max_sizes: The list of supported per database max sizes. + :vartype supported_per_database_max_sizes: list[~azure.mgmt.sql.models.MaxSizeRangeCapability] + :ivar supported_per_database_max_performance_levels: The list of supported per database max + performance levels. + :vartype supported_per_database_max_performance_levels: + list[~azure.mgmt.sql.models.ElasticPoolPerDatabaseMaxPerformanceLevelCapability] + :ivar zone_redundant: Whether or not zone redundancy is supported for the performance level. + :vartype zone_redundant: bool + :ivar supported_maintenance_configurations: List of supported maintenance configurations. + :vartype supported_maintenance_configurations: + list[~azure.mgmt.sql.models.MaintenanceConfigurationCapability] + :ivar supported_min_capacities: List of supported min capacities. + :vartype supported_min_capacities: list[~azure.mgmt.sql.models.MinCapacityCapability] + :ivar supported_auto_pause_delay: Supported time range for auto pause delay. + :vartype supported_auto_pause_delay: ~azure.mgmt.sql.models.AutoPauseDelayTimeRange + :ivar supported_per_database_auto_pause_delay: Supported time range for per database auto pause + delay. + :vartype supported_per_database_auto_pause_delay: + ~azure.mgmt.sql.models.PerDatabaseAutoPauseDelayTimeRange + :ivar supported_zones: List of supported availability zones. + :vartype supported_zones: list[~azure.mgmt.sql.models.ZonePinningCapability] + :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 + """ + + performance_level: Optional["_models.PerformanceLevelCapability"] = rest_field( + name="performanceLevel", visibility=["read"] + ) + """The performance level for the pool.""" + sku: Optional["_models.Sku"] = rest_field(visibility=["read"]) + """The sku.""" + supported_license_types: Optional[list["_models.LicenseTypeCapability"]] = rest_field( + name="supportedLicenseTypes", visibility=["read"] + ) + """List of supported license types.""" + max_database_count: Optional[int] = rest_field(name="maxDatabaseCount", visibility=["read"]) + """The maximum number of databases supported.""" + included_max_size: Optional["_models.MaxSizeCapability"] = rest_field(name="includedMaxSize", visibility=["read"]) + """The included (free) max size for this performance level.""" + supported_max_sizes: Optional[list["_models.MaxSizeRangeCapability"]] = rest_field( + name="supportedMaxSizes", visibility=["read"] + ) + """The list of supported max sizes.""" + supported_per_database_max_sizes: Optional[list["_models.MaxSizeRangeCapability"]] = rest_field( + name="supportedPerDatabaseMaxSizes", visibility=["read"] + ) + """The list of supported per database max sizes.""" + supported_per_database_max_performance_levels: Optional[ + list["_models.ElasticPoolPerDatabaseMaxPerformanceLevelCapability"] + ] = rest_field(name="supportedPerDatabaseMaxPerformanceLevels", visibility=["read"]) + """The list of supported per database max performance levels.""" + zone_redundant: Optional[bool] = rest_field(name="zoneRedundant", visibility=["read"]) + """Whether or not zone redundancy is supported for the performance level.""" + supported_maintenance_configurations: Optional[list["_models.MaintenanceConfigurationCapability"]] = rest_field( + name="supportedMaintenanceConfigurations", visibility=["read"] + ) + """List of supported maintenance configurations.""" + supported_min_capacities: Optional[list["_models.MinCapacityCapability"]] = rest_field( + name="supportedMinCapacities", visibility=["read"] + ) + """List of supported min capacities.""" + supported_auto_pause_delay: Optional["_models.AutoPauseDelayTimeRange"] = rest_field( + name="supportedAutoPauseDelay", visibility=["read"] + ) + """Supported time range for auto pause delay.""" + supported_per_database_auto_pause_delay: Optional["_models.PerDatabaseAutoPauseDelayTimeRange"] = rest_field( + name="supportedPerDatabaseAutoPauseDelay", visibility=["read"] + ) + """Supported time range for per database auto pause delay.""" + supported_zones: Optional[list["_models.ZonePinningCapability"]] = rest_field( + name="supportedZones", visibility=["read"] + ) + """List of supported availability zones.""" + status: Optional[Union[str, "_models.CapabilityStatus"]] = rest_field(visibility=["read"]) + """The status of the capability. Known values are: \"Visible\", \"Available\", \"Default\", and + \"Disabled\".""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for the capability not being available.""" + + @overload + def __init__( + self, + *, + reason: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ElasticPoolProperties(_Model): + """Properties of an elastic pool. + + :ivar state: The state of the elastic pool. Known values are: "Creating", "Ready", and + "Disabled". + :vartype state: str or ~azure.mgmt.sql.models.ElasticPoolState + :ivar creation_date: The creation date of the elastic pool (ISO8601 format). + :vartype creation_date: ~datetime.datetime + :ivar max_size_bytes: The storage limit for the database elastic pool in bytes. + :vartype max_size_bytes: int + :ivar min_capacity: Minimal capacity that serverless pool will not shrink below, if not paused. + :vartype min_capacity: float + :ivar per_database_settings: The per database settings for the elastic pool. + :vartype per_database_settings: ~azure.mgmt.sql.models.ElasticPoolPerDatabaseSettings + :ivar zone_redundant: Whether or not this elastic pool is zone redundant, which means the + replicas of this elastic pool will be spread across multiple availability zones. + :vartype zone_redundant: bool + :ivar license_type: The license type to apply for this elastic pool. Known values are: + "LicenseIncluded" and "BasePrice". + :vartype license_type: str or ~azure.mgmt.sql.models.ElasticPoolLicenseType + :ivar maintenance_configuration_id: Maintenance configuration id assigned to the elastic pool. + This configuration defines the period when the maintenance updates will will occur. + :vartype maintenance_configuration_id: str + :ivar high_availability_replica_count: The number of secondary replicas associated with the + Business Critical, Premium, or Hyperscale edition elastic pool that are used to provide high + availability. Applicable only to Hyperscale elastic pools. + :vartype high_availability_replica_count: int + :ivar auto_pause_delay: Time in minutes after which elastic pool is automatically paused. A + value of -1 means that automatic pause is disabled. + :vartype auto_pause_delay: int + :ivar preferred_enclave_type: Type of enclave requested on the elastic pool. Known values are: + "Default" and "VBS". + :vartype preferred_enclave_type: str or ~azure.mgmt.sql.models.AlwaysEncryptedEnclaveType + :ivar availability_zone: Specifies the availability zone the pool's primary replica is pinned + to. Known values are: "NoPreference", "1", "2", and "3". + :vartype availability_zone: str or ~azure.mgmt.sql.models.AvailabilityZoneType + :ivar current_sku: The name and tier of the current SKU. + :vartype current_sku: ~azure.mgmt.sql.models.Sku + """ + + state: Optional[Union[str, "_models.ElasticPoolState"]] = rest_field(visibility=["read"]) + """The state of the elastic pool. Known values are: \"Creating\", \"Ready\", and \"Disabled\".""" + creation_date: Optional[datetime.datetime] = rest_field(name="creationDate", visibility=["read"], format="rfc3339") + """The creation date of the elastic pool (ISO8601 format).""" + max_size_bytes: Optional[int] = rest_field( + name="maxSizeBytes", visibility=["read", "create", "update", "delete", "query"] + ) + """The storage limit for the database elastic pool in bytes.""" + min_capacity: Optional[float] = rest_field( + name="minCapacity", visibility=["read", "create", "update", "delete", "query"] + ) + """Minimal capacity that serverless pool will not shrink below, if not paused.""" + per_database_settings: Optional["_models.ElasticPoolPerDatabaseSettings"] = rest_field( + name="perDatabaseSettings", visibility=["read", "create", "update", "delete", "query"] + ) + """The per database settings for the elastic pool.""" + zone_redundant: Optional[bool] = rest_field( + name="zoneRedundant", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether or not this elastic pool is zone redundant, which means the replicas of this elastic + pool will be spread across multiple availability zones.""" + license_type: Optional[Union[str, "_models.ElasticPoolLicenseType"]] = rest_field( + name="licenseType", visibility=["read", "create", "update", "delete", "query"] + ) + """The license type to apply for this elastic pool. Known values are: \"LicenseIncluded\" and + \"BasePrice\".""" + maintenance_configuration_id: Optional[str] = rest_field( + name="maintenanceConfigurationId", visibility=["read", "create", "update", "delete", "query"] + ) + """Maintenance configuration id assigned to the elastic pool. This configuration defines the + period when the maintenance updates will will occur.""" + high_availability_replica_count: Optional[int] = rest_field( + name="highAvailabilityReplicaCount", visibility=["read", "create", "update", "delete", "query"] + ) + """The number of secondary replicas associated with the Business Critical, Premium, or Hyperscale + edition elastic pool that are used to provide high availability. Applicable only to Hyperscale + elastic pools.""" + auto_pause_delay: Optional[int] = rest_field( + name="autoPauseDelay", visibility=["read", "create", "update", "delete", "query"] + ) + """Time in minutes after which elastic pool is automatically paused. A value of -1 means that + automatic pause is disabled.""" + preferred_enclave_type: Optional[Union[str, "_models.AlwaysEncryptedEnclaveType"]] = rest_field( + name="preferredEnclaveType", visibility=["read", "create", "update", "delete", "query"] + ) + """Type of enclave requested on the elastic pool. Known values are: \"Default\" and \"VBS\".""" + availability_zone: Optional[Union[str, "_models.AvailabilityZoneType"]] = rest_field( + name="availabilityZone", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the availability zone the pool's primary replica is pinned to. Known values are: + \"NoPreference\", \"1\", \"2\", and \"3\".""" + current_sku: Optional["_models.Sku"] = rest_field(name="currentSku", visibility=["read"]) + """The name and tier of the current SKU.""" + + @overload + def __init__( + self, + *, + max_size_bytes: Optional[int] = None, + min_capacity: Optional[float] = None, + per_database_settings: Optional["_models.ElasticPoolPerDatabaseSettings"] = None, + zone_redundant: Optional[bool] = None, + license_type: Optional[Union[str, "_models.ElasticPoolLicenseType"]] = None, + maintenance_configuration_id: Optional[str] = None, + high_availability_replica_count: Optional[int] = None, + auto_pause_delay: Optional[int] = None, + preferred_enclave_type: Optional[Union[str, "_models.AlwaysEncryptedEnclaveType"]] = None, + availability_zone: Optional[Union[str, "_models.AvailabilityZoneType"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ElasticPoolUpdate(_Model): + """An elastic pool update. + + :ivar sku: An ARM Resource SKU. + :vartype sku: ~azure.mgmt.sql.models.Sku + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ElasticPoolUpdateProperties + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + sku: Optional["_models.Sku"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """An ARM Resource SKU.""" + properties: Optional["_models.ElasticPoolUpdateProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource tags.""" + + __flattened_items = [ + "max_size_bytes", + "min_capacity", + "per_database_settings", + "zone_redundant", + "license_type", + "maintenance_configuration_id", + "high_availability_replica_count", + "auto_pause_delay", + "preferred_enclave_type", + "availability_zone", + "current_sku", + ] + + @overload + def __init__( + self, + *, + sku: Optional["_models.Sku"] = None, + properties: Optional["_models.ElasticPoolUpdateProperties"] = None, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ElasticPoolUpdateProperties(_Model): + """Properties of an elastic pool. + + :ivar max_size_bytes: The storage limit for the database elastic pool in bytes. + :vartype max_size_bytes: int + :ivar min_capacity: Minimal capacity that serverless pool will not shrink below, if not paused. + :vartype min_capacity: float + :ivar per_database_settings: The per database settings for the elastic pool. + :vartype per_database_settings: ~azure.mgmt.sql.models.ElasticPoolPerDatabaseSettings + :ivar zone_redundant: Whether or not this elastic pool is zone redundant, which means the + replicas of this elastic pool will be spread across multiple availability zones. + :vartype zone_redundant: bool + :ivar license_type: The license type to apply for this elastic pool. Known values are: + "LicenseIncluded" and "BasePrice". + :vartype license_type: str or ~azure.mgmt.sql.models.ElasticPoolLicenseType + :ivar maintenance_configuration_id: Maintenance configuration id assigned to the elastic pool. + This configuration defines the period when the maintenance updates will will occur. + :vartype maintenance_configuration_id: str + :ivar high_availability_replica_count: The number of secondary replicas associated with the + Business Critical, Premium, or Hyperscale edition elastic pool that are used to provide high + availability. Applicable only to Hyperscale elastic pools. + :vartype high_availability_replica_count: int + :ivar auto_pause_delay: Time in minutes after which elastic pool is automatically paused. A + value of -1 means that automatic pause is disabled. + :vartype auto_pause_delay: int + :ivar preferred_enclave_type: Type of enclave requested on the elastic pool. Known values are: + "Default" and "VBS". + :vartype preferred_enclave_type: str or ~azure.mgmt.sql.models.AlwaysEncryptedEnclaveType + :ivar availability_zone: Specifies the availability zone the pool's primary replica is pinned + to. Known values are: "NoPreference", "1", "2", and "3". + :vartype availability_zone: str or ~azure.mgmt.sql.models.AvailabilityZoneType + :ivar current_sku: The name and tier of the current SKU. + :vartype current_sku: ~azure.mgmt.sql.models.Sku + """ + + max_size_bytes: Optional[int] = rest_field( + name="maxSizeBytes", visibility=["read", "create", "update", "delete", "query"] + ) + """The storage limit for the database elastic pool in bytes.""" + min_capacity: Optional[float] = rest_field( + name="minCapacity", visibility=["read", "create", "update", "delete", "query"] + ) + """Minimal capacity that serverless pool will not shrink below, if not paused.""" + per_database_settings: Optional["_models.ElasticPoolPerDatabaseSettings"] = rest_field( + name="perDatabaseSettings", visibility=["read", "create", "update", "delete", "query"] + ) + """The per database settings for the elastic pool.""" + zone_redundant: Optional[bool] = rest_field( + name="zoneRedundant", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether or not this elastic pool is zone redundant, which means the replicas of this elastic + pool will be spread across multiple availability zones.""" + license_type: Optional[Union[str, "_models.ElasticPoolLicenseType"]] = rest_field( + name="licenseType", visibility=["read", "create", "update", "delete", "query"] + ) + """The license type to apply for this elastic pool. Known values are: \"LicenseIncluded\" and + \"BasePrice\".""" + maintenance_configuration_id: Optional[str] = rest_field( + name="maintenanceConfigurationId", visibility=["read", "create", "update", "delete", "query"] + ) + """Maintenance configuration id assigned to the elastic pool. This configuration defines the + period when the maintenance updates will will occur.""" + high_availability_replica_count: Optional[int] = rest_field( + name="highAvailabilityReplicaCount", visibility=["read", "create", "update", "delete", "query"] + ) + """The number of secondary replicas associated with the Business Critical, Premium, or Hyperscale + edition elastic pool that are used to provide high availability. Applicable only to Hyperscale + elastic pools.""" + auto_pause_delay: Optional[int] = rest_field( + name="autoPauseDelay", visibility=["read", "create", "update", "delete", "query"] + ) + """Time in minutes after which elastic pool is automatically paused. A value of -1 means that + automatic pause is disabled.""" + preferred_enclave_type: Optional[Union[str, "_models.AlwaysEncryptedEnclaveType"]] = rest_field( + name="preferredEnclaveType", visibility=["read", "create", "update", "delete", "query"] + ) + """Type of enclave requested on the elastic pool. Known values are: \"Default\" and \"VBS\".""" + availability_zone: Optional[Union[str, "_models.AvailabilityZoneType"]] = rest_field( + name="availabilityZone", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the availability zone the pool's primary replica is pinned to. Known values are: + \"NoPreference\", \"1\", \"2\", and \"3\".""" + current_sku: Optional["_models.Sku"] = rest_field(name="currentSku", visibility=["read"]) + """The name and tier of the current SKU.""" + + @overload + def __init__( + self, + *, + max_size_bytes: Optional[int] = None, + min_capacity: Optional[float] = None, + per_database_settings: Optional["_models.ElasticPoolPerDatabaseSettings"] = None, + zone_redundant: Optional[bool] = None, + license_type: Optional[Union[str, "_models.ElasticPoolLicenseType"]] = None, + maintenance_configuration_id: Optional[str] = None, + high_availability_replica_count: Optional[int] = None, + auto_pause_delay: Optional[int] = None, + preferred_enclave_type: Optional[Union[str, "_models.AlwaysEncryptedEnclaveType"]] = None, + availability_zone: Optional[Union[str, "_models.AvailabilityZoneType"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class EncryptionProtector(ProxyResource): + """The server encryption protector. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.EncryptionProtectorProperties + :ivar kind: Kind of encryption protector. This is metadata used for the Azure portal + experience. + :vartype kind: str + :ivar location: Resource location. + :vartype location: str + """ + + properties: Optional["_models.EncryptionProtectorProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + kind: Optional[str] = rest_field(visibility=["read"]) + """Kind of encryption protector. This is metadata used for the Azure portal experience.""" + location: Optional[str] = rest_field(visibility=["read"]) + """Resource location.""" + + __flattened_items = [ + "subregion", + "server_key_name", + "server_key_type", + "uri", + "thumbprint", + "auto_rotation_enabled", + "key_version", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.EncryptionProtectorProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class EncryptionProtectorProperties(_Model): + """Properties for an encryption protector execution. + + :ivar subregion: Subregion of the encryption protector. + :vartype subregion: str + :ivar server_key_name: The name of the server key. + :vartype server_key_name: str + :ivar server_key_type: The encryption protector type like 'ServiceManaged', 'AzureKeyVault'. + Required. Known values are: "ServiceManaged" and "AzureKeyVault". + :vartype server_key_type: str or ~azure.mgmt.sql.models.ServerKeyType + :ivar uri: The URI of the server key. + :vartype uri: str + :ivar thumbprint: Thumbprint of the server key. + :vartype thumbprint: str + :ivar auto_rotation_enabled: Key auto rotation opt-in flag. Either true or false. + :vartype auto_rotation_enabled: bool + :ivar key_version: The version of the server key being used as encryption protector. + :vartype key_version: str + """ + + subregion: Optional[str] = rest_field(visibility=["read"]) + """Subregion of the encryption protector.""" + server_key_name: Optional[str] = rest_field( + name="serverKeyName", visibility=["read", "create", "update", "delete", "query"] + ) + """The name of the server key.""" + server_key_type: Union[str, "_models.ServerKeyType"] = rest_field( + name="serverKeyType", visibility=["read", "create", "update", "delete", "query"] + ) + """The encryption protector type like 'ServiceManaged', 'AzureKeyVault'. Required. Known values + are: \"ServiceManaged\" and \"AzureKeyVault\".""" + uri: Optional[str] = rest_field(visibility=["read"]) + """The URI of the server key.""" + thumbprint: Optional[str] = rest_field(visibility=["read"]) + """Thumbprint of the server key.""" + auto_rotation_enabled: Optional[bool] = rest_field( + name="autoRotationEnabled", visibility=["read", "create", "update", "delete", "query"] + ) + """Key auto rotation opt-in flag. Either true or false.""" + key_version: Optional[str] = rest_field(name="keyVersion", visibility=["read"]) + """The version of the server key being used as encryption protector.""" + + @overload + def __init__( + self, + *, + server_key_type: Union[str, "_models.ServerKeyType"], + server_key_name: Optional[str] = None, + auto_rotation_enabled: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class EndpointCertificate(ProxyResource): + """Certificate used on an endpoint on the Managed Instance. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.EndpointCertificateProperties + """ + + properties: Optional["_models.EndpointCertificateProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["public_blob"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.EndpointCertificateProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class EndpointCertificateProperties(_Model): + """The properties of an endpoint certificate. + + :ivar public_blob: The certificate public blob. + :vartype public_blob: str + """ + + public_blob: Optional[str] = rest_field( + name="publicBlob", visibility=["read", "create", "update", "delete", "query"] + ) + """The certificate public blob.""" + + @overload + def __init__( + self, + *, + public_blob: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class EndpointDependency(_Model): + """A domain name that the managed instance service needs to communicate with, along with + additional details. + + :ivar domain_name: The domain name of the dependency. + :vartype domain_name: str + :ivar endpoint_details: The IP Addresses and Ports used when connecting to DomainName. + :vartype endpoint_details: list[~azure.mgmt.sql.models.EndpointDetail] + """ + + domain_name: Optional[str] = rest_field(name="domainName", visibility=["read"]) + """The domain name of the dependency.""" + endpoint_details: Optional[list["_models.EndpointDetail"]] = rest_field(name="endpointDetails", visibility=["read"]) + """The IP Addresses and Ports used when connecting to DomainName.""" + + +class EndpointDetail(_Model): + """A domain name that the managed instance service needs to communicate with, along with + additional details. + + :ivar port: The port an endpoint is connected to. + :vartype port: int + """ + + port: Optional[int] = rest_field(visibility=["read"]) + """The port an endpoint is connected to.""" + + +class ErrorAdditionalInfo(_Model): + """The resource management error additional info. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: any + """ + + type: Optional[str] = rest_field(visibility=["read"]) + """The additional info type.""" + info: Optional[Any] = rest_field(visibility=["read"]) + """The additional info.""" + + +class ErrorDetail(_Model): + """The error detail. + + :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] + """ + + code: Optional[str] = rest_field(visibility=["read"]) + """The error code.""" + message: Optional[str] = rest_field(visibility=["read"]) + """The error message.""" + target: Optional[str] = rest_field(visibility=["read"]) + """The error target.""" + details: Optional[list["_models.ErrorDetail"]] = rest_field(visibility=["read"]) + """The error details.""" + additional_info: Optional[list["_models.ErrorAdditionalInfo"]] = rest_field( + name="additionalInfo", visibility=["read"] + ) + """The error additional info.""" + + +class ErrorResponse(_Model): + """Error response. + + :ivar error: The error object. + :vartype error: ~azure.mgmt.sql.models.ErrorDetail + """ + + error: Optional["_models.ErrorDetail"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The error object.""" + + @overload + def __init__( + self, + *, + error: Optional["_models.ErrorDetail"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ExportDatabaseDefinition(_Model): + """Contains the information necessary to perform export database operation. + + :ivar storage_key_type: Storage key type: StorageAccessKey, SharedAccessKey, or + ManagedIdentity. Required. Known values are: "SharedAccessKey", "StorageAccessKey", and + "ManagedIdentity". + :vartype storage_key_type: str or ~azure.mgmt.sql.models.StorageKeyType + :ivar storage_key: Storage key for the storage account. If StorageKeyType is ManagedIdentity, + this field should specify the Managed Identity's resource ID. Required. + :vartype storage_key: str + :ivar storage_uri: Storage Uri. Required. + :vartype storage_uri: str + :ivar administrator_login: Administrator login name. If AuthenticationType is ManagedIdentity, + this field should specify the Managed Identity's resource ID. Required. + :vartype administrator_login: str + :ivar administrator_login_password: Administrator login password. If AuthenticationType is + ManagedIdentity, this field should not be specified. + :vartype administrator_login_password: str + :ivar authentication_type: Type of credentials provided for access to the target SQL server: + SQL, ADPassword or ManagedIdentity. + :vartype authentication_type: str + :ivar network_isolation: Optional resource information to enable network isolation for request. + :vartype network_isolation: ~azure.mgmt.sql.models.NetworkIsolationSettings + """ + + storage_key_type: Union[str, "_models.StorageKeyType"] = rest_field(name="storageKeyType", visibility=["create"]) + """Storage key type: StorageAccessKey, SharedAccessKey, or ManagedIdentity. Required. Known values + are: \"SharedAccessKey\", \"StorageAccessKey\", and \"ManagedIdentity\".""" + storage_key: str = rest_field(name="storageKey", visibility=["create"]) + """Storage key for the storage account. If StorageKeyType is ManagedIdentity, this field should + specify the Managed Identity's resource ID. Required.""" + storage_uri: str = rest_field(name="storageUri", visibility=["create"]) + """Storage Uri. Required.""" + administrator_login: str = rest_field(name="administratorLogin", visibility=["create"]) + """Administrator login name. If AuthenticationType is ManagedIdentity, this field should specify + the Managed Identity's resource ID. Required.""" + administrator_login_password: Optional[str] = rest_field(name="administratorLoginPassword", visibility=["create"]) + """Administrator login password. If AuthenticationType is ManagedIdentity, this field should not + be specified.""" + authentication_type: Optional[str] = rest_field(name="authenticationType", visibility=["create"]) + """Type of credentials provided for access to the target SQL server: SQL, ADPassword or + ManagedIdentity.""" + network_isolation: Optional["_models.NetworkIsolationSettings"] = rest_field( + name="networkIsolation", visibility=["create"] + ) + """Optional resource information to enable network isolation for request.""" + + @overload + def __init__( + self, + *, + storage_key_type: Union[str, "_models.StorageKeyType"], + storage_key: str, + storage_uri: str, + administrator_login: str, + administrator_login_password: Optional[str] = None, + authentication_type: Optional[str] = None, + network_isolation: Optional["_models.NetworkIsolationSettings"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ExtendedDatabaseBlobAuditingPolicy(ProxyResource): + """An extended database blob auditing policy. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicyProperties + """ + + properties: Optional["_models.ExtendedDatabaseBlobAuditingPolicyProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "predicate_expression", + "retention_days", + "audit_actions_and_groups", + "is_storage_secondary_key_in_use", + "is_azure_monitor_target_enabled", + "queue_delay_ms", + "is_managed_identity_in_use", + "state", + "storage_endpoint", + "storage_account_access_key", + "storage_account_subscription_id", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ExtendedDatabaseBlobAuditingPolicyProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ExtendedDatabaseBlobAuditingPolicyProperties(_Model): # pylint: disable=name-too-long + """Properties of an extended database blob auditing policy. + + :ivar predicate_expression: Specifies condition of where clause when creating an audit. + :vartype predicate_expression: str + :ivar retention_days: Specifies the number of days to keep in the audit logs in the storage + account. + :vartype retention_days: int + :ivar audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. + + The recommended set of action groups to use is the following combination - this will audit all + the queries and stored procedures executed against the database, as well as successful and + failed logins: + + BATCH_COMPLETED_GROUP, + SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, + FAILED_DATABASE_AUTHENTICATION_GROUP. + + This above combination is also the set that is configured by default when enabling auditing + from the Azure portal. + + The supported action groups to audit are (note: choose only specific groups that cover your + auditing needs. Using unnecessary groups could lead to very large quantities of audit records): + + APPLICATION_ROLE_CHANGE_PASSWORD_GROUP + BACKUP_RESTORE_GROUP + DATABASE_LOGOUT_GROUP + DATABASE_OBJECT_CHANGE_GROUP + DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP + DATABASE_OBJECT_PERMISSION_CHANGE_GROUP + DATABASE_OPERATION_GROUP + DATABASE_PERMISSION_CHANGE_GROUP + DATABASE_PRINCIPAL_CHANGE_GROUP + DATABASE_PRINCIPAL_IMPERSONATION_GROUP + DATABASE_ROLE_MEMBER_CHANGE_GROUP + FAILED_DATABASE_AUTHENTICATION_GROUP + SCHEMA_OBJECT_ACCESS_GROUP + SCHEMA_OBJECT_CHANGE_GROUP + SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP + SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP + SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP + USER_CHANGE_PASSWORD_GROUP + BATCH_STARTED_GROUP + BATCH_COMPLETED_GROUP + DBCC_GROUP + DATABASE_OWNERSHIP_CHANGE_GROUP + DATABASE_CHANGE_GROUP + LEDGER_OPERATION_GROUP + + These are groups that cover all sql statements and stored procedures executed against the + database, and should not be used in combination with other groups as this will result in + duplicate audit logs. + + For more information, see `Database-Level Audit Action Groups + `_. + + For Database auditing policy, specific Actions can also be specified (note that Actions cannot + be specified for Server auditing policy). The supported actions to audit are: + SELECT + UPDATE + INSERT + DELETE + EXECUTE + RECEIVE + REFERENCES + + The general form for defining an action to be audited is: + {action} ON {object} BY {principal} + + Note that in the above format can refer to an object like a table, view, or stored + procedure, or an entire database or schema. For the latter cases, the forms DATABASE::{db_name} + and SCHEMA::{schema_name} are used, respectively. + + For example: + SELECT on dbo.myTable by public + SELECT on DATABASE::myDatabase by public + SELECT on SCHEMA::mySchema by public + + For more information, see `Database-Level Audit Actions + `_. + :vartype audit_actions_and_groups: list[str] + :ivar is_storage_secondary_key_in_use: Specifies whether storageAccountAccessKey value is the + storage's secondary key. + :vartype is_storage_secondary_key_in_use: bool + :ivar is_azure_monitor_target_enabled: Specifies whether audit events are sent to Azure + Monitor. + In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and + 'IsAzureMonitorTargetEnabled' as true. + + When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' + diagnostic logs category on the database should be also created. + Note that for server level audit you should use the 'master' database as {databaseName}. + + Diagnostic Settings URI format: + PUT + `https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + `_ + + For more information, see `Diagnostic Settings REST API + `_ + or `Diagnostic Settings PowerShell `_. + :vartype is_azure_monitor_target_enabled: bool + :ivar queue_delay_ms: Specifies the amount of time in milliseconds that can elapse before audit + actions are forced to be processed. The default minimum value is 1000 (1 second). The maximum + is 2,147,483,647. + :vartype queue_delay_ms: int + :ivar is_managed_identity_in_use: Specifies whether Managed Identity is used to access blob + storage. + :vartype is_managed_identity_in_use: bool + :ivar state: Specifies the state of the audit. If state is Enabled, storageEndpoint or + isAzureMonitorTargetEnabled are required. Required. Known values are: "Enabled" and "Disabled". + :vartype state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState + :ivar storage_endpoint: Specifies the blob storage endpoint (e.g. + `https://MyAccount.blob.core.windows.net `_). If state + is Enabled, storageEndpoint or isAzureMonitorTargetEnabled is required. + :vartype storage_endpoint: str + :ivar storage_account_access_key: Specifies the identifier key of the auditing storage account. + If state is Enabled and storageEndpoint is specified, not specifying the + storageAccountAccessKey will use SQL server system-assigned managed identity to access the + storage. + Prerequisites for using managed identity authentication: + + 1. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). + 2. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data + Contributor' RBAC role to the server identity. + For more information, see [Auditing to storage using Managed Identity + authentication](https://go.microsoft.com/fwlink/?linkid=2114355). + :vartype storage_account_access_key: str + :ivar storage_account_subscription_id: Specifies the blob storage subscription Id. + :vartype storage_account_subscription_id: str + """ + + predicate_expression: Optional[str] = rest_field( + name="predicateExpression", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies condition of where clause when creating an audit.""" + retention_days: Optional[int] = rest_field( + name="retentionDays", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the number of days to keep in the audit logs in the storage account.""" + audit_actions_and_groups: Optional[list[str]] = rest_field( + name="auditActionsAndGroups", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the Actions-Groups and Actions to audit. + + The recommended set of action groups to use is the following combination - this will audit all + the queries and stored procedures executed against the database, as well as successful and + failed logins: + + BATCH_COMPLETED_GROUP, + SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, + FAILED_DATABASE_AUTHENTICATION_GROUP. + + This above combination is also the set that is configured by default when enabling auditing + from the Azure portal. + + The supported action groups to audit are (note: choose only specific groups that cover your + auditing needs. Using unnecessary groups could lead to very large quantities of audit records): + + APPLICATION_ROLE_CHANGE_PASSWORD_GROUP + BACKUP_RESTORE_GROUP + DATABASE_LOGOUT_GROUP + DATABASE_OBJECT_CHANGE_GROUP + DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP + DATABASE_OBJECT_PERMISSION_CHANGE_GROUP + DATABASE_OPERATION_GROUP + DATABASE_PERMISSION_CHANGE_GROUP + DATABASE_PRINCIPAL_CHANGE_GROUP + DATABASE_PRINCIPAL_IMPERSONATION_GROUP + DATABASE_ROLE_MEMBER_CHANGE_GROUP + FAILED_DATABASE_AUTHENTICATION_GROUP + SCHEMA_OBJECT_ACCESS_GROUP + SCHEMA_OBJECT_CHANGE_GROUP + SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP + SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP + SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP + USER_CHANGE_PASSWORD_GROUP + BATCH_STARTED_GROUP + BATCH_COMPLETED_GROUP + DBCC_GROUP + DATABASE_OWNERSHIP_CHANGE_GROUP + DATABASE_CHANGE_GROUP + LEDGER_OPERATION_GROUP + + These are groups that cover all sql statements and stored procedures executed against the + database, and should not be used in combination with other groups as this will result in + duplicate audit logs. + + For more information, see `Database-Level Audit Action Groups + `_. + + For Database auditing policy, specific Actions can also be specified (note that Actions cannot + be specified for Server auditing policy). The supported actions to audit are: + SELECT + UPDATE + INSERT + DELETE + EXECUTE + RECEIVE + REFERENCES + + The general form for defining an action to be audited is: + {action} ON {object} BY {principal} + + Note that in the above format can refer to an object like a table, view, or stored + procedure, or an entire database or schema. For the latter cases, the forms DATABASE::{db_name} + and SCHEMA::{schema_name} are used, respectively. + + For example: + SELECT on dbo.myTable by public + SELECT on DATABASE::myDatabase by public + SELECT on SCHEMA::mySchema by public + + For more information, see `Database-Level Audit Actions + `_.""" + is_storage_secondary_key_in_use: Optional[bool] = rest_field( + name="isStorageSecondaryKeyInUse", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies whether storageAccountAccessKey value is the storage's secondary key.""" + is_azure_monitor_target_enabled: Optional[bool] = rest_field( + name="isAzureMonitorTargetEnabled", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies whether audit events are sent to Azure Monitor. + In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and + 'IsAzureMonitorTargetEnabled' as true. + + When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' + diagnostic logs category on the database should be also created. + Note that for server level audit you should use the 'master' database as {databaseName}. + + Diagnostic Settings URI format: + PUT + `https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + `_ + + For more information, see `Diagnostic Settings REST API + `_ + or `Diagnostic Settings PowerShell `_.""" + queue_delay_ms: Optional[int] = rest_field( + name="queueDelayMs", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the amount of time in milliseconds that can elapse before audit actions are forced to + be processed. The default minimum value is 1000 (1 second). The maximum is 2,147,483,647.""" + is_managed_identity_in_use: Optional[bool] = rest_field( + name="isManagedIdentityInUse", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies whether Managed Identity is used to access blob storage.""" + state: Union[str, "_models.BlobAuditingPolicyState"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the state of the audit. If state is Enabled, storageEndpoint or + isAzureMonitorTargetEnabled are required. Required. Known values are: \"Enabled\" and + \"Disabled\".""" + storage_endpoint: Optional[str] = rest_field( + name="storageEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the blob storage endpoint (e.g. `https://MyAccount.blob.core.windows.net + `_). If state is Enabled, storageEndpoint or + isAzureMonitorTargetEnabled is required.""" + storage_account_access_key: Optional[str] = rest_field( + name="storageAccountAccessKey", visibility=["create", "update"] + ) + """Specifies the identifier key of the auditing storage account. + If state is Enabled and storageEndpoint is specified, not specifying the + storageAccountAccessKey will use SQL server system-assigned managed identity to access the + storage. + Prerequisites for using managed identity authentication: + + 1. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). + 2. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data + Contributor' RBAC role to the server identity. + For more information, see [Auditing to storage using Managed Identity + authentication](https://go.microsoft.com/fwlink/?linkid=2114355).""" + storage_account_subscription_id: Optional[str] = rest_field( + name="storageAccountSubscriptionId", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the blob storage subscription Id.""" + + @overload + def __init__( + self, + *, + state: Union[str, "_models.BlobAuditingPolicyState"], + predicate_expression: Optional[str] = None, + retention_days: Optional[int] = None, + audit_actions_and_groups: Optional[list[str]] = None, + is_storage_secondary_key_in_use: Optional[bool] = None, + is_azure_monitor_target_enabled: Optional[bool] = None, + queue_delay_ms: Optional[int] = None, + is_managed_identity_in_use: Optional[bool] = None, + storage_endpoint: Optional[str] = None, + storage_account_access_key: Optional[str] = None, + storage_account_subscription_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ExtendedServerBlobAuditingPolicy(ProxyResource): + """An extended server blob auditing policy. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicyProperties + """ + + properties: Optional["_models.ExtendedServerBlobAuditingPolicyProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "is_devops_audit_enabled", + "predicate_expression", + "retention_days", + "audit_actions_and_groups", + "is_storage_secondary_key_in_use", + "is_azure_monitor_target_enabled", + "queue_delay_ms", + "is_managed_identity_in_use", + "state", + "storage_endpoint", + "storage_account_access_key", + "storage_account_subscription_id", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ExtendedServerBlobAuditingPolicyProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ExtendedServerBlobAuditingPolicyProperties(_Model): # pylint: disable=name-too-long + """Properties of an extended server blob auditing policy. + + :ivar is_devops_audit_enabled: Specifies the state of devops audit. If state is Enabled, devops + logs will be sent to Azure Monitor. + In order to send the events to Azure Monitor, specify 'State' as 'Enabled', + 'IsAzureMonitorTargetEnabled' as true and 'IsDevopsAuditEnabled' as true + + When using REST API to configure auditing, Diagnostic Settings with 'DevOpsOperationsAudit' + diagnostic logs category on the master database should also be created. + + Diagnostic Settings URI format: + PUT + `https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/master/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + `_ + + For more information, see `Diagnostic Settings REST API + `_ + or `Diagnostic Settings PowerShell `_. + :vartype is_devops_audit_enabled: bool + :ivar predicate_expression: Specifies condition of where clause when creating an audit. + :vartype predicate_expression: str + :ivar retention_days: Specifies the number of days to keep in the audit logs in the storage + account. + :vartype retention_days: int + :ivar audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. + + The recommended set of action groups to use is the following combination - this will audit all + the queries and stored procedures executed against the database, as well as successful and + failed logins: + + BATCH_COMPLETED_GROUP, + SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, + FAILED_DATABASE_AUTHENTICATION_GROUP. + + This above combination is also the set that is configured by default when enabling auditing + from the Azure portal. + + The supported action groups to audit are (note: choose only specific groups that cover your + auditing needs. Using unnecessary groups could lead to very large quantities of audit records): + + APPLICATION_ROLE_CHANGE_PASSWORD_GROUP + BACKUP_RESTORE_GROUP + DATABASE_LOGOUT_GROUP + DATABASE_OBJECT_CHANGE_GROUP + DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP + DATABASE_OBJECT_PERMISSION_CHANGE_GROUP + DATABASE_OPERATION_GROUP + DATABASE_PERMISSION_CHANGE_GROUP + DATABASE_PRINCIPAL_CHANGE_GROUP + DATABASE_PRINCIPAL_IMPERSONATION_GROUP + DATABASE_ROLE_MEMBER_CHANGE_GROUP + FAILED_DATABASE_AUTHENTICATION_GROUP + SCHEMA_OBJECT_ACCESS_GROUP + SCHEMA_OBJECT_CHANGE_GROUP + SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP + SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP + SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP + USER_CHANGE_PASSWORD_GROUP + BATCH_STARTED_GROUP + BATCH_COMPLETED_GROUP + DBCC_GROUP + DATABASE_OWNERSHIP_CHANGE_GROUP + DATABASE_CHANGE_GROUP + LEDGER_OPERATION_GROUP + + These are groups that cover all sql statements and stored procedures executed against the + database, and should not be used in combination with other groups as this will result in + duplicate audit logs. + + For more information, see `Database-Level Audit Action Groups + `_. + + For Database auditing policy, specific Actions can also be specified (note that Actions cannot + be specified for Server auditing policy). The supported actions to audit are: + SELECT + UPDATE + INSERT + DELETE + EXECUTE + RECEIVE + REFERENCES + + The general form for defining an action to be audited is: + {action} ON {object} BY {principal} + + Note that in the above format can refer to an object like a table, view, or stored + procedure, or an entire database or schema. For the latter cases, the forms DATABASE::{db_name} + and SCHEMA::{schema_name} are used, respectively. + + For example: + SELECT on dbo.myTable by public + SELECT on DATABASE::myDatabase by public + SELECT on SCHEMA::mySchema by public + + For more information, see `Database-Level Audit Actions + `_. + :vartype audit_actions_and_groups: list[str] + :ivar is_storage_secondary_key_in_use: Specifies whether storageAccountAccessKey value is the + storage's secondary key. + :vartype is_storage_secondary_key_in_use: bool + :ivar is_azure_monitor_target_enabled: Specifies whether audit events are sent to Azure + Monitor. + In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and + 'IsAzureMonitorTargetEnabled' as true. + + When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' + diagnostic logs category on the database should be also created. + Note that for server level audit you should use the 'master' database as {databaseName}. + + Diagnostic Settings URI format: + PUT + `https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + `_ + + For more information, see `Diagnostic Settings REST API + `_ + or `Diagnostic Settings PowerShell `_. + :vartype is_azure_monitor_target_enabled: bool + :ivar queue_delay_ms: Specifies the amount of time in milliseconds that can elapse before audit + actions are forced to be processed. The default minimum value is 1000 (1 second). The maximum + is 2,147,483,647. + :vartype queue_delay_ms: int + :ivar is_managed_identity_in_use: Specifies whether Managed Identity is used to access blob + storage. + :vartype is_managed_identity_in_use: bool + :ivar state: Specifies the state of the audit. If state is Enabled, storageEndpoint or + isAzureMonitorTargetEnabled are required. Required. Known values are: "Enabled" and "Disabled". + :vartype state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState + :ivar storage_endpoint: Specifies the blob storage endpoint (e.g. + `https://MyAccount.blob.core.windows.net `_). If state + is Enabled, storageEndpoint or isAzureMonitorTargetEnabled is required. + :vartype storage_endpoint: str + :ivar storage_account_access_key: Specifies the identifier key of the auditing storage account. + If state is Enabled and storageEndpoint is specified, not specifying the + storageAccountAccessKey will use SQL server system-assigned managed identity to access the + storage. + Prerequisites for using managed identity authentication: + + 1. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). + 2. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data + Contributor' RBAC role to the server identity. + For more information, see [Auditing to storage using Managed Identity + authentication](https://go.microsoft.com/fwlink/?linkid=2114355). + :vartype storage_account_access_key: str + :ivar storage_account_subscription_id: Specifies the blob storage subscription Id. + :vartype storage_account_subscription_id: str + """ + + is_devops_audit_enabled: Optional[bool] = rest_field( + name="isDevopsAuditEnabled", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the state of devops audit. If state is Enabled, devops logs will be sent to Azure + Monitor. + In order to send the events to Azure Monitor, specify 'State' as 'Enabled', + 'IsAzureMonitorTargetEnabled' as true and 'IsDevopsAuditEnabled' as true + + When using REST API to configure auditing, Diagnostic Settings with 'DevOpsOperationsAudit' + diagnostic logs category on the master database should also be created. + + Diagnostic Settings URI format: + PUT + `https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/master/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + `_ + + For more information, see `Diagnostic Settings REST API + `_ + or `Diagnostic Settings PowerShell `_.""" + predicate_expression: Optional[str] = rest_field( + name="predicateExpression", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies condition of where clause when creating an audit.""" + retention_days: Optional[int] = rest_field( + name="retentionDays", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the number of days to keep in the audit logs in the storage account.""" + audit_actions_and_groups: Optional[list[str]] = rest_field( + name="auditActionsAndGroups", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the Actions-Groups and Actions to audit. + + The recommended set of action groups to use is the following combination - this will audit all + the queries and stored procedures executed against the database, as well as successful and + failed logins: + + BATCH_COMPLETED_GROUP, + SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, + FAILED_DATABASE_AUTHENTICATION_GROUP. + + This above combination is also the set that is configured by default when enabling auditing + from the Azure portal. + + The supported action groups to audit are (note: choose only specific groups that cover your + auditing needs. Using unnecessary groups could lead to very large quantities of audit records): + + APPLICATION_ROLE_CHANGE_PASSWORD_GROUP + BACKUP_RESTORE_GROUP + DATABASE_LOGOUT_GROUP + DATABASE_OBJECT_CHANGE_GROUP + DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP + DATABASE_OBJECT_PERMISSION_CHANGE_GROUP + DATABASE_OPERATION_GROUP + DATABASE_PERMISSION_CHANGE_GROUP + DATABASE_PRINCIPAL_CHANGE_GROUP + DATABASE_PRINCIPAL_IMPERSONATION_GROUP + DATABASE_ROLE_MEMBER_CHANGE_GROUP + FAILED_DATABASE_AUTHENTICATION_GROUP + SCHEMA_OBJECT_ACCESS_GROUP + SCHEMA_OBJECT_CHANGE_GROUP + SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP + SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP + SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP + USER_CHANGE_PASSWORD_GROUP + BATCH_STARTED_GROUP + BATCH_COMPLETED_GROUP + DBCC_GROUP + DATABASE_OWNERSHIP_CHANGE_GROUP + DATABASE_CHANGE_GROUP + LEDGER_OPERATION_GROUP + + These are groups that cover all sql statements and stored procedures executed against the + database, and should not be used in combination with other groups as this will result in + duplicate audit logs. + + For more information, see `Database-Level Audit Action Groups + `_. + + For Database auditing policy, specific Actions can also be specified (note that Actions cannot + be specified for Server auditing policy). The supported actions to audit are: + SELECT + UPDATE + INSERT + DELETE + EXECUTE + RECEIVE + REFERENCES + + The general form for defining an action to be audited is: + {action} ON {object} BY {principal} + + Note that in the above format can refer to an object like a table, view, or stored + procedure, or an entire database or schema. For the latter cases, the forms DATABASE::{db_name} + and SCHEMA::{schema_name} are used, respectively. + + For example: + SELECT on dbo.myTable by public + SELECT on DATABASE::myDatabase by public + SELECT on SCHEMA::mySchema by public + + For more information, see `Database-Level Audit Actions + `_.""" + is_storage_secondary_key_in_use: Optional[bool] = rest_field( + name="isStorageSecondaryKeyInUse", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies whether storageAccountAccessKey value is the storage's secondary key.""" + is_azure_monitor_target_enabled: Optional[bool] = rest_field( + name="isAzureMonitorTargetEnabled", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies whether audit events are sent to Azure Monitor. + In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and + 'IsAzureMonitorTargetEnabled' as true. + + When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' + diagnostic logs category on the database should be also created. + Note that for server level audit you should use the 'master' database as {databaseName}. + + Diagnostic Settings URI format: + PUT + `https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + `_ + + For more information, see `Diagnostic Settings REST API + `_ + or `Diagnostic Settings PowerShell `_.""" + queue_delay_ms: Optional[int] = rest_field( + name="queueDelayMs", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the amount of time in milliseconds that can elapse before audit actions are forced to + be processed. The default minimum value is 1000 (1 second). The maximum is 2,147,483,647.""" + is_managed_identity_in_use: Optional[bool] = rest_field( + name="isManagedIdentityInUse", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies whether Managed Identity is used to access blob storage.""" + state: Union[str, "_models.BlobAuditingPolicyState"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the state of the audit. If state is Enabled, storageEndpoint or + isAzureMonitorTargetEnabled are required. Required. Known values are: \"Enabled\" and + \"Disabled\".""" + storage_endpoint: Optional[str] = rest_field( + name="storageEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the blob storage endpoint (e.g. `https://MyAccount.blob.core.windows.net + `_). If state is Enabled, storageEndpoint or + isAzureMonitorTargetEnabled is required.""" + storage_account_access_key: Optional[str] = rest_field( + name="storageAccountAccessKey", visibility=["create", "update"] + ) + """Specifies the identifier key of the auditing storage account. + If state is Enabled and storageEndpoint is specified, not specifying the + storageAccountAccessKey will use SQL server system-assigned managed identity to access the + storage. + Prerequisites for using managed identity authentication: + + 1. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). + 2. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data + Contributor' RBAC role to the server identity. + For more information, see [Auditing to storage using Managed Identity + authentication](https://go.microsoft.com/fwlink/?linkid=2114355).""" + storage_account_subscription_id: Optional[str] = rest_field( + name="storageAccountSubscriptionId", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the blob storage subscription Id.""" + + @overload + def __init__( + self, + *, + state: Union[str, "_models.BlobAuditingPolicyState"], + is_devops_audit_enabled: Optional[bool] = None, + predicate_expression: Optional[str] = None, + retention_days: Optional[int] = None, + audit_actions_and_groups: Optional[list[str]] = None, + is_storage_secondary_key_in_use: Optional[bool] = None, + is_azure_monitor_target_enabled: Optional[bool] = None, + queue_delay_ms: Optional[int] = None, + is_managed_identity_in_use: Optional[bool] = None, + storage_endpoint: Optional[str] = None, + storage_account_access_key: Optional[str] = None, + storage_account_subscription_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class FailoverGroup(ProxyResource): + """A failover group. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.FailoverGroupProperties + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + """ + + properties: Optional["_models.FailoverGroupProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource tags.""" + location: Optional[str] = rest_field(visibility=["read"]) + """Resource location.""" + + __flattened_items = [ + "read_write_endpoint", + "read_only_endpoint", + "replication_role", + "replication_state", + "partner_servers", + "databases", + "secondary_type", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.FailoverGroupProperties"] = None, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class FailoverGroupProperties(_Model): + """Properties of a failover group. + + :ivar read_write_endpoint: Read-write endpoint of the failover group instance. Required. + :vartype read_write_endpoint: ~azure.mgmt.sql.models.FailoverGroupReadWriteEndpoint + :ivar read_only_endpoint: Read-only endpoint of the failover group instance. + :vartype read_only_endpoint: ~azure.mgmt.sql.models.FailoverGroupReadOnlyEndpoint + :ivar replication_role: Local replication role of the failover group instance. Known values + are: "Primary" and "Secondary". + :vartype replication_role: str or ~azure.mgmt.sql.models.FailoverGroupReplicationRole + :ivar replication_state: Replication state of the failover group instance. + :vartype replication_state: str + :ivar partner_servers: List of partner server information for the failover group. Required. + :vartype partner_servers: list[~azure.mgmt.sql.models.PartnerInfo] + :ivar databases: List of databases in the failover group. + :vartype databases: list[str] + :ivar secondary_type: Databases secondary type on partner server. Known values are: "Geo" and + "Standby". + :vartype secondary_type: str or ~azure.mgmt.sql.models.FailoverGroupDatabasesSecondaryType + """ + + read_write_endpoint: "_models.FailoverGroupReadWriteEndpoint" = rest_field( + name="readWriteEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """Read-write endpoint of the failover group instance. Required.""" + read_only_endpoint: Optional["_models.FailoverGroupReadOnlyEndpoint"] = rest_field( + name="readOnlyEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """Read-only endpoint of the failover group instance.""" + replication_role: Optional[Union[str, "_models.FailoverGroupReplicationRole"]] = rest_field( + name="replicationRole", visibility=["read"] + ) + """Local replication role of the failover group instance. Known values are: \"Primary\" and + \"Secondary\".""" + replication_state: Optional[str] = rest_field(name="replicationState", visibility=["read"]) + """Replication state of the failover group instance.""" + partner_servers: list["_models.PartnerInfo"] = rest_field( + name="partnerServers", visibility=["read", "create", "update", "delete", "query"] + ) + """List of partner server information for the failover group. Required.""" + databases: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """List of databases in the failover group.""" + secondary_type: Optional[Union[str, "_models.FailoverGroupDatabasesSecondaryType"]] = rest_field( + name="secondaryType", visibility=["create", "update"] + ) + """Databases secondary type on partner server. Known values are: \"Geo\" and \"Standby\".""" + + @overload + def __init__( + self, + *, + read_write_endpoint: "_models.FailoverGroupReadWriteEndpoint", + partner_servers: list["_models.PartnerInfo"], + read_only_endpoint: Optional["_models.FailoverGroupReadOnlyEndpoint"] = None, + databases: Optional[list[str]] = None, + secondary_type: Optional[Union[str, "_models.FailoverGroupDatabasesSecondaryType"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class FailoverGroupReadOnlyEndpoint(_Model): + """Read-only endpoint of the failover group instance. + + :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 + """ + + failover_policy: Optional[Union[str, "_models.ReadOnlyEndpointFailoverPolicy"]] = rest_field( + name="failoverPolicy", visibility=["read", "create", "update", "delete", "query"] + ) + """Failover policy of the read-only endpoint for the failover group. Known values are: + \"Disabled\" and \"Enabled\".""" + target_server: Optional[str] = rest_field( + name="targetServer", visibility=["read", "create", "update", "delete", "query"] + ) + """The target partner server where the read-only endpoint points to.""" + + @overload + def __init__( + self, + *, + failover_policy: Optional[Union[str, "_models.ReadOnlyEndpointFailoverPolicy"]] = None, + target_server: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class FailoverGroupReadWriteEndpoint(_Model): + """Read-write endpoint of the failover group instance. + + :ivar failover_policy: Failover policy of the read-write endpoint for the failover group. If + failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. Required. + Known values are: "Manual" and "Automatic". + :vartype failover_policy: str or ~azure.mgmt.sql.models.ReadWriteEndpointFailoverPolicy + :ivar failover_with_data_loss_grace_period_minutes: Grace period before failover with data loss + is attempted for the read-write endpoint. If failoverPolicy is Automatic then + failoverWithDataLossGracePeriodMinutes is required. + :vartype failover_with_data_loss_grace_period_minutes: int + """ + + failover_policy: Union[str, "_models.ReadWriteEndpointFailoverPolicy"] = rest_field( + name="failoverPolicy", visibility=["read", "create", "update", "delete", "query"] + ) + """Failover policy of the read-write endpoint for the failover group. If failoverPolicy is + Automatic then failoverWithDataLossGracePeriodMinutes is required. Required. Known values are: + \"Manual\" and \"Automatic\".""" + failover_with_data_loss_grace_period_minutes: Optional[int] = rest_field( + name="failoverWithDataLossGracePeriodMinutes", visibility=["read", "create", "update", "delete", "query"] + ) + """Grace period before failover with data loss is attempted for the read-write endpoint. If + failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required.""" + + @overload + def __init__( + self, + *, + failover_policy: Union[str, "_models.ReadWriteEndpointFailoverPolicy"], + failover_with_data_loss_grace_period_minutes: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class FailoverGroupUpdate(_Model): + """A failover group update request. + + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.FailoverGroupUpdateProperties + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + properties: Optional["_models.FailoverGroupUpdateProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource tags.""" + + __flattened_items = ["read_write_endpoint", "read_only_endpoint", "databases", "partner_servers", "secondary_type"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.FailoverGroupUpdateProperties"] = None, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class FailoverGroupUpdateProperties(_Model): + """Properties of a failover group update. + + :ivar read_write_endpoint: Read-write endpoint of the failover group instance. + :vartype read_write_endpoint: ~azure.mgmt.sql.models.FailoverGroupReadWriteEndpoint + :ivar read_only_endpoint: Read-only endpoint of the failover group instance. + :vartype read_only_endpoint: ~azure.mgmt.sql.models.FailoverGroupReadOnlyEndpoint + :ivar databases: List of databases in the failover group. + :vartype databases: list[str] + :ivar partner_servers: List of partner server information for the failover group. + :vartype partner_servers: list[~azure.mgmt.sql.models.PartnerInfo] + :ivar secondary_type: Databases secondary type on partner server. Known values are: "Geo" and + "Standby". + :vartype secondary_type: str or ~azure.mgmt.sql.models.FailoverGroupDatabasesSecondaryType + """ + + read_write_endpoint: Optional["_models.FailoverGroupReadWriteEndpoint"] = rest_field( + name="readWriteEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """Read-write endpoint of the failover group instance.""" + read_only_endpoint: Optional["_models.FailoverGroupReadOnlyEndpoint"] = rest_field( + name="readOnlyEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """Read-only endpoint of the failover group instance.""" + databases: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """List of databases in the failover group.""" + partner_servers: Optional[list["_models.PartnerInfo"]] = rest_field( + name="partnerServers", visibility=["read", "create", "update", "delete", "query"] + ) + """List of partner server information for the failover group.""" + secondary_type: Optional[Union[str, "_models.FailoverGroupDatabasesSecondaryType"]] = rest_field( + name="secondaryType", visibility=["create", "update"] + ) + """Databases secondary type on partner server. Known values are: \"Geo\" and \"Standby\".""" + + @overload + def __init__( + self, + *, + 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, + secondary_type: Optional[Union[str, "_models.FailoverGroupDatabasesSecondaryType"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ResourceWithWritableName(_Model): + """ARM resource. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """Resource ID.""" + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource name.""" + type: Optional[str] = rest_field(visibility=["read"]) + """Resource type.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ProxyResourceWithWritableName(ResourceWithWritableName): + """ARM proxy resource. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + """ + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class FirewallRule(ProxyResourceWithWritableName): + """A server firewall rule. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ServerFirewallRuleProperties + """ + + properties: Optional["_models.ServerFirewallRuleProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["start_ip_address", "end_ip_address"] + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + properties: Optional["_models.ServerFirewallRuleProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class FirewallRuleList(_Model): + """A list of server firewall rules. + + :ivar values_property: + :vartype values_property: list[~azure.mgmt.sql.models.FirewallRule] + """ + + values_property: Optional[list["_models.FirewallRule"]] = rest_field( + name="values", visibility=["read", "create", "update", "delete", "query"], original_tsp_name="values" + ) + + @overload + def __init__( + self, + *, + values_property: Optional[list["_models.FirewallRule"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class FreeLimitExhaustionBehaviorCapability(_Model): + """Supported free limit exhaustion behavior options. + + :ivar exhaustion_behavior_type: Free limit exhaustion behavior type. Known values are: + "AutoPause" and "BillOverUsage". + :vartype exhaustion_behavior_type: str or ~azure.mgmt.sql.models.FreeLimitExhaustionBehavior + :ivar status: Free limit exhaustion behavior status. Known values are: "Visible", "Available", + "Default", and "Disabled". + :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus + """ + + exhaustion_behavior_type: Optional[Union[str, "_models.FreeLimitExhaustionBehavior"]] = rest_field( + name="exhaustionBehaviorType", visibility=["read"] + ) + """Free limit exhaustion behavior type. Known values are: \"AutoPause\" and \"BillOverUsage\".""" + status: Optional[Union[str, "_models.CapabilityStatus"]] = rest_field(visibility=["read"]) + """Free limit exhaustion behavior status. Known values are: \"Visible\", \"Available\", + \"Default\", and \"Disabled\".""" + + +class GeoBackupPolicy(ProxyResource): + """A Geo backup policy. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.GeoBackupPolicyProperties + :ivar location: Backup policy location. + :vartype location: str + :ivar kind: Kind of geo backup policy. This is metadata used for the Azure portal experience. + :vartype kind: str + """ + + properties: Optional["_models.GeoBackupPolicyProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + location: Optional[str] = rest_field(visibility=["read"]) + """Backup policy location.""" + kind: Optional[str] = rest_field(visibility=["read"]) + """Kind of geo backup policy. This is metadata used for the Azure portal experience.""" + + __flattened_items = ["state", "storage_type"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.GeoBackupPolicyProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class GeoBackupPolicyProperties(_Model): + """The properties of the geo backup policy. + + :ivar state: The state of the geo backup policy. Required. 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 + """ + + state: Union[str, "_models.GeoBackupPolicyState"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The state of the geo backup policy. Required. Known values are: \"Enabled\" and \"Disabled\".""" + storage_type: Optional[str] = rest_field(name="storageType", visibility=["read"]) + """The storage type of the geo backup policy.""" + + @overload + def __init__( + self, + *, + state: Union[str, "_models.GeoBackupPolicyState"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ImportExistingDatabaseDefinition(_Model): + """Contains the information necessary to perform import operation for existing database. + + :ivar storage_key_type: Storage key type: StorageAccessKey, SharedAccessKey, or + ManagedIdentity. Required. Known values are: "SharedAccessKey", "StorageAccessKey", and + "ManagedIdentity". + :vartype storage_key_type: str or ~azure.mgmt.sql.models.StorageKeyType + :ivar storage_key: Storage key for the storage account. If StorageKeyType is ManagedIdentity, + this field should specify the Managed Identity's resource ID. Required. + :vartype storage_key: str + :ivar storage_uri: Storage Uri. Required. + :vartype storage_uri: str + :ivar administrator_login: Administrator login name. If AuthenticationType is ManagedIdentity, + this field should specify the Managed Identity's resource ID. Required. + :vartype administrator_login: str + :ivar administrator_login_password: Administrator login password. If AuthenticationType is + ManagedIdentity, this field should not be specified. + :vartype administrator_login_password: str + :ivar authentication_type: Type of credentials provided for access to the target SQL server: + SQL, ADPassword or ManagedIdentity. + :vartype authentication_type: str + :ivar network_isolation: Optional resource information to enable network isolation for request. + :vartype network_isolation: ~azure.mgmt.sql.models.NetworkIsolationSettings + """ + + storage_key_type: Union[str, "_models.StorageKeyType"] = rest_field(name="storageKeyType", visibility=["create"]) + """Storage key type: StorageAccessKey, SharedAccessKey, or ManagedIdentity. Required. Known values + are: \"SharedAccessKey\", \"StorageAccessKey\", and \"ManagedIdentity\".""" + storage_key: str = rest_field(name="storageKey", visibility=["create"]) + """Storage key for the storage account. If StorageKeyType is ManagedIdentity, this field should + specify the Managed Identity's resource ID. Required.""" + storage_uri: str = rest_field(name="storageUri", visibility=["create"]) + """Storage Uri. Required.""" + administrator_login: str = rest_field(name="administratorLogin", visibility=["create"]) + """Administrator login name. If AuthenticationType is ManagedIdentity, this field should specify + the Managed Identity's resource ID. Required.""" + administrator_login_password: Optional[str] = rest_field(name="administratorLoginPassword", visibility=["create"]) + """Administrator login password. If AuthenticationType is ManagedIdentity, this field should not + be specified.""" + authentication_type: Optional[str] = rest_field(name="authenticationType", visibility=["create"]) + """Type of credentials provided for access to the target SQL server: SQL, ADPassword or + ManagedIdentity.""" + network_isolation: Optional["_models.NetworkIsolationSettings"] = rest_field( + name="networkIsolation", visibility=["create"] + ) + """Optional resource information to enable network isolation for request.""" + + @overload + def __init__( + self, + *, + storage_key_type: Union[str, "_models.StorageKeyType"], + storage_key: str, + storage_uri: str, + administrator_login: str, + administrator_login_password: Optional[str] = None, + authentication_type: Optional[str] = None, + network_isolation: Optional["_models.NetworkIsolationSettings"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ImportExportExtensionsOperationResult(ProxyResource): + """An Extension operation result resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ImportExportExtensionsOperationResultProperties + """ + + properties: Optional["_models.ImportExportExtensionsOperationResultProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "request_id", + "request_type", + "last_modified_time", + "server_name", + "database_name", + "status", + "error_message", + "queued_time", + "blob_uri", + "private_endpoint_connections", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ImportExportExtensionsOperationResultProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ImportExportExtensionsOperationResultProperties(_Model): # pylint: disable=name-too-long + """Contains the operation result properties for import/export operation. + + :ivar request_id: Request Id. + :vartype request_id: str + :ivar request_type: Request type. + :vartype request_type: str + :ivar last_modified_time: Last modified time. + :vartype last_modified_time: str + :ivar server_name: Server name. + :vartype server_name: str + :ivar database_name: Database name. + :vartype database_name: str + :ivar status: Operation status. + :vartype status: str + :ivar error_message: Error message. + :vartype error_message: str + :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] + """ + + request_id: Optional[str] = rest_field(name="requestId", visibility=["read"]) + """Request Id.""" + request_type: Optional[str] = rest_field(name="requestType", visibility=["read"]) + """Request type.""" + last_modified_time: Optional[str] = rest_field(name="lastModifiedTime", visibility=["read"]) + """Last modified time.""" + server_name: Optional[str] = rest_field(name="serverName", visibility=["read"]) + """Server name.""" + database_name: Optional[str] = rest_field(name="databaseName", visibility=["read"]) + """Database name.""" + status: Optional[str] = rest_field(visibility=["read"]) + """Operation status.""" + error_message: Optional[str] = rest_field(name="errorMessage", visibility=["read"]) + """Error message.""" + queued_time: Optional[str] = rest_field(name="queuedTime", visibility=["read"]) + """Queued time.""" + blob_uri: Optional[str] = rest_field(name="blobUri", visibility=["read"]) + """Blob URI.""" + private_endpoint_connections: Optional[list["_models.PrivateEndpointConnectionRequestStatus"]] = rest_field( + name="privateEndpointConnections", visibility=["read"] + ) + """Gets the status of private endpoints associated with this request.""" + + +class ImportExportOperationResult(ProxyResource): + """An ImportExport operation result resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ImportExportOperationResultProperties + """ + + properties: Optional["_models.ImportExportOperationResultProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "request_id", + "request_type", + "queued_time", + "last_modified_time", + "blob_uri", + "server_name", + "database_name", + "status", + "error_message", + "private_endpoint_connections", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ImportExportOperationResultProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ImportExportOperationResultProperties(_Model): + """Contains the operation result properties for import/export operation. + + :ivar request_id: Request Id. + :vartype request_id: str + :ivar request_type: Request type. + :vartype request_type: str + :ivar queued_time: Queued time. + :vartype queued_time: str + :ivar last_modified_time: Last modified time. + :vartype last_modified_time: str + :ivar blob_uri: Blob Uri. + :vartype blob_uri: str + :ivar server_name: Server name. + :vartype server_name: str + :ivar database_name: Database name. + :vartype database_name: str + :ivar status: Operation status. + :vartype status: str + :ivar error_message: Error message. + :vartype error_message: str + :ivar private_endpoint_connections: Gets the status of private endpoints associated with this + request. + :vartype private_endpoint_connections: + list[~azure.mgmt.sql.models.PrivateEndpointConnectionRequestStatus] + """ + + request_id: Optional[str] = rest_field(name="requestId", visibility=["read"]) + """Request Id.""" + request_type: Optional[str] = rest_field(name="requestType", visibility=["read"]) + """Request type.""" + queued_time: Optional[str] = rest_field(name="queuedTime", visibility=["read"]) + """Queued time.""" + last_modified_time: Optional[str] = rest_field(name="lastModifiedTime", visibility=["read"]) + """Last modified time.""" + blob_uri: Optional[str] = rest_field(name="blobUri", visibility=["read"]) + """Blob Uri.""" + server_name: Optional[str] = rest_field(name="serverName", visibility=["read"]) + """Server name.""" + database_name: Optional[str] = rest_field(name="databaseName", visibility=["read"]) + """Database name.""" + status: Optional[str] = rest_field(visibility=["read"]) + """Operation status.""" + error_message: Optional[str] = rest_field(name="errorMessage", visibility=["read"]) + """Error message.""" + private_endpoint_connections: Optional[list["_models.PrivateEndpointConnectionRequestStatus"]] = rest_field( + name="privateEndpointConnections", visibility=["read"] + ) + """Gets the status of private endpoints associated with this request.""" + + +class ImportNewDatabaseDefinition(_Model): + """Contains the information necessary to perform import operation for new database. + + :ivar database_name: Name of the import database. + :vartype database_name: str + :ivar edition: Edition of the import database. + :vartype edition: str + :ivar service_objective_name: Service level objective name of the import database. + :vartype service_objective_name: str + :ivar max_size_bytes: Max size in bytes for the import database. + :vartype max_size_bytes: str + :ivar storage_key_type: Storage key type: StorageAccessKey, SharedAccessKey, or + ManagedIdentity. Required. Known values are: "SharedAccessKey", "StorageAccessKey", and + "ManagedIdentity". + :vartype storage_key_type: str or ~azure.mgmt.sql.models.StorageKeyType + :ivar storage_key: Storage key for the storage account. If StorageKeyType is ManagedIdentity, + this field should specify the Managed Identity's resource ID. Required. + :vartype storage_key: str + :ivar storage_uri: Storage Uri. Required. + :vartype storage_uri: str + :ivar administrator_login: Administrator login name. If AuthenticationType is ManagedIdentity, + this field should specify the Managed Identity's resource ID. Required. + :vartype administrator_login: str + :ivar administrator_login_password: Administrator login password. If AuthenticationType is + ManagedIdentity, this field should not be specified. + :vartype administrator_login_password: str + :ivar authentication_type: Type of credentials provided for access to the target SQL server: + SQL, ADPassword or ManagedIdentity. + :vartype authentication_type: str + :ivar network_isolation: Optional resource information to enable network isolation for request. + :vartype network_isolation: ~azure.mgmt.sql.models.NetworkIsolationSettings + """ + + database_name: Optional[str] = rest_field(name="databaseName", visibility=["create"]) + """Name of the import database.""" + edition: Optional[str] = rest_field(visibility=["create"]) + """Edition of the import database.""" + service_objective_name: Optional[str] = rest_field(name="serviceObjectiveName", visibility=["create"]) + """Service level objective name of the import database.""" + max_size_bytes: Optional[str] = rest_field(name="maxSizeBytes", visibility=["create"]) + """Max size in bytes for the import database.""" + storage_key_type: Union[str, "_models.StorageKeyType"] = rest_field(name="storageKeyType", visibility=["create"]) + """Storage key type: StorageAccessKey, SharedAccessKey, or ManagedIdentity. Required. Known values + are: \"SharedAccessKey\", \"StorageAccessKey\", and \"ManagedIdentity\".""" + storage_key: str = rest_field(name="storageKey", visibility=["create"]) + """Storage key for the storage account. If StorageKeyType is ManagedIdentity, this field should + specify the Managed Identity's resource ID. Required.""" + storage_uri: str = rest_field(name="storageUri", visibility=["create"]) + """Storage Uri. Required.""" + administrator_login: str = rest_field(name="administratorLogin", visibility=["create"]) + """Administrator login name. If AuthenticationType is ManagedIdentity, this field should specify + the Managed Identity's resource ID. Required.""" + administrator_login_password: Optional[str] = rest_field(name="administratorLoginPassword", visibility=["create"]) + """Administrator login password. If AuthenticationType is ManagedIdentity, this field should not + be specified.""" + authentication_type: Optional[str] = rest_field(name="authenticationType", visibility=["create"]) + """Type of credentials provided for access to the target SQL server: SQL, ADPassword or + ManagedIdentity.""" + network_isolation: Optional["_models.NetworkIsolationSettings"] = rest_field( + name="networkIsolation", visibility=["create"] + ) + """Optional resource information to enable network isolation for request.""" + + @overload + def __init__( + self, + *, + storage_key_type: Union[str, "_models.StorageKeyType"], + storage_key: str, + storage_uri: str, + administrator_login: str, + database_name: Optional[str] = None, + edition: Optional[str] = None, + service_objective_name: Optional[str] = None, + max_size_bytes: Optional[str] = None, + administrator_login_password: Optional[str] = None, + authentication_type: Optional[str] = None, + network_isolation: Optional["_models.NetworkIsolationSettings"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class InstanceFailoverGroup(ProxyResource): + """An instance failover group. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.InstanceFailoverGroupProperties + """ + + properties: Optional["_models.InstanceFailoverGroupProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "secondary_type", + "read_write_endpoint", + "read_only_endpoint", + "replication_role", + "replication_state", + "partner_regions", + "managed_instance_pairs", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.InstanceFailoverGroupProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class InstanceFailoverGroupProperties(_Model): + """Properties of a instance failover group. + + :ivar secondary_type: Type of the geo-secondary instance. Set 'Standby' if the instance is used + as a DR option only. Known values are: "Geo" and "Standby". + :vartype secondary_type: str or ~azure.mgmt.sql.models.SecondaryInstanceType + :ivar read_write_endpoint: Read-write endpoint of the failover group instance. Required. + :vartype read_write_endpoint: ~azure.mgmt.sql.models.InstanceFailoverGroupReadWriteEndpoint + :ivar read_only_endpoint: Read-only endpoint of the failover group instance. + :vartype read_only_endpoint: ~azure.mgmt.sql.models.InstanceFailoverGroupReadOnlyEndpoint + :ivar replication_role: Local replication role of the failover group instance. Known values + are: "Primary" and "Secondary". + :vartype replication_role: str or ~azure.mgmt.sql.models.InstanceFailoverGroupReplicationRole + :ivar replication_state: Replication state of the failover group instance. + :vartype replication_state: str + :ivar partner_regions: Partner region information for the failover group. Required. + :vartype partner_regions: list[~azure.mgmt.sql.models.PartnerRegionInfo] + :ivar managed_instance_pairs: List of managed instance pairs in the failover group. Required. + :vartype managed_instance_pairs: list[~azure.mgmt.sql.models.ManagedInstancePairInfo] + """ + + secondary_type: Optional[Union[str, "_models.SecondaryInstanceType"]] = rest_field( + name="secondaryType", visibility=["read", "create", "update", "delete", "query"] + ) + """Type of the geo-secondary instance. Set 'Standby' if the instance is used as a DR option only. + Known values are: \"Geo\" and \"Standby\".""" + read_write_endpoint: "_models.InstanceFailoverGroupReadWriteEndpoint" = rest_field( + name="readWriteEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """Read-write endpoint of the failover group instance. Required.""" + read_only_endpoint: Optional["_models.InstanceFailoverGroupReadOnlyEndpoint"] = rest_field( + name="readOnlyEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """Read-only endpoint of the failover group instance.""" + replication_role: Optional[Union[str, "_models.InstanceFailoverGroupReplicationRole"]] = rest_field( + name="replicationRole", visibility=["read"] + ) + """Local replication role of the failover group instance. Known values are: \"Primary\" and + \"Secondary\".""" + replication_state: Optional[str] = rest_field(name="replicationState", visibility=["read"]) + """Replication state of the failover group instance.""" + partner_regions: list["_models.PartnerRegionInfo"] = rest_field( + name="partnerRegions", visibility=["read", "create"] + ) + """Partner region information for the failover group. Required.""" + managed_instance_pairs: list["_models.ManagedInstancePairInfo"] = rest_field( + name="managedInstancePairs", visibility=["read", "create", "update", "delete", "query"] + ) + """List of managed instance pairs in the failover group. Required.""" + + @overload + def __init__( + self, + *, + read_write_endpoint: "_models.InstanceFailoverGroupReadWriteEndpoint", + partner_regions: list["_models.PartnerRegionInfo"], + managed_instance_pairs: list["_models.ManagedInstancePairInfo"], + secondary_type: Optional[Union[str, "_models.SecondaryInstanceType"]] = None, + read_only_endpoint: Optional["_models.InstanceFailoverGroupReadOnlyEndpoint"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class InstanceFailoverGroupReadOnlyEndpoint(_Model): + """Read-only endpoint of the failover group instance. + + :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 + """ + + failover_policy: Optional[Union[str, "_models.ReadOnlyEndpointFailoverPolicy"]] = rest_field( + name="failoverPolicy", visibility=["read", "create", "update", "delete", "query"] + ) + """Failover policy of the read-only endpoint for the failover group. Known values are: + \"Disabled\" and \"Enabled\".""" + + @overload + def __init__( + self, + *, + failover_policy: Optional[Union[str, "_models.ReadOnlyEndpointFailoverPolicy"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class InstanceFailoverGroupReadWriteEndpoint(_Model): + """Read-write endpoint of the failover group instance. + + :ivar failover_policy: Failover policy of the read-write endpoint for the failover group. If + failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. Required. + Known values are: "Manual" and "Automatic". + :vartype failover_policy: str or ~azure.mgmt.sql.models.ReadWriteEndpointFailoverPolicy + :ivar failover_with_data_loss_grace_period_minutes: Grace period before failover with data loss + is attempted for the read-write endpoint. If failoverPolicy is Automatic then + failoverWithDataLossGracePeriodMinutes is required. + :vartype failover_with_data_loss_grace_period_minutes: int + """ + + failover_policy: Union[str, "_models.ReadWriteEndpointFailoverPolicy"] = rest_field( + name="failoverPolicy", visibility=["read", "create", "update", "delete", "query"] + ) + """Failover policy of the read-write endpoint for the failover group. If failoverPolicy is + Automatic then failoverWithDataLossGracePeriodMinutes is required. Required. Known values are: + \"Manual\" and \"Automatic\".""" + failover_with_data_loss_grace_period_minutes: Optional[int] = rest_field( + name="failoverWithDataLossGracePeriodMinutes", visibility=["read", "create", "update", "delete", "query"] + ) + """Grace period before failover with data loss is attempted for the read-write endpoint. If + failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required.""" + + @overload + def __init__( + self, + *, + failover_policy: Union[str, "_models.ReadWriteEndpointFailoverPolicy"], + failover_with_data_loss_grace_period_minutes: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class InstancePool(TrackedResource): + """An Azure SQL instance pool. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.InstancePoolProperties + :ivar sku: The name and tier of the SKU. + :vartype sku: ~azure.mgmt.sql.models.Sku + """ + + properties: Optional["_models.InstancePoolProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + sku: Optional["_models.Sku"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name and tier of the SKU.""" + + __flattened_items = ["subnet_id", "v_cores", "license_type", "dns_zone", "maintenance_configuration_id"] + + @overload + def __init__( + self, + *, + location: str, + tags: Optional[dict[str, str]] = None, + properties: Optional["_models.InstancePoolProperties"] = None, + sku: Optional["_models.Sku"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class InstancePoolEditionCapability(_Model): + """The instance pool capability. + + :ivar name: The instance pool version name. + :vartype name: str + :ivar supported_families: The supported families. + :vartype supported_families: list[~azure.mgmt.sql.models.InstancePoolFamilyCapability] + :ivar status: The status of the capability. 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 + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """The instance pool version name.""" + supported_families: Optional[list["_models.InstancePoolFamilyCapability"]] = rest_field( + name="supportedFamilies", visibility=["read"] + ) + """The supported families.""" + status: Optional[Union[str, "_models.CapabilityStatus"]] = rest_field(visibility=["read"]) + """The status of the capability. Known values are: \"Visible\", \"Available\", \"Default\", and + \"Disabled\".""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for the capability not being available.""" + + @overload + def __init__( + self, + *, + reason: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class InstancePoolFamilyCapability(_Model): + """The instance pool family capability. + + :ivar name: Family name. + :vartype name: str + :ivar supported_license_types: List of supported license types. + :vartype supported_license_types: list[~azure.mgmt.sql.models.LicenseTypeCapability] + :ivar supported_vcores_values: List of supported virtual cores values. + :vartype supported_vcores_values: list[~azure.mgmt.sql.models.InstancePoolVcoresCapability] + :ivar status: The status of the capability. 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 + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """Family name.""" + supported_license_types: Optional[list["_models.LicenseTypeCapability"]] = rest_field( + name="supportedLicenseTypes", visibility=["read"] + ) + """List of supported license types.""" + supported_vcores_values: Optional[list["_models.InstancePoolVcoresCapability"]] = rest_field( + name="supportedVcoresValues", visibility=["read"] + ) + """List of supported virtual cores values.""" + status: Optional[Union[str, "_models.CapabilityStatus"]] = rest_field(visibility=["read"]) + """The status of the capability. Known values are: \"Visible\", \"Available\", \"Default\", and + \"Disabled\".""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for the capability not being available.""" + + @overload + def __init__( + self, + *, + reason: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class InstancePoolOperation(ProxyResource): + """A instance pool operation. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.InstancePoolOperationProperties + """ + + properties: Optional["_models.InstancePoolOperationProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "instance_pool_name", + "operation", + "operation_friendly_name", + "percent_complete", + "start_time", + "state", + "error_code", + "error_description", + "error_severity", + "error_type", + "estimated_completion_time", + "description", + "is_cancellable", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.InstancePoolOperationProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class InstancePoolOperationProperties(_Model): + """The properties of a instance pool operation. + + :ivar instance_pool_name: The name of the instance pool the operation is being performed on. + :vartype instance_pool_name: str + :ivar operation: The name of operation. + :vartype operation: str + :ivar operation_friendly_name: The friendly name of operation. + :vartype operation_friendly_name: str + :ivar percent_complete: The percentage of the operation completed. + :vartype percent_complete: int + :ivar start_time: The operation start time. + :vartype start_time: ~datetime.datetime + :ivar state: The operation state. Known values are: "Pending", "InProgress", "Succeeded", + "Failed", "CancelInProgress", and "Cancelled". + :vartype state: str or ~azure.mgmt.sql.models.ManagementOperationState + :ivar error_code: The operation error code. + :vartype error_code: int + :ivar error_description: The operation error description. + :vartype error_description: str + :ivar error_severity: The operation error severity. + :vartype error_severity: int + :ivar error_type: Error type (e.g. None, User). Known values are: "None" and "User". + :vartype error_type: str or ~azure.mgmt.sql.models.ErrorType + :ivar estimated_completion_time: The estimated completion time of the operation. + :vartype estimated_completion_time: ~datetime.datetime + :ivar description: The operation description. + :vartype description: str + :ivar is_cancellable: Whether the operation can be cancelled. + :vartype is_cancellable: bool + """ + + instance_pool_name: Optional[str] = rest_field(name="instancePoolName", visibility=["read"]) + """The name of the instance pool the operation is being performed on.""" + operation: Optional[str] = rest_field(visibility=["read"]) + """The name of operation.""" + operation_friendly_name: Optional[str] = rest_field(name="operationFriendlyName", visibility=["read"]) + """The friendly name of operation.""" + percent_complete: Optional[int] = rest_field(name="percentComplete", visibility=["read"]) + """The percentage of the operation completed.""" + start_time: Optional[datetime.datetime] = rest_field(name="startTime", visibility=["read"], format="rfc3339") + """The operation start time.""" + state: Optional[Union[str, "_models.ManagementOperationState"]] = rest_field(visibility=["read"]) + """The operation state. Known values are: \"Pending\", \"InProgress\", \"Succeeded\", \"Failed\", + \"CancelInProgress\", and \"Cancelled\".""" + error_code: Optional[int] = rest_field(name="errorCode", visibility=["read"]) + """The operation error code.""" + error_description: Optional[str] = rest_field(name="errorDescription", visibility=["read"]) + """The operation error description.""" + error_severity: Optional[int] = rest_field(name="errorSeverity", visibility=["read"]) + """The operation error severity.""" + error_type: Optional[Union[str, "_models.ErrorType"]] = rest_field(name="errorType", visibility=["read"]) + """Error type (e.g. None, User). Known values are: \"None\" and \"User\".""" + estimated_completion_time: Optional[datetime.datetime] = rest_field( + name="estimatedCompletionTime", visibility=["read"], format="rfc3339" + ) + """The estimated completion time of the operation.""" + description: Optional[str] = rest_field(visibility=["read"]) + """The operation description.""" + is_cancellable: Optional[bool] = rest_field(name="isCancellable", visibility=["read"]) + """Whether the operation can be cancelled.""" + + +class InstancePoolProperties(_Model): + """Properties of an instance pool. + + :ivar subnet_id: Resource ID of the subnet to place this instance pool in. Required. + :vartype subnet_id: str + :ivar v_cores: Count of vCores belonging to this instance pool. Required. + :vartype v_cores: int + :ivar license_type: The license type. Possible values are 'LicenseIncluded' (price for SQL + license is included) and 'BasePrice' (without SQL license price). Required. Known values are: + "LicenseIncluded" and "BasePrice". + :vartype license_type: str or ~azure.mgmt.sql.models.InstancePoolLicenseType + :ivar dns_zone: The Dns Zone that the managed instance pool is in. + :vartype dns_zone: str + :ivar maintenance_configuration_id: Specifies maintenance configuration id to apply to this + managed instance. + :vartype maintenance_configuration_id: str + """ + + subnet_id: str = rest_field(name="subnetId", visibility=["read", "create"]) + """Resource ID of the subnet to place this instance pool in. Required.""" + v_cores: int = rest_field(name="vCores", visibility=["read", "create", "update", "delete", "query"]) + """Count of vCores belonging to this instance pool. Required.""" + license_type: Union[str, "_models.InstancePoolLicenseType"] = rest_field( + name="licenseType", visibility=["read", "create", "update", "delete", "query"] + ) + """The license type. Possible values are 'LicenseIncluded' (price for SQL license is included) and + 'BasePrice' (without SQL license price). Required. Known values are: \"LicenseIncluded\" and + \"BasePrice\".""" + dns_zone: Optional[str] = rest_field(name="dnsZone", visibility=["read"]) + """The Dns Zone that the managed instance pool is in.""" + maintenance_configuration_id: Optional[str] = rest_field( + name="maintenanceConfigurationId", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies maintenance configuration id to apply to this managed instance.""" + + @overload + def __init__( + self, + *, + subnet_id: str, + v_cores: int, + license_type: Union[str, "_models.InstancePoolLicenseType"], + maintenance_configuration_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class InstancePoolUpdate(_Model): + """An update to an Instance pool. + + :ivar sku: The name and tier of the SKU. + :vartype sku: ~azure.mgmt.sql.models.Sku + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.InstancePoolProperties + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + sku: Optional["_models.Sku"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name and tier of the SKU.""" + properties: Optional["_models.InstancePoolProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource tags.""" + + __flattened_items = ["subnet_id", "v_cores", "license_type", "dns_zone", "maintenance_configuration_id"] + + @overload + def __init__( + self, + *, + sku: Optional["_models.Sku"] = None, + properties: Optional["_models.InstancePoolProperties"] = None, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class InstancePoolVcoresCapability(_Model): + """The managed instance virtual cores capability. + + :ivar name: The virtual cores identifier. + :vartype name: str + :ivar value: The virtual cores value. + :vartype value: int + :ivar storage_limit: Storage limit. + :vartype storage_limit: ~azure.mgmt.sql.models.MaxSizeCapability + :ivar status: The status of the capability. 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 + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """The virtual cores identifier.""" + value: Optional[int] = rest_field(visibility=["read"]) + """The virtual cores value.""" + storage_limit: Optional["_models.MaxSizeCapability"] = rest_field(name="storageLimit", visibility=["read"]) + """Storage limit.""" + status: Optional[Union[str, "_models.CapabilityStatus"]] = rest_field(visibility=["read"]) + """The status of the capability. Known values are: \"Visible\", \"Available\", \"Default\", and + \"Disabled\".""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for the capability not being available.""" + + @overload + def __init__( + self, + *, + reason: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class IPv6FirewallRule(ProxyResourceWithWritableName): + """An IPv6 server firewall rule. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.IPv6ServerFirewallRuleProperties + """ + + properties: Optional["_models.IPv6ServerFirewallRuleProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["start_i_pv6_address", "end_i_pv6_address"] + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + properties: Optional["_models.IPv6ServerFirewallRuleProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class IPv6ServerFirewallRuleProperties(_Model): + """The properties of an IPv6 server firewall rule. + + :ivar start_i_pv6_address: The start IP address of the firewall rule. Must be IPv6 format. + :vartype start_i_pv6_address: str + :ivar end_i_pv6_address: The end IP address of the firewall rule. Must be IPv6 format. Must be + greater than or equal to startIpv6Address. + :vartype end_i_pv6_address: str + """ + + start_i_pv6_address: Optional[str] = rest_field( + name="startIPv6Address", visibility=["read", "create", "update", "delete", "query"] + ) + """The start IP address of the firewall rule. Must be IPv6 format.""" + end_i_pv6_address: Optional[str] = rest_field( + name="endIPv6Address", visibility=["read", "create", "update", "delete", "query"] + ) + """The end IP address of the firewall rule. Must be IPv6 format. Must be greater than or equal to + startIpv6Address.""" + + @overload + def __init__( + self, + *, + start_i_pv6_address: Optional[str] = None, + end_i_pv6_address: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Job(ProxyResource): + """A job. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.JobProperties + """ + + properties: Optional["_models.JobProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["description", "version", "schedule"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.JobProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class JobAgent(TrackedResource): + """An Azure SQL job agent. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.JobAgentProperties + :ivar sku: The name and tier of the SKU. + :vartype sku: ~azure.mgmt.sql.models.Sku + :ivar identity: The identity of the job agent. + :vartype identity: ~azure.mgmt.sql.models.JobAgentIdentity + """ + + properties: Optional["_models.JobAgentProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + sku: Optional["_models.Sku"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name and tier of the SKU.""" + identity: Optional["_models.JobAgentIdentity"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The identity of the job agent.""" + + __flattened_items = ["database_id", "state"] + + @overload + def __init__( + self, + *, + location: str, + tags: Optional[dict[str, str]] = None, + properties: Optional["_models.JobAgentProperties"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.JobAgentIdentity"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class JobAgentEditionCapability(_Model): + """The job agent edition capability. + + :ivar name: The job agent edition name. + :vartype name: str + :ivar supported_service_level_objectives: The list of supported service level objectives for + the edition. + :vartype supported_service_level_objectives: + list[~azure.mgmt.sql.models.JobAgentServiceLevelObjectiveCapability] + :ivar status: The status of the capability. Known values are: "Visible", "Available", + "Default", and "Disabled". + :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus + :ivar reason: The reason for the capability not being available. + :vartype reason: str + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """The job agent edition name.""" + supported_service_level_objectives: Optional[list["_models.JobAgentServiceLevelObjectiveCapability"]] = rest_field( + name="supportedServiceLevelObjectives", visibility=["read"] + ) + """The list of supported service level objectives for the edition.""" + status: Optional[Union[str, "_models.CapabilityStatus"]] = rest_field(visibility=["read"]) + """The status of the capability. Known values are: \"Visible\", \"Available\", \"Default\", and + \"Disabled\".""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for the capability not being available.""" + + @overload + def __init__( + self, + *, + reason: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class JobAgentIdentity(_Model): + """Azure Active Directory identity configuration for a resource. + + :ivar tenant_id: The job agent identity tenant id. + :vartype tenant_id: str + :ivar type: The job agent identity type. Required. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssignedUserAssigned". + :vartype type: str or ~azure.mgmt.sql.models.JobAgentIdentityType + :ivar user_assigned_identities: The resource ids of the user assigned identities to use. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.sql.models.JobAgentUserAssignedIdentity] + """ + + tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read", "create", "update", "delete", "query"]) + """The job agent identity tenant id.""" + type: Union[str, "_models.JobAgentIdentityType"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The job agent identity type. Required. Known values are: \"None\", \"SystemAssigned\", + \"UserAssigned\", and \"SystemAssignedUserAssigned\".""" + user_assigned_identities: Optional[dict[str, "_models.JobAgentUserAssignedIdentity"]] = rest_field( + name="userAssignedIdentities", visibility=["read", "create", "update", "delete", "query"] + ) + """The resource ids of the user assigned identities to use.""" + + @overload + def __init__( + self, + *, + type: Union[str, "_models.JobAgentIdentityType"], + tenant_id: Optional[str] = None, + user_assigned_identities: Optional[dict[str, "_models.JobAgentUserAssignedIdentity"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class JobAgentProperties(_Model): + """Properties of a job agent. + + :ivar database_id: Resource ID of the database to store job metadata in. Required. + :vartype database_id: str + :ivar state: The state of the job agent. Known values are: "Creating", "Ready", "Updating", + "Deleting", and "Disabled". + :vartype state: str or ~azure.mgmt.sql.models.JobAgentState + """ + + database_id: str = rest_field(name="databaseId", visibility=["read", "create"]) + """Resource ID of the database to store job metadata in. Required.""" + state: Optional[Union[str, "_models.JobAgentState"]] = rest_field(visibility=["read"]) + """The state of the job agent. Known values are: \"Creating\", \"Ready\", \"Updating\", + \"Deleting\", and \"Disabled\".""" + + @overload + def __init__( + self, + *, + database_id: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class JobAgentServiceLevelObjectiveCapability(_Model): + """The job agent service level objective capability. + + :ivar name: The service objective name. + :vartype name: str + :ivar sku: The sku. + :vartype sku: ~azure.mgmt.sql.models.Sku + :ivar status: The status of the capability. Known values are: "Visible", "Available", + "Default", and "Disabled". + :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus + :ivar reason: The reason for the capability not being available. + :vartype reason: str + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """The service objective name.""" + sku: Optional["_models.Sku"] = rest_field(visibility=["read"]) + """The sku.""" + status: Optional[Union[str, "_models.CapabilityStatus"]] = rest_field(visibility=["read"]) + """The status of the capability. Known values are: \"Visible\", \"Available\", \"Default\", and + \"Disabled\".""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for the capability not being available.""" + + @overload + def __init__( + self, + *, + reason: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class JobAgentUpdate(_Model): + """An update to an Azure SQL job agent. + + :ivar identity: Managed identity assigned to job agent. + :vartype identity: ~azure.mgmt.sql.models.JobAgentIdentity + :ivar sku: The name and tier of the SKU. + :vartype sku: ~azure.mgmt.sql.models.Sku + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + identity: Optional["_models.JobAgentIdentity"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Managed identity assigned to job agent.""" + sku: Optional["_models.Sku"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name and tier of the SKU.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource tags.""" + + @overload + def __init__( + self, + *, + identity: Optional["_models.JobAgentIdentity"] = None, + sku: Optional["_models.Sku"] = None, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class JobAgentUserAssignedIdentity(_Model): + """Azure Active Directory identity configuration for a resource. + + :ivar principal_id: The Azure Active Directory principal id. + :vartype principal_id: str + :ivar client_id: The Azure Active Directory client id. + :vartype client_id: str + """ + + principal_id: Optional[str] = rest_field(name="principalId", visibility=["read"]) + """The Azure Active Directory principal id.""" + client_id: Optional[str] = rest_field(name="clientId", visibility=["read"]) + """The Azure Active Directory client id.""" + + +class JobAgentVersionCapability(_Model): + """The job agent version capability. + + :ivar name: The job agent version name. + :vartype name: str + :ivar supported_editions: The list of supported editions. + :vartype supported_editions: list[~azure.mgmt.sql.models.JobAgentEditionCapability] + :ivar status: The status of the capability. Known values are: "Visible", "Available", + "Default", and "Disabled". + :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus + :ivar reason: The reason for the capability not being available. + :vartype reason: str + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """The job agent version name.""" + supported_editions: Optional[list["_models.JobAgentEditionCapability"]] = rest_field( + name="supportedEditions", visibility=["read"] + ) + """The list of supported editions.""" + status: Optional[Union[str, "_models.CapabilityStatus"]] = rest_field(visibility=["read"]) + """The status of the capability. Known values are: \"Visible\", \"Available\", \"Default\", and + \"Disabled\".""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for the capability not being available.""" + + @overload + def __init__( + self, + *, + reason: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class JobCredential(ProxyResource): + """A stored credential that can be used by a job to connect to target databases. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.JobCredentialProperties + """ + + properties: Optional["_models.JobCredentialProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["username", "password"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.JobCredentialProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class JobCredentialProperties(_Model): + """Properties of a job credential. + + :ivar username: The credential user name. Required. + :vartype username: str + :ivar password: The credential password. Required. + :vartype password: str + """ + + username: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The credential user name. Required.""" + password: str = rest_field(visibility=["create", "update"]) + """The credential password. Required.""" + + @overload + def __init__( + self, + *, + username: str, + password: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class JobExecution(ProxyResource): + """An execution of a job. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.JobExecutionProperties + """ + + properties: Optional["_models.JobExecutionProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "job_version", + "step_name", + "step_id", + "job_execution_id", + "lifecycle", + "provisioning_state", + "create_time", + "start_time", + "end_time", + "current_attempts", + "current_attempt_start_time", + "last_message", + "target", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.JobExecutionProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class JobExecutionProperties(_Model): + """Properties for an Azure SQL Database Elastic job execution. + + :ivar job_version: The job version number. + :vartype job_version: int + :ivar step_name: The job step name. + :vartype step_name: str + :ivar step_id: The job step id. + :vartype step_id: int + :ivar job_execution_id: The unique identifier of the job execution. + :vartype job_execution_id: str + :ivar lifecycle: The detailed state of the job execution. Known values are: "Created", + "InProgress", "WaitingForChildJobExecutions", "WaitingForRetry", "Succeeded", + "SucceededWithSkipped", "Failed", "TimedOut", "Canceled", and "Skipped". + :vartype lifecycle: str or ~azure.mgmt.sql.models.JobExecutionLifecycle + :ivar provisioning_state: The ARM provisioning state of the job execution. Known values are: + "Created", "InProgress", "Succeeded", "Failed", and "Canceled". + :vartype provisioning_state: str or ~azure.mgmt.sql.models.ProvisioningState + :ivar create_time: The time that the job execution was created. + :vartype create_time: ~datetime.datetime + :ivar start_time: The time that the job execution started. + :vartype start_time: ~datetime.datetime + :ivar end_time: The time that the job execution completed. + :vartype end_time: ~datetime.datetime + :ivar current_attempts: Number of times the job execution has been attempted. + :vartype current_attempts: int + :ivar current_attempt_start_time: Start time of the current attempt. + :vartype current_attempt_start_time: ~datetime.datetime + :ivar last_message: The last status or error message. + :vartype last_message: str + :ivar target: The target that this execution is executed on. + :vartype target: ~azure.mgmt.sql.models.JobExecutionTarget + """ + + job_version: Optional[int] = rest_field(name="jobVersion", visibility=["read"]) + """The job version number.""" + step_name: Optional[str] = rest_field(name="stepName", visibility=["read"]) + """The job step name.""" + step_id: Optional[int] = rest_field(name="stepId", visibility=["read"]) + """The job step id.""" + job_execution_id: Optional[str] = rest_field(name="jobExecutionId", visibility=["read"]) + """The unique identifier of the job execution.""" + lifecycle: Optional[Union[str, "_models.JobExecutionLifecycle"]] = rest_field(visibility=["read"]) + """The detailed state of the job execution. Known values are: \"Created\", \"InProgress\", + \"WaitingForChildJobExecutions\", \"WaitingForRetry\", \"Succeeded\", \"SucceededWithSkipped\", + \"Failed\", \"TimedOut\", \"Canceled\", and \"Skipped\".""" + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """The ARM provisioning state of the job execution. Known values are: \"Created\", \"InProgress\", + \"Succeeded\", \"Failed\", and \"Canceled\".""" + create_time: Optional[datetime.datetime] = rest_field(name="createTime", visibility=["read"], format="rfc3339") + """The time that the job execution was created.""" + start_time: Optional[datetime.datetime] = rest_field(name="startTime", visibility=["read"], format="rfc3339") + """The time that the job execution started.""" + end_time: Optional[datetime.datetime] = rest_field(name="endTime", visibility=["read"], format="rfc3339") + """The time that the job execution completed.""" + current_attempts: Optional[int] = rest_field( + name="currentAttempts", visibility=["read", "create", "update", "delete", "query"] + ) + """Number of times the job execution has been attempted.""" + current_attempt_start_time: Optional[datetime.datetime] = rest_field( + name="currentAttemptStartTime", visibility=["read"], format="rfc3339" + ) + """Start time of the current attempt.""" + last_message: Optional[str] = rest_field(name="lastMessage", visibility=["read"]) + """The last status or error message.""" + target: Optional["_models.JobExecutionTarget"] = rest_field(visibility=["read"]) + """The target that this execution is executed on.""" + + @overload + def __init__( + self, + *, + current_attempts: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class JobExecutionTarget(_Model): + """The target that a job execution is executed on. + + :ivar type: The type of the target. Known values are: "TargetGroup", "SqlDatabase", + "SqlElasticPool", "SqlShardMap", and "SqlServer". + :vartype type: str or ~azure.mgmt.sql.models.JobTargetType + :ivar server_name: The server name. + :vartype server_name: str + :ivar database_name: The database name. + :vartype database_name: str + """ + + type: Optional[Union[str, "_models.JobTargetType"]] = rest_field(visibility=["read"]) + """The type of the target. Known values are: \"TargetGroup\", \"SqlDatabase\", \"SqlElasticPool\", + \"SqlShardMap\", and \"SqlServer\".""" + server_name: Optional[str] = rest_field(name="serverName", visibility=["read"]) + """The server name.""" + database_name: Optional[str] = rest_field(name="databaseName", visibility=["read"]) + """The database name.""" + + +class JobPrivateEndpoint(ProxyResource): + """A job agent private endpoint. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.JobPrivateEndpointProperties + """ + + properties: Optional["_models.JobPrivateEndpointProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["target_server_azure_resource_id", "private_endpoint_id"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.JobPrivateEndpointProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class JobPrivateEndpointProperties(_Model): + """Properties of job agent private endpoint. + + :ivar target_server_azure_resource_id: ARM resource id of the server the private endpoint will + target. Required. + :vartype target_server_azure_resource_id: str + :ivar private_endpoint_id: Private endpoint id of the private endpoint. + :vartype private_endpoint_id: str + """ + + target_server_azure_resource_id: str = rest_field( + name="targetServerAzureResourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """ARM resource id of the server the private endpoint will target. Required.""" + private_endpoint_id: Optional[str] = rest_field(name="privateEndpointId", visibility=["read"]) + """Private endpoint id of the private endpoint.""" + + @overload + def __init__( + self, + *, + target_server_azure_resource_id: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class JobProperties(_Model): + """Properties of a job. + + :ivar description: User-defined description of the job. + :vartype description: str + :ivar version: The job version number. + :vartype version: int + :ivar schedule: Schedule properties of the job. + :vartype schedule: ~azure.mgmt.sql.models.JobSchedule + """ + + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """User-defined description of the job.""" + version: Optional[int] = rest_field(visibility=["read"]) + """The job version number.""" + schedule: Optional["_models.JobSchedule"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Schedule properties of the job.""" + + @overload + def __init__( + self, + *, + description: Optional[str] = None, + schedule: Optional["_models.JobSchedule"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class JobSchedule(_Model): + """Scheduling properties of a job. + + :ivar start_time: Schedule start time. + :vartype start_time: ~datetime.datetime + :ivar end_time: Schedule end time. + :vartype end_time: ~datetime.datetime + :ivar type: Schedule interval type. Known values are: "Once" and "Recurring". + :vartype type: str or ~azure.mgmt.sql.models.JobScheduleType + :ivar enabled: Whether or not the schedule is enabled. + :vartype enabled: bool + :ivar interval: Value of the schedule's recurring interval, if the ScheduleType is recurring. + ISO8601 duration format. + :vartype interval: str + """ + + start_time: Optional[datetime.datetime] = rest_field( + name="startTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Schedule start time.""" + end_time: Optional[datetime.datetime] = rest_field( + name="endTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Schedule end time.""" + type: Optional[Union[str, "_models.JobScheduleType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Schedule interval type. Known values are: \"Once\" and \"Recurring\".""" + enabled: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether or not the schedule is enabled.""" + interval: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Value of the schedule's recurring interval, if the ScheduleType is recurring. ISO8601 duration + format.""" + + @overload + def __init__( + self, + *, + start_time: Optional[datetime.datetime] = None, + end_time: Optional[datetime.datetime] = None, + type: Optional[Union[str, "_models.JobScheduleType"]] = None, + enabled: Optional[bool] = None, + interval: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class JobStep(ProxyResource): + """A job step. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.JobStepProperties + """ + + properties: Optional["_models.JobStepProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["step_id", "target_group", "credential", "action", "output", "execution_options"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.JobStepProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class JobStepAction(_Model): + """The action to be executed by a job step. + + :ivar type: Type of action being executed by the job step. "TSql" + :vartype type: str or ~azure.mgmt.sql.models.JobStepActionType + :ivar source: The source of the action to execute. "Inline" + :vartype source: str or ~azure.mgmt.sql.models.JobStepActionSource + :ivar value: The action value, for example the text of the T-SQL script to execute. Required. + :vartype value: str + """ + + type: Optional[Union[str, "_models.JobStepActionType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Type of action being executed by the job step. \"TSql\"""" + source: Optional[Union[str, "_models.JobStepActionSource"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The source of the action to execute. \"Inline\"""" + value: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The action value, for example the text of the T-SQL script to execute. Required.""" + + @overload + def __init__( + self, + *, + value: str, + type: Optional[Union[str, "_models.JobStepActionType"]] = None, + source: Optional[Union[str, "_models.JobStepActionSource"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class JobStepExecutionOptions(_Model): + """The execution options of a job step. + + :ivar timeout_seconds: Execution timeout for the job step. + :vartype timeout_seconds: int + :ivar retry_attempts: Maximum number of times the job step will be reattempted if the first + attempt fails. + :vartype retry_attempts: int + :ivar initial_retry_interval_seconds: Initial delay between retries for job step execution. + :vartype initial_retry_interval_seconds: int + :ivar maximum_retry_interval_seconds: The maximum amount of time to wait between retries for + job step execution. + :vartype maximum_retry_interval_seconds: int + :ivar retry_interval_backoff_multiplier: The backoff multiplier for the time between retries. + :vartype retry_interval_backoff_multiplier: float + """ + + timeout_seconds: Optional[int] = rest_field( + name="timeoutSeconds", visibility=["read", "create", "update", "delete", "query"] + ) + """Execution timeout for the job step.""" + retry_attempts: Optional[int] = rest_field( + name="retryAttempts", visibility=["read", "create", "update", "delete", "query"] + ) + """Maximum number of times the job step will be reattempted if the first attempt fails.""" + initial_retry_interval_seconds: Optional[int] = rest_field( + name="initialRetryIntervalSeconds", visibility=["read", "create", "update", "delete", "query"] + ) + """Initial delay between retries for job step execution.""" + maximum_retry_interval_seconds: Optional[int] = rest_field( + name="maximumRetryIntervalSeconds", visibility=["read", "create", "update", "delete", "query"] + ) + """The maximum amount of time to wait between retries for job step execution.""" + retry_interval_backoff_multiplier: Optional[float] = rest_field( + name="retryIntervalBackoffMultiplier", visibility=["read", "create", "update", "delete", "query"] + ) + """The backoff multiplier for the time between retries.""" + + @overload + def __init__( + self, + *, + timeout_seconds: Optional[int] = None, + retry_attempts: Optional[int] = None, + initial_retry_interval_seconds: Optional[int] = None, + maximum_retry_interval_seconds: Optional[int] = None, + retry_interval_backoff_multiplier: Optional[float] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class JobStepOutput(_Model): + """The output configuration of a job step. + + :ivar type: The output destination type. "SqlDatabase" + :vartype type: str or ~azure.mgmt.sql.models.JobStepOutputType + :ivar subscription_id: The output destination subscription id. + :vartype subscription_id: str + :ivar resource_group_name: The output destination resource group. + :vartype resource_group_name: str + :ivar server_name: The output destination server name. Required. + :vartype server_name: str + :ivar database_name: The output destination database. Required. + :vartype database_name: str + :ivar schema_name: The output destination schema. + :vartype schema_name: str + :ivar table_name: The output destination table. Required. + :vartype table_name: str + :ivar credential: The resource ID of the credential to use to connect to the output + destination. + :vartype credential: str + """ + + type: Optional[Union[str, "_models.JobStepOutputType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The output destination type. \"SqlDatabase\"""" + subscription_id: Optional[str] = rest_field( + name="subscriptionId", visibility=["read", "create", "update", "delete", "query"] + ) + """The output destination subscription id.""" + resource_group_name: Optional[str] = rest_field( + name="resourceGroupName", visibility=["read", "create", "update", "delete", "query"] + ) + """The output destination resource group.""" + server_name: str = rest_field(name="serverName", visibility=["read", "create", "update", "delete", "query"]) + """The output destination server name. Required.""" + database_name: str = rest_field(name="databaseName", visibility=["read", "create", "update", "delete", "query"]) + """The output destination database. Required.""" + schema_name: Optional[str] = rest_field( + name="schemaName", visibility=["read", "create", "update", "delete", "query"] + ) + """The output destination schema.""" + table_name: str = rest_field(name="tableName", visibility=["read", "create", "update", "delete", "query"]) + """The output destination table. Required.""" + credential: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The resource ID of the credential to use to connect to the output destination.""" + + @overload + def __init__( + self, + *, + server_name: str, + database_name: str, + table_name: str, + type: Optional[Union[str, "_models.JobStepOutputType"]] = None, + subscription_id: Optional[str] = None, + resource_group_name: Optional[str] = None, + schema_name: Optional[str] = None, + credential: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class JobStepProperties(_Model): + """Properties of a job step. + + :ivar step_id: The job step's index within the job. If not specified when creating the job + step, it will be created as the last step. If not specified when updating the job step, the + step id is not modified. + :vartype step_id: int + :ivar target_group: The resource ID of the target group that the job step will be executed on. + Required. + :vartype target_group: str + :ivar credential: The resource ID of the job credential that will be used to connect to the + targets. + :vartype credential: str + :ivar action: The action payload of the job step. Required. + :vartype action: ~azure.mgmt.sql.models.JobStepAction + :ivar output: Output destination properties of the job step. + :vartype output: ~azure.mgmt.sql.models.JobStepOutput + :ivar execution_options: Execution options for the job step. + :vartype execution_options: ~azure.mgmt.sql.models.JobStepExecutionOptions + """ + + step_id: Optional[int] = rest_field(name="stepId", visibility=["read", "create", "update", "delete", "query"]) + """The job step's index within the job. If not specified when creating the job step, it will be + created as the last step. If not specified when updating the job step, the step id is not + modified.""" + target_group: str = rest_field(name="targetGroup", visibility=["read", "create", "update", "delete", "query"]) + """The resource ID of the target group that the job step will be executed on. Required.""" + credential: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The resource ID of the job credential that will be used to connect to the targets.""" + action: "_models.JobStepAction" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The action payload of the job step. Required.""" + output: Optional["_models.JobStepOutput"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Output destination properties of the job step.""" + execution_options: Optional["_models.JobStepExecutionOptions"] = rest_field( + name="executionOptions", visibility=["read", "create", "update", "delete", "query"] + ) + """Execution options for the job step.""" + + @overload + def __init__( + self, + *, + target_group: str, + action: "_models.JobStepAction", + step_id: Optional[int] = None, + credential: Optional[str] = None, + output: Optional["_models.JobStepOutput"] = None, + execution_options: Optional["_models.JobStepExecutionOptions"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class JobTarget(_Model): + """A job target, for example a specific database or a container of databases that is evaluated + during job execution. + + :ivar membership_type: Whether the target is included or excluded from the group. Known values + are: "Include" and "Exclude". + :vartype membership_type: str or ~azure.mgmt.sql.models.JobTargetGroupMembershipType + :ivar type: The target type. Required. Known values are: "TargetGroup", "SqlDatabase", + "SqlElasticPool", "SqlShardMap", and "SqlServer". + :vartype type: str or ~azure.mgmt.sql.models.JobTargetType + :ivar server_name: The target server name. + :vartype server_name: str + :ivar database_name: The target database name. + :vartype database_name: str + :ivar elastic_pool_name: The target elastic pool name. + :vartype elastic_pool_name: str + :ivar shard_map_name: The target shard map. + :vartype shard_map_name: str + :ivar refresh_credential: The resource ID of the credential that is used during job execution + to connect to the target and determine the list of databases inside the target. + :vartype refresh_credential: str + """ + + membership_type: Optional[Union[str, "_models.JobTargetGroupMembershipType"]] = rest_field( + name="membershipType", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether the target is included or excluded from the group. Known values are: \"Include\" and + \"Exclude\".""" + type: Union[str, "_models.JobTargetType"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The target type. Required. Known values are: \"TargetGroup\", \"SqlDatabase\", + \"SqlElasticPool\", \"SqlShardMap\", and \"SqlServer\".""" + server_name: Optional[str] = rest_field( + name="serverName", visibility=["read", "create", "update", "delete", "query"] + ) + """The target server name.""" + database_name: Optional[str] = rest_field( + name="databaseName", visibility=["read", "create", "update", "delete", "query"] + ) + """The target database name.""" + elastic_pool_name: Optional[str] = rest_field( + name="elasticPoolName", visibility=["read", "create", "update", "delete", "query"] + ) + """The target elastic pool name.""" + shard_map_name: Optional[str] = rest_field( + name="shardMapName", visibility=["read", "create", "update", "delete", "query"] + ) + """The target shard map.""" + refresh_credential: Optional[str] = rest_field( + name="refreshCredential", visibility=["read", "create", "update", "delete", "query"] + ) + """The resource ID of the credential that is used during job execution to connect to the target + and determine the list of databases inside the target.""" + + @overload + def __init__( + self, + *, + type: Union[str, "_models.JobTargetType"], + membership_type: Optional[Union[str, "_models.JobTargetGroupMembershipType"]] = None, + server_name: Optional[str] = None, + database_name: Optional[str] = None, + elastic_pool_name: Optional[str] = None, + shard_map_name: Optional[str] = None, + refresh_credential: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class JobTargetGroup(ProxyResource): + """A group of job targets. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.JobTargetGroupProperties + """ + + properties: Optional["_models.JobTargetGroupProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["members"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.JobTargetGroupProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class JobTargetGroupProperties(_Model): + """Properties of job target group. + + :ivar members: Members of the target group. Required. + :vartype members: list[~azure.mgmt.sql.models.JobTarget] + """ + + members: list["_models.JobTarget"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Members of the target group. Required.""" + + @overload + def __init__( + self, + *, + members: list["_models.JobTarget"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class JobVersion(ProxyResource): + """A job version. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + """ + + +class LedgerDigestUploads(ProxyResource): + """Azure SQL Database ledger digest upload settings. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.LedgerDigestUploadsProperties + """ + + properties: Optional["_models.LedgerDigestUploadsProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["digest_storage_endpoint", "state"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.LedgerDigestUploadsProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class LedgerDigestUploadsProperties(_Model): + """The properties of a database ledger digest upload settings. + + :ivar digest_storage_endpoint: The digest storage endpoint, which must be either an Azure blob + storage endpoint or an URI for Azure Confidential Ledger. + :vartype digest_storage_endpoint: str + :ivar state: Specifies the state of ledger digest upload. Known values are: "Enabled" and + "Disabled". + :vartype state: str or ~azure.mgmt.sql.models.LedgerDigestUploadsState + """ + + digest_storage_endpoint: Optional[str] = rest_field( + name="digestStorageEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """The digest storage endpoint, which must be either an Azure blob storage endpoint or an URI for + Azure Confidential Ledger.""" + state: Optional[Union[str, "_models.LedgerDigestUploadsState"]] = rest_field(visibility=["read"]) + """Specifies the state of ledger digest upload. Known values are: \"Enabled\" and \"Disabled\".""" + + @overload + def __init__( + self, + *, + digest_storage_endpoint: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class LicenseTypeCapability(_Model): + """The license type capability. + + :ivar name: License type identifier. + :vartype name: str + :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 + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """License type identifier.""" + status: Optional[Union[str, "_models.CapabilityStatus"]] = rest_field(visibility=["read"]) + """The status of the capability. Known values are: \"Visible\", \"Available\", \"Default\", and + \"Disabled\".""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for the capability not being available.""" + + @overload + def __init__( + self, + *, + reason: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class LocationCapabilities(_Model): + """The location capability. + + :ivar name: The location name. + :vartype name: str + :ivar supported_server_versions: The list of supported server versions. + :vartype supported_server_versions: list[~azure.mgmt.sql.models.ServerVersionCapability] + :ivar supported_managed_instance_versions: The list of supported managed instance versions. + :vartype supported_managed_instance_versions: + list[~azure.mgmt.sql.models.ManagedInstanceVersionCapability] + :ivar supported_job_agent_versions: The list of supported job agent versions. + :vartype supported_job_agent_versions: list[~azure.mgmt.sql.models.JobAgentVersionCapability] + :ivar is_zone_resilient_provisioning_allowed: Whether or not the subscription is allowed to + provision zone resilient resources. + :vartype is_zone_resilient_provisioning_allowed: 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 + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """The location name.""" + supported_server_versions: Optional[list["_models.ServerVersionCapability"]] = rest_field( + name="supportedServerVersions", visibility=["read"] + ) + """The list of supported server versions.""" + supported_managed_instance_versions: Optional[list["_models.ManagedInstanceVersionCapability"]] = rest_field( + name="supportedManagedInstanceVersions", visibility=["read"] + ) + """The list of supported managed instance versions.""" + supported_job_agent_versions: Optional[list["_models.JobAgentVersionCapability"]] = rest_field( + name="supportedJobAgentVersions", visibility=["read"] + ) + """The list of supported job agent versions.""" + is_zone_resilient_provisioning_allowed: Optional[bool] = rest_field( + name="isZoneResilientProvisioningAllowed", visibility=["read"] + ) + """Whether or not the subscription is allowed to provision zone resilient resources.""" + status: Optional[Union[str, "_models.CapabilityStatus"]] = rest_field(visibility=["read"]) + """The status of the capability. Known values are: \"Visible\", \"Available\", \"Default\", and + \"Disabled\".""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for the capability not being available.""" + + @overload + def __init__( + self, + *, + reason: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class LogicalDatabaseTransparentDataEncryption(ProxyResource): + """A logical database transparent data encryption scan state. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.TransparentDataEncryptionProperties + """ + + properties: Optional["_models.TransparentDataEncryptionProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["state", "scan_state"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.TransparentDataEncryptionProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class LogSizeCapability(_Model): + """The log size capability. + + :ivar limit: The log size limit (see 'unit' for the units). + :vartype limit: int + :ivar unit: The units that the limit is expressed in. Known values are: "Megabytes", + "Gigabytes", "Terabytes", "Petabytes", and "Percent". + :vartype unit: str or ~azure.mgmt.sql.models.LogSizeUnit + """ + + limit: Optional[int] = rest_field(visibility=["read"]) + """The log size limit (see 'unit' for the units).""" + unit: Optional[Union[str, "_models.LogSizeUnit"]] = rest_field(visibility=["read"]) + """The units that the limit is expressed in. Known values are: \"Megabytes\", \"Gigabytes\", + \"Terabytes\", \"Petabytes\", and \"Percent\".""" + + +class LongTermRetentionBackup(ProxyResource): + """A long term retention backup. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.LongTermRetentionBackupProperties + """ + + properties: Optional["_models.LongTermRetentionBackupProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "server_name", + "server_create_time", + "database_name", + "database_deletion_time", + "backup_time", + "backup_expiration_time", + "backup_storage_redundancy", + "requested_backup_storage_redundancy", + "is_backup_immutable", + "time_based_immutability", + "time_based_immutability_mode", + "legal_hold_immutability", + "backup_storage_access_tier", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.LongTermRetentionBackupProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class LongTermRetentionBackupOperationResult(ProxyResource): + """A LongTermRetentionBackup operation result resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.LongTermRetentionOperationResultProperties + """ + + properties: Optional["_models.LongTermRetentionOperationResultProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "request_id", + "operation_type", + "from_backup_resource_id", + "to_backup_resource_id", + "target_backup_storage_redundancy", + "status", + "message", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.LongTermRetentionOperationResultProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class LongTermRetentionBackupProperties(_Model): + """Properties of a long term retention backup. + + :ivar server_name: The server name that the backup database belong to. + :vartype server_name: str + :ivar server_create_time: The create time of the server. + :vartype server_create_time: ~datetime.datetime + :ivar database_name: The name of the database the backup belong to. + :vartype database_name: str + :ivar database_deletion_time: The delete time of the database. + :vartype database_deletion_time: ~datetime.datetime + :ivar backup_time: The time the backup was taken. + :vartype backup_time: ~datetime.datetime + :ivar backup_expiration_time: The time the long term retention backup will expire. + :vartype backup_expiration_time: ~datetime.datetime + :ivar backup_storage_redundancy: The storage redundancy type of the backup. Known values are: + "Geo", "Local", "Zone", and "GeoZone". + :vartype backup_storage_redundancy: str or ~azure.mgmt.sql.models.BackupStorageRedundancy + :ivar requested_backup_storage_redundancy: The storage redundancy type of the backup. Known + values are: "Geo", "Local", "Zone", and "GeoZone". + :vartype requested_backup_storage_redundancy: str or + ~azure.mgmt.sql.models.BackupStorageRedundancy + :ivar is_backup_immutable: The setting whether the LTR backup is immutable. + :vartype is_backup_immutable: bool + :ivar time_based_immutability: The setting for whether or not time-based immutability is + enabled for the LTR backup. When time-based immutability is enabled and locked, the backup + cannot be deleted until BackupExpirationTime. Known values are: "Enabled" and "Disabled". + :vartype time_based_immutability: str or ~azure.mgmt.sql.models.TimeBasedImmutability + :ivar time_based_immutability_mode: The time-based immutability mode. Only applicable if + time-based immutability is enabled. Known values are: "Locked" and "Unlocked". + :vartype time_based_immutability_mode: str or ~azure.mgmt.sql.models.TimeBasedImmutabilityMode + :ivar legal_hold_immutability: The setting for whether LegalHold is enabled or disabled on the + LTR backup. When LegalHold is enabled, the backup cannot be deleted until the LegalHold is + removed. Known values are: "Enabled" and "Disabled". + :vartype legal_hold_immutability: str or ~azure.mgmt.sql.models.SetLegalHoldImmutability + :ivar backup_storage_access_tier: The BackupStorageAccessTier for the LTR backup. Known values + are: "Hot" and "Archive". + :vartype backup_storage_access_tier: str or ~azure.mgmt.sql.models.BackupStorageAccessTier + """ + + server_name: Optional[str] = rest_field(name="serverName", visibility=["read"]) + """The server name that the backup database belong to.""" + server_create_time: Optional[datetime.datetime] = rest_field( + name="serverCreateTime", visibility=["read"], format="rfc3339" + ) + """The create time of the server.""" + database_name: Optional[str] = rest_field(name="databaseName", visibility=["read"]) + """The name of the database the backup belong to.""" + database_deletion_time: Optional[datetime.datetime] = rest_field( + name="databaseDeletionTime", visibility=["read"], format="rfc3339" + ) + """The delete time of the database.""" + backup_time: Optional[datetime.datetime] = rest_field(name="backupTime", visibility=["read"], format="rfc3339") + """The time the backup was taken.""" + backup_expiration_time: Optional[datetime.datetime] = rest_field( + name="backupExpirationTime", visibility=["read"], format="rfc3339" + ) + """The time the long term retention backup will expire.""" + backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = rest_field( + name="backupStorageRedundancy", visibility=["read"] + ) + """The storage redundancy type of the backup. Known values are: \"Geo\", \"Local\", \"Zone\", and + \"GeoZone\".""" + requested_backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = rest_field( + name="requestedBackupStorageRedundancy", visibility=["create", "update"] + ) + """The storage redundancy type of the backup. Known values are: \"Geo\", \"Local\", \"Zone\", and + \"GeoZone\".""" + is_backup_immutable: Optional[bool] = rest_field( + name="isBackupImmutable", visibility=["read", "create", "update", "delete", "query"] + ) + """The setting whether the LTR backup is immutable.""" + time_based_immutability: Optional[Union[str, "_models.TimeBasedImmutability"]] = rest_field( + name="timeBasedImmutability", visibility=["read", "create", "update", "delete", "query"] + ) + """The setting for whether or not time-based immutability is enabled for the LTR backup. When + time-based immutability is enabled and locked, the backup cannot be deleted until + BackupExpirationTime. Known values are: \"Enabled\" and \"Disabled\".""" + time_based_immutability_mode: Optional[Union[str, "_models.TimeBasedImmutabilityMode"]] = rest_field( + name="timeBasedImmutabilityMode", visibility=["read", "create", "update", "delete", "query"] + ) + """The time-based immutability mode. Only applicable if time-based immutability is enabled. Known + values are: \"Locked\" and \"Unlocked\".""" + legal_hold_immutability: Optional[Union[str, "_models.SetLegalHoldImmutability"]] = rest_field( + name="legalHoldImmutability", visibility=["read", "create", "update", "delete", "query"] + ) + """The setting for whether LegalHold is enabled or disabled on the LTR backup. When LegalHold is + enabled, the backup cannot be deleted until the LegalHold is removed. Known values are: + \"Enabled\" and \"Disabled\".""" + backup_storage_access_tier: Optional[Union[str, "_models.BackupStorageAccessTier"]] = rest_field( + name="backupStorageAccessTier", visibility=["read"] + ) + """The BackupStorageAccessTier for the LTR backup. Known values are: \"Hot\" and \"Archive\".""" + + @overload + def __init__( + self, + *, + requested_backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = None, + is_backup_immutable: Optional[bool] = None, + time_based_immutability: Optional[Union[str, "_models.TimeBasedImmutability"]] = None, + time_based_immutability_mode: Optional[Union[str, "_models.TimeBasedImmutabilityMode"]] = None, + legal_hold_immutability: Optional[Union[str, "_models.SetLegalHoldImmutability"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class LongTermRetentionOperationResultProperties(_Model): # pylint: disable=name-too-long + """Contains the operation result properties for long term retention backup operation. + + :ivar request_id: Request Id. + :vartype request_id: str + :ivar operation_type: Operation type. + :vartype operation_type: str + :ivar from_backup_resource_id: Source backup resource id. + :vartype from_backup_resource_id: str + :ivar to_backup_resource_id: Target backup resource id. + :vartype to_backup_resource_id: str + :ivar target_backup_storage_redundancy: The storage redundancy type of the copied backup. Known + values are: "Geo", "Local", "Zone", and "GeoZone". + :vartype target_backup_storage_redundancy: str or + ~azure.mgmt.sql.models.BackupStorageRedundancy + :ivar status: Operation status. + :vartype status: str + :ivar message: Progress message. + :vartype message: str + """ + + request_id: Optional[str] = rest_field(name="requestId", visibility=["read"]) + """Request Id.""" + operation_type: Optional[str] = rest_field(name="operationType", visibility=["read"]) + """Operation type.""" + from_backup_resource_id: Optional[str] = rest_field(name="fromBackupResourceId", visibility=["read"]) + """Source backup resource id.""" + to_backup_resource_id: Optional[str] = rest_field(name="toBackupResourceId", visibility=["read"]) + """Target backup resource id.""" + target_backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = rest_field( + name="targetBackupStorageRedundancy", visibility=["read"] + ) + """The storage redundancy type of the copied backup. Known values are: \"Geo\", \"Local\", + \"Zone\", and \"GeoZone\".""" + status: Optional[str] = rest_field(visibility=["read"]) + """Operation status.""" + message: Optional[str] = rest_field(visibility=["read"]) + """Progress message.""" + + +class LongTermRetentionPolicy(ProxyResource): + """A long term retention policy. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.LongTermRetentionPolicyProperties + """ + + properties: Optional["_models.LongTermRetentionPolicyProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "time_based_immutability", + "time_based_immutability_mode", + "weekly_retention", + "monthly_retention", + "yearly_retention", + "week_of_year", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.LongTermRetentionPolicyProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class LongTermRetentionPolicyProperties(_Model): + """Properties of a long term retention policy. + + :ivar time_based_immutability: The setting for whether to enable time-based immutability for + future backups. When set, future backups will have TimeBasedImmutability enabled. Known values + are: "Enabled" and "Disabled". + :vartype time_based_immutability: str or ~azure.mgmt.sql.models.TimeBasedImmutability + :ivar time_based_immutability_mode: The setting for time-based immutability mode for future + backup (Value can be either Locked or UnLocked. Only effective if TimeBasedImmutability is + enabled). Caution: Immutability of LTR backup cannot be removed if TimeBasedImmutabilityMode is + Locked. Known values are: "Locked" and "Unlocked". + :vartype time_based_immutability_mode: str or ~azure.mgmt.sql.models.TimeBasedImmutabilityMode + :ivar weekly_retention: The weekly retention policy for an LTR backup in an ISO 8601 format. + :vartype weekly_retention: str + :ivar monthly_retention: The monthly retention policy for an LTR backup in an ISO 8601 format. + :vartype monthly_retention: str + :ivar yearly_retention: The yearly retention policy for an LTR backup in an ISO 8601 format. + :vartype yearly_retention: str + :ivar week_of_year: The week of year to take the yearly backup in an ISO 8601 format. + :vartype week_of_year: int + """ + + time_based_immutability: Optional[Union[str, "_models.TimeBasedImmutability"]] = rest_field( + name="timeBasedImmutability", visibility=["read", "create", "update", "delete", "query"] + ) + """The setting for whether to enable time-based immutability for future backups. When set, future + backups will have TimeBasedImmutability enabled. Known values are: \"Enabled\" and + \"Disabled\".""" + time_based_immutability_mode: Optional[Union[str, "_models.TimeBasedImmutabilityMode"]] = rest_field( + name="timeBasedImmutabilityMode", visibility=["read", "create", "update", "delete", "query"] + ) + """The setting for time-based immutability mode for future backup (Value can be either Locked or + UnLocked. Only effective if TimeBasedImmutability is enabled). Caution: Immutability of LTR + backup cannot be removed if TimeBasedImmutabilityMode is Locked. Known values are: \"Locked\" + and \"Unlocked\".""" + weekly_retention: Optional[str] = rest_field( + name="weeklyRetention", visibility=["read", "create", "update", "delete", "query"] + ) + """The weekly retention policy for an LTR backup in an ISO 8601 format.""" + monthly_retention: Optional[str] = rest_field( + name="monthlyRetention", visibility=["read", "create", "update", "delete", "query"] + ) + """The monthly retention policy for an LTR backup in an ISO 8601 format.""" + yearly_retention: Optional[str] = rest_field( + name="yearlyRetention", visibility=["read", "create", "update", "delete", "query"] + ) + """The yearly retention policy for an LTR backup in an ISO 8601 format.""" + week_of_year: Optional[int] = rest_field( + name="weekOfYear", visibility=["read", "create", "update", "delete", "query"] + ) + """The week of year to take the yearly backup in an ISO 8601 format.""" + + @overload + def __init__( + self, + *, + time_based_immutability: Optional[Union[str, "_models.TimeBasedImmutability"]] = None, + time_based_immutability_mode: Optional[Union[str, "_models.TimeBasedImmutabilityMode"]] = None, + weekly_retention: Optional[str] = None, + monthly_retention: Optional[str] = None, + yearly_retention: Optional[str] = None, + week_of_year: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MaintenanceConfigurationCapability(_Model): + """The maintenance configuration capability. + + :ivar name: Maintenance configuration name. + :vartype name: str + :ivar zone_redundant: Whether or not zone redundancy is supported for the maintenance + configuration. + :vartype zone_redundant: bool + :ivar status: The status of the capability. 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 + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """Maintenance configuration name.""" + zone_redundant: Optional[bool] = rest_field(name="zoneRedundant", visibility=["read"]) + """Whether or not zone redundancy is supported for the maintenance configuration.""" + status: Optional[Union[str, "_models.CapabilityStatus"]] = rest_field(visibility=["read"]) + """The status of the capability. Known values are: \"Visible\", \"Available\", \"Default\", and + \"Disabled\".""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for the capability not being available.""" + + @overload + def __init__( + self, + *, + reason: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MaintenanceWindowOptions(ProxyResource): + """Maintenance window options. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.MaintenanceWindowOptionsProperties + """ + + properties: Optional["_models.MaintenanceWindowOptionsProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "is_enabled", + "maintenance_window_cycles", + "min_duration_in_minutes", + "default_duration_in_minutes", + "min_cycles", + "time_granularity_in_minutes", + "allow_multiple_maintenance_windows_per_cycle", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.MaintenanceWindowOptionsProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class MaintenanceWindowOptionsProperties(_Model): + """Maintenance window options properties. + + :ivar is_enabled: Whether maintenance windows are enabled for the database. + :vartype is_enabled: bool + :ivar maintenance_window_cycles: Available maintenance cycles e.g. {Saturday, 0, 48*60}, + {Wednesday, 0, 24*60}. + :vartype maintenance_window_cycles: list[~azure.mgmt.sql.models.MaintenanceWindowTimeRange] + :ivar min_duration_in_minutes: Minimum duration of maintenance window. + :vartype min_duration_in_minutes: int + :ivar default_duration_in_minutes: Default duration for maintenance window. + :vartype default_duration_in_minutes: int + :ivar min_cycles: Minimum number of maintenance windows cycles to be set on the database. + :vartype min_cycles: int + :ivar time_granularity_in_minutes: Time granularity in minutes for maintenance windows. + :vartype time_granularity_in_minutes: int + :ivar allow_multiple_maintenance_windows_per_cycle: Whether we allow multiple maintenance + windows per cycle. + :vartype allow_multiple_maintenance_windows_per_cycle: bool + """ + + is_enabled: Optional[bool] = rest_field( + name="isEnabled", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether maintenance windows are enabled for the database.""" + maintenance_window_cycles: Optional[list["_models.MaintenanceWindowTimeRange"]] = rest_field( + name="maintenanceWindowCycles", visibility=["read", "create", "update", "delete", "query"] + ) + """Available maintenance cycles e.g. {Saturday, 0, 48*60}, {Wednesday, 0, 24*60}.""" + min_duration_in_minutes: Optional[int] = rest_field( + name="minDurationInMinutes", visibility=["read", "create", "update", "delete", "query"] + ) + """Minimum duration of maintenance window.""" + default_duration_in_minutes: Optional[int] = rest_field( + name="defaultDurationInMinutes", visibility=["read", "create", "update", "delete", "query"] + ) + """Default duration for maintenance window.""" + min_cycles: Optional[int] = rest_field(name="minCycles", visibility=["read", "create", "update", "delete", "query"]) + """Minimum number of maintenance windows cycles to be set on the database.""" + time_granularity_in_minutes: Optional[int] = rest_field( + name="timeGranularityInMinutes", visibility=["read", "create", "update", "delete", "query"] + ) + """Time granularity in minutes for maintenance windows.""" + allow_multiple_maintenance_windows_per_cycle: Optional[bool] = rest_field( + name="allowMultipleMaintenanceWindowsPerCycle", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether we allow multiple maintenance windows per cycle.""" + + @overload + def __init__( + self, + *, + is_enabled: Optional[bool] = None, + maintenance_window_cycles: Optional[list["_models.MaintenanceWindowTimeRange"]] = None, + min_duration_in_minutes: Optional[int] = None, + default_duration_in_minutes: Optional[int] = None, + min_cycles: Optional[int] = None, + time_granularity_in_minutes: Optional[int] = None, + allow_multiple_maintenance_windows_per_cycle: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MaintenanceWindows(ProxyResource): + """Maintenance windows. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.MaintenanceWindowsProperties + """ + + properties: Optional["_models.MaintenanceWindowsProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["time_ranges"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.MaintenanceWindowsProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class MaintenanceWindowsProperties(_Model): + """Maintenance windows resource properties. + + :ivar time_ranges: + :vartype time_ranges: list[~azure.mgmt.sql.models.MaintenanceWindowTimeRange] + """ + + time_ranges: Optional[list["_models.MaintenanceWindowTimeRange"]] = rest_field( + name="timeRanges", visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + time_ranges: Optional[list["_models.MaintenanceWindowTimeRange"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MaintenanceWindowTimeRange(_Model): + """Maintenance window time range. + + :ivar day_of_week: Day of maintenance window. Known values are: "Sunday", "Monday", "Tuesday", + "Wednesday", "Thursday", "Friday", and "Saturday". + :vartype day_of_week: str or ~azure.mgmt.sql.models.DayOfWeek + :ivar start_time: Start time minutes offset from 12am. + :vartype start_time: str + :ivar duration: Duration of maintenance window in minutes. + :vartype duration: str + """ + + day_of_week: Optional[Union[str, "_models.DayOfWeek"]] = rest_field( + name="dayOfWeek", visibility=["read", "create", "update", "delete", "query"] + ) + """Day of maintenance window. Known values are: \"Sunday\", \"Monday\", \"Tuesday\", + \"Wednesday\", \"Thursday\", \"Friday\", and \"Saturday\".""" + start_time: Optional[str] = rest_field(name="startTime", visibility=["read", "create", "update", "delete", "query"]) + """Start time minutes offset from 12am.""" + duration: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Duration of maintenance window in minutes.""" + + @overload + def __init__( + self, + *, + day_of_week: Optional[Union[str, "_models.DayOfWeek"]] = None, + start_time: Optional[str] = None, + duration: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedBackupShortTermRetentionPolicy(ProxyResource): + """A short term retention policy. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicyProperties + """ + + properties: Optional["_models.ManagedBackupShortTermRetentionPolicyProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["retention_days"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ManagedBackupShortTermRetentionPolicyProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ManagedBackupShortTermRetentionPolicyProperties(_Model): # pylint: disable=name-too-long + """Properties of a short term retention policy. + + :ivar retention_days: The backup retention period in days. This is how many days Point-in-Time + Restore will be supported. + :vartype retention_days: int + """ + + retention_days: Optional[int] = rest_field( + name="retentionDays", visibility=["read", "create", "update", "delete", "query"] + ) + """The backup retention period in days. This is how many days Point-in-Time Restore will be + supported.""" + + @overload + def __init__( + self, + *, + retention_days: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedDatabase(TrackedResource): + """A managed database resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ManagedDatabaseProperties + """ + + properties: Optional["_models.ManagedDatabaseProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "collation", + "status", + "creation_date", + "earliest_restore_point", + "restore_point_in_time", + "default_secondary_location", + "catalog_collation", + "create_mode", + "storage_container_uri", + "source_database_id", + "cross_subscription_source_database_id", + "restorable_dropped_database_id", + "cross_subscription_restorable_dropped_database_id", + "storage_container_identity", + "storage_container_sas_token", + "failover_group_id", + "recoverable_database_id", + "long_term_retention_backup_resource_id", + "auto_complete_restore", + "last_backup_name", + "cross_subscription_target_managed_instance_id", + "is_ledger_on", + "extended_accessibility_info", + ] + + @overload + def __init__( + self, + *, + location: str, + tags: Optional[dict[str, str]] = None, + properties: Optional["_models.ManagedDatabaseProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ManagedDatabaseAdvancedThreatProtection(ProxyResource): + """A managed database Advanced Threat Protection. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.AdvancedThreatProtectionProperties + """ + + properties: Optional["_models.AdvancedThreatProtectionProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["state", "creation_time"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.AdvancedThreatProtectionProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ManagedDatabaseExtendedAccessibilityInfo(_Model): + """Managed Database Extended Accessibility Information. + + :ivar inaccessibility_reason_error_code: SQL Server error code connected to the inaccessibility + root cause. Required. + :vartype inaccessibility_reason_error_code: str + :ivar inaccessibility_reason_description: Root cause explanation and mitigation action. + Required. + :vartype inaccessibility_reason_description: str + :ivar inaccessibility_reason_kind: Root cause kind. Allowed values are + “TransparentDataEncryption”, “DatabaseReplication”, and “Unknown”. Required. Known values are: + "Unknown", "TransparentDataEncryption", and "DatabaseReplication". + :vartype inaccessibility_reason_kind: str or ~azure.mgmt.sql.models.InaccessibilityReason + :ivar inaccessibility_reason_tde_key_uri: For the root cause kind “TransparentDataEncryption”, + the CMK URI. + :vartype inaccessibility_reason_tde_key_uri: str + """ + + inaccessibility_reason_error_code: str = rest_field(name="inaccessibilityReasonErrorCode", visibility=["read"]) + """SQL Server error code connected to the inaccessibility root cause. Required.""" + inaccessibility_reason_description: str = rest_field(name="inaccessibilityReasonDescription", visibility=["read"]) + """Root cause explanation and mitigation action. Required.""" + inaccessibility_reason_kind: Union[str, "_models.InaccessibilityReason"] = rest_field( + name="inaccessibilityReasonKind", visibility=["read"] + ) + """Root cause kind. Allowed values are “TransparentDataEncryption”, “DatabaseReplication”, and + “Unknown”. Required. Known values are: \"Unknown\", \"TransparentDataEncryption\", and + \"DatabaseReplication\".""" + inaccessibility_reason_tde_key_uri: Optional[str] = rest_field( + name="inaccessibilityReasonTdeKeyUri", visibility=["read"] + ) + """For the root cause kind “TransparentDataEncryption”, the CMK URI.""" + + +class ManagedDatabaseMoveDefinition(_Model): + """Contains the information necessary to perform a managed database move. + + :ivar destination_managed_database_id: The destination managed database ID. Required. + :vartype destination_managed_database_id: str + """ + + destination_managed_database_id: str = rest_field( + name="destinationManagedDatabaseId", visibility=["read", "create", "update", "delete", "query"] + ) + """The destination managed database ID. Required.""" + + @overload + def __init__( + self, + *, + destination_managed_database_id: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedDatabaseMoveOperationResult(ProxyResource): + """A managed database move operation. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ManagedDatabaseMoveOperationResultProperties + """ + + properties: Optional["_models.ManagedDatabaseMoveOperationResultProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "operation", + "operation_friendly_name", + "start_time", + "state", + "operation_mode", + "source_managed_instance_name", + "target_managed_instance_name", + "source_managed_instance_id", + "target_managed_instance_id", + "source_database_name", + "target_database_name", + "is_cancellable", + "error_code", + "error_description", + "error_severity", + "is_user_error", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ManagedDatabaseMoveOperationResultProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ManagedDatabaseMoveOperationResultProperties(_Model): # pylint: disable=name-too-long + """Contains the operation result properties for managed database move operation. + + :ivar operation: The name of operation. + :vartype operation: str + :ivar operation_friendly_name: The friendly name of operation. + :vartype operation_friendly_name: str + :ivar start_time: The operation start time. + :vartype start_time: ~datetime.datetime + :ivar state: The operation state. Known values are: "Pending", "InProgress", "Succeeded", + "Failed", "CancelInProgress", and "Cancelled". + :vartype state: str or ~azure.mgmt.sql.models.ManagementOperationState + :ivar operation_mode: Operation mode. Known values are: "Move" and "Copy". + :vartype operation_mode: str or ~azure.mgmt.sql.models.MoveOperationMode + :ivar source_managed_instance_name: Source Managed Instance name. + :vartype source_managed_instance_name: str + :ivar target_managed_instance_name: Target Managed Instance name. + :vartype target_managed_instance_name: str + :ivar source_managed_instance_id: Source Managed Instance resource id. + :vartype source_managed_instance_id: str + :ivar target_managed_instance_id: Target Managed instance resource id. + :vartype target_managed_instance_id: str + :ivar source_database_name: Source database name. + :vartype source_database_name: str + :ivar target_database_name: Target database name. + :vartype target_database_name: str + :ivar is_cancellable: Is move operation cancellable. + :vartype is_cancellable: bool + :ivar error_code: The operation error code. + :vartype error_code: int + :ivar error_description: The operation error description. + :vartype error_description: str + :ivar error_severity: The operation error severity. + :vartype error_severity: int + :ivar is_user_error: Whether or not the error is a user error. + :vartype is_user_error: bool + """ + + operation: Optional[str] = rest_field(visibility=["read"]) + """The name of operation.""" + operation_friendly_name: Optional[str] = rest_field(name="operationFriendlyName", visibility=["read"]) + """The friendly name of operation.""" + start_time: Optional[datetime.datetime] = rest_field(name="startTime", visibility=["read"], format="rfc3339") + """The operation start time.""" + state: Optional[Union[str, "_models.ManagementOperationState"]] = rest_field(visibility=["read"]) + """The operation state. Known values are: \"Pending\", \"InProgress\", \"Succeeded\", \"Failed\", + \"CancelInProgress\", and \"Cancelled\".""" + operation_mode: Optional[Union[str, "_models.MoveOperationMode"]] = rest_field( + name="operationMode", visibility=["read"] + ) + """Operation mode. Known values are: \"Move\" and \"Copy\".""" + source_managed_instance_name: Optional[str] = rest_field(name="sourceManagedInstanceName", visibility=["read"]) + """Source Managed Instance name.""" + target_managed_instance_name: Optional[str] = rest_field(name="targetManagedInstanceName", visibility=["read"]) + """Target Managed Instance name.""" + source_managed_instance_id: Optional[str] = rest_field(name="sourceManagedInstanceId", visibility=["read"]) + """Source Managed Instance resource id.""" + target_managed_instance_id: Optional[str] = rest_field(name="targetManagedInstanceId", visibility=["read"]) + """Target Managed instance resource id.""" + source_database_name: Optional[str] = rest_field(name="sourceDatabaseName", visibility=["read"]) + """Source database name.""" + target_database_name: Optional[str] = rest_field(name="targetDatabaseName", visibility=["read"]) + """Target database name.""" + is_cancellable: Optional[bool] = rest_field(name="isCancellable", visibility=["read"]) + """Is move operation cancellable.""" + error_code: Optional[int] = rest_field(name="errorCode", visibility=["read"]) + """The operation error code.""" + error_description: Optional[str] = rest_field(name="errorDescription", visibility=["read"]) + """The operation error description.""" + error_severity: Optional[int] = rest_field(name="errorSeverity", visibility=["read"]) + """The operation error severity.""" + is_user_error: Optional[bool] = rest_field(name="isUserError", visibility=["read"]) + """Whether or not the error is a user error.""" + + +class ManagedDatabaseProperties(_Model): + """The managed database's properties. + + :ivar collation: Collation of the managed database. + :vartype collation: str + :ivar status: Status of the database. Known values are: "Online", "Offline", "Shutdown", + "Creating", "Inaccessible", "Restoring", "Updating", "Stopping", "Stopped", "Starting", + "DbMoving", and "DbCopying". + :vartype status: str or ~azure.mgmt.sql.models.ManagedDatabaseStatus + :ivar creation_date: Creation date of the database. + :vartype creation_date: ~datetime.datetime + :ivar earliest_restore_point: Earliest restore point in time for point in time restore. + :vartype earliest_restore_point: ~datetime.datetime + :ivar restore_point_in_time: Conditional. If createMode is PointInTimeRestore, this value is + required. Specifies the point in time (ISO8601 format) of the source database that will be + restored to create the new database. + :vartype restore_point_in_time: ~datetime.datetime + :ivar default_secondary_location: Geo paired region. + :vartype default_secondary_location: str + :ivar catalog_collation: Collation of the metadata catalog. Known values are: + "DATABASE_DEFAULT" and "SQL_Latin1_General_CP1_CI_AS". + :vartype catalog_collation: str or ~azure.mgmt.sql.models.CatalogCollationType + :ivar create_mode: Managed database create mode. PointInTimeRestore: Create a database by + restoring a point in time backup of an existing database. SourceDatabaseName, + SourceManagedInstanceName and PointInTime must be specified. RestoreExternalBackup: Create a + database by restoring from external backup files. Collation, StorageContainerUri and + StorageContainerSasToken must be specified. Recovery: Creates a database by restoring a + geo-replicated backup. RecoverableDatabaseId must be specified as the recoverable database + resource ID to restore. RestoreLongTermRetentionBackup: Create a database by restoring from a + long term retention backup (longTermRetentionBackupResourceId required). Known values are: + "Default", "RestoreExternalBackup", "PointInTimeRestore", "Recovery", and + "RestoreLongTermRetentionBackup". + :vartype create_mode: str or ~azure.mgmt.sql.models.ManagedDatabaseCreateMode + :ivar storage_container_uri: Conditional. If createMode is RestoreExternalBackup, this value is + required. Specifies the uri of the storage container where backups for this restore are stored. + :vartype storage_container_uri: str + :ivar source_database_id: The resource identifier of the source database associated with create + operation of this database. + :vartype source_database_id: str + :ivar cross_subscription_source_database_id: The resource identifier of the cross-subscription + source database associated with create operation of this database. + :vartype cross_subscription_source_database_id: str + :ivar restorable_dropped_database_id: The restorable dropped database resource id to restore + when creating this database. + :vartype restorable_dropped_database_id: str + :ivar cross_subscription_restorable_dropped_database_id: The restorable cross-subscription + dropped database resource id to restore when creating this database. + :vartype cross_subscription_restorable_dropped_database_id: str + :ivar storage_container_identity: Conditional. If createMode is RestoreExternalBackup, this + value is used. Specifies the identity used for storage container authentication. Can be + 'SharedAccessSignature' or 'ManagedIdentity'; if not specified 'SharedAccessSignature' is + assumed. + :vartype storage_container_identity: str + :ivar storage_container_sas_token: Conditional. If createMode is RestoreExternalBackup and + storageContainerIdentity is not ManagedIdentity, this value is required. Specifies the storage + container sas token. + :vartype storage_container_sas_token: str + :ivar failover_group_id: Instance Failover Group resource identifier that this managed database + belongs to. + :vartype failover_group_id: str + :ivar recoverable_database_id: The resource identifier of the recoverable database associated + with create operation of this database. + :vartype recoverable_database_id: str + :ivar long_term_retention_backup_resource_id: The name of the Long Term Retention backup to be + used for restore of this managed database. + :vartype long_term_retention_backup_resource_id: str + :ivar auto_complete_restore: Whether to auto complete restore of this managed database. + :vartype auto_complete_restore: bool + :ivar last_backup_name: Last backup file name for restore of this managed database. + :vartype last_backup_name: str + :ivar cross_subscription_target_managed_instance_id: Target managed instance id used in + cross-subscription restore. + :vartype cross_subscription_target_managed_instance_id: str + :ivar is_ledger_on: Whether or not this database is a ledger database, which means all tables + in the database are ledger tables. Note: the value of this property cannot be changed after the + database has been created. + :vartype is_ledger_on: bool + :ivar extended_accessibility_info: Additional observability and troubleshooting information for + databases in ‘Inaccessible’ state. + :vartype extended_accessibility_info: + ~azure.mgmt.sql.models.ManagedDatabaseExtendedAccessibilityInfo + """ + + collation: Optional[str] = rest_field(visibility=["read", "create"]) + """Collation of the managed database.""" + status: Optional[Union[str, "_models.ManagedDatabaseStatus"]] = rest_field(visibility=["read"]) + """Status of the database. Known values are: \"Online\", \"Offline\", \"Shutdown\", \"Creating\", + \"Inaccessible\", \"Restoring\", \"Updating\", \"Stopping\", \"Stopped\", \"Starting\", + \"DbMoving\", and \"DbCopying\".""" + creation_date: Optional[datetime.datetime] = rest_field(name="creationDate", visibility=["read"], format="rfc3339") + """Creation date of the database.""" + earliest_restore_point: Optional[datetime.datetime] = rest_field( + name="earliestRestorePoint", visibility=["read"], format="rfc3339" + ) + """Earliest restore point in time for point in time restore.""" + restore_point_in_time: Optional[datetime.datetime] = rest_field( + name="restorePointInTime", visibility=["create"], format="rfc3339" + ) + """Conditional. If createMode is PointInTimeRestore, this value is required. Specifies the point + in time (ISO8601 format) of the source database that will be restored to create the new + database.""" + default_secondary_location: Optional[str] = rest_field(name="defaultSecondaryLocation", visibility=["read"]) + """Geo paired region.""" + catalog_collation: Optional[Union[str, "_models.CatalogCollationType"]] = rest_field( + name="catalogCollation", visibility=["read", "create"] + ) + """Collation of the metadata catalog. Known values are: \"DATABASE_DEFAULT\" and + \"SQL_Latin1_General_CP1_CI_AS\".""" + create_mode: Optional[Union[str, "_models.ManagedDatabaseCreateMode"]] = rest_field( + name="createMode", visibility=["create"] + ) + """Managed database create mode. PointInTimeRestore: Create a database by restoring a point in + time backup of an existing database. SourceDatabaseName, SourceManagedInstanceName and + PointInTime must be specified. RestoreExternalBackup: Create a database by restoring from + external backup files. Collation, StorageContainerUri and StorageContainerSasToken must be + specified. Recovery: Creates a database by restoring a geo-replicated backup. + RecoverableDatabaseId must be specified as the recoverable database resource ID to restore. + RestoreLongTermRetentionBackup: Create a database by restoring from a long term retention + backup (longTermRetentionBackupResourceId required). Known values are: \"Default\", + \"RestoreExternalBackup\", \"PointInTimeRestore\", \"Recovery\", and + \"RestoreLongTermRetentionBackup\".""" + storage_container_uri: Optional[str] = rest_field(name="storageContainerUri", visibility=["create"]) + """Conditional. If createMode is RestoreExternalBackup, this value is required. Specifies the uri + of the storage container where backups for this restore are stored.""" + source_database_id: Optional[str] = rest_field(name="sourceDatabaseId", visibility=["create"]) + """The resource identifier of the source database associated with create operation of this + database.""" + cross_subscription_source_database_id: Optional[str] = rest_field( + name="crossSubscriptionSourceDatabaseId", visibility=["create"] + ) + """The resource identifier of the cross-subscription source database associated with create + operation of this database.""" + restorable_dropped_database_id: Optional[str] = rest_field( + name="restorableDroppedDatabaseId", visibility=["create"] + ) + """The restorable dropped database resource id to restore when creating this database.""" + cross_subscription_restorable_dropped_database_id: Optional[str] = rest_field( + name="crossSubscriptionRestorableDroppedDatabaseId", visibility=["create"] + ) + """The restorable cross-subscription dropped database resource id to restore when creating this + database.""" + storage_container_identity: Optional[str] = rest_field(name="storageContainerIdentity", visibility=["create"]) + """Conditional. If createMode is RestoreExternalBackup, this value is used. Specifies the identity + used for storage container authentication. Can be 'SharedAccessSignature' or 'ManagedIdentity'; + if not specified 'SharedAccessSignature' is assumed.""" + storage_container_sas_token: Optional[str] = rest_field(name="storageContainerSasToken", visibility=["create"]) + """Conditional. If createMode is RestoreExternalBackup and storageContainerIdentity is not + ManagedIdentity, this value is required. Specifies the storage container sas token.""" + failover_group_id: Optional[str] = rest_field(name="failoverGroupId", visibility=["read"]) + """Instance Failover Group resource identifier that this managed database belongs to.""" + recoverable_database_id: Optional[str] = rest_field(name="recoverableDatabaseId", visibility=["create"]) + """The resource identifier of the recoverable database associated with create operation of this + database.""" + long_term_retention_backup_resource_id: Optional[str] = rest_field( + name="longTermRetentionBackupResourceId", visibility=["create"] + ) + """The name of the Long Term Retention backup to be used for restore of this managed database.""" + auto_complete_restore: Optional[bool] = rest_field(name="autoCompleteRestore", visibility=["create"]) + """Whether to auto complete restore of this managed database.""" + last_backup_name: Optional[str] = rest_field(name="lastBackupName", visibility=["create"]) + """Last backup file name for restore of this managed database.""" + cross_subscription_target_managed_instance_id: Optional[str] = rest_field( + name="crossSubscriptionTargetManagedInstanceId", visibility=["create"] + ) + """Target managed instance id used in cross-subscription restore.""" + is_ledger_on: Optional[bool] = rest_field(name="isLedgerOn", visibility=["read", "create"]) + """Whether or not this database is a ledger database, which means all tables in the database are + ledger tables. Note: the value of this property cannot be changed after the database has been + created.""" + extended_accessibility_info: Optional["_models.ManagedDatabaseExtendedAccessibilityInfo"] = rest_field( + name="extendedAccessibilityInfo", visibility=["read"] + ) + """Additional observability and troubleshooting information for databases in ‘Inaccessible’ state.""" + + @overload + def __init__( + self, + *, + collation: Optional[str] = None, + restore_point_in_time: Optional[datetime.datetime] = None, + catalog_collation: Optional[Union[str, "_models.CatalogCollationType"]] = None, + create_mode: Optional[Union[str, "_models.ManagedDatabaseCreateMode"]] = None, + storage_container_uri: Optional[str] = None, + source_database_id: Optional[str] = None, + cross_subscription_source_database_id: Optional[str] = None, + restorable_dropped_database_id: Optional[str] = None, + cross_subscription_restorable_dropped_database_id: Optional[str] = None, + storage_container_identity: Optional[str] = None, + storage_container_sas_token: Optional[str] = None, + recoverable_database_id: Optional[str] = None, + long_term_retention_backup_resource_id: Optional[str] = None, + auto_complete_restore: Optional[bool] = None, + last_backup_name: Optional[str] = None, + cross_subscription_target_managed_instance_id: Optional[str] = None, + is_ledger_on: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedDatabaseRestoreDetailsBackupSetProperties(_Model): # pylint: disable=name-too-long + """The managed database's restore details backup set properties. + + :ivar status: Backup set status. + :vartype status: str + :ivar first_stripe_name: First stripe name. + :vartype first_stripe_name: str + :ivar number_of_stripes: Number of stripes. + :vartype number_of_stripes: int + :ivar backup_size_mb: Backup size. + :vartype backup_size_mb: int + :ivar restore_started_timestamp_utc: Last restored file time. + :vartype restore_started_timestamp_utc: ~datetime.datetime + :ivar restore_finished_timestamp_utc: Last restored file time. + :vartype restore_finished_timestamp_utc: ~datetime.datetime + """ + + status: Optional[str] = rest_field(visibility=["read"]) + """Backup set status.""" + first_stripe_name: Optional[str] = rest_field(name="firstStripeName", visibility=["read"]) + """First stripe name.""" + number_of_stripes: Optional[int] = rest_field(name="numberOfStripes", visibility=["read"]) + """Number of stripes.""" + backup_size_mb: Optional[int] = rest_field(name="backupSizeMB", visibility=["read"]) + """Backup size.""" + restore_started_timestamp_utc: Optional[datetime.datetime] = rest_field( + name="restoreStartedTimestampUtc", visibility=["read"], format="rfc3339" + ) + """Last restored file time.""" + restore_finished_timestamp_utc: Optional[datetime.datetime] = rest_field( + name="restoreFinishedTimestampUtc", visibility=["read"], format="rfc3339" + ) + """Last restored file time.""" + + +class ManagedDatabaseRestoreDetailsProperties(_Model): + """The managed database's restore details properties. + + :ivar type: Restore type. + :vartype type: str + :ivar status: Restore status. + :vartype status: str + :ivar block_reason: The reason why restore is in Blocked state. + :vartype block_reason: str + :ivar last_uploaded_file_name: Last uploaded file name. + :vartype last_uploaded_file_name: str + :ivar last_uploaded_file_time: Last uploaded file time. + :vartype last_uploaded_file_time: ~datetime.datetime + :ivar last_restored_file_name: Last restored file name. + :vartype last_restored_file_name: str + :ivar last_restored_file_time: Last restored file time. + :vartype last_restored_file_time: ~datetime.datetime + :ivar percent_completed: Percent completed. + :vartype percent_completed: int + :ivar current_restored_size_mb: Current restored size MB. + :vartype current_restored_size_mb: int + :ivar current_restore_plan_size_mb: Current restore plan size MB. + :vartype current_restore_plan_size_mb: int + :ivar current_backup_type: Current backup type. + :vartype current_backup_type: str + :ivar current_restoring_file_name: Current restoring file name. + :vartype current_restoring_file_name: str + :ivar number_of_files_detected: Number of files detected. + :vartype number_of_files_detected: int + :ivar number_of_files_queued: Number of files queued. + :vartype number_of_files_queued: int + :ivar number_of_files_skipped: Number of files skipped. + :vartype number_of_files_skipped: int + :ivar number_of_files_restoring: Number of files restoring. + :vartype number_of_files_restoring: int + :ivar number_of_files_restored: Number of files restored. + :vartype number_of_files_restored: int + :ivar number_of_files_unrestorable: Number of files unrestorable. + :vartype number_of_files_unrestorable: int + :ivar full_backup_sets: Full backup sets. + :vartype full_backup_sets: + list[~azure.mgmt.sql.models.ManagedDatabaseRestoreDetailsBackupSetProperties] + :ivar diff_backup_sets: Diff backup sets. + :vartype diff_backup_sets: + list[~azure.mgmt.sql.models.ManagedDatabaseRestoreDetailsBackupSetProperties] + :ivar log_backup_sets: Log backup sets. + :vartype log_backup_sets: + list[~azure.mgmt.sql.models.ManagedDatabaseRestoreDetailsBackupSetProperties] + :ivar unrestorable_files: Unrestorable files. + :vartype unrestorable_files: + list[~azure.mgmt.sql.models.ManagedDatabaseRestoreDetailsUnrestorableFileProperties] + """ + + type: Optional[str] = rest_field(visibility=["read"]) + """Restore type.""" + status: Optional[str] = rest_field(visibility=["read"]) + """Restore status.""" + block_reason: Optional[str] = rest_field(name="blockReason", visibility=["read"]) + """The reason why restore is in Blocked state.""" + last_uploaded_file_name: Optional[str] = rest_field(name="lastUploadedFileName", visibility=["read"]) + """Last uploaded file name.""" + last_uploaded_file_time: Optional[datetime.datetime] = rest_field( + name="lastUploadedFileTime", visibility=["read"], format="rfc3339" + ) + """Last uploaded file time.""" + last_restored_file_name: Optional[str] = rest_field(name="lastRestoredFileName", visibility=["read"]) + """Last restored file name.""" + last_restored_file_time: Optional[datetime.datetime] = rest_field( + name="lastRestoredFileTime", visibility=["read"], format="rfc3339" + ) + """Last restored file time.""" + percent_completed: Optional[int] = rest_field(name="percentCompleted", visibility=["read"]) + """Percent completed.""" + current_restored_size_mb: Optional[int] = rest_field(name="currentRestoredSizeMB", visibility=["read"]) + """Current restored size MB.""" + current_restore_plan_size_mb: Optional[int] = rest_field(name="currentRestorePlanSizeMB", visibility=["read"]) + """Current restore plan size MB.""" + current_backup_type: Optional[str] = rest_field(name="currentBackupType", visibility=["read"]) + """Current backup type.""" + current_restoring_file_name: Optional[str] = rest_field(name="currentRestoringFileName", visibility=["read"]) + """Current restoring file name.""" + number_of_files_detected: Optional[int] = rest_field(name="numberOfFilesDetected", visibility=["read"]) + """Number of files detected.""" + number_of_files_queued: Optional[int] = rest_field(name="numberOfFilesQueued", visibility=["read"]) + """Number of files queued.""" + number_of_files_skipped: Optional[int] = rest_field(name="numberOfFilesSkipped", visibility=["read"]) + """Number of files skipped.""" + number_of_files_restoring: Optional[int] = rest_field(name="numberOfFilesRestoring", visibility=["read"]) + """Number of files restoring.""" + number_of_files_restored: Optional[int] = rest_field(name="numberOfFilesRestored", visibility=["read"]) + """Number of files restored.""" + number_of_files_unrestorable: Optional[int] = rest_field(name="numberOfFilesUnrestorable", visibility=["read"]) + """Number of files unrestorable.""" + full_backup_sets: Optional[list["_models.ManagedDatabaseRestoreDetailsBackupSetProperties"]] = rest_field( + name="fullBackupSets", visibility=["read"] + ) + """Full backup sets.""" + diff_backup_sets: Optional[list["_models.ManagedDatabaseRestoreDetailsBackupSetProperties"]] = rest_field( + name="diffBackupSets", visibility=["read"] + ) + """Diff backup sets.""" + log_backup_sets: Optional[list["_models.ManagedDatabaseRestoreDetailsBackupSetProperties"]] = rest_field( + name="logBackupSets", visibility=["read"] + ) + """Log backup sets.""" + unrestorable_files: Optional[list["_models.ManagedDatabaseRestoreDetailsUnrestorableFileProperties"]] = rest_field( + name="unrestorableFiles", visibility=["read"] + ) + """Unrestorable files.""" + + +class ManagedDatabaseRestoreDetailsResult(ProxyResource): + """A managed database restore details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ManagedDatabaseRestoreDetailsProperties + """ + + properties: Optional["_models.ManagedDatabaseRestoreDetailsProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "type", + "status", + "block_reason", + "last_uploaded_file_name", + "last_uploaded_file_time", + "last_restored_file_name", + "last_restored_file_time", + "percent_completed", + "current_restored_size_mb", + "current_restore_plan_size_mb", + "current_backup_type", + "current_restoring_file_name", + "number_of_files_detected", + "number_of_files_queued", + "number_of_files_skipped", + "number_of_files_restoring", + "number_of_files_restored", + "number_of_files_unrestorable", + "full_backup_sets", + "diff_backup_sets", + "log_backup_sets", + "unrestorable_files", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ManagedDatabaseRestoreDetailsProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ManagedDatabaseRestoreDetailsUnrestorableFileProperties(_Model): # pylint: disable=name-too-long + """The managed database's restore details unrestorable file properties. + + :ivar name: File name. + :vartype name: str + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """File name.""" + + +class ManagedDatabaseSecurityAlertPolicy(ProxyResource): + """A managed database security alert policy. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.SecurityAlertPolicyProperties + """ + + properties: Optional["_models.SecurityAlertPolicyProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "state", + "disabled_alerts", + "email_addresses", + "email_account_admins", + "storage_endpoint", + "storage_account_access_key", + "retention_days", + "creation_time", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.SecurityAlertPolicyProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ManagedDatabaseStartMoveDefinition(_Model): + """Contains the information necessary to start a managed database move. + + :ivar destination_managed_database_id: The destination managed database ID. Required. + :vartype destination_managed_database_id: str + :ivar operation_mode: The move operation mode. Known values are: "Move" and "Copy". + :vartype operation_mode: str or ~azure.mgmt.sql.models.MoveOperationMode + """ + + destination_managed_database_id: str = rest_field( + name="destinationManagedDatabaseId", visibility=["read", "create", "update", "delete", "query"] + ) + """The destination managed database ID. Required.""" + operation_mode: Optional[Union[str, "_models.MoveOperationMode"]] = rest_field( + name="operationMode", visibility=["read", "create", "update", "delete", "query"] + ) + """The move operation mode. Known values are: \"Move\" and \"Copy\".""" + + @overload + def __init__( + self, + *, + destination_managed_database_id: str, + operation_mode: Optional[Union[str, "_models.MoveOperationMode"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedDatabaseUpdate(_Model): + """An managed database update. + + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ManagedDatabaseProperties + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + properties: Optional["_models.ManagedDatabaseProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource tags.""" + + __flattened_items = [ + "collation", + "status", + "creation_date", + "earliest_restore_point", + "restore_point_in_time", + "default_secondary_location", + "catalog_collation", + "create_mode", + "storage_container_uri", + "source_database_id", + "cross_subscription_source_database_id", + "restorable_dropped_database_id", + "cross_subscription_restorable_dropped_database_id", + "storage_container_identity", + "storage_container_sas_token", + "failover_group_id", + "recoverable_database_id", + "long_term_retention_backup_resource_id", + "auto_complete_restore", + "last_backup_name", + "cross_subscription_target_managed_instance_id", + "is_ledger_on", + "extended_accessibility_info", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ManagedDatabaseProperties"] = None, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ManagedInstance(TrackedResource): + """An Azure SQL managed instance. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ManagedInstanceProperties + :ivar identity: The Azure Active Directory identity of the managed instance. + :vartype identity: ~azure.mgmt.sql.models.ResourceIdentity + :ivar sku: Managed instance SKU. Allowed values for sku.name: GP_Gen5 (General Purpose, + Standard-series); GP_G8IM (General Purpose, Premium-series); GP_G8IH (General Purpose, + Premium-series memory optimized); BC_Gen5 (Business Critical, Standard-Series); BC_G8IM + (Business Critical, Premium-series); BC_G8IH (Business Critical, Premium-series memory + optimized). + :vartype sku: ~azure.mgmt.sql.models.Sku + """ + + properties: Optional["_models.ManagedInstanceProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + identity: Optional["_models.ResourceIdentity"] = rest_field(visibility=["read", "create"]) + """The Azure Active Directory identity of the managed instance.""" + sku: Optional["_models.Sku"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Managed instance SKU. Allowed values for sku.name: GP_Gen5 (General Purpose, Standard-series); + GP_G8IM (General Purpose, Premium-series); GP_G8IH (General Purpose, Premium-series memory + optimized); BC_Gen5 (Business Critical, Standard-Series); BC_G8IM (Business Critical, + Premium-series); BC_G8IH (Business Critical, Premium-series memory optimized).""" + + __flattened_items = [ + "provisioning_state", + "managed_instance_create_mode", + "fully_qualified_domain_name", + "is_general_purpose_v2", + "administrator_login", + "administrator_login_password", + "subnet_id", + "state", + "license_type", + "hybrid_secondary_usage", + "hybrid_secondary_usage_detected", + "v_cores", + "storage_size_in_gb", + "storage_i_ops", + "storage_throughput_m_bps", + "memory_size_in_gb", + "collation", + "dns_zone", + "dns_zone_partner", + "public_data_endpoint_enabled", + "source_managed_instance_id", + "restore_point_in_time", + "proxy_override", + "timezone_id", + "instance_pool_id", + "maintenance_configuration_id", + "private_endpoint_connections", + "minimal_tls_version", + "current_backup_storage_redundancy", + "requested_backup_storage_redundancy", + "zone_redundant", + "primary_user_assigned_identity_id", + "key_id", + "administrators", + "service_principal", + "virtual_cluster_id", + "external_governance_status", + "pricing_model", + "create_time", + "authentication_metadata", + "database_format", + "requested_logical_availability_zone", + ] + + @overload + def __init__( + self, + *, + location: str, + tags: Optional[dict[str, str]] = None, + properties: Optional["_models.ManagedInstanceProperties"] = None, + identity: Optional["_models.ResourceIdentity"] = None, + sku: Optional["_models.Sku"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ManagedInstanceAdministrator(ProxyResource): + """An Azure SQL managed instance administrator. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ManagedInstanceAdministratorProperties + """ + + properties: Optional["_models.ManagedInstanceAdministratorProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["administrator_type", "login", "sid", "tenant_id"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ManagedInstanceAdministratorProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ManagedInstanceAdministratorProperties(_Model): + """The properties of a managed instance administrator. + + :ivar administrator_type: Type of the managed instance administrator. Required. + "ActiveDirectory" + :vartype administrator_type: str or ~azure.mgmt.sql.models.ManagedInstanceAdministratorType + :ivar login: Login name of the managed instance administrator. Required. + :vartype login: str + :ivar sid: SID (object ID) of the managed instance administrator. Required. + :vartype sid: str + :ivar tenant_id: Tenant ID of the managed instance administrator. + :vartype tenant_id: str + """ + + administrator_type: Union[str, "_models.ManagedInstanceAdministratorType"] = rest_field( + name="administratorType", visibility=["read", "create", "update", "delete", "query"] + ) + """Type of the managed instance administrator. Required. \"ActiveDirectory\"""" + login: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Login name of the managed instance administrator. Required.""" + sid: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """SID (object ID) of the managed instance administrator. Required.""" + tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read", "create", "update", "delete", "query"]) + """Tenant ID of the managed instance administrator.""" + + @overload + def __init__( + self, + *, + administrator_type: Union[str, "_models.ManagedInstanceAdministratorType"], + login: str, + sid: str, + tenant_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedInstanceAdvancedThreatProtection(ProxyResource): + """A managed instance Advanced Threat Protection. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.AdvancedThreatProtectionProperties + """ + + properties: Optional["_models.AdvancedThreatProtectionProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["state", "creation_time"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.AdvancedThreatProtectionProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ManagedInstanceAzureADOnlyAuthentication(ProxyResource): + """Azure Active Directory only authentication. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthProperties + """ + + properties: Optional["_models.ManagedInstanceAzureADOnlyAuthProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["azure_ad_only_authentication"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ManagedInstanceAzureADOnlyAuthProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ManagedInstanceAzureADOnlyAuthProperties(_Model): + """Properties of a active directory only authentication for Managed Instance. + + :ivar azure_ad_only_authentication: Azure Active Directory only Authentication enabled. + Required. + :vartype azure_ad_only_authentication: bool + """ + + azure_ad_only_authentication: bool = rest_field( + name="azureADOnlyAuthentication", visibility=["read", "create", "update", "delete", "query"] + ) + """Azure Active Directory only Authentication enabled. Required.""" + + @overload + def __init__( + self, + *, + azure_ad_only_authentication: bool, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedInstanceDtc(ProxyResource): + """SQL Managed Instance DTC. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ManagedInstanceDtcProperties + """ + + properties: Optional["_models.ManagedInstanceDtcProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "dtc_enabled", + "security_settings", + "external_dns_suffix_search_list", + "dtc_host_name_dns_suffix", + "fqdn_enabled", + "provisioning_state", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ManagedInstanceDtcProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ManagedInstanceDtcProperties(_Model): + """The properties of managed instance DTC. + + :ivar dtc_enabled: Active status of managed instance DTC. + :vartype dtc_enabled: bool + :ivar security_settings: Security settings of managed instance DTC. + :vartype security_settings: ~azure.mgmt.sql.models.ManagedInstanceDtcSecuritySettings + :ivar external_dns_suffix_search_list: External dns suffix search list of managed instance DTC. + :vartype external_dns_suffix_search_list: list[str] + :ivar dtc_host_name_dns_suffix: Host name dns suffix of managed instance DTC. + :vartype dtc_host_name_dns_suffix: str + :ivar fqdn_enabled: Status of FQDN of managed instance DTC. Toggling this setting might trigger + a restart of the managed instance. + :vartype fqdn_enabled: bool + :ivar provisioning_state: Provisioning state of managed instance DTC. Known values are: + "Created", "InProgress", "Succeeded", "Failed", and "Canceled". + :vartype provisioning_state: str or ~azure.mgmt.sql.models.ProvisioningState + """ + + dtc_enabled: Optional[bool] = rest_field( + name="dtcEnabled", visibility=["read", "create", "update", "delete", "query"] + ) + """Active status of managed instance DTC.""" + security_settings: Optional["_models.ManagedInstanceDtcSecuritySettings"] = rest_field( + name="securitySettings", visibility=["read", "create", "update", "delete", "query"] + ) + """Security settings of managed instance DTC.""" + external_dns_suffix_search_list: Optional[list[str]] = rest_field( + name="externalDnsSuffixSearchList", visibility=["read", "create", "update", "delete", "query"] + ) + """External dns suffix search list of managed instance DTC.""" + dtc_host_name_dns_suffix: Optional[str] = rest_field(name="dtcHostNameDnsSuffix", visibility=["read"]) + """Host name dns suffix of managed instance DTC.""" + fqdn_enabled: Optional[bool] = rest_field( + name="fqdnEnabled", visibility=["read", "create", "update", "delete", "query"] + ) + """Status of FQDN of managed instance DTC. Toggling this setting might trigger a restart of the + managed instance.""" + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning state of managed instance DTC. Known values are: \"Created\", \"InProgress\", + \"Succeeded\", \"Failed\", and \"Canceled\".""" + + @overload + def __init__( + self, + *, + dtc_enabled: Optional[bool] = None, + security_settings: Optional["_models.ManagedInstanceDtcSecuritySettings"] = None, + external_dns_suffix_search_list: Optional[list[str]] = None, + fqdn_enabled: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedInstanceDtcSecuritySettings(_Model): + """The Security Settings of managed instance DTC. + + :ivar transaction_manager_communication_settings: Transaction Manager communication settings of + managed instance DTC. + :vartype transaction_manager_communication_settings: + ~azure.mgmt.sql.models.ManagedInstanceDtcTransactionManagerCommunicationSettings + :ivar xa_transactions_enabled: Allow XA Transactions to managed instance DTC. + :vartype xa_transactions_enabled: bool + :ivar sna_lu6_point2_transactions_enabled: Allow SNA LU 6.2 Transactions to managed instance + DTC. + :vartype sna_lu6_point2_transactions_enabled: bool + :ivar xa_transactions_default_timeout: Default timeout for XA Transactions (in seconds). + :vartype xa_transactions_default_timeout: int + :ivar xa_transactions_maximum_timeout: Maximum timeout for XA Transactions (in seconds). + :vartype xa_transactions_maximum_timeout: int + """ + + transaction_manager_communication_settings: Optional[ + "_models.ManagedInstanceDtcTransactionManagerCommunicationSettings" + ] = rest_field( + name="transactionManagerCommunicationSettings", visibility=["read", "create", "update", "delete", "query"] + ) + """Transaction Manager communication settings of managed instance DTC.""" + xa_transactions_enabled: Optional[bool] = rest_field( + name="xaTransactionsEnabled", visibility=["read", "create", "update", "delete", "query"] + ) + """Allow XA Transactions to managed instance DTC.""" + sna_lu6_point2_transactions_enabled: Optional[bool] = rest_field( + name="snaLu6point2TransactionsEnabled", visibility=["read", "create", "update", "delete", "query"] + ) + """Allow SNA LU 6.2 Transactions to managed instance DTC.""" + xa_transactions_default_timeout: Optional[int] = rest_field( + name="xaTransactionsDefaultTimeout", visibility=["read", "create", "update", "delete", "query"] + ) + """Default timeout for XA Transactions (in seconds).""" + xa_transactions_maximum_timeout: Optional[int] = rest_field( + name="xaTransactionsMaximumTimeout", visibility=["read", "create", "update", "delete", "query"] + ) + """Maximum timeout for XA Transactions (in seconds).""" + + @overload + def __init__( + self, + *, + transaction_manager_communication_settings: Optional[ + "_models.ManagedInstanceDtcTransactionManagerCommunicationSettings" + ] = None, + xa_transactions_enabled: Optional[bool] = None, + sna_lu6_point2_transactions_enabled: Optional[bool] = None, + xa_transactions_default_timeout: Optional[int] = None, + xa_transactions_maximum_timeout: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedInstanceDtcTransactionManagerCommunicationSettings(_Model): # pylint: disable=name-too-long + """The Transaction Manager Communication Settings of managed instance DTC. + + :ivar allow_inbound_enabled: Allow Inbound traffic to managed instance DTC. + :vartype allow_inbound_enabled: bool + :ivar allow_outbound_enabled: Allow Outbound traffic of managed instance DTC. + :vartype allow_outbound_enabled: bool + :ivar authentication: Authentication type of managed instance DTC. + :vartype authentication: str + """ + + allow_inbound_enabled: Optional[bool] = rest_field( + name="allowInboundEnabled", visibility=["read", "create", "update", "delete", "query"] + ) + """Allow Inbound traffic to managed instance DTC.""" + allow_outbound_enabled: Optional[bool] = rest_field( + name="allowOutboundEnabled", visibility=["read", "create", "update", "delete", "query"] + ) + """Allow Outbound traffic of managed instance DTC.""" + authentication: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Authentication type of managed instance DTC.""" + + @overload + def __init__( + self, + *, + allow_inbound_enabled: Optional[bool] = None, + allow_outbound_enabled: Optional[bool] = None, + authentication: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedInstanceEditionCapability(_Model): + """The managed server capability. + + :ivar name: The managed server version name. + :vartype name: str + :ivar is_general_purpose_v2: Whether or not this is a GPv2 variant of General Purpose edition. + :vartype is_general_purpose_v2: bool + :ivar supported_families: The supported families. + :vartype supported_families: list[~azure.mgmt.sql.models.ManagedInstanceFamilyCapability] + :ivar supported_storage_capabilities: The list of supported storage capabilities for this + edition. + :vartype supported_storage_capabilities: list[~azure.mgmt.sql.models.StorageCapability] + :ivar 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 + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """The managed server version name.""" + is_general_purpose_v2: Optional[bool] = rest_field(name="isGeneralPurposeV2", visibility=["read"]) + """Whether or not this is a GPv2 variant of General Purpose edition.""" + supported_families: Optional[list["_models.ManagedInstanceFamilyCapability"]] = rest_field( + name="supportedFamilies", visibility=["read"] + ) + """The supported families.""" + supported_storage_capabilities: Optional[list["_models.StorageCapability"]] = rest_field( + name="supportedStorageCapabilities", visibility=["read"] + ) + """The list of supported storage capabilities for this edition.""" + status: Optional[Union[str, "_models.CapabilityStatus"]] = rest_field(visibility=["read"]) + """The status of the capability. Known values are: \"Visible\", \"Available\", \"Default\", and + \"Disabled\".""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for the capability not being available.""" + + @overload + def __init__( + self, + *, + reason: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedInstanceEncryptionProtector(ProxyResource): + """The managed instance encryption protector. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ManagedInstanceEncryptionProtectorProperties + :ivar kind: Kind of encryption protector. This is metadata used for the Azure portal + experience. + :vartype kind: str + """ + + properties: Optional["_models.ManagedInstanceEncryptionProtectorProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + kind: Optional[str] = rest_field(visibility=["read"]) + """Kind of encryption protector. This is metadata used for the Azure portal experience.""" + + __flattened_items = ["server_key_name", "server_key_type", "uri", "thumbprint", "auto_rotation_enabled"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ManagedInstanceEncryptionProtectorProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ManagedInstanceEncryptionProtectorProperties(_Model): # pylint: disable=name-too-long + """Properties for an encryption protector execution. + + :ivar server_key_name: The name of the managed instance key. + :vartype server_key_name: str + :ivar server_key_type: The encryption protector type like 'ServiceManaged', 'AzureKeyVault'. + Required. Known values are: "ServiceManaged" and "AzureKeyVault". + :vartype server_key_type: str or ~azure.mgmt.sql.models.ServerKeyType + :ivar uri: The URI of the server key. + :vartype uri: str + :ivar thumbprint: Thumbprint of the server key. + :vartype thumbprint: str + :ivar auto_rotation_enabled: Key auto rotation opt-in flag. Either true or false. + :vartype auto_rotation_enabled: bool + """ + + server_key_name: Optional[str] = rest_field( + name="serverKeyName", visibility=["read", "create", "update", "delete", "query"] + ) + """The name of the managed instance key.""" + server_key_type: Union[str, "_models.ServerKeyType"] = rest_field( + name="serverKeyType", visibility=["read", "create", "update", "delete", "query"] + ) + """The encryption protector type like 'ServiceManaged', 'AzureKeyVault'. Required. Known values + are: \"ServiceManaged\" and \"AzureKeyVault\".""" + uri: Optional[str] = rest_field(visibility=["read"]) + """The URI of the server key.""" + thumbprint: Optional[str] = rest_field(visibility=["read"]) + """Thumbprint of the server key.""" + auto_rotation_enabled: Optional[bool] = rest_field( + name="autoRotationEnabled", visibility=["read", "create", "update", "delete", "query"] + ) + """Key auto rotation opt-in flag. Either true or false.""" + + @overload + def __init__( + self, + *, + server_key_type: Union[str, "_models.ServerKeyType"], + server_key_name: Optional[str] = None, + auto_rotation_enabled: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedInstanceExternalAdministrator(_Model): + """Properties of a active directory administrator. + + :ivar administrator_type: Type of the sever administrator. "ActiveDirectory" + :vartype administrator_type: str or ~azure.mgmt.sql.models.AdministratorType + :ivar principal_type: Principal Type of the sever administrator. Known values are: "User", + "Group", and "Application". + :vartype principal_type: str or ~azure.mgmt.sql.models.PrincipalType + :ivar login: Login name of the server administrator. + :vartype login: str + :ivar sid: SID (object ID) of the server administrator. + :vartype sid: str + :ivar tenant_id: Tenant ID of the administrator. + :vartype tenant_id: str + :ivar azure_ad_only_authentication: Azure Active Directory only Authentication enabled. + :vartype azure_ad_only_authentication: bool + """ + + administrator_type: Optional[Union[str, "_models.AdministratorType"]] = rest_field( + name="administratorType", visibility=["read", "create", "update", "delete", "query"] + ) + """Type of the sever administrator. \"ActiveDirectory\"""" + principal_type: Optional[Union[str, "_models.PrincipalType"]] = rest_field( + name="principalType", visibility=["read", "create", "update", "delete", "query"] + ) + """Principal Type of the sever administrator. Known values are: \"User\", \"Group\", and + \"Application\".""" + login: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Login name of the server administrator.""" + sid: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """SID (object ID) of the server administrator.""" + tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read", "create", "update", "delete", "query"]) + """Tenant ID of the administrator.""" + azure_ad_only_authentication: Optional[bool] = rest_field( + name="azureADOnlyAuthentication", visibility=["read", "create", "update", "delete", "query"] + ) + """Azure Active Directory only Authentication enabled.""" + + @overload + def __init__( + self, + *, + administrator_type: Optional[Union[str, "_models.AdministratorType"]] = None, + principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, + login: Optional[str] = None, + sid: Optional[str] = None, + tenant_id: Optional[str] = None, + azure_ad_only_authentication: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedInstanceFamilyCapability(_Model): + """The managed server family capability. + + :ivar name: Family name. + :vartype name: str + :ivar sku: SKU name. + :vartype sku: str + :ivar zone_redundant: Whether or not zone redundancy is supported for the family. + :vartype zone_redundant: bool + :ivar supported_license_types: List of supported license types. + :vartype supported_license_types: list[~azure.mgmt.sql.models.LicenseTypeCapability] + :ivar supported_vcores_values: List of supported virtual cores values. + :vartype supported_vcores_values: list[~azure.mgmt.sql.models.ManagedInstanceVcoresCapability] + :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 + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """Family name.""" + sku: Optional[str] = rest_field(visibility=["read"]) + """SKU name.""" + zone_redundant: Optional[bool] = rest_field(name="zoneRedundant", visibility=["read"]) + """Whether or not zone redundancy is supported for the family.""" + supported_license_types: Optional[list["_models.LicenseTypeCapability"]] = rest_field( + name="supportedLicenseTypes", visibility=["read"] + ) + """List of supported license types.""" + supported_vcores_values: Optional[list["_models.ManagedInstanceVcoresCapability"]] = rest_field( + name="supportedVcoresValues", visibility=["read"] + ) + """List of supported virtual cores values.""" + status: Optional[Union[str, "_models.CapabilityStatus"]] = rest_field(visibility=["read"]) + """The status of the capability. Known values are: \"Visible\", \"Available\", \"Default\", and + \"Disabled\".""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for the capability not being available.""" + + @overload + def __init__( + self, + *, + reason: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedInstanceKey(ProxyResource): + """A managed instance key. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ManagedInstanceKeyProperties + :ivar kind: Kind of encryption protector. This is metadata used for the Azure portal + experience. + :vartype kind: str + """ + + properties: Optional["_models.ManagedInstanceKeyProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + kind: Optional[str] = rest_field(visibility=["read"]) + """Kind of encryption protector. This is metadata used for the Azure portal experience.""" + + __flattened_items = ["server_key_type", "uri", "thumbprint", "creation_date", "auto_rotation_enabled"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ManagedInstanceKeyProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ManagedInstanceKeyProperties(_Model): + """Properties for a key execution. + + :ivar server_key_type: The key type like 'ServiceManaged', 'AzureKeyVault'. Required. Known + values are: "ServiceManaged" and "AzureKeyVault". + :vartype server_key_type: str or ~azure.mgmt.sql.models.ServerKeyType + :ivar uri: The URI of the key. If the ServerKeyType is AzureKeyVault, then the URI is required. + :vartype uri: str + :ivar thumbprint: Thumbprint of the key. + :vartype thumbprint: str + :ivar creation_date: The key creation date. + :vartype creation_date: ~datetime.datetime + :ivar auto_rotation_enabled: Key auto rotation opt-in flag. Either true or false. + :vartype auto_rotation_enabled: bool + """ + + server_key_type: Union[str, "_models.ServerKeyType"] = rest_field(name="serverKeyType", visibility=["create"]) + """The key type like 'ServiceManaged', 'AzureKeyVault'. Required. Known values are: + \"ServiceManaged\" and \"AzureKeyVault\".""" + uri: Optional[str] = rest_field(visibility=["create"]) + """The URI of the key. If the ServerKeyType is AzureKeyVault, then the URI is required.""" + thumbprint: Optional[str] = rest_field(visibility=["read"]) + """Thumbprint of the key.""" + creation_date: Optional[datetime.datetime] = rest_field(name="creationDate", visibility=["read"], format="rfc3339") + """The key creation date.""" + auto_rotation_enabled: Optional[bool] = rest_field(name="autoRotationEnabled", visibility=["read"]) + """Key auto rotation opt-in flag. Either true or false.""" + + @overload + def __init__( + self, + *, + server_key_type: Union[str, "_models.ServerKeyType"], + uri: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedInstanceLongTermRetentionBackup(ProxyResource): + """A long term retention backup for a managed database. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackupProperties + """ + + properties: Optional["_models.ManagedInstanceLongTermRetentionBackupProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "managed_instance_name", + "managed_instance_create_time", + "database_name", + "database_deletion_time", + "backup_time", + "backup_expiration_time", + "backup_storage_redundancy", + "backup_storage_access_tier", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ManagedInstanceLongTermRetentionBackupProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ManagedInstanceLongTermRetentionBackupProperties(_Model): # pylint: disable=name-too-long + """Properties of a long term retention backup. + + :ivar managed_instance_name: The managed instance that the backup database belongs to. + :vartype managed_instance_name: str + :ivar managed_instance_create_time: The create time of the instance. + :vartype managed_instance_create_time: ~datetime.datetime + :ivar database_name: The name of the database the backup belong to. + :vartype database_name: str + :ivar database_deletion_time: The delete time of the database. + :vartype database_deletion_time: ~datetime.datetime + :ivar backup_time: The time the backup was taken. + :vartype backup_time: ~datetime.datetime + :ivar backup_expiration_time: The time the long term retention backup will expire. + :vartype backup_expiration_time: ~datetime.datetime + :ivar backup_storage_redundancy: The storage redundancy type of the backup. Known values are: + "Geo", "Local", "Zone", and "GeoZone". + :vartype backup_storage_redundancy: str or ~azure.mgmt.sql.models.BackupStorageRedundancy + :ivar backup_storage_access_tier: The BackupStorageAccessTier for the LTR backup. Known values + are: "Hot" and "Archive". + :vartype backup_storage_access_tier: str or ~azure.mgmt.sql.models.BackupStorageAccessTier + """ + + managed_instance_name: Optional[str] = rest_field(name="managedInstanceName", visibility=["read"]) + """The managed instance that the backup database belongs to.""" + managed_instance_create_time: Optional[datetime.datetime] = rest_field( + name="managedInstanceCreateTime", visibility=["read"], format="rfc3339" + ) + """The create time of the instance.""" + database_name: Optional[str] = rest_field(name="databaseName", visibility=["read"]) + """The name of the database the backup belong to.""" + database_deletion_time: Optional[datetime.datetime] = rest_field( + name="databaseDeletionTime", visibility=["read"], format="rfc3339" + ) + """The delete time of the database.""" + backup_time: Optional[datetime.datetime] = rest_field(name="backupTime", visibility=["read"], format="rfc3339") + """The time the backup was taken.""" + backup_expiration_time: Optional[datetime.datetime] = rest_field( + name="backupExpirationTime", visibility=["read"], format="rfc3339" + ) + """The time the long term retention backup will expire.""" + backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = rest_field( + name="backupStorageRedundancy", visibility=["read"] + ) + """The storage redundancy type of the backup. Known values are: \"Geo\", \"Local\", \"Zone\", and + \"GeoZone\".""" + backup_storage_access_tier: Optional[Union[str, "_models.BackupStorageAccessTier"]] = rest_field( + name="backupStorageAccessTier", visibility=["read"] + ) + """The BackupStorageAccessTier for the LTR backup. Known values are: \"Hot\" and \"Archive\".""" + + +class ManagedInstanceLongTermRetentionPolicy(ProxyResource): + """A long term retention policy. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicyProperties + """ + + properties: Optional["_models.ManagedInstanceLongTermRetentionPolicyProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "backup_storage_access_tier", + "weekly_retention", + "monthly_retention", + "yearly_retention", + "week_of_year", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ManagedInstanceLongTermRetentionPolicyProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ManagedInstanceLongTermRetentionPolicyProperties(_Model): # pylint: disable=name-too-long + """Properties of a long term retention policy. + + :ivar backup_storage_access_tier: The BackupStorageAccessTier for the LTR backups. Known values + are: "Hot" and "Archive". + :vartype backup_storage_access_tier: str or ~azure.mgmt.sql.models.BackupStorageAccessTier + :ivar weekly_retention: The weekly retention policy for an LTR backup in an ISO 8601 format. + :vartype weekly_retention: str + :ivar monthly_retention: The monthly retention policy for an LTR backup in an ISO 8601 format. + :vartype monthly_retention: str + :ivar yearly_retention: The yearly retention policy for an LTR backup in an ISO 8601 format. + :vartype yearly_retention: str + :ivar week_of_year: The week of year to take the yearly backup in an ISO 8601 format. + :vartype week_of_year: int + """ + + backup_storage_access_tier: Optional[Union[str, "_models.BackupStorageAccessTier"]] = rest_field( + name="backupStorageAccessTier", visibility=["read", "create", "update", "delete", "query"] + ) + """The BackupStorageAccessTier for the LTR backups. Known values are: \"Hot\" and \"Archive\".""" + weekly_retention: Optional[str] = rest_field( + name="weeklyRetention", visibility=["read", "create", "update", "delete", "query"] + ) + """The weekly retention policy for an LTR backup in an ISO 8601 format.""" + monthly_retention: Optional[str] = rest_field( + name="monthlyRetention", visibility=["read", "create", "update", "delete", "query"] + ) + """The monthly retention policy for an LTR backup in an ISO 8601 format.""" + yearly_retention: Optional[str] = rest_field( + name="yearlyRetention", visibility=["read", "create", "update", "delete", "query"] + ) + """The yearly retention policy for an LTR backup in an ISO 8601 format.""" + week_of_year: Optional[int] = rest_field( + name="weekOfYear", visibility=["read", "create", "update", "delete", "query"] + ) + """The week of year to take the yearly backup in an ISO 8601 format.""" + + @overload + def __init__( + self, + *, + backup_storage_access_tier: Optional[Union[str, "_models.BackupStorageAccessTier"]] = None, + weekly_retention: Optional[str] = None, + monthly_retention: Optional[str] = None, + yearly_retention: Optional[str] = None, + week_of_year: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedInstanceMaintenanceConfigurationCapability(_Model): # pylint: disable=name-too-long + """The maintenance configuration capability. + + :ivar name: Maintenance configuration name. + :vartype name: str + :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 + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """Maintenance configuration name.""" + status: Optional[Union[str, "_models.CapabilityStatus"]] = rest_field(visibility=["read"]) + """The status of the capability. Known values are: \"Visible\", \"Available\", \"Default\", and + \"Disabled\".""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for the capability not being available.""" + + @overload + def __init__( + self, + *, + reason: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedInstanceOperation(ProxyResource): + """A managed instance operation. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ManagedInstanceOperationProperties + """ + + properties: Optional["_models.ManagedInstanceOperationProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "managed_instance_name", + "operation", + "operation_friendly_name", + "percent_complete", + "start_time", + "state", + "error_code", + "error_description", + "error_severity", + "is_user_error", + "estimated_completion_time", + "description", + "is_cancellable", + "operation_parameters", + "operation_steps", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ManagedInstanceOperationProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ManagedInstanceOperationParametersPair(_Model): + """The parameters of a managed instance operation. + + :ivar current_parameters: The current parameters. + :vartype current_parameters: ~azure.mgmt.sql.models.UpsertManagedServerOperationParameters + :ivar requested_parameters: The requested parameters. + :vartype requested_parameters: ~azure.mgmt.sql.models.UpsertManagedServerOperationParameters + """ + + current_parameters: Optional["_models.UpsertManagedServerOperationParameters"] = rest_field( + name="currentParameters", visibility=["read"] + ) + """The current parameters.""" + requested_parameters: Optional["_models.UpsertManagedServerOperationParameters"] = rest_field( + name="requestedParameters", visibility=["read"] + ) + """The requested parameters.""" + + +class ManagedInstanceOperationProperties(_Model): + """The properties of a managed instance operation. + + :ivar managed_instance_name: The name of the managed instance the operation is being performed + on. + :vartype managed_instance_name: str + :ivar operation: The name of operation. + :vartype operation: str + :ivar operation_friendly_name: The friendly name of operation. + :vartype operation_friendly_name: str + :ivar percent_complete: The percentage of the operation completed. + :vartype percent_complete: int + :ivar start_time: The operation start time. + :vartype start_time: ~datetime.datetime + :ivar state: The operation state. Known values are: "Pending", "InProgress", "Succeeded", + "Failed", "CancelInProgress", and "Cancelled". + :vartype state: str or ~azure.mgmt.sql.models.ManagementOperationState + :ivar error_code: The operation error code. + :vartype error_code: int + :ivar error_description: The operation error description. + :vartype error_description: str + :ivar error_severity: The operation error severity. + :vartype error_severity: int + :ivar is_user_error: Whether or not the error is a user error. + :vartype is_user_error: bool + :ivar estimated_completion_time: The estimated completion time of the operation. + :vartype estimated_completion_time: ~datetime.datetime + :ivar description: The operation description. + :vartype description: str + :ivar is_cancellable: Whether the operation can be cancelled. + :vartype is_cancellable: bool + :ivar operation_parameters: The operation parameters. + :vartype operation_parameters: ~azure.mgmt.sql.models.ManagedInstanceOperationParametersPair + :ivar operation_steps: The operation steps. + :vartype operation_steps: ~azure.mgmt.sql.models.ManagedInstanceOperationSteps + """ + + managed_instance_name: Optional[str] = rest_field(name="managedInstanceName", visibility=["read"]) + """The name of the managed instance the operation is being performed on.""" + operation: Optional[str] = rest_field(visibility=["read"]) + """The name of operation.""" + operation_friendly_name: Optional[str] = rest_field(name="operationFriendlyName", visibility=["read"]) + """The friendly name of operation.""" + percent_complete: Optional[int] = rest_field(name="percentComplete", visibility=["read"]) + """The percentage of the operation completed.""" + start_time: Optional[datetime.datetime] = rest_field(name="startTime", visibility=["read"], format="rfc3339") + """The operation start time.""" + state: Optional[Union[str, "_models.ManagementOperationState"]] = rest_field(visibility=["read"]) + """The operation state. Known values are: \"Pending\", \"InProgress\", \"Succeeded\", \"Failed\", + \"CancelInProgress\", and \"Cancelled\".""" + error_code: Optional[int] = rest_field(name="errorCode", visibility=["read"]) + """The operation error code.""" + error_description: Optional[str] = rest_field(name="errorDescription", visibility=["read"]) + """The operation error description.""" + error_severity: Optional[int] = rest_field(name="errorSeverity", visibility=["read"]) + """The operation error severity.""" + is_user_error: Optional[bool] = rest_field(name="isUserError", visibility=["read"]) + """Whether or not the error is a user error.""" + estimated_completion_time: Optional[datetime.datetime] = rest_field( + name="estimatedCompletionTime", visibility=["read"], format="rfc3339" + ) + """The estimated completion time of the operation.""" + description: Optional[str] = rest_field(visibility=["read"]) + """The operation description.""" + is_cancellable: Optional[bool] = rest_field(name="isCancellable", visibility=["read"]) + """Whether the operation can be cancelled.""" + operation_parameters: Optional["_models.ManagedInstanceOperationParametersPair"] = rest_field( + name="operationParameters", visibility=["read"] + ) + """The operation parameters.""" + operation_steps: Optional["_models.ManagedInstanceOperationSteps"] = rest_field( + name="operationSteps", visibility=["read"] + ) + """The operation steps.""" + + +class ManagedInstanceOperationSteps(_Model): + """The steps of a managed instance operation. + + :ivar total_steps: The total number of operation steps. + :vartype total_steps: str + :ivar current_step: The number of current operation steps. + :vartype current_step: int + :ivar steps_list: The operation steps list. + :vartype steps_list: + list[~azure.mgmt.sql.models.UpsertManagedServerOperationStepWithEstimatesAndDuration] + """ + + total_steps: Optional[str] = rest_field(name="totalSteps", visibility=["read"]) + """The total number of operation steps.""" + current_step: Optional[int] = rest_field(name="currentStep", visibility=["read"]) + """The number of current operation steps.""" + steps_list: Optional[list["_models.UpsertManagedServerOperationStepWithEstimatesAndDuration"]] = rest_field( + name="stepsList", visibility=["read"] + ) + """The operation steps list.""" + + +class ManagedInstancePairInfo(_Model): + """Pairs of Managed Instances in the failover group. + + :ivar primary_managed_instance_id: Id of Primary Managed Instance in pair. + :vartype primary_managed_instance_id: str + :ivar partner_managed_instance_id: Id of Partner Managed Instance in pair. + :vartype partner_managed_instance_id: str + """ + + primary_managed_instance_id: Optional[str] = rest_field( + name="primaryManagedInstanceId", visibility=["read", "create", "update", "delete", "query"] + ) + """Id of Primary Managed Instance in pair.""" + partner_managed_instance_id: Optional[str] = rest_field( + name="partnerManagedInstanceId", visibility=["read", "create", "update", "delete", "query"] + ) + """Id of Partner Managed Instance in pair.""" + + @overload + def __init__( + self, + *, + primary_managed_instance_id: Optional[str] = None, + partner_managed_instance_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedInstancePecProperty(_Model): + """A private endpoint connection under a managed instance. + + :ivar id: Resource ID. + :vartype id: str + :ivar properties: Private endpoint connection properties. + :vartype properties: ~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnectionProperties + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """Resource ID.""" + properties: Optional["_models.ManagedInstancePrivateEndpointConnectionProperties"] = rest_field(visibility=["read"]) + """Private endpoint connection properties.""" + + +class ManagedInstancePrivateEndpointConnection(ProxyResource): + """A private endpoint connection. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnectionProperties + """ + + properties: Optional["_models.ManagedInstancePrivateEndpointConnectionProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["private_endpoint", "private_link_service_connection_state", "provisioning_state"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ManagedInstancePrivateEndpointConnectionProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ManagedInstancePrivateEndpointConnectionProperties(_Model): # pylint: disable=name-too-long + """Properties of a private endpoint connection. + + :ivar private_endpoint: Private endpoint which the connection belongs to. + :vartype private_endpoint: ~azure.mgmt.sql.models.ManagedInstancePrivateEndpointProperty + :ivar private_link_service_connection_state: Connection State of the Private Endpoint + Connection. + :vartype private_link_service_connection_state: + ~azure.mgmt.sql.models.ManagedInstancePrivateLinkServiceConnectionStateProperty + :ivar provisioning_state: State of the Private Endpoint Connection. + :vartype provisioning_state: str + """ + + private_endpoint: Optional["_models.ManagedInstancePrivateEndpointProperty"] = rest_field( + name="privateEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """Private endpoint which the connection belongs to.""" + private_link_service_connection_state: Optional[ + "_models.ManagedInstancePrivateLinkServiceConnectionStateProperty" + ] = rest_field(name="privateLinkServiceConnectionState", visibility=["read", "create", "update", "delete", "query"]) + """Connection State of the Private Endpoint Connection.""" + provisioning_state: Optional[str] = rest_field(name="provisioningState", visibility=["read"]) + """State of the Private Endpoint Connection.""" + + @overload + def __init__( + self, + *, + private_endpoint: Optional["_models.ManagedInstancePrivateEndpointProperty"] = None, + private_link_service_connection_state: Optional[ + "_models.ManagedInstancePrivateLinkServiceConnectionStateProperty" + ] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedInstancePrivateEndpointProperty(_Model): + """ManagedInstancePrivateEndpointProperty. + + :ivar id: Resource id of the private endpoint. + :vartype id: str + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource id of the private endpoint.""" + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedInstancePrivateLink(ProxyResource): + """A private link resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: The private link resource group id. + :vartype properties: ~azure.mgmt.sql.models.ManagedInstancePrivateLinkProperties + """ + + properties: Optional["_models.ManagedInstancePrivateLinkProperties"] = rest_field(visibility=["read"]) + """The private link resource group id.""" + + +class ManagedInstancePrivateLinkProperties(_Model): + """Properties of a private link resource. + + :ivar group_id: The private link resource group id. + :vartype group_id: str + :ivar required_members: The private link resource required member names. + :vartype required_members: list[str] + :ivar required_zone_names: The private link resource required zone names. + :vartype required_zone_names: list[str] + """ + + group_id: Optional[str] = rest_field(name="groupId", visibility=["read"]) + """The private link resource group id.""" + required_members: Optional[list[str]] = rest_field(name="requiredMembers", visibility=["read"]) + """The private link resource required member names.""" + required_zone_names: Optional[list[str]] = rest_field(name="requiredZoneNames", visibility=["read"]) + """The private link resource required zone names.""" + + +class ManagedInstancePrivateLinkServiceConnectionStateProperty(_Model): # pylint: disable=name-too-long + """ManagedInstancePrivateLinkServiceConnectionStateProperty. + + :ivar status: The private link service connection status. Required. + :vartype status: str + :ivar description: The private link service connection description. Required. + :vartype description: str + :ivar actions_required: The private link service connection description. + :vartype actions_required: str + """ + + status: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The private link service connection status. Required.""" + description: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The private link service connection description. Required.""" + actions_required: Optional[str] = rest_field(name="actionsRequired", visibility=["read"]) + """The private link service connection description.""" + + @overload + def __init__( + self, + *, + status: str, + description: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedInstanceProperties(_Model): + """The properties of a managed instance. + + :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. + + Restore: Creates an instance by restoring a set of backups to specific point in time. + RestorePointInTime and SourceManagedInstanceId must be specified. Known values are: "Default" + and "PointInTimeRestore". + :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 + :ivar administrator_login_password: The administrator login password (required for managed + instance creation). + :vartype administrator_login_password: str + :ivar subnet_id: Subnet resource ID for the managed instance. + :vartype subnet_id: str + :ivar state: The state of the managed instance. + :vartype state: str + :ivar license_type: The license type. Possible values are 'LicenseIncluded' (regular price + inclusive of a new SQL license) and 'BasePrice' (discounted AHB price for bringing your own SQL + licenses). 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: 4, 6, 8, 10, 12, 16, 20, 24, 32, 40, 48, + 56, 64, 80, 96, 128. Supported vCores depends on the selected hardware family and service tier. + :vartype v_cores: int + :ivar storage_size_in_gb: Storage size in GB. Minimum value: 32. Maximum value: 32768. + 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: 300. Maximum value: 80000. 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 MBps parameter is not supported in the + instance create/update operation. + :vartype storage_throughput_m_bps: int + :ivar memory_size_in_gb: Memory size in GB. Minimum value: 28. Maximum value: 870. Minimum and + maximum value depend on the number of vCores and service tier. Read more about resource limits: + `https://aka.ms/mi-resource-limits-api `_. + :vartype memory_size_in_gb: int + :ivar collation: Collation of the managed instance. + :vartype collation: str + :ivar dns_zone: The Dns Zone that the managed instance is in. + :vartype dns_zone: str + :ivar dns_zone_partner: The resource id of another managed instance whose DNS zone this managed + instance will share after creation. + :vartype dns_zone_partner: str + :ivar public_data_endpoint_enabled: Whether or not the public data endpoint is enabled. + :vartype public_data_endpoint_enabled: bool + :ivar source_managed_instance_id: The resource identifier of the source managed instance + associated with create operation of this instance. + :vartype source_managed_instance_id: str + :ivar restore_point_in_time: Specifies the point in time (ISO8601 format) of the source + database that will be restored to create the new database. + :vartype restore_point_in_time: ~datetime.datetime + :ivar proxy_override: Connection type used for connecting to the instance. Known values are: + "Proxy", "Redirect", and "Default". + :vartype proxy_override: str or ~azure.mgmt.sql.models.ManagedInstanceProxyOverride + :ivar timezone_id: Id of the timezone. Allowed values are timezones supported by Windows. + Windows keeps details on supported timezones, including the id, in registry under + KEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones. You can get + those registry values via SQL Server by querying SELECT name AS timezone_id FROM + sys.time_zone_info. List of Ids can also be obtained by executing + [System.TimeZoneInfo]::GetSystemTimeZones() in PowerShell. An example of valid timezone id is + "Pacific Standard Time" or "W. Europe Standard Time". + :vartype timezone_id: str + :ivar instance_pool_id: The Id of the instance pool this managed server belongs to. + :vartype instance_pool_id: str + :ivar maintenance_configuration_id: Specifies maintenance configuration id to apply to this + managed instance. + :vartype maintenance_configuration_id: str + :ivar private_endpoint_connections: List of private endpoint connections on a managed instance. + :vartype private_endpoint_connections: list[~azure.mgmt.sql.models.ManagedInstancePecProperty] + :ivar minimal_tls_version: Minimal TLS version. Allowed values: 'None', '1.0', '1.1', '1.2'. + :vartype minimal_tls_version: str + :ivar current_backup_storage_redundancy: The storage account type used to store backups for + this instance. The options are Local (LocallyRedundantStorage), Zone (ZoneRedundantStorage), + Geo (GeoRedundantStorage) and GeoZone(GeoZoneRedundantStorage). Known values are: "Geo", + "Local", "Zone", and "GeoZone". + :vartype current_backup_storage_redundancy: str or + ~azure.mgmt.sql.models.BackupStorageRedundancy + :ivar requested_backup_storage_redundancy: The storage account type to be used to store backups + for this instance. The options are Local (LocallyRedundantStorage), Zone + (ZoneRedundantStorage), Geo (GeoRedundantStorage) and GeoZone(GeoZoneRedundantStorage). Known + values are: "Geo", "Local", "Zone", and "GeoZone". + :vartype requested_backup_storage_redundancy: str or + ~azure.mgmt.sql.models.BackupStorageRedundancy + :ivar zone_redundant: Whether or not the zone-redundancy is enabled. + :vartype zone_redundant: bool + :ivar primary_user_assigned_identity_id: The resource id of a user assigned identity to be used + by default. + :vartype primary_user_assigned_identity_id: str + :ivar key_id: A CMK URI of the key to use for encryption. + :vartype key_id: str + :ivar administrators: The Azure Active Directory administrator can be utilized during instance + creation and for instance updates, except for the azureADOnlyAuthentication property. To update + the azureADOnlyAuthentication property, individual API must be used. + :vartype administrators: ~azure.mgmt.sql.models.ManagedInstanceExternalAdministrator + :ivar service_principal: The managed instance's service principal. + :vartype service_principal: ~azure.mgmt.sql.models.ServicePrincipal + :ivar virtual_cluster_id: Virtual cluster resource id for the Managed Instance. + :vartype virtual_cluster_id: str + :ivar external_governance_status: Status of external governance. Known values are: "Enabled" + and "Disabled". + :vartype external_governance_status: str or ~azure.mgmt.sql.models.ExternalGovernanceStatus + :ivar pricing_model: Pricing model of Managed Instance. Known values are: "Regular" and + "Freemium". + :vartype pricing_model: str or ~azure.mgmt.sql.models.PricingModel + :ivar create_time: Specifies the point in time (ISO8601 format) of the Managed Instance + creation. + :vartype create_time: ~datetime.datetime + :ivar authentication_metadata: The managed instance's authentication metadata lookup mode. + Known values are: "AzureAD", "Paired", and "Windows". + :vartype authentication_metadata: str or ~azure.mgmt.sql.models.AuthMetadataLookupModes + :ivar database_format: Specifies the internal format of instance databases specific to the SQL + engine version. Known values are: "AlwaysUpToDate", "SQLServer2022", and "SQLServer2025". + :vartype database_format: str or ~azure.mgmt.sql.models.ManagedInstanceDatabaseFormat + :ivar requested_logical_availability_zone: Specifies the logical availability zone Managed + Instance is pinned to. Known values are: "NoPreference", "1", "2", and "3". + :vartype requested_logical_availability_zone: str or + ~azure.mgmt.sql.models.AvailabilityZoneType + """ + + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning state of managed instance. Known values are: \"Created\", \"InProgress\", + \"Succeeded\", \"Failed\", and \"Canceled\".""" + managed_instance_create_mode: Optional[Union[str, "_models.ManagedServerCreateMode"]] = rest_field( + name="managedInstanceCreateMode", visibility=["create"] + ) + """Specifies the mode of database creation. + + Default: Regular instance creation. + + Restore: Creates an instance by restoring a set of backups to specific point in time. + RestorePointInTime and SourceManagedInstanceId must be specified. Known values are: \"Default\" + and \"PointInTimeRestore\".""" + fully_qualified_domain_name: Optional[str] = rest_field(name="fullyQualifiedDomainName", visibility=["read"]) + """The fully qualified domain name of the managed instance.""" + is_general_purpose_v2: Optional[bool] = rest_field( + name="isGeneralPurposeV2", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether or not this is a GPv2 variant of General Purpose edition.""" + administrator_login: Optional[str] = rest_field(name="administratorLogin", visibility=["read", "create"]) + """Administrator username for the managed instance. Can only be specified when the managed + instance is being created (and is required for creation).""" + administrator_login_password: Optional[str] = rest_field( + name="administratorLoginPassword", visibility=["create", "update"] + ) + """The administrator login password (required for managed instance creation).""" + subnet_id: Optional[str] = rest_field(name="subnetId", visibility=["read", "create", "update", "delete", "query"]) + """Subnet resource ID for the managed instance.""" + state: Optional[str] = rest_field(visibility=["read"]) + """The state of the managed instance.""" + license_type: Optional[Union[str, "_models.ManagedInstanceLicenseType"]] = rest_field( + name="licenseType", visibility=["read", "create", "update", "delete", "query"] + ) + """The license type. Possible values are 'LicenseIncluded' (regular price inclusive of a new SQL + license) and 'BasePrice' (discounted AHB price for bringing your own SQL licenses). Known + values are: \"LicenseIncluded\" and \"BasePrice\".""" + hybrid_secondary_usage: Optional[Union[str, "_models.HybridSecondaryUsage"]] = rest_field( + name="hybridSecondaryUsage", visibility=["read", "create", "update", "delete", "query"] + ) + """Hybrid secondary usage. Possible values are 'Active' (default value) and 'Passive' (customer + uses the secondary as Passive DR). Known values are: \"Active\" and \"Passive\".""" + hybrid_secondary_usage_detected: Optional[Union[str, "_models.HybridSecondaryUsageDetected"]] = rest_field( + name="hybridSecondaryUsageDetected", visibility=["read"] + ) + """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\".""" + v_cores: Optional[int] = rest_field(name="vCores", visibility=["read", "create", "update", "delete", "query"]) + """The number of vCores. Allowed values: 4, 6, 8, 10, 12, 16, 20, 24, 32, 40, 48, 56, 64, 80, 96, + 128. Supported vCores depends on the selected hardware family and service tier.""" + storage_size_in_gb: Optional[int] = rest_field( + name="storageSizeInGB", visibility=["read", "create", "update", "delete", "query"] + ) + """Storage size in GB. Minimum value: 32. Maximum value: 32768. Increments of 32 GB allowed only. + Maximum value depends on the selected hardware family and number of vCores.""" + storage_i_ops: Optional[int] = rest_field( + name="storageIOps", visibility=["read", "create", "update", "delete", "query"] + ) + """Storage IOps. Minimum value: 300. Maximum value: 80000. Increments of 1 IOps allowed only. + Maximum value depends on the selected hardware family and number of vCores.""" + storage_throughput_m_bps: Optional[int] = rest_field( + name="storageThroughputMBps", visibility=["read", "create", "update", "delete", "query"] + ) + """Storage throughput MBps parameter is not supported in the instance create/update operation.""" + memory_size_in_gb: Optional[int] = rest_field( + name="memorySizeInGB", visibility=["read", "create", "update", "delete", "query"] + ) + """Memory size in GB. Minimum value: 28. Maximum value: 870. Minimum and maximum value depend on + the number of vCores and service tier. Read more about resource limits: + `https://aka.ms/mi-resource-limits-api `_.""" + collation: Optional[str] = rest_field(visibility=["read", "create"]) + """Collation of the managed instance.""" + dns_zone: Optional[str] = rest_field(name="dnsZone", visibility=["read"]) + """The Dns Zone that the managed instance is in.""" + dns_zone_partner: Optional[str] = rest_field(name="dnsZonePartner", visibility=["create"]) + """The resource id of another managed instance whose DNS zone this managed instance will share + after creation.""" + public_data_endpoint_enabled: Optional[bool] = rest_field( + name="publicDataEndpointEnabled", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether or not the public data endpoint is enabled.""" + source_managed_instance_id: Optional[str] = rest_field(name="sourceManagedInstanceId", visibility=["create"]) + """The resource identifier of the source managed instance associated with create operation of this + instance.""" + restore_point_in_time: Optional[datetime.datetime] = rest_field( + name="restorePointInTime", visibility=["create"], format="rfc3339" + ) + """Specifies the point in time (ISO8601 format) of the source database that will be restored to + create the new database.""" + proxy_override: Optional[Union[str, "_models.ManagedInstanceProxyOverride"]] = rest_field( + name="proxyOverride", visibility=["read", "create", "update", "delete", "query"] + ) + """Connection type used for connecting to the instance. Known values are: \"Proxy\", \"Redirect\", + and \"Default\".""" + timezone_id: Optional[str] = rest_field(name="timezoneId", visibility=["read", "create"]) + """Id of the timezone. Allowed values are timezones supported by Windows. Windows keeps details on + supported timezones, including the id, in registry under + KEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones. You can get those + registry values via SQL Server by querying SELECT name AS timezone_id FROM sys.time_zone_info. + List of Ids can also be obtained by executing [System.TimeZoneInfo]::GetSystemTimeZones() in + PowerShell. An example of valid timezone id is \"Pacific Standard Time\" or \"W. Europe + Standard Time\".""" + instance_pool_id: Optional[str] = rest_field( + name="instancePoolId", visibility=["read", "create", "update", "delete", "query"] + ) + """The Id of the instance pool this managed server belongs to.""" + maintenance_configuration_id: Optional[str] = rest_field( + name="maintenanceConfigurationId", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies maintenance configuration id to apply to this managed instance.""" + private_endpoint_connections: Optional[list["_models.ManagedInstancePecProperty"]] = rest_field( + name="privateEndpointConnections", visibility=["read"] + ) + """List of private endpoint connections on a managed instance.""" + minimal_tls_version: Optional[str] = rest_field( + name="minimalTlsVersion", visibility=["read", "create", "update", "delete", "query"] + ) + """Minimal TLS version. Allowed values: 'None', '1.0', '1.1', '1.2'.""" + current_backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = rest_field( + name="currentBackupStorageRedundancy", visibility=["read"] + ) + """The storage account type used to store backups for this instance. The options are Local + (LocallyRedundantStorage), Zone (ZoneRedundantStorage), Geo (GeoRedundantStorage) and + GeoZone(GeoZoneRedundantStorage). Known values are: \"Geo\", \"Local\", \"Zone\", and + \"GeoZone\".""" + requested_backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = rest_field( + name="requestedBackupStorageRedundancy", visibility=["read", "create", "update", "delete", "query"] + ) + """The storage account type to be used to store backups for this instance. The options are Local + (LocallyRedundantStorage), Zone (ZoneRedundantStorage), Geo (GeoRedundantStorage) and + GeoZone(GeoZoneRedundantStorage). Known values are: \"Geo\", \"Local\", \"Zone\", and + \"GeoZone\".""" + zone_redundant: Optional[bool] = rest_field( + name="zoneRedundant", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether or not the zone-redundancy is enabled.""" + primary_user_assigned_identity_id: Optional[str] = rest_field( + name="primaryUserAssignedIdentityId", visibility=["read", "create", "update", "delete", "query"] + ) + """The resource id of a user assigned identity to be used by default.""" + key_id: Optional[str] = rest_field(name="keyId", visibility=["read", "create"]) + """A CMK URI of the key to use for encryption.""" + administrators: Optional["_models.ManagedInstanceExternalAdministrator"] = rest_field(visibility=["read", "create"]) + """The Azure Active Directory administrator can be utilized during instance creation and for + instance updates, except for the azureADOnlyAuthentication property. To update the + azureADOnlyAuthentication property, individual API must be used.""" + service_principal: Optional["_models.ServicePrincipal"] = rest_field( + name="servicePrincipal", visibility=["read", "create", "update", "delete", "query"] + ) + """The managed instance's service principal.""" + virtual_cluster_id: Optional[str] = rest_field(name="virtualClusterId", visibility=["read"]) + """Virtual cluster resource id for the Managed Instance.""" + external_governance_status: Optional[Union[str, "_models.ExternalGovernanceStatus"]] = rest_field( + name="externalGovernanceStatus", visibility=["read"] + ) + """Status of external governance. Known values are: \"Enabled\" and \"Disabled\".""" + pricing_model: Optional[Union[str, "_models.PricingModel"]] = rest_field( + name="pricingModel", visibility=["read", "create", "update", "delete", "query"] + ) + """Pricing model of Managed Instance. Known values are: \"Regular\" and \"Freemium\".""" + create_time: Optional[datetime.datetime] = rest_field(name="createTime", visibility=["read"], format="rfc3339") + """Specifies the point in time (ISO8601 format) of the Managed Instance creation.""" + authentication_metadata: Optional[Union[str, "_models.AuthMetadataLookupModes"]] = rest_field( + name="authenticationMetadata", visibility=["read", "create", "update", "delete", "query"] + ) + """The managed instance's authentication metadata lookup mode. Known values are: \"AzureAD\", + \"Paired\", and \"Windows\".""" + database_format: Optional[Union[str, "_models.ManagedInstanceDatabaseFormat"]] = rest_field( + name="databaseFormat", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the internal format of instance databases specific to the SQL engine version. Known + values are: \"AlwaysUpToDate\", \"SQLServer2022\", and \"SQLServer2025\".""" + requested_logical_availability_zone: Optional[Union[str, "_models.AvailabilityZoneType"]] = rest_field( + name="requestedLogicalAvailabilityZone", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the logical availability zone Managed Instance is pinned to. Known values are: + \"NoPreference\", \"1\", \"2\", and \"3\".""" + + @overload + def __init__( # pylint: disable=too-many-locals + self, + *, + 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, + memory_size_in_gb: Optional[int] = None, + collation: Optional[str] = None, + dns_zone_partner: Optional[str] = None, + public_data_endpoint_enabled: Optional[bool] = None, + source_managed_instance_id: Optional[str] = None, + restore_point_in_time: Optional[datetime.datetime] = None, + proxy_override: Optional[Union[str, "_models.ManagedInstanceProxyOverride"]] = None, + timezone_id: Optional[str] = None, + instance_pool_id: Optional[str] = None, + maintenance_configuration_id: Optional[str] = None, + minimal_tls_version: Optional[str] = None, + requested_backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = None, + zone_redundant: Optional[bool] = None, + primary_user_assigned_identity_id: Optional[str] = None, + key_id: Optional[str] = None, + administrators: Optional["_models.ManagedInstanceExternalAdministrator"] = None, + service_principal: Optional["_models.ServicePrincipal"] = None, + pricing_model: Optional[Union[str, "_models.PricingModel"]] = None, + authentication_metadata: Optional[Union[str, "_models.AuthMetadataLookupModes"]] = None, + database_format: Optional[Union[str, "_models.ManagedInstanceDatabaseFormat"]] = None, + requested_logical_availability_zone: Optional[Union[str, "_models.AvailabilityZoneType"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedInstanceQuery(ProxyResource): + """Database query. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.QueryProperties + """ + + properties: Optional["_models.QueryProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["query_text"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.QueryProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ManagedInstanceUpdate(_Model): + """An update request for an Azure SQL Database managed instance. + + :ivar sku: Managed instance sku. + :vartype sku: ~azure.mgmt.sql.models.Sku + :ivar identity: Managed instance identity. + :vartype identity: ~azure.mgmt.sql.models.ResourceIdentity + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ManagedInstanceProperties + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + sku: Optional["_models.Sku"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Managed instance sku.""" + identity: Optional["_models.ResourceIdentity"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Managed instance identity.""" + properties: Optional["_models.ManagedInstanceProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource tags.""" + + __flattened_items = [ + "provisioning_state", + "managed_instance_create_mode", + "fully_qualified_domain_name", + "is_general_purpose_v2", + "administrator_login", + "administrator_login_password", + "subnet_id", + "state", + "license_type", + "hybrid_secondary_usage", + "hybrid_secondary_usage_detected", + "v_cores", + "storage_size_in_gb", + "storage_i_ops", + "storage_throughput_m_bps", + "memory_size_in_gb", + "collation", + "dns_zone", + "dns_zone_partner", + "public_data_endpoint_enabled", + "source_managed_instance_id", + "restore_point_in_time", + "proxy_override", + "timezone_id", + "instance_pool_id", + "maintenance_configuration_id", + "private_endpoint_connections", + "minimal_tls_version", + "current_backup_storage_redundancy", + "requested_backup_storage_redundancy", + "zone_redundant", + "primary_user_assigned_identity_id", + "key_id", + "administrators", + "service_principal", + "virtual_cluster_id", + "external_governance_status", + "pricing_model", + "create_time", + "authentication_metadata", + "database_format", + "requested_logical_availability_zone", + ] + + @overload + def __init__( + self, + *, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.ResourceIdentity"] = None, + properties: Optional["_models.ManagedInstanceProperties"] = None, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ManagedInstanceValidateAzureKeyVaultEncryptionKeyRequest(_Model): # pylint: disable=name-too-long + """Validate azure key vault encryption key. + + :ivar tde_key_uri: The URI of the key. Required. + :vartype tde_key_uri: str + """ + + tde_key_uri: str = rest_field(name="tdeKeyUri", visibility=["create", "update"]) + """The URI of the key. Required.""" + + @overload + def __init__( + self, + *, + tde_key_uri: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedInstanceVcoresCapability(_Model): + """The managed instance virtual cores capability. + + :ivar name: The virtual cores identifier. + :vartype name: str + :ivar value: The virtual cores value. + :vartype value: int + :ivar supported_memory_sizes_in_gb: Supported memory sizes in GB. + :vartype supported_memory_sizes_in_gb: ~azure.mgmt.sql.models.MaxLimitRangeCapability + :ivar supported_memory_limits_mb: Memory limit MB ranges. + :vartype supported_memory_limits_mb: ~azure.mgmt.sql.models.MaxLimitRangeCapability + :ivar included_max_size: Included size. + :vartype included_max_size: ~azure.mgmt.sql.models.MaxSizeCapability + :ivar supported_storage_sizes: Storage size ranges. + :vartype supported_storage_sizes: list[~azure.mgmt.sql.models.MaxSizeRangeCapability] + :ivar 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 + :ivar standalone_supported: True if this service objective is supported for standalone managed + instances. + :vartype standalone_supported: bool + :ivar supported_maintenance_configurations: List of supported maintenance configurations. + :vartype supported_maintenance_configurations: + list[~azure.mgmt.sql.models.ManagedInstanceMaintenanceConfigurationCapability] + :ivar status: The status of the capability. 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 + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """The virtual cores identifier.""" + value: Optional[int] = rest_field(visibility=["read"]) + """The virtual cores value.""" + supported_memory_sizes_in_gb: Optional["_models.MaxLimitRangeCapability"] = rest_field( + name="supportedMemorySizesInGB", visibility=["read"] + ) + """Supported memory sizes in GB.""" + supported_memory_limits_mb: Optional["_models.MaxLimitRangeCapability"] = rest_field( + name="supportedMemoryLimitsMB", visibility=["read"] + ) + """Memory limit MB ranges.""" + included_max_size: Optional["_models.MaxSizeCapability"] = rest_field(name="includedMaxSize", visibility=["read"]) + """Included size.""" + supported_storage_sizes: Optional[list["_models.MaxSizeRangeCapability"]] = rest_field( + name="supportedStorageSizes", visibility=["read"] + ) + """Storage size ranges.""" + included_storage_i_ops: Optional[int] = rest_field(name="includedStorageIOps", visibility=["read"]) + """Included storage IOps.""" + supported_storage_i_ops: Optional["_models.MaxLimitRangeCapability"] = rest_field( + name="supportedStorageIOps", visibility=["read"] + ) + """Storage IOps ranges.""" + iops_min_value_override_factor_per_selected_storage_gb: Optional[float] = rest_field( + name="iopsMinValueOverrideFactorPerSelectedStorageGB", visibility=["read"] + ) + """Min IOps override factor per selected storage GB.""" + iops_included_value_override_factor_per_selected_storage_gb: Optional[float] = rest_field( + name="iopsIncludedValueOverrideFactorPerSelectedStorageGB", visibility=["read"] + ) + """Included IOps override factor per selected storage GB.""" + included_storage_throughput_m_bps: Optional[int] = rest_field( + name="includedStorageThroughputMBps", visibility=["read"] + ) + """Included storage throughput MBps.""" + supported_storage_throughput_m_bps: Optional["_models.MaxLimitRangeCapability"] = rest_field( + name="supportedStorageThroughputMBps", visibility=["read"] + ) + """Storage throughput MBps ranges.""" + throughput_m_bps_min_value_override_factor_per_selected_storage_gb: Optional[float] = rest_field( + name="throughputMBpsMinValueOverrideFactorPerSelectedStorageGB", visibility=["read"] + ) + """Min throughput MBps override factor per selected storage GB.""" + throughput_m_bps_included_value_override_factor_per_selected_storage_gb: Optional[float] = rest_field( + name="throughputMBpsIncludedValueOverrideFactorPerSelectedStorageGB", visibility=["read"] + ) + """Included throughput MBps override factor per selected storage GB.""" + instance_pool_supported: Optional[bool] = rest_field(name="instancePoolSupported", visibility=["read"]) + """True if this service objective is supported for managed instances in an instance pool.""" + standalone_supported: Optional[bool] = rest_field(name="standaloneSupported", visibility=["read"]) + """True if this service objective is supported for standalone managed instances.""" + supported_maintenance_configurations: Optional[ + list["_models.ManagedInstanceMaintenanceConfigurationCapability"] + ] = rest_field(name="supportedMaintenanceConfigurations", visibility=["read"]) + """List of supported maintenance configurations.""" + status: Optional[Union[str, "_models.CapabilityStatus"]] = rest_field(visibility=["read"]) + """The status of the capability. Known values are: \"Visible\", \"Available\", \"Default\", and + \"Disabled\".""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for the capability not being available.""" + + @overload + def __init__( + self, + *, + reason: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedInstanceVersionCapability(_Model): + """The managed instance capability. + + :ivar name: The server version name. + :vartype name: str + :ivar supported_editions: The list of supported managed instance editions. + :vartype supported_editions: list[~azure.mgmt.sql.models.ManagedInstanceEditionCapability] + :ivar supported_instance_pool_editions: The list of supported instance pool editions. + :vartype supported_instance_pool_editions: + list[~azure.mgmt.sql.models.InstancePoolEditionCapability] + :ivar status: The status of the capability. 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 + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """The server version name.""" + supported_editions: Optional[list["_models.ManagedInstanceEditionCapability"]] = rest_field( + name="supportedEditions", visibility=["read"] + ) + """The list of supported managed instance editions.""" + supported_instance_pool_editions: Optional[list["_models.InstancePoolEditionCapability"]] = rest_field( + name="supportedInstancePoolEditions", visibility=["read"] + ) + """The list of supported instance pool editions.""" + status: Optional[Union[str, "_models.CapabilityStatus"]] = rest_field(visibility=["read"]) + """The status of the capability. Known values are: \"Visible\", \"Available\", \"Default\", and + \"Disabled\".""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for the capability not being available.""" + + @overload + def __init__( + self, + *, + reason: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedInstanceVulnerabilityAssessment(ProxyResource): + """A managed instance vulnerability assessment. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessmentProperties + """ + + properties: Optional["_models.ManagedInstanceVulnerabilityAssessmentProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "storage_container_path", + "storage_container_sas_key", + "storage_account_access_key", + "recurring_scans", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ManagedInstanceVulnerabilityAssessmentProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ManagedInstanceVulnerabilityAssessmentProperties(_Model): # pylint: disable=name-too-long + """Properties of a managed instance vulnerability assessment. + + :ivar storage_container_path: A blob storage container path to hold the scan results (e.g. + `https://myStorage.blob.core.windows.net/VaScans/ + `_). Required. + :vartype storage_container_path: str + :ivar storage_container_sas_key: A shared access signature (SAS Key) that has write access to + the blob container specified in 'storageContainerPath' parameter. If 'storageAccountAccessKey' + isn't specified, StorageContainerSasKey is required. Applies only if the storage account is not + behind a Vnet or a firewall. + :vartype storage_container_sas_key: str + :ivar storage_account_access_key: Specifies the identifier key of the storage account for + vulnerability assessment scan results. If 'StorageContainerSasKey' isn't specified, + storageAccountAccessKey is required. Applies only if the storage account is not behind a Vnet + or a firewall. + :vartype storage_account_access_key: str + :ivar recurring_scans: The recurring scans settings. + :vartype recurring_scans: + ~azure.mgmt.sql.models.VulnerabilityAssessmentRecurringScansProperties + """ + + storage_container_path: str = rest_field(name="storageContainerPath", visibility=["create", "update"]) + """A blob storage container path to hold the scan results (e.g. + `https://myStorage.blob.core.windows.net/VaScans/ + `_). Required.""" + storage_container_sas_key: Optional[str] = rest_field( + name="storageContainerSasKey", visibility=["create", "update"] + ) + """A shared access signature (SAS Key) that has write access to the blob container specified in + 'storageContainerPath' parameter. If 'storageAccountAccessKey' isn't specified, + StorageContainerSasKey is required. Applies only if the storage account is not behind a Vnet or + a firewall.""" + storage_account_access_key: Optional[str] = rest_field( + name="storageAccountAccessKey", visibility=["create", "update"] + ) + """Specifies the identifier key of the storage account for vulnerability assessment scan results. + If 'StorageContainerSasKey' isn't specified, storageAccountAccessKey is required. Applies only + if the storage account is not behind a Vnet or a firewall.""" + recurring_scans: Optional["_models.VulnerabilityAssessmentRecurringScansProperties"] = rest_field( + name="recurringScans", visibility=["read", "create", "update", "delete", "query"] + ) + """The recurring scans settings.""" + + @overload + def __init__( + self, + *, + storage_container_path: str, + storage_container_sas_key: Optional[str] = None, + storage_account_access_key: Optional[str] = None, + recurring_scans: Optional["_models.VulnerabilityAssessmentRecurringScansProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedLedgerDigestUploads(ProxyResource): + """Azure SQL Database ledger digest upload settings. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ManagedLedgerDigestUploadsProperties + """ + + properties: Optional["_models.ManagedLedgerDigestUploadsProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["digest_storage_endpoint", "state"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ManagedLedgerDigestUploadsProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ManagedLedgerDigestUploadsProperties(_Model): + """The properties of a database ledger digest upload settings. + + :ivar digest_storage_endpoint: The digest storage endpoint, which must be either an Azure blob + storage endpoint or an URI for Azure Confidential Ledger. + :vartype digest_storage_endpoint: str + :ivar state: Specifies the state of ledger digest upload. Known values are: "Enabled" and + "Disabled". + :vartype state: str or ~azure.mgmt.sql.models.ManagedLedgerDigestUploadsState + """ + + digest_storage_endpoint: Optional[str] = rest_field( + name="digestStorageEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """The digest storage endpoint, which must be either an Azure blob storage endpoint or an URI for + Azure Confidential Ledger.""" + state: Optional[Union[str, "_models.ManagedLedgerDigestUploadsState"]] = rest_field(visibility=["read"]) + """Specifies the state of ledger digest upload. Known values are: \"Enabled\" and \"Disabled\".""" + + @overload + def __init__( + self, + *, + digest_storage_endpoint: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedServerDnsAlias(ProxyResource): + """A managed server DNS alias. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ManagedServerDnsAliasProperties + """ + + properties: Optional["_models.ManagedServerDnsAliasProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["azure_dns_record", "public_azure_dns_record"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ManagedServerDnsAliasProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ManagedServerDnsAliasAcquisition(_Model): + """A managed server DNS alias acquisition request. + + :ivar old_managed_server_dns_alias_resource_id: The resource ID of the managed server DNS alias + that will be acquired to point to this managed server instead. Required. + :vartype old_managed_server_dns_alias_resource_id: str + """ + + old_managed_server_dns_alias_resource_id: str = rest_field( + name="oldManagedServerDnsAliasResourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """The resource ID of the managed server DNS alias that will be acquired to point to this managed + server instead. Required.""" + + @overload + def __init__( + self, + *, + old_managed_server_dns_alias_resource_id: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedServerDnsAliasCreation(_Model): + """A managed server dns alias creation request. + + :ivar create_dns_record: Whether or not DNS record should be created for this alias. + :vartype create_dns_record: bool + """ + + create_dns_record: Optional[bool] = rest_field( + name="createDnsRecord", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether or not DNS record should be created for this alias.""" + + @overload + def __init__( + self, + *, + create_dns_record: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedServerDnsAliasProperties(_Model): + """Properties of a managed server DNS alias. + + :ivar azure_dns_record: The fully qualified DNS record for managed server alias. + :vartype azure_dns_record: str + :ivar public_azure_dns_record: The fully qualified public DNS record for managed server alias. + :vartype public_azure_dns_record: str + """ + + azure_dns_record: Optional[str] = rest_field(name="azureDnsRecord", visibility=["read"]) + """The fully qualified DNS record for managed server alias.""" + public_azure_dns_record: Optional[str] = rest_field(name="publicAzureDnsRecord", visibility=["read"]) + """The fully qualified public DNS record for managed server alias.""" + + +class ManagedServerSecurityAlertPolicy(ProxyResource): + """A managed server security alert policy. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.SecurityAlertsPolicyProperties + """ + + properties: Optional["_models.SecurityAlertsPolicyProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "state", + "disabled_alerts", + "email_addresses", + "email_account_admins", + "storage_endpoint", + "storage_account_access_key", + "retention_days", + "creation_time", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.SecurityAlertsPolicyProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ManagedTransparentDataEncryption(ProxyResource): + """A managed database transparent data encryption state. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ManagedTransparentDataEncryptionProperties + """ + + properties: Optional["_models.ManagedTransparentDataEncryptionProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["state"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ManagedTransparentDataEncryptionProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ManagedTransparentDataEncryptionProperties(_Model): # pylint: disable=name-too-long + """Properties of a transparent data encryption. + + :ivar state: Specifies the state of the transparent data encryption. Required. Known values + are: "Enabled" and "Disabled". + :vartype state: str or ~azure.mgmt.sql.models.TransparentDataEncryptionState + """ + + state: Union[str, "_models.TransparentDataEncryptionState"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the state of the transparent data encryption. Required. Known values are: \"Enabled\" + and \"Disabled\".""" + + @overload + def __init__( + self, + *, + state: Union[str, "_models.TransparentDataEncryptionState"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MaxLimitRangeCapability(_Model): + """The maximum limit range capability. + + :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 + """ + + min_value: Optional[int] = rest_field(name="minValue", visibility=["read"]) + """Minimum value.""" + max_value: Optional[int] = rest_field(name="maxValue", visibility=["read"]) + """Maximum value.""" + scale_size: Optional[int] = rest_field(name="scaleSize", visibility=["read"]) + """Scale/step size for discrete values between the minimum value and the maximum value.""" + status: Optional[Union[str, "_models.CapabilityStatus"]] = rest_field(visibility=["read"]) + """The status of the capability. Known values are: \"Visible\", \"Available\", \"Default\", and + \"Disabled\".""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for the capability not being available.""" + + @overload + def __init__( + self, + *, + reason: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MaxSizeCapability(_Model): + """The maximum size capability. + + :ivar limit: The maximum size limit (see 'unit' for the units). + :vartype limit: int + :ivar unit: The units that the limit is expressed in. Known values are: "Megabytes", + "Gigabytes", "Terabytes", and "Petabytes". + :vartype unit: str or ~azure.mgmt.sql.models.MaxSizeUnit + """ + + limit: Optional[int] = rest_field(visibility=["read"]) + """The maximum size limit (see 'unit' for the units).""" + unit: Optional[Union[str, "_models.MaxSizeUnit"]] = rest_field(visibility=["read"]) + """The units that the limit is expressed in. Known values are: \"Megabytes\", \"Gigabytes\", + \"Terabytes\", and \"Petabytes\".""" + + +class MaxSizeRangeCapability(_Model): + """The maximum size range capability. + + :ivar min_value: Minimum value. + :vartype min_value: ~azure.mgmt.sql.models.MaxSizeCapability + :ivar max_value: Maximum value. + :vartype max_value: ~azure.mgmt.sql.models.MaxSizeCapability + :ivar scale_size: Scale/step size for discrete values between the minimum value and the maximum + value. + :vartype scale_size: ~azure.mgmt.sql.models.MaxSizeCapability + :ivar log_size: Size of transaction log. + :vartype log_size: ~azure.mgmt.sql.models.LogSizeCapability + :ivar status: The status of the capability. 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 + """ + + min_value: Optional["_models.MaxSizeCapability"] = rest_field(name="minValue", visibility=["read"]) + """Minimum value.""" + max_value: Optional["_models.MaxSizeCapability"] = rest_field(name="maxValue", visibility=["read"]) + """Maximum value.""" + scale_size: Optional["_models.MaxSizeCapability"] = rest_field(name="scaleSize", visibility=["read"]) + """Scale/step size for discrete values between the minimum value and the maximum value.""" + log_size: Optional["_models.LogSizeCapability"] = rest_field(name="logSize", visibility=["read"]) + """Size of transaction log.""" + status: Optional[Union[str, "_models.CapabilityStatus"]] = rest_field(visibility=["read"]) + """The status of the capability. Known values are: \"Visible\", \"Available\", \"Default\", and + \"Disabled\".""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for the capability not being available.""" + + @overload + def __init__( + self, + *, + reason: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MinCapacityCapability(_Model): + """The min capacity capability. + + :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 + """ + + value: Optional[float] = rest_field(visibility=["read"]) + """Min capacity value.""" + status: Optional[Union[str, "_models.CapabilityStatus"]] = rest_field(visibility=["read"]) + """The status of the capability. Known values are: \"Visible\", \"Available\", \"Default\", and + \"Disabled\".""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for the capability not being available.""" + + @overload + def __init__( + self, + *, + reason: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Name(_Model): + """ARM Usage Name. + + :ivar value: Usage name value. + :vartype value: str + :ivar localized_value: Usage name localized value. + :vartype localized_value: str + """ + + value: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Usage name value.""" + localized_value: Optional[str] = rest_field( + name="localizedValue", visibility=["read", "create", "update", "delete", "query"] + ) + """Usage name localized value.""" + + @overload + def __init__( + self, + *, + value: Optional[str] = None, + localized_value: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NetworkIsolationSettings(_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 + """ + + storage_account_resource_id: Optional[str] = rest_field(name="storageAccountResourceId", visibility=["create"]) + """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.""" + sql_server_resource_id: Optional[str] = rest_field(name="sqlServerResourceId", visibility=["create"]) + """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.""" + + @overload + def __init__( + self, + *, + storage_account_resource_id: Optional[str] = None, + sql_server_resource_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NetworkSecurityPerimeterConfiguration(ProxyResource): + """NSP Configuration for a server. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.NetworkSecurityPerimeterConfigurationProperties + """ + + properties: Optional["_models.NetworkSecurityPerimeterConfigurationProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "provisioning_state", + "network_security_perimeter", + "resource_association", + "profile", + "provisioning_issues", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.NetworkSecurityPerimeterConfigurationProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class NetworkSecurityPerimeterConfigurationProperties(_Model): # pylint: disable=name-too-long + """The properties of an NSP config. + + :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] + """ + + provisioning_state: Optional[str] = rest_field(name="provisioningState", visibility=["read"]) + network_security_perimeter: Optional["_models.NSPConfigPerimeter"] = rest_field( + name="networkSecurityPerimeter", visibility=["read", "create", "update", "delete", "query"] + ) + resource_association: Optional["_models.NSPConfigAssociation"] = rest_field( + name="resourceAssociation", visibility=["read", "create", "update", "delete", "query"] + ) + profile: Optional["_models.NSPConfigProfile"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + provisioning_issues: Optional[list["_models.NSPProvisioningIssue"]] = rest_field( + name="provisioningIssues", visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + 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, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NSPConfigAccessRule(_Model): + """NSPConfigAccessRule. + + :ivar name: + :vartype name: str + :ivar properties: + :vartype properties: ~azure.mgmt.sql.models.NSPConfigAccessRuleProperties + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + properties: Optional["_models.NSPConfigAccessRuleProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + properties: Optional["_models.NSPConfigAccessRuleProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NSPConfigAccessRuleProperties(_Model): + """NSPConfigAccessRuleProperties. + + :ivar direction: + :vartype direction: str + :ivar address_prefixes: + :vartype address_prefixes: list[str] + :ivar fully_qualified_domain_names: + :vartype fully_qualified_domain_names: list[str] + :ivar subscriptions: + :vartype subscriptions: list[str] + :ivar network_security_perimeters: + :vartype network_security_perimeters: + list[~azure.mgmt.sql.models.NSPConfigNetworkSecurityPerimeterRule] + :ivar service_tags: + :vartype service_tags: list[str] + """ + + direction: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + address_prefixes: Optional[list[str]] = rest_field( + name="addressPrefixes", visibility=["read", "create", "update", "delete", "query"] + ) + fully_qualified_domain_names: Optional[list[str]] = rest_field( + name="fullyQualifiedDomainNames", visibility=["read", "create", "update", "delete", "query"] + ) + subscriptions: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + network_security_perimeters: Optional[list["_models.NSPConfigNetworkSecurityPerimeterRule"]] = rest_field( + name="networkSecurityPerimeters", visibility=["read", "create", "update", "delete", "query"] + ) + service_tags: Optional[list[str]] = rest_field( + name="serviceTags", visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + 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, + service_tags: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NSPConfigAssociation(_Model): + """NSPConfigAssociation. + + :ivar name: + :vartype name: str + :ivar access_mode: + :vartype access_mode: str + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + access_mode: Optional[str] = rest_field( + name="accessMode", visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + access_mode: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NSPConfigNetworkSecurityPerimeterRule(_Model): + """NSPConfigNetworkSecurityPerimeterRule. + + :ivar id: + :vartype id: str + :ivar perimeter_guid: + :vartype perimeter_guid: str + :ivar location: + :vartype location: str + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + perimeter_guid: Optional[str] = rest_field( + name="perimeterGuid", visibility=["read", "create", "update", "delete", "query"] + ) + location: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + perimeter_guid: Optional[str] = None, + location: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NSPConfigPerimeter(_Model): + """NSPConfigPerimeter. + + :ivar id: + :vartype id: str + :ivar perimeter_guid: + :vartype perimeter_guid: str + :ivar location: + :vartype location: str + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + perimeter_guid: Optional[str] = rest_field( + name="perimeterGuid", visibility=["read", "create", "update", "delete", "query"] + ) + location: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + perimeter_guid: Optional[str] = None, + location: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NSPConfigProfile(_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] + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + access_rules_version: Optional[str] = rest_field( + name="accessRulesVersion", visibility=["read", "create", "update", "delete", "query"] + ) + access_rules: Optional[list["_models.NSPConfigAccessRule"]] = rest_field( + name="accessRules", visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + access_rules_version: Optional[str] = None, + access_rules: Optional[list["_models.NSPConfigAccessRule"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NSPProvisioningIssue(_Model): + """NSPProvisioningIssue. + + :ivar name: + :vartype name: str + :ivar properties: + :vartype properties: ~azure.mgmt.sql.models.NSPProvisioningIssueProperties + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + properties: Optional["_models.NSPProvisioningIssueProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + properties: Optional["_models.NSPProvisioningIssueProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NSPProvisioningIssueProperties(_Model): + """NSPProvisioningIssueProperties. + + :ivar issue_type: + :vartype issue_type: str + :ivar severity: + :vartype severity: str + :ivar description: + :vartype description: str + :ivar suggested_resource_ids: + :vartype suggested_resource_ids: list[str] + :ivar suggested_access_rules: + :vartype suggested_access_rules: list[str] + """ + + issue_type: Optional[str] = rest_field(name="issueType", visibility=["read", "create", "update", "delete", "query"]) + severity: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + suggested_resource_ids: Optional[list[str]] = rest_field( + name="suggestedResourceIds", visibility=["read", "create", "update", "delete", "query"] + ) + suggested_access_rules: Optional[list[str]] = rest_field( + name="suggestedAccessRules", visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + issue_type: Optional[str] = None, + severity: Optional[str] = None, + description: Optional[str] = None, + suggested_resource_ids: Optional[list[str]] = None, + suggested_access_rules: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Operation(_Model): + """SQL REST API operation definition. + + :ivar name: The name of the operation being performed on this particular object. + :vartype name: str + :ivar display: The localized display information for this particular operation / action. + :vartype display: ~azure.mgmt.sql.models.OperationDisplay + :ivar origin: The intended executor of the operation. Known values are: "user" and "system". + :vartype origin: str or ~azure.mgmt.sql.models.OperationOrigin + :ivar properties: Additional descriptions for the operation. + :vartype properties: dict[str, any] + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """The name of the operation being performed on this particular object.""" + display: Optional["_models.OperationDisplay"] = rest_field(visibility=["read"]) + """The localized display information for this particular operation / action.""" + origin: Optional[Union[str, "_models.OperationOrigin"]] = rest_field(visibility=["read"]) + """The intended executor of the operation. Known values are: \"user\" and \"system\".""" + properties: Optional[dict[str, Any]] = rest_field(visibility=["read"]) + """Additional descriptions for the operation.""" + + +class OperationDisplay(_Model): + """Display metadata associated with the operation. + + :ivar provider: The localized friendly form of the resource provider name. + :vartype provider: str + :ivar resource: The localized friendly form of the resource type related to this + action/operation. + :vartype resource: str + :ivar operation: The localized friendly name for the operation. + :vartype operation: str + :ivar description: The localized friendly description for the operation. + :vartype description: str + """ + + provider: Optional[str] = rest_field(visibility=["read"]) + """The localized friendly form of the resource provider name.""" + resource: Optional[str] = rest_field(visibility=["read"]) + """The localized friendly form of the resource type related to this action/operation.""" + operation: Optional[str] = rest_field(visibility=["read"]) + """The localized friendly name for the operation.""" + description: Optional[str] = rest_field(visibility=["read"]) + """The localized friendly description for the operation.""" + + +class OutboundEnvironmentEndpoint(_Model): + """An endpoint that the managed instance service requires outbound network access to. + + :ivar category: The type of service accessed by the managed instance service, e.g., Azure + Storage, Azure Active Directory, etc. + :vartype category: str + :ivar endpoints: The endpoints that the managed instance service communicates with in order to + function correctly. + :vartype endpoints: list[~azure.mgmt.sql.models.EndpointDependency] + """ + + category: Optional[str] = rest_field(visibility=["read"]) + """The type of service accessed by the managed instance service, e.g., Azure Storage, Azure Active + Directory, etc.""" + endpoints: Optional[list["_models.EndpointDependency"]] = rest_field(visibility=["read"]) + """The endpoints that the managed instance service communicates with in order to function + correctly.""" + + +class OutboundFirewallRule(ProxyResource): + """An Azure SQL DB Server Outbound Firewall Rule. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.OutboundFirewallRuleProperties + """ + + properties: Optional["_models.OutboundFirewallRuleProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["provisioning_state"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.OutboundFirewallRuleProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class OutboundFirewallRuleProperties(_Model): + """The properties of an outbound firewall rule. + + :ivar provisioning_state: The state of the outbound rule. + :vartype provisioning_state: str + """ + + provisioning_state: Optional[str] = rest_field(name="provisioningState", visibility=["read"]) + """The state of the outbound rule.""" + + +class PartnerInfo(_Model): + """Partner server information for the failover group. + + :ivar id: Resource identifier of the partner server. Required. + :vartype id: str + :ivar location: Geo location of the partner server. + :vartype location: str + :ivar replication_role: Replication role of the partner server. Known values are: "Primary" and + "Secondary". + :vartype replication_role: str or ~azure.mgmt.sql.models.FailoverGroupReplicationRole + """ + + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource identifier of the partner server. Required.""" + location: Optional[str] = rest_field(visibility=["read"]) + """Geo location of the partner server.""" + replication_role: Optional[Union[str, "_models.FailoverGroupReplicationRole"]] = rest_field( + name="replicationRole", visibility=["read"] + ) + """Replication role of the partner server. Known values are: \"Primary\" and \"Secondary\".""" + + @overload + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PartnerRegionInfo(_Model): + """Partner region information for the failover group. + + :ivar location: Geo location of the partner managed instances. + :vartype location: str + :ivar replication_role: Replication role of the partner managed instances. Known values are: + "Primary" and "Secondary". + :vartype replication_role: str or ~azure.mgmt.sql.models.InstanceFailoverGroupReplicationRole + """ + + location: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Geo location of the partner managed instances.""" + replication_role: Optional[Union[str, "_models.InstanceFailoverGroupReplicationRole"]] = rest_field( + name="replicationRole", visibility=["read"] + ) + """Replication role of the partner managed instances. Known values are: \"Primary\" and + \"Secondary\".""" + + @overload + def __init__( + self, + *, + location: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PerDatabaseAutoPauseDelayTimeRange(_Model): + """Supported auto pause delay time range. + + :ivar min_value: Minimum value. + :vartype min_value: int + :ivar max_value: Maximum value. + :vartype max_value: int + :ivar step_size: Step value for discrete values between the minimum value and the maximum + value. + :vartype step_size: int + :ivar default: Default value if no value is provided. + :vartype default: int + :ivar unit: Unit of time that delay is expressed in. "Minutes" + :vartype unit: str or ~azure.mgmt.sql.models.PauseDelayTimeUnit + :ivar do_not_pause_value: Value that is used to not pause (infinite delay before pause). + :vartype do_not_pause_value: int + """ + + min_value: Optional[int] = rest_field(name="minValue", visibility=["read"]) + """Minimum value.""" + max_value: Optional[int] = rest_field(name="maxValue", visibility=["read"]) + """Maximum value.""" + step_size: Optional[int] = rest_field(name="stepSize", visibility=["read"]) + """Step value for discrete values between the minimum value and the maximum value.""" + default: Optional[int] = rest_field(visibility=["read"]) + """Default value if no value is provided.""" + unit: Optional[Union[str, "_models.PauseDelayTimeUnit"]] = rest_field(visibility=["read"]) + """Unit of time that delay is expressed in. \"Minutes\"""" + do_not_pause_value: Optional[int] = rest_field(name="doNotPauseValue", visibility=["read"]) + """Value that is used to not pause (infinite delay before pause).""" + + +class PerformanceLevelCapability(_Model): + """The performance level capability. + + :ivar value: Performance level value. + :vartype value: float + :ivar unit: Unit type used to measure performance level. Known values are: "DTU" and "VCores". + :vartype unit: str or ~azure.mgmt.sql.models.PerformanceLevelUnit + """ + + value: Optional[float] = rest_field(visibility=["read"]) + """Performance level value.""" + unit: Optional[Union[str, "_models.PerformanceLevelUnit"]] = rest_field(visibility=["read"]) + """Unit type used to measure performance level. Known values are: \"DTU\" and \"VCores\".""" + + +class PhaseDetails(_Model): + """The phase details properties of a database operation. + + :ivar phase: The operation phase. Known values are: "LogTransitionInProgress", "Copying", + "BuildingHyperscaleComponents", "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] + """ + + phase: Optional[Union[str, "_models.Phase"]] = rest_field(visibility=["read"]) + """The operation phase. Known values are: \"LogTransitionInProgress\", \"Copying\", + \"BuildingHyperscaleComponents\", \"Catchup\", \"WaitingForCutover\", and + \"CutoverInProgress\".""" + phase_information: Optional[dict[str, str]] = rest_field(name="phaseInformation", visibility=["read"]) + """The operation phase information.""" + + +class PrivateEndpointConnection(ProxyResource): + """A private endpoint connection. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.PrivateEndpointConnectionProperties + """ + + properties: Optional["_models.PrivateEndpointConnectionProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["private_endpoint", "group_ids", "private_link_service_connection_state", "provisioning_state"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.PrivateEndpointConnectionProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class PrivateEndpointConnectionProperties(_Model): + """Properties of a private endpoint connection. + + :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: + ~azure.mgmt.sql.models.PrivateLinkServiceConnectionStateProperty + :ivar provisioning_state: State of the private endpoint connection. Known values are: + "Approving", "Ready", "Dropping", "Failed", and "Rejecting". + :vartype provisioning_state: str or ~azure.mgmt.sql.models.PrivateEndpointProvisioningState + """ + + private_endpoint: Optional["_models.PrivateEndpointProperty"] = rest_field( + name="privateEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """Private endpoint which the connection belongs to.""" + group_ids: Optional[list[str]] = rest_field(name="groupIds", visibility=["read"]) + """Group IDs.""" + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionStateProperty"] = rest_field( + name="privateLinkServiceConnectionState", visibility=["read", "create", "update", "delete", "query"] + ) + """Connection state of the private endpoint connection.""" + provisioning_state: Optional[Union[str, "_models.PrivateEndpointProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """State of the private endpoint connection. Known values are: \"Approving\", \"Ready\", + \"Dropping\", \"Failed\", and \"Rejecting\".""" + + @overload + def __init__( + self, + *, + private_endpoint: Optional["_models.PrivateEndpointProperty"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionStateProperty"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PrivateEndpointConnectionRequestStatus(_Model): + """Contains the private endpoint connection requests status. + + :ivar private_link_service_id: Resource id for which the private endpoint is created. + :vartype private_link_service_id: str + :ivar private_endpoint_connection_name: The connection name for the private endpoint. + :vartype private_endpoint_connection_name: str + :ivar status: Status of this private endpoint connection. + :vartype status: str + """ + + private_link_service_id: Optional[str] = rest_field(name="privateLinkServiceId", visibility=["read"]) + """Resource id for which the private endpoint is created.""" + private_endpoint_connection_name: Optional[str] = rest_field( + name="privateEndpointConnectionName", visibility=["read"] + ) + """The connection name for the private endpoint.""" + status: Optional[str] = rest_field(visibility=["read"]) + """Status of this private endpoint connection.""" + + +class PrivateEndpointProperty(_Model): + """PrivateEndpointProperty. + + :ivar id: Resource id of the private endpoint. + :vartype id: str + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource id of the private endpoint.""" + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PrivateLinkResource(ProxyResource): + """A private link resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: The private link resource group id. + :vartype properties: ~azure.mgmt.sql.models.PrivateLinkResourceProperties + """ + + properties: Optional["_models.PrivateLinkResourceProperties"] = rest_field(visibility=["read"]) + """The private link resource group id.""" + + +class PrivateLinkResourceProperties(_Model): + """Properties of a private link resource. + + :ivar group_id: The private link resource group id. + :vartype group_id: str + :ivar required_members: The private link resource required member names. + :vartype required_members: list[str] + :ivar required_zone_names: The private link resource required zone names. + :vartype required_zone_names: list[str] + """ + + group_id: Optional[str] = rest_field(name="groupId", visibility=["read"]) + """The private link resource group id.""" + required_members: Optional[list[str]] = rest_field(name="requiredMembers", visibility=["read"]) + """The private link resource required member names.""" + required_zone_names: Optional[list[str]] = rest_field(name="requiredZoneNames", visibility=["read"]) + """The private link resource required zone names.""" + + +class PrivateLinkServiceConnectionStateProperty(_Model): # pylint: disable=name-too-long + """PrivateLinkServiceConnectionStateProperty. + + :ivar status: The private link service connection status. Required. Known values are: + "Approved", "Pending", "Rejected", and "Disconnected". + :vartype status: str or ~azure.mgmt.sql.models.PrivateLinkServiceConnectionStateStatus + :ivar description: The private link service connection description. Required. + :vartype description: str + :ivar actions_required: The actions required for private link service connection. "None" + :vartype actions_required: str or + ~azure.mgmt.sql.models.PrivateLinkServiceConnectionStateActionsRequire + """ + + status: Union[str, "_models.PrivateLinkServiceConnectionStateStatus"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The private link service connection status. Required. Known values are: \"Approved\", + \"Pending\", \"Rejected\", and \"Disconnected\".""" + description: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The private link service connection description. Required.""" + actions_required: Optional[Union[str, "_models.PrivateLinkServiceConnectionStateActionsRequire"]] = rest_field( + name="actionsRequired", visibility=["read"] + ) + """The actions required for private link service connection. \"None\"""" + + @overload + def __init__( + self, + *, + status: Union[str, "_models.PrivateLinkServiceConnectionStateStatus"], + description: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class QueryCheck(_Model): + """SQL Vulnerability Assessment query check object. + + :ivar query: SQL Vulnerability Assessment rule query. + :vartype query: str + :ivar expected_result: SQL Vulnerability Assessment query expected result. + :vartype expected_result: list[list[str]] + :ivar column_names: SQL Vulnerability Assessment column names of query expected result. + :vartype column_names: list[str] + """ + + query: Optional[str] = rest_field(visibility=["read"]) + """SQL Vulnerability Assessment rule query.""" + expected_result: Optional[list[list[str]]] = rest_field(name="expectedResult", visibility=["read"]) + """SQL Vulnerability Assessment query expected result.""" + column_names: Optional[list[str]] = rest_field(name="columnNames", visibility=["read"]) + """SQL Vulnerability Assessment column names of query expected result.""" + + +class QueryMetricInterval(_Model): + """Properties of a query metrics interval. + + :ivar interval_start_time: The start time for the metric interval (ISO-8601 format). + :vartype interval_start_time: str + :ivar interval_type: Interval type (length). Known values are: "PT1H" and "P1D". + :vartype interval_type: str or ~azure.mgmt.sql.models.QueryTimeGrainType + :ivar execution_count: Execution count of a query in this interval. + :vartype execution_count: int + :ivar metrics: List of metric objects for this interval. + :vartype metrics: list[~azure.mgmt.sql.models.QueryMetricProperties] + """ + + interval_start_time: Optional[str] = rest_field(name="intervalStartTime", visibility=["read"]) + """The start time for the metric interval (ISO-8601 format).""" + interval_type: Optional[Union[str, "_models.QueryTimeGrainType"]] = rest_field( + name="intervalType", visibility=["read"] + ) + """Interval type (length). Known values are: \"PT1H\" and \"P1D\".""" + execution_count: Optional[int] = rest_field(name="executionCount", visibility=["read"]) + """Execution count of a query in this interval.""" + metrics: Optional[list["_models.QueryMetricProperties"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of metric objects for this interval.""" + + @overload + def __init__( + self, + *, + metrics: Optional[list["_models.QueryMetricProperties"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class QueryMetricProperties(_Model): + """Properties of a topquery metric in one interval. + + :ivar name: The name information for the metric. + :vartype name: str + :ivar display_name: The UI appropriate name for the metric. + :vartype display_name: str + :ivar unit: The unit of the metric. Known values are: "percentage", "KB", "microseconds", and + "count". + :vartype unit: str or ~azure.mgmt.sql.models.QueryMetricUnitType + :ivar value: The value of the metric. + :vartype value: float + :ivar min: Metric value when min() aggregate function is used over the interval. + :vartype min: float + :ivar max: Metric value when max() aggregate function is used over the interval. + :vartype max: float + :ivar avg: Metric value when avg() aggregate function is used over the interval. + :vartype avg: float + :ivar sum: Metric value when sum() aggregate function is used over the interval. + :vartype sum: float + :ivar stdev: Metric value when stdev aggregate function is used over the interval. + :vartype stdev: float + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """The name information for the metric.""" + display_name: Optional[str] = rest_field(name="displayName", visibility=["read"]) + """The UI appropriate name for the metric.""" + unit: Optional[Union[str, "_models.QueryMetricUnitType"]] = rest_field(visibility=["read"]) + """The unit of the metric. Known values are: \"percentage\", \"KB\", \"microseconds\", and + \"count\".""" + value: Optional[float] = rest_field(visibility=["read"]) + """The value of the metric.""" + min: Optional[float] = rest_field(visibility=["read"]) + """Metric value when min() aggregate function is used over the interval.""" + max: Optional[float] = rest_field(visibility=["read"]) + """Metric value when max() aggregate function is used over the interval.""" + avg: Optional[float] = rest_field(visibility=["read"]) + """Metric value when avg() aggregate function is used over the interval.""" + sum: Optional[float] = rest_field(visibility=["read"]) + """Metric value when sum() aggregate function is used over the interval.""" + stdev: Optional[float] = rest_field(visibility=["read"]) + """Metric value when stdev aggregate function is used over the interval.""" + + +class QueryProperties(_Model): + """Properties of a database query. + + :ivar query_text: Query text. + :vartype query_text: str + """ + + query_text: Optional[str] = rest_field(name="queryText", visibility=["read", "create", "update", "delete", "query"]) + """Query text.""" + + @overload + def __init__( + self, + *, + query_text: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class QueryStatistics(ProxyResource): + """QueryStatistics. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.QueryStatisticsProperties + """ + + properties: Optional["_models.QueryStatisticsProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["database_name", "query_id", "start_time", "end_time", "intervals"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.QueryStatisticsProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class QueryStatisticsProperties(_Model): + """Properties of a query execution statistics. + + :ivar database_name: Database name of the database in which this query was executed. + :vartype database_name: str + :ivar query_id: Unique query id (unique within one database). + :vartype query_id: str + :ivar start_time: The start time for the metric (ISO-8601 format). + :vartype start_time: str + :ivar end_time: The end time for the metric (ISO-8601 format). + :vartype end_time: str + :ivar intervals: List of intervals with appropriate metric data. + :vartype intervals: list[~azure.mgmt.sql.models.QueryMetricInterval] + """ + + database_name: Optional[str] = rest_field(name="databaseName", visibility=["read"]) + """Database name of the database in which this query was executed.""" + query_id: Optional[str] = rest_field(name="queryId", visibility=["read"]) + """Unique query id (unique within one database).""" + start_time: Optional[str] = rest_field(name="startTime", visibility=["read"]) + """The start time for the metric (ISO-8601 format).""" + end_time: Optional[str] = rest_field(name="endTime", visibility=["read"]) + """The end time for the metric (ISO-8601 format).""" + intervals: Optional[list["_models.QueryMetricInterval"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of intervals with appropriate metric data.""" + + @overload + def __init__( + self, + *, + intervals: Optional[list["_models.QueryMetricInterval"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ReadScaleCapability(_Model): + """The read scale capability. + + :ivar max_number_of_replicas: The maximum number of read scale replicas. + :vartype max_number_of_replicas: int + :ivar status: The status of the capability. 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 + """ + + max_number_of_replicas: Optional[int] = rest_field(name="maxNumberOfReplicas", visibility=["read"]) + """The maximum number of read scale replicas.""" + status: Optional[Union[str, "_models.CapabilityStatus"]] = rest_field(visibility=["read"]) + """The status of the capability. Known values are: \"Visible\", \"Available\", \"Default\", and + \"Disabled\".""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for the capability not being available.""" + + @overload + def __init__( + self, + *, + reason: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RecommendedAction(ProxyResource): + """Database, Server or Elastic Pool Recommended Action. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.RecommendedActionProperties + :ivar kind: Resource kind. + :vartype kind: str + :ivar location: Resource location. + :vartype location: str + """ + + properties: Optional["_models.RecommendedActionProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + kind: Optional[str] = rest_field(visibility=["read"]) + """Resource kind.""" + location: Optional[str] = rest_field(visibility=["read"]) + """Resource location.""" + + __flattened_items = [ + "recommendation_reason", + "valid_since", + "last_refresh", + "state", + "is_executable_action", + "is_revertable_action", + "is_archived_action", + "execute_action_start_time", + "execute_action_duration", + "revert_action_start_time", + "revert_action_duration", + "execute_action_initiated_by", + "execute_action_initiated_time", + "revert_action_initiated_by", + "revert_action_initiated_time", + "score", + "implementation_details", + "error_details", + "estimated_impact", + "observed_impact", + "time_series", + "linked_objects", + "details", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.RecommendedActionProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class RecommendedActionErrorInfo(_Model): + """Contains error information for an Azure SQL Database, Server or Elastic Pool Recommended + Action. + + :ivar error_code: Gets the reason why the recommended action was put to error state. e.g., + DatabaseHasQdsOff, IndexAlreadyExists. + :vartype error_code: str + :ivar is_retryable: Gets whether the error could be ignored and recommended action could be + retried. Possible values are: Yes/No. Known values are: "Yes" and "No". + :vartype is_retryable: str or ~azure.mgmt.sql.models.IsRetryable + """ + + error_code: Optional[str] = rest_field(name="errorCode", visibility=["read"]) + """Gets the reason why the recommended action was put to error state. e.g., DatabaseHasQdsOff, + IndexAlreadyExists.""" + is_retryable: Optional[Union[str, "_models.IsRetryable"]] = rest_field(name="isRetryable", visibility=["read"]) + """Gets whether the error could be ignored and recommended action could be retried. Possible + values are: Yes/No. Known values are: \"Yes\" and \"No\".""" + + +class RecommendedActionImpactRecord(_Model): + """Contains information of estimated or observed impact on various metrics for an Azure SQL + Database, Server or Elastic Pool Recommended Action. + + :ivar dimension_name: Gets the name of the impact dimension. e.g., CPUChange, DiskSpaceChange, + NumberOfQueriesAffected. + :vartype dimension_name: str + :ivar unit: Gets the name of the impact dimension. e.g., CPUChange, DiskSpaceChange, + NumberOfQueriesAffected. + :vartype unit: str + :ivar absolute_value: Gets the absolute value of this dimension if applicable. e.g., Number of + Queries affected. + :vartype absolute_value: float + :ivar change_value_absolute: Gets the absolute change in the value of this dimension. e.g., + Absolute Disk space change in Megabytes. + :vartype change_value_absolute: float + :ivar change_value_relative: Gets the relative change in the value of this dimension. e.g., + Relative Disk space change in Percentage. + :vartype change_value_relative: float + """ + + dimension_name: Optional[str] = rest_field(name="dimensionName", visibility=["read"]) + """Gets the name of the impact dimension. e.g., CPUChange, DiskSpaceChange, + NumberOfQueriesAffected.""" + unit: Optional[str] = rest_field(visibility=["read"]) + """Gets the name of the impact dimension. e.g., CPUChange, DiskSpaceChange, + NumberOfQueriesAffected.""" + absolute_value: Optional[float] = rest_field(name="absoluteValue", visibility=["read"]) + """Gets the absolute value of this dimension if applicable. e.g., Number of Queries affected.""" + change_value_absolute: Optional[float] = rest_field(name="changeValueAbsolute", visibility=["read"]) + """Gets the absolute change in the value of this dimension. e.g., Absolute Disk space change in + Megabytes.""" + change_value_relative: Optional[float] = rest_field(name="changeValueRelative", visibility=["read"]) + """Gets the relative change in the value of this dimension. e.g., Relative Disk space change in + Percentage.""" + + +class RecommendedActionImplementationInfo(_Model): + """Contains information for manual implementation for an Azure SQL Database, Server or Elastic + Pool Recommended Action. + + :ivar method: Gets the method in which this recommended action can be manually implemented. + e.g., TSql, AzurePowerShell. Known values are: "TSql" and "AzurePowerShell". + :vartype method: str or ~azure.mgmt.sql.models.ImplementationMethod + :ivar script: Gets the manual implementation script. e.g., T-SQL script that could be executed + on the database. + :vartype script: str + """ + + method: Optional[Union[str, "_models.ImplementationMethod"]] = rest_field(visibility=["read"]) + """Gets the method in which this recommended action can be manually implemented. e.g., TSql, + AzurePowerShell. Known values are: \"TSql\" and \"AzurePowerShell\".""" + script: Optional[str] = rest_field(visibility=["read"]) + """Gets the manual implementation script. e.g., T-SQL script that could be executed on the + database.""" + + +class RecommendedActionMetricInfo(_Model): + """Contains time series of various impacted metrics for an Azure SQL Database, Server or Elastic + Pool Recommended Action. + + :ivar metric_name: Gets the name of the metric. e.g., CPU, Number of Queries. + :vartype metric_name: str + :ivar unit: Gets the unit in which metric is measured. e.g., DTU, Frequency. + :vartype unit: str + :ivar time_grain: Gets the duration of time interval for the value given by this MetricInfo. + e.g., PT1H (1 hour). + :vartype time_grain: str + :ivar start_time: Gets the start time of time interval given by this MetricInfo. + :vartype start_time: ~datetime.datetime + :ivar value: Gets the value of the metric in the time interval given by this MetricInfo. + :vartype value: float + """ + + metric_name: Optional[str] = rest_field(name="metricName", visibility=["read"]) + """Gets the name of the metric. e.g., CPU, Number of Queries.""" + unit: Optional[str] = rest_field(visibility=["read"]) + """Gets the unit in which metric is measured. e.g., DTU, Frequency.""" + time_grain: Optional[str] = rest_field(name="timeGrain", visibility=["read"]) + """Gets the duration of time interval for the value given by this MetricInfo. e.g., PT1H (1 hour).""" + start_time: Optional[datetime.datetime] = rest_field(name="startTime", visibility=["read"], format="rfc3339") + """Gets the start time of time interval given by this MetricInfo.""" + value: Optional[float] = rest_field(visibility=["read"]) + """Gets the value of the metric in the time interval given by this MetricInfo.""" + + +class RecommendedActionProperties(_Model): + """Properties for a Database, Server or Elastic Pool Recommended Action. + + :ivar recommendation_reason: Gets the reason for recommending this action. e.g., + DuplicateIndex. + :vartype recommendation_reason: str + :ivar valid_since: Gets the time since when this recommended action is valid. + :vartype valid_since: ~datetime.datetime + :ivar last_refresh: Gets time when this recommended action was last refreshed. + :vartype last_refresh: ~datetime.datetime + :ivar state: Gets the info of the current state the recommended action is in. Required. + :vartype state: ~azure.mgmt.sql.models.RecommendedActionStateInfo + :ivar is_executable_action: Gets if this recommended action is actionable by user. + :vartype is_executable_action: bool + :ivar is_revertable_action: Gets if changes applied by this recommended action can be reverted + by user. + :vartype is_revertable_action: bool + :ivar is_archived_action: Gets if this recommended action was suggested some time ago but user + chose to ignore this and system added a new recommended action again. + :vartype is_archived_action: bool + :ivar execute_action_start_time: Gets the time when system started applying this recommended + action on the user resource. e.g., index creation start time. + :vartype execute_action_start_time: ~datetime.datetime + :ivar execute_action_duration: Gets the time taken for applying this recommended action on user + resource. e.g., time taken for index creation. + :vartype execute_action_duration: ~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: ~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 + ~azure.mgmt.sql.models.RecommendedActionInitiatedBy + :ivar execute_action_initiated_time: Gets the time when this recommended action was approved + for execution. + :vartype execute_action_initiated_time: ~datetime.datetime + :ivar revert_action_initiated_by: Gets if approval for reverting this recommended action was + given by user/system. Known values are: "User" and "System". + :vartype revert_action_initiated_by: str or ~azure.mgmt.sql.models.RecommendedActionInitiatedBy + :ivar revert_action_initiated_time: Gets the time when this recommended action was approved for + revert. + :vartype revert_action_initiated_time: ~datetime.datetime + :ivar score: Gets the impact of this recommended action. Possible values are 1 - Low impact, 2 + - Medium Impact and 3 - High Impact. + :vartype score: int + :ivar implementation_details: Gets the implementation details of this recommended action for + user to apply it manually. + :vartype implementation_details: ~azure.mgmt.sql.models.RecommendedActionImplementationInfo + :ivar error_details: Gets the error details if and why this recommended action is put to error + state. + :vartype error_details: ~azure.mgmt.sql.models.RecommendedActionErrorInfo + :ivar estimated_impact: Gets the estimated impact info for this recommended action e.g., + Estimated CPU gain, Estimated Disk Space change. + :vartype estimated_impact: list[~azure.mgmt.sql.models.RecommendedActionImpactRecord] + :ivar observed_impact: Gets the observed/actual impact info for this recommended action e.g., + Actual CPU gain, Actual Disk Space change. + :vartype observed_impact: list[~azure.mgmt.sql.models.RecommendedActionImpactRecord] + :ivar time_series: Gets the time series info of metrics for this recommended action e.g., CPU + consumption time series. + :vartype time_series: list[~azure.mgmt.sql.models.RecommendedActionMetricInfo] + :ivar linked_objects: Gets the linked objects, if any. + :vartype linked_objects: list[str] + :ivar details: Gets additional details specific to this recommended action. + :vartype details: dict[str, str] + """ + + recommendation_reason: Optional[str] = rest_field(name="recommendationReason", visibility=["read"]) + """Gets the reason for recommending this action. e.g., DuplicateIndex.""" + valid_since: Optional[datetime.datetime] = rest_field(name="validSince", visibility=["read"], format="rfc3339") + """Gets the time since when this recommended action is valid.""" + last_refresh: Optional[datetime.datetime] = rest_field(name="lastRefresh", visibility=["read"], format="rfc3339") + """Gets time when this recommended action was last refreshed.""" + state: "_models.RecommendedActionStateInfo" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Gets the info of the current state the recommended action is in. Required.""" + is_executable_action: Optional[bool] = rest_field(name="isExecutableAction", visibility=["read"]) + """Gets if this recommended action is actionable by user.""" + is_revertable_action: Optional[bool] = rest_field(name="isRevertableAction", visibility=["read"]) + """Gets if changes applied by this recommended action can be reverted by user.""" + is_archived_action: Optional[bool] = rest_field(name="isArchivedAction", visibility=["read"]) + """Gets if this recommended action was suggested some time ago but user chose to ignore this and + system added a new recommended action again.""" + execute_action_start_time: Optional[datetime.datetime] = rest_field( + name="executeActionStartTime", visibility=["read"], format="rfc3339" + ) + """Gets the time when system started applying this recommended action on the user resource. e.g., + index creation start time.""" + execute_action_duration: Optional[datetime.timedelta] = rest_field( + name="executeActionDuration", visibility=["read"] + ) + """Gets the time taken for applying this recommended action on user resource. e.g., time taken for + index creation.""" + revert_action_start_time: Optional[datetime.datetime] = rest_field( + name="revertActionStartTime", visibility=["read"], format="rfc3339" + ) + """Gets the time when system started reverting changes of this recommended action on user + resource. e.g., time when index drop is executed.""" + revert_action_duration: Optional[datetime.timedelta] = rest_field(name="revertActionDuration", visibility=["read"]) + """Gets the time taken for reverting changes of this recommended action on user resource. e.g., + time taken for dropping the created index.""" + execute_action_initiated_by: Optional[Union[str, "_models.RecommendedActionInitiatedBy"]] = rest_field( + name="executeActionInitiatedBy", visibility=["read"] + ) + """Gets if approval for applying this recommended action was given by user/system. Known values + are: \"User\" and \"System\".""" + execute_action_initiated_time: Optional[datetime.datetime] = rest_field( + name="executeActionInitiatedTime", visibility=["read"], format="rfc3339" + ) + """Gets the time when this recommended action was approved for execution.""" + revert_action_initiated_by: Optional[Union[str, "_models.RecommendedActionInitiatedBy"]] = rest_field( + name="revertActionInitiatedBy", visibility=["read"] + ) + """Gets if approval for reverting this recommended action was given by user/system. Known values + are: \"User\" and \"System\".""" + revert_action_initiated_time: Optional[datetime.datetime] = rest_field( + name="revertActionInitiatedTime", visibility=["read"], format="rfc3339" + ) + """Gets the time when this recommended action was approved for revert.""" + score: Optional[int] = rest_field(visibility=["read"]) + """Gets the impact of this recommended action. Possible values are 1 - Low impact, 2 - Medium + Impact and 3 - High Impact.""" + implementation_details: Optional["_models.RecommendedActionImplementationInfo"] = rest_field( + name="implementationDetails", visibility=["read"] + ) + """Gets the implementation details of this recommended action for user to apply it manually.""" + error_details: Optional["_models.RecommendedActionErrorInfo"] = rest_field(name="errorDetails", visibility=["read"]) + """Gets the error details if and why this recommended action is put to error state.""" + estimated_impact: Optional[list["_models.RecommendedActionImpactRecord"]] = rest_field( + name="estimatedImpact", visibility=["read"] + ) + """Gets the estimated impact info for this recommended action e.g., Estimated CPU gain, Estimated + Disk Space change.""" + observed_impact: Optional[list["_models.RecommendedActionImpactRecord"]] = rest_field( + name="observedImpact", visibility=["read"] + ) + """Gets the observed/actual impact info for this recommended action e.g., Actual CPU gain, Actual + Disk Space change.""" + time_series: Optional[list["_models.RecommendedActionMetricInfo"]] = rest_field( + name="timeSeries", visibility=["read"] + ) + """Gets the time series info of metrics for this recommended action e.g., CPU consumption time + series.""" + linked_objects: Optional[list[str]] = rest_field(name="linkedObjects", visibility=["read"]) + """Gets the linked objects, if any.""" + details: Optional[dict[str, str]] = rest_field(visibility=["read"]) + """Gets additional details specific to this recommended action.""" + + @overload + def __init__( + self, + *, + state: "_models.RecommendedActionStateInfo", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RecommendedActionStateInfo(_Model): + """Contains information of current state for an Azure SQL Database, Server or Elastic Pool + Recommended Action. + + :ivar current_value: Current state the recommended action is in. Some commonly used states are: + Active -> recommended action is active and no action has been taken yet. Pending -> + recommended action is approved for and is awaiting execution. Executing -> recommended action + is being applied on the user database. Verifying -> recommended action was applied and is + being verified of its usefulness by the system. Success -> recommended action was applied + and improvement found during verification. Pending Revert -> verification found little or no + improvement so recommended action is queued for revert or user has manually reverted. Reverting + -> changes made while applying recommended action are being reverted on the user database. + Reverted -> successfully reverted the changes made by recommended action on user database. + Ignored -> user explicitly ignored/discarded the recommended action. Required. Known values + are: "Active", "Pending", "Executing", "Verifying", "PendingRevert", "RevertCancelled", + "Reverting", "Reverted", "Ignored", "Expired", "Monitoring", "Resolved", "Success", and + "Error". + :vartype current_value: str or ~azure.mgmt.sql.models.RecommendedActionCurrentState + :ivar action_initiated_by: Gets who initiated the execution of this recommended action. + Possible Value are: User -> When user explicity notified system to apply the recommended + action. System -> When auto-execute status of this advisor was set to 'Enabled', in which case + the system applied it. Known values are: "User" and "System". + :vartype action_initiated_by: str or ~azure.mgmt.sql.models.RecommendedActionInitiatedBy + :ivar last_modified: Gets the time when the state was last modified. + :vartype last_modified: ~datetime.datetime + """ + + current_value: Union[str, "_models.RecommendedActionCurrentState"] = rest_field( + name="currentValue", visibility=["read", "create", "update", "delete", "query"] + ) + """Current state the recommended action is in. Some commonly used states are: Active -> + recommended action is active and no action has been taken yet. Pending -> recommended + action is approved for and is awaiting execution. Executing -> recommended action is being + applied on the user database. Verifying -> recommended action was applied and is being + verified of its usefulness by the system. Success -> recommended action was applied and + improvement found during verification. Pending Revert -> verification found little or no + improvement so recommended action is queued for revert or user has manually reverted. Reverting + -> changes made while applying recommended action are being reverted on the user database. + Reverted -> successfully reverted the changes made by recommended action on user database. + Ignored -> user explicitly ignored/discarded the recommended action. Required. Known values + are: \"Active\", \"Pending\", \"Executing\", \"Verifying\", \"PendingRevert\", + \"RevertCancelled\", \"Reverting\", \"Reverted\", \"Ignored\", \"Expired\", \"Monitoring\", + \"Resolved\", \"Success\", and \"Error\".""" + action_initiated_by: Optional[Union[str, "_models.RecommendedActionInitiatedBy"]] = rest_field( + name="actionInitiatedBy", visibility=["read"] + ) + """Gets who initiated the execution of this recommended action. Possible Value are: User -> + When user explicity notified system to apply the recommended action. System -> When + auto-execute status of this advisor was set to 'Enabled', in which case the system applied it. + Known values are: \"User\" and \"System\".""" + last_modified: Optional[datetime.datetime] = rest_field(name="lastModified", visibility=["read"], format="rfc3339") + """Gets the time when the state was last modified.""" + + @overload + def __init__( + self, + *, + current_value: Union[str, "_models.RecommendedActionCurrentState"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RecommendedSensitivityLabelUpdate(ProxyResource): + """A recommended sensitivity label update operation. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.RecommendedSensitivityLabelUpdateProperties + """ + + properties: Optional["_models.RecommendedSensitivityLabelUpdateProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["op", "schema", "table", "column"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.RecommendedSensitivityLabelUpdateProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class RecommendedSensitivityLabelUpdateList(_Model): + """A list of recommended sensitivity label update operations. + + :ivar operations: + :vartype operations: list[~azure.mgmt.sql.models.RecommendedSensitivityLabelUpdate] + """ + + operations: Optional[list["_models.RecommendedSensitivityLabelUpdate"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + operations: Optional[list["_models.RecommendedSensitivityLabelUpdate"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RecommendedSensitivityLabelUpdateProperties(_Model): # pylint: disable=name-too-long + """Properties of an operation executed on a recommended sensitivity label. + + :ivar op: Required. Known values are: "enable" and "disable". + :vartype op: str or ~azure.mgmt.sql.models.RecommendedSensitivityLabelUpdateKind + :ivar schema: Schema name of the column to update. Required. + :vartype schema: str + :ivar table: Table name of the column to update. Required. + :vartype table: str + :ivar column: Column name to update. Required. + :vartype column: str + """ + + op: Union[str, "_models.RecommendedSensitivityLabelUpdateKind"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Required. Known values are: \"enable\" and \"disable\".""" + schema: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Schema name of the column to update. Required.""" + table: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Table name of the column to update. Required.""" + column: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Column name to update. Required.""" + + @overload + def __init__( + self, + *, + op: Union[str, "_models.RecommendedSensitivityLabelUpdateKind"], + schema: str, + table: str, + column: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RecoverableDatabase(ProxyResource): + """A recoverable database resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.RecoverableDatabaseProperties + """ + + properties: Optional["_models.RecoverableDatabaseProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "edition", + "service_level_objective", + "elastic_pool_name", + "last_available_backup_date", + "keys_property", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.RecoverableDatabaseProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class RecoverableDatabaseProperties(_Model): + """The recoverable database's properties. + + :ivar edition: The edition of the database. + :vartype edition: str + :ivar service_level_objective: The service level objective name of the database. + :vartype service_level_objective: str + :ivar elastic_pool_name: The elastic pool name of the database. + :vartype elastic_pool_name: str + :ivar last_available_backup_date: The last available backup date. + :vartype last_available_backup_date: ~datetime.datetime + :ivar keys_property: The resource ids of the user assigned identities to use. + :vartype keys_property: dict[str, ~azure.mgmt.sql.models.DatabaseKey] + """ + + edition: Optional[str] = rest_field(visibility=["read"]) + """The edition of the database.""" + service_level_objective: Optional[str] = rest_field(name="serviceLevelObjective", visibility=["read"]) + """The service level objective name of the database.""" + elastic_pool_name: Optional[str] = rest_field(name="elasticPoolName", visibility=["read"]) + """The elastic pool name of the database.""" + last_available_backup_date: Optional[datetime.datetime] = rest_field( + name="lastAvailableBackupDate", visibility=["read"], format="rfc3339" + ) + """The last available backup date.""" + keys_property: Optional[dict[str, "_models.DatabaseKey"]] = rest_field( + name="keys", visibility=["read", "create", "update", "delete", "query"], original_tsp_name="keys" + ) + """The resource ids of the user assigned identities to use.""" + + @overload + def __init__( + self, + *, + keys_property: Optional[dict[str, "_models.DatabaseKey"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RecoverableManagedDatabase(ProxyResource): + """A recoverable managed database resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.RecoverableManagedDatabaseProperties + """ + + properties: Optional["_models.RecoverableManagedDatabaseProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["last_available_backup_date"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.RecoverableManagedDatabaseProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class RecoverableManagedDatabaseProperties(_Model): + """The recoverable managed database's properties. + + :ivar last_available_backup_date: The last available backup date. + :vartype last_available_backup_date: str + """ + + last_available_backup_date: Optional[str] = rest_field(name="lastAvailableBackupDate", visibility=["read"]) + """The last available backup date.""" + + +class RefreshExternalGovernanceStatusOperationResult(ProxyResource): # pylint: disable=name-too-long + """An RefreshExternalGovernanceStatus operation result resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: + ~azure.mgmt.sql.models.RefreshExternalGovernanceStatusOperationResultProperties + """ + + properties: Optional["_models.RefreshExternalGovernanceStatusOperationResultProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["request_id", "request_type", "queued_time", "server_name", "status", "error_message"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.RefreshExternalGovernanceStatusOperationResultProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class RefreshExternalGovernanceStatusOperationResultMI(ProxyResource): # pylint: disable=name-too-long + """An RefreshExternalGovernanceStatus operation result resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: + ~azure.mgmt.sql.models.RefreshExternalGovernanceStatusOperationResultPropertiesMI + """ + + properties: Optional["_models.RefreshExternalGovernanceStatusOperationResultPropertiesMI"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "request_id", + "request_type", + "queued_time", + "managed_instance_name", + "status", + "error_message", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.RefreshExternalGovernanceStatusOperationResultPropertiesMI"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class RefreshExternalGovernanceStatusOperationResultProperties(_Model): # pylint: disable=name-too-long + """Contains the operation result properties for refresh external governance status operation. + + :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 server_name: Server name. + :vartype server_name: str + :ivar status: Operation status. + :vartype status: str + :ivar error_message: Error message. + :vartype error_message: str + """ + + request_id: Optional[str] = rest_field(name="requestId", visibility=["read"]) + """Request Id.""" + request_type: Optional[str] = rest_field(name="requestType", visibility=["read"]) + """Request type.""" + queued_time: Optional[str] = rest_field(name="queuedTime", visibility=["read"]) + """Queued time.""" + server_name: Optional[str] = rest_field(name="serverName", visibility=["read"]) + """Server name.""" + status: Optional[str] = rest_field(visibility=["read"]) + """Operation status.""" + error_message: Optional[str] = rest_field(name="errorMessage", visibility=["read"]) + """Error message.""" + + +class RefreshExternalGovernanceStatusOperationResultPropertiesMI(_Model): # pylint: disable=name-too-long + """Contains the operation result properties for refresh external governance status operation. + + :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 + """ + + request_id: Optional[str] = rest_field(name="requestId", visibility=["read"]) + """Request Id.""" + request_type: Optional[str] = rest_field(name="requestType", visibility=["read"]) + """Request type.""" + queued_time: Optional[str] = rest_field(name="queuedTime", visibility=["read"]) + """Queued time.""" + managed_instance_name: Optional[str] = rest_field(name="managedInstanceName", visibility=["read"]) + """Managed instance name.""" + status: Optional[str] = rest_field(visibility=["read"]) + """Operation status.""" + error_message: Optional[str] = rest_field(name="errorMessage", visibility=["read"]) + """Error message.""" + + +class Remediation(_Model): + """SQL Vulnerability Assessment remediation Details. + + :ivar description: SQL Vulnerability Assessment remediation description. + :vartype description: str + :ivar scripts: SQL Vulnerability Assessment remediation script. + :vartype scripts: list[str] + :ivar automated: SQL Vulnerability Assessment is remediation automated. + :vartype automated: bool + :ivar portal_link: SQL Vulnerability Assessment optional link to remediate in Azure Portal. + :vartype portal_link: str + """ + + description: Optional[str] = rest_field(visibility=["read"]) + """SQL Vulnerability Assessment remediation description.""" + scripts: Optional[list[str]] = rest_field(visibility=["read"]) + """SQL Vulnerability Assessment remediation script.""" + automated: Optional[bool] = rest_field(visibility=["read"]) + """SQL Vulnerability Assessment is remediation automated.""" + portal_link: Optional[str] = rest_field(name="portalLink", visibility=["read"]) + """SQL Vulnerability Assessment optional link to remediate in Azure Portal.""" + + +class ReplicationLink(ProxyResource): + """A replication link. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ReplicationLinkProperties + """ + + properties: Optional["_models.ReplicationLinkProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "partner_server", + "partner_database", + "partner_database_id", + "partner_location", + "role", + "partner_role", + "replication_mode", + "start_time", + "percent_complete", + "replication_state", + "is_termination_allowed", + "link_type", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ReplicationLinkProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ReplicationLinkProperties(_Model): + """Properties of a replication link. + + :ivar partner_server: Resource partner server. + :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", + "NonReadableSecondary", "Source", and "Copy". + :vartype role: str or ~azure.mgmt.sql.models.ReplicationRole + :ivar partner_role: Partner replication role. Known values are: "Primary", "Secondary", + "NonReadableSecondary", "Source", and "Copy". + :vartype partner_role: str or ~azure.mgmt.sql.models.ReplicationRole + :ivar replication_mode: Replication mode. + :vartype replication_mode: str + :ivar start_time: Time at which the link was created. + :vartype start_time: ~datetime.datetime + :ivar percent_complete: Seeding completion percentage for the link. + :vartype percent_complete: int + :ivar replication_state: Replication state (PENDING, SEEDING, CATCHUP, SUSPENDED). Known values + are: "PENDING", "SEEDING", "CATCH_UP", and "SUSPENDED". + :vartype replication_state: str or ~azure.mgmt.sql.models.ReplicationState + :ivar is_termination_allowed: Whether the user is currently allowed to terminate the link. + :vartype is_termination_allowed: bool + :ivar link_type: Link type (GEO, NAMED, STANDBY). Update operation does not support NAMED. + Known values are: "GEO", "NAMED", and "STANDBY". + :vartype link_type: str or ~azure.mgmt.sql.models.ReplicationLinkType + """ + + partner_server: Optional[str] = rest_field(name="partnerServer", visibility=["read"]) + """Resource partner server.""" + partner_database: Optional[str] = rest_field(name="partnerDatabase", visibility=["read"]) + """Resource partner database.""" + partner_database_id: Optional[str] = rest_field(name="partnerDatabaseId", visibility=["read"]) + """Resource partner database Id.""" + partner_location: Optional[str] = rest_field(name="partnerLocation", visibility=["read"]) + """Resource partner location.""" + role: Optional[Union[str, "_models.ReplicationRole"]] = rest_field(visibility=["read"]) + """Local replication role. Known values are: \"Primary\", \"Secondary\", \"NonReadableSecondary\", + \"Source\", and \"Copy\".""" + partner_role: Optional[Union[str, "_models.ReplicationRole"]] = rest_field(name="partnerRole", visibility=["read"]) + """Partner replication role. Known values are: \"Primary\", \"Secondary\", + \"NonReadableSecondary\", \"Source\", and \"Copy\".""" + replication_mode: Optional[str] = rest_field(name="replicationMode", visibility=["read"]) + """Replication mode.""" + start_time: Optional[datetime.datetime] = rest_field(name="startTime", visibility=["read"], format="rfc3339") + """Time at which the link was created.""" + percent_complete: Optional[int] = rest_field(name="percentComplete", visibility=["read"]) + """Seeding completion percentage for the link.""" + replication_state: Optional[Union[str, "_models.ReplicationState"]] = rest_field( + name="replicationState", visibility=["read"] + ) + """Replication state (PENDING, SEEDING, CATCHUP, SUSPENDED). Known values are: \"PENDING\", + \"SEEDING\", \"CATCH_UP\", and \"SUSPENDED\".""" + is_termination_allowed: Optional[bool] = rest_field(name="isTerminationAllowed", visibility=["read"]) + """Whether the user is currently allowed to terminate the link.""" + link_type: Optional[Union[str, "_models.ReplicationLinkType"]] = rest_field( + name="linkType", visibility=["read", "create", "update", "delete", "query"] + ) + """Link type (GEO, NAMED, STANDBY). Update operation does not support NAMED. Known values are: + \"GEO\", \"NAMED\", and \"STANDBY\".""" + + @overload + def __init__( + self, + *, + link_type: Optional[Union[str, "_models.ReplicationLinkType"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ReplicationLinkUpdate(ProxyResource): + """A replication link update request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ReplicationLinkUpdateProperties + """ + + properties: Optional["_models.ReplicationLinkUpdateProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["link_type"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ReplicationLinkUpdateProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ReplicationLinkUpdateProperties(_Model): + """Properties of a replication link update. + + :ivar link_type: Link type (GEO, NAMED, STANDBY). Update operation does not support NAMED. + Known values are: "GEO", "NAMED", and "STANDBY". + :vartype link_type: str or ~azure.mgmt.sql.models.ReplicationLinkType + """ + + link_type: Optional[Union[str, "_models.ReplicationLinkType"]] = rest_field( + name="linkType", visibility=["read", "create", "update", "delete", "query"] + ) + """Link type (GEO, NAMED, STANDBY). Update operation does not support NAMED. Known values are: + \"GEO\", \"NAMED\", and \"STANDBY\".""" + + @overload + def __init__( + self, + *, + link_type: Optional[Union[str, "_models.ReplicationLinkType"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ResourceIdentity(_Model): + """Azure Active Directory identity configuration for a resource. + + :ivar user_assigned_identities: The resource ids of the user assigned identities to use. + :vartype user_assigned_identities: dict[str, ~azure.mgmt.sql.models.UserIdentity] + :ivar principal_id: The Azure Active Directory principal id. + :vartype principal_id: str + :ivar type: The identity type. Set this to 'SystemAssigned' in order to automatically create + and assign an Azure Active Directory principal for the resource. Known values are: "None", + "SystemAssigned", "UserAssigned", and "SystemAssigned,UserAssigned". + :vartype type: str or ~azure.mgmt.sql.models.IdentityType + :ivar tenant_id: The Azure Active Directory tenant id. + :vartype tenant_id: str + """ + + user_assigned_identities: Optional[dict[str, "_models.UserIdentity"]] = rest_field( + name="userAssignedIdentities", visibility=["read", "create", "update", "delete", "query"] + ) + """The resource ids of the user assigned identities to use.""" + principal_id: Optional[str] = rest_field(name="principalId", visibility=["read"]) + """The Azure Active Directory principal id.""" + type: Optional[Union[str, "_models.IdentityType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The identity type. Set this to 'SystemAssigned' in order to automatically create and assign an + Azure Active Directory principal for the resource. Known values are: \"None\", + \"SystemAssigned\", \"UserAssigned\", and \"SystemAssigned,UserAssigned\".""" + tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read"]) + """The Azure Active Directory tenant id.""" + + @overload + def __init__( + self, + *, + user_assigned_identities: Optional[dict[str, "_models.UserIdentity"]] = None, + type: Optional[Union[str, "_models.IdentityType"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ResourceMoveDefinition(_Model): + """Contains the information necessary to perform a resource move (rename). + + :ivar id: The target ID for the resource. Required. + :vartype id: str + """ + + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The target ID for the resource. Required.""" + + @overload + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RestorableDroppedDatabase(Resource): + """A restorable dropped database resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.RestorableDroppedDatabaseProperties + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar sku: The name and tier of the SKU. + :vartype sku: ~azure.mgmt.sql.models.Sku + """ + + properties: Optional["_models.RestorableDroppedDatabaseProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource tags.""" + location: Optional[str] = rest_field(visibility=["read", "create"]) + """Resource location.""" + sku: Optional["_models.Sku"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name and tier of the SKU.""" + + __flattened_items = [ + "database_name", + "max_size_bytes", + "creation_date", + "deletion_date", + "earliest_restore_date", + "backup_storage_redundancy", + "keys_property", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.RestorableDroppedDatabaseProperties"] = None, + tags: Optional[dict[str, str]] = None, + location: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class RestorableDroppedDatabaseProperties(_Model): + """The restorable dropped database's properties. + + :ivar database_name: The name of the database. + :vartype database_name: str + :ivar max_size_bytes: The max size of the database expressed in bytes. + :vartype max_size_bytes: int + :ivar creation_date: The creation date of the database (ISO8601 format). + :vartype creation_date: ~datetime.datetime + :ivar deletion_date: The deletion date of the database (ISO8601 format). + :vartype deletion_date: ~datetime.datetime + :ivar earliest_restore_date: The earliest restore date of the database (ISO8601 format). + :vartype earliest_restore_date: ~datetime.datetime + :ivar backup_storage_redundancy: The storage account type used to store backups for this + database. Known values are: "Geo", "Local", "Zone", and "GeoZone". + :vartype backup_storage_redundancy: str or ~azure.mgmt.sql.models.BackupStorageRedundancy + :ivar keys_property: The resource ids of the user assigned identities to use. + :vartype keys_property: dict[str, ~azure.mgmt.sql.models.DatabaseKey] + """ + + database_name: Optional[str] = rest_field(name="databaseName", visibility=["read"]) + """The name of the database.""" + max_size_bytes: Optional[int] = rest_field(name="maxSizeBytes", visibility=["read"]) + """The max size of the database expressed in bytes.""" + creation_date: Optional[datetime.datetime] = rest_field(name="creationDate", visibility=["read"], format="rfc3339") + """The creation date of the database (ISO8601 format).""" + deletion_date: Optional[datetime.datetime] = rest_field(name="deletionDate", visibility=["read"], format="rfc3339") + """The deletion date of the database (ISO8601 format).""" + earliest_restore_date: Optional[datetime.datetime] = rest_field( + name="earliestRestoreDate", visibility=["read"], format="rfc3339" + ) + """The earliest restore date of the database (ISO8601 format).""" + backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = rest_field( + name="backupStorageRedundancy", visibility=["read"] + ) + """The storage account type used to store backups for this database. Known values are: \"Geo\", + \"Local\", \"Zone\", and \"GeoZone\".""" + keys_property: Optional[dict[str, "_models.DatabaseKey"]] = rest_field( + name="keys", visibility=["read", "create", "update", "delete", "query"], original_tsp_name="keys" + ) + """The resource ids of the user assigned identities to use.""" + + @overload + def __init__( + self, + *, + keys_property: Optional[dict[str, "_models.DatabaseKey"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RestorableDroppedManagedDatabase(TrackedResource): + """A restorable dropped managed database resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.RestorableDroppedManagedDatabaseProperties + """ + + properties: Optional["_models.RestorableDroppedManagedDatabaseProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["database_name", "creation_date", "deletion_date", "earliest_restore_date"] + + @overload + def __init__( + self, + *, + location: str, + tags: Optional[dict[str, str]] = None, + properties: Optional["_models.RestorableDroppedManagedDatabaseProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class RestorableDroppedManagedDatabaseProperties(_Model): # pylint: disable=name-too-long + """The restorable dropped managed database's properties. + + :ivar database_name: The name of the database. + :vartype database_name: str + :ivar creation_date: The creation date of the database (ISO8601 format). + :vartype creation_date: ~datetime.datetime + :ivar deletion_date: The deletion date of the database (ISO8601 format). + :vartype deletion_date: ~datetime.datetime + :ivar earliest_restore_date: The earliest restore date of the database (ISO8601 format). + :vartype earliest_restore_date: ~datetime.datetime + """ + + database_name: Optional[str] = rest_field(name="databaseName", visibility=["read"]) + """The name of the database.""" + creation_date: Optional[datetime.datetime] = rest_field(name="creationDate", visibility=["read"], format="rfc3339") + """The creation date of the database (ISO8601 format).""" + deletion_date: Optional[datetime.datetime] = rest_field(name="deletionDate", visibility=["read"], format="rfc3339") + """The deletion date of the database (ISO8601 format).""" + earliest_restore_date: Optional[datetime.datetime] = rest_field( + name="earliestRestoreDate", visibility=["read"], format="rfc3339" + ) + """The earliest restore date of the database (ISO8601 format).""" + + +class RestorePoint(ProxyResource): + """Database restore points. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.RestorePointProperties + :ivar location: Resource location. + :vartype location: str + """ + + properties: Optional["_models.RestorePointProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + location: Optional[str] = rest_field(visibility=["read"]) + """Resource location.""" + + __flattened_items = [ + "restore_point_type", + "earliest_restore_date", + "restore_point_creation_date", + "restore_point_label", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.RestorePointProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class RestorePointProperties(_Model): + """Properties of a database restore point. + + :ivar restore_point_type: The type of restore point. Known values are: "CONTINUOUS" and + "DISCRETE". + :vartype restore_point_type: str or ~azure.mgmt.sql.models.RestorePointType + :ivar earliest_restore_date: The earliest time to which this database can be restored. + :vartype earliest_restore_date: ~datetime.datetime + :ivar restore_point_creation_date: The time the backup was taken. + :vartype restore_point_creation_date: ~datetime.datetime + :ivar restore_point_label: The label of restore point for backup request by user. + :vartype restore_point_label: str + """ + + restore_point_type: Optional[Union[str, "_models.RestorePointType"]] = rest_field( + name="restorePointType", visibility=["read"] + ) + """The type of restore point. Known values are: \"CONTINUOUS\" and \"DISCRETE\".""" + earliest_restore_date: Optional[datetime.datetime] = rest_field( + name="earliestRestoreDate", visibility=["read"], format="rfc3339" + ) + """The earliest time to which this database can be restored.""" + restore_point_creation_date: Optional[datetime.datetime] = rest_field( + name="restorePointCreationDate", visibility=["read"], format="rfc3339" + ) + """The time the backup was taken.""" + restore_point_label: Optional[str] = rest_field(name="restorePointLabel", visibility=["read"]) + """The label of restore point for backup request by user.""" + + +class ScheduleItem(_Model): + """Schedule info describing when the server should be started or stopped. + + :ivar start_day: Start day. Required. Known values are: "Sunday", "Monday", "Tuesday", + "Wednesday", "Thursday", "Friday", and "Saturday". + :vartype start_day: str or ~azure.mgmt.sql.models.DayOfWeek + :ivar start_time: Start time. Required. + :vartype start_time: str + :ivar stop_day: Stop day. Required. Known values are: "Sunday", "Monday", "Tuesday", + "Wednesday", "Thursday", "Friday", and "Saturday". + :vartype stop_day: str or ~azure.mgmt.sql.models.DayOfWeek + :ivar stop_time: Stop time. Required. + :vartype stop_time: str + """ + + start_day: Union[str, "_models.DayOfWeek"] = rest_field( + name="startDay", visibility=["read", "create", "update", "delete", "query"] + ) + """Start day. Required. Known values are: \"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", + \"Thursday\", \"Friday\", and \"Saturday\".""" + start_time: str = rest_field(name="startTime", visibility=["read", "create", "update", "delete", "query"]) + """Start time. Required.""" + stop_day: Union[str, "_models.DayOfWeek"] = rest_field( + name="stopDay", visibility=["read", "create", "update", "delete", "query"] + ) + """Stop day. Required. Known values are: \"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", + \"Thursday\", \"Friday\", and \"Saturday\".""" + stop_time: str = rest_field(name="stopTime", visibility=["read", "create", "update", "delete", "query"]) + """Stop time. Required.""" + + @overload + def __init__( + self, + *, + start_day: Union[str, "_models.DayOfWeek"], + start_time: str, + stop_day: Union[str, "_models.DayOfWeek"], + stop_time: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SecurityAlertPolicyProperties(_Model): + """Properties of a security alert policy. + + :ivar state: Specifies the state of the policy, whether it is enabled or disabled or a policy + has not been applied yet on the specific database. Required. Known values are: "New", + "Enabled", and "Disabled". + :vartype state: str or ~azure.mgmt.sql.models.SecurityAlertPolicyState + :ivar disabled_alerts: Specifies an array of alerts that are disabled. Allowed values are: + Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, Unsafe_Action, + Brute_Force. + :vartype disabled_alerts: list[str] + :ivar email_addresses: Specifies an array of e-mail addresses to which the alert is sent. + :vartype email_addresses: list[str] + :ivar email_account_admins: Specifies that the alert is sent to the account administrators. + :vartype email_account_admins: bool + :ivar storage_endpoint: Specifies the blob storage endpoint (e.g. + `https://MyAccount.blob.core.windows.net `_). This + blob storage will hold all Threat Detection audit logs. + :vartype storage_endpoint: str + :ivar storage_account_access_key: Specifies the identifier key of the Threat Detection audit + storage account. + :vartype storage_account_access_key: str + :ivar retention_days: Specifies the number of days to keep in the Threat Detection audit logs. + :vartype retention_days: int + :ivar creation_time: Specifies the UTC creation time of the policy. + :vartype creation_time: ~datetime.datetime + """ + + state: Union[str, "_models.SecurityAlertPolicyState"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the state of the policy, whether it is enabled or disabled or a policy has not been + applied yet on the specific database. Required. Known values are: \"New\", \"Enabled\", and + \"Disabled\".""" + disabled_alerts: Optional[list[str]] = rest_field( + name="disabledAlerts", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies an array of alerts that are disabled. Allowed values are: Sql_Injection, + Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, Unsafe_Action, Brute_Force.""" + email_addresses: Optional[list[str]] = rest_field( + name="emailAddresses", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies an array of e-mail addresses to which the alert is sent.""" + email_account_admins: Optional[bool] = rest_field( + name="emailAccountAdmins", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies that the alert is sent to the account administrators.""" + storage_endpoint: Optional[str] = rest_field( + name="storageEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the blob storage endpoint (e.g. `https://MyAccount.blob.core.windows.net + `_). This blob storage will hold all Threat Detection + audit logs.""" + storage_account_access_key: Optional[str] = rest_field( + name="storageAccountAccessKey", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the identifier key of the Threat Detection audit storage account.""" + retention_days: Optional[int] = rest_field( + name="retentionDays", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the number of days to keep in the Threat Detection audit logs.""" + creation_time: Optional[datetime.datetime] = rest_field(name="creationTime", visibility=["read"], format="rfc3339") + """Specifies the UTC creation time of the policy.""" + + @overload + def __init__( + self, + *, + state: Union[str, "_models.SecurityAlertPolicyState"], + disabled_alerts: Optional[list[str]] = None, + email_addresses: Optional[list[str]] = None, + email_account_admins: Optional[bool] = None, + storage_endpoint: Optional[str] = None, + storage_account_access_key: Optional[str] = None, + retention_days: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SecurityAlertsPolicyProperties(_Model): + """Properties of a security alert policy. + + :ivar state: Specifies the state of the policy, whether it is enabled or disabled or a policy + has not been applied yet on the specific database. Required. Known values are: "Enabled" and + "Disabled". + :vartype state: str or ~azure.mgmt.sql.models.SecurityAlertsPolicyState + :ivar disabled_alerts: Specifies an array of alerts that are disabled. Allowed values are: + Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, Unsafe_Action, + Brute_Force. + :vartype disabled_alerts: list[str] + :ivar email_addresses: Specifies an array of e-mail addresses to which the alert is sent. + :vartype email_addresses: list[str] + :ivar email_account_admins: Specifies that the alert is sent to the account administrators. + :vartype email_account_admins: bool + :ivar storage_endpoint: Specifies the blob storage endpoint (e.g. + `https://MyAccount.blob.core.windows.net `_). This + blob storage will hold all Threat Detection audit logs. + :vartype storage_endpoint: str + :ivar storage_account_access_key: Specifies the identifier key of the Threat Detection audit + storage account. + :vartype storage_account_access_key: str + :ivar retention_days: Specifies the number of days to keep in the Threat Detection audit logs. + :vartype retention_days: int + :ivar creation_time: Specifies the UTC creation time of the policy. + :vartype creation_time: ~datetime.datetime + """ + + state: Union[str, "_models.SecurityAlertsPolicyState"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the state of the policy, whether it is enabled or disabled or a policy has not been + applied yet on the specific database. Required. Known values are: \"Enabled\" and \"Disabled\".""" + disabled_alerts: Optional[list[str]] = rest_field( + name="disabledAlerts", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies an array of alerts that are disabled. Allowed values are: Sql_Injection, + Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, Unsafe_Action, Brute_Force.""" + email_addresses: Optional[list[str]] = rest_field( + name="emailAddresses", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies an array of e-mail addresses to which the alert is sent.""" + email_account_admins: Optional[bool] = rest_field( + name="emailAccountAdmins", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies that the alert is sent to the account administrators.""" + storage_endpoint: Optional[str] = rest_field( + name="storageEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the blob storage endpoint (e.g. `https://MyAccount.blob.core.windows.net + `_). This blob storage will hold all Threat Detection + audit logs.""" + storage_account_access_key: Optional[str] = rest_field( + name="storageAccountAccessKey", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the identifier key of the Threat Detection audit storage account.""" + retention_days: Optional[int] = rest_field( + name="retentionDays", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the number of days to keep in the Threat Detection audit logs.""" + creation_time: Optional[datetime.datetime] = rest_field(name="creationTime", visibility=["read"], format="rfc3339") + """Specifies the UTC creation time of the policy.""" + + @overload + def __init__( + self, + *, + state: Union[str, "_models.SecurityAlertsPolicyState"], + disabled_alerts: Optional[list[str]] = None, + email_addresses: Optional[list[str]] = None, + email_account_admins: Optional[bool] = None, + storage_endpoint: Optional[str] = None, + storage_account_access_key: Optional[str] = None, + retention_days: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SecurityEvent(ProxyResource): + """A security event. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.SecurityEventProperties + """ + + properties: Optional["_models.SecurityEventProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "event_time", + "security_event_type", + "subscription", + "server", + "database", + "client_ip", + "application_name", + "principal_name", + "security_event_sql_injection_additional_properties", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.SecurityEventProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class SecurityEventProperties(_Model): + """The properties of a security event. + + :ivar event_time: The time when the security event occurred. + :vartype event_time: ~datetime.datetime + :ivar security_event_type: The type of the security event. Known values are: "Undefined", + "SqlInjectionVulnerability", and "SqlInjectionExploit". + :vartype security_event_type: str or ~azure.mgmt.sql.models.SecurityEventType + :ivar subscription: The subscription name. + :vartype subscription: str + :ivar server: The server name. + :vartype server: str + :ivar database: The database name. + :vartype database: str + :ivar client_ip: The IP address of the client who executed the statement. + :vartype client_ip: str + :ivar application_name: The application used to execute the statement. + :vartype application_name: str + :ivar principal_name: The principal user who executed the statement. + :vartype principal_name: str + :ivar security_event_sql_injection_additional_properties: The sql injection additional + properties, populated only if the type of the security event is sql injection. + :vartype security_event_sql_injection_additional_properties: + ~azure.mgmt.sql.models.SecurityEventSqlInjectionAdditionalProperties + """ + + event_time: Optional[datetime.datetime] = rest_field(name="eventTime", visibility=["read"], format="rfc3339") + """The time when the security event occurred.""" + security_event_type: Optional[Union[str, "_models.SecurityEventType"]] = rest_field( + name="securityEventType", visibility=["read"] + ) + """The type of the security event. Known values are: \"Undefined\", \"SqlInjectionVulnerability\", + and \"SqlInjectionExploit\".""" + subscription: Optional[str] = rest_field(visibility=["read"]) + """The subscription name.""" + server: Optional[str] = rest_field(visibility=["read"]) + """The server name.""" + database: Optional[str] = rest_field(visibility=["read"]) + """The database name.""" + client_ip: Optional[str] = rest_field(name="clientIp", visibility=["read"]) + """The IP address of the client who executed the statement.""" + application_name: Optional[str] = rest_field(name="applicationName", visibility=["read"]) + """The application used to execute the statement.""" + principal_name: Optional[str] = rest_field(name="principalName", visibility=["read"]) + """The principal user who executed the statement.""" + security_event_sql_injection_additional_properties: Optional[ + "_models.SecurityEventSqlInjectionAdditionalProperties" + ] = rest_field(name="securityEventSqlInjectionAdditionalProperties", visibility=["read"]) + """The sql injection additional properties, populated only if the type of the security event is + sql injection.""" + + +class SecurityEventSqlInjectionAdditionalProperties(_Model): # pylint: disable=name-too-long + """The properties of a security event sql injection additional properties. + + :ivar threat_id: The threat ID. + :vartype threat_id: str + :ivar statement: The statement. + :vartype statement: str + :ivar statement_highlight_offset: The statement highlight offset. + :vartype statement_highlight_offset: int + :ivar statement_highlight_length: The statement highlight length. + :vartype statement_highlight_length: int + :ivar error_code: The sql error code. + :vartype error_code: int + :ivar error_severity: The sql error severity. + :vartype error_severity: int + :ivar error_message: The sql error message. + :vartype error_message: str + """ + + threat_id: Optional[str] = rest_field(name="threatId", visibility=["read"]) + """The threat ID.""" + statement: Optional[str] = rest_field(visibility=["read"]) + """The statement.""" + statement_highlight_offset: Optional[int] = rest_field(name="statementHighlightOffset", visibility=["read"]) + """The statement highlight offset.""" + statement_highlight_length: Optional[int] = rest_field(name="statementHighlightLength", visibility=["read"]) + """The statement highlight length.""" + error_code: Optional[int] = rest_field(name="errorCode", visibility=["read"]) + """The sql error code.""" + error_severity: Optional[int] = rest_field(name="errorSeverity", visibility=["read"]) + """The sql error severity.""" + error_message: Optional[str] = rest_field(name="errorMessage", visibility=["read"]) + """The sql error message.""" + + +class SensitivityLabel(ProxyResource): + """A sensitivity label. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.SensitivityLabelProperties + :ivar managed_by: Resource that manages the sensitivity label. + :vartype managed_by: str + """ + + properties: Optional["_models.SensitivityLabelProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + managed_by: Optional[str] = rest_field(name="managedBy", visibility=["read"]) + """Resource that manages the sensitivity label.""" + + __flattened_items = [ + "schema_name", + "table_name", + "column_name", + "label_name", + "label_id", + "information_type", + "information_type_id", + "is_disabled", + "rank", + "client_classification_source", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.SensitivityLabelProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class SensitivityLabelProperties(_Model): + """Properties of a sensitivity label. + + :ivar schema_name: The schema name. + :vartype schema_name: str + :ivar table_name: The table name. + :vartype table_name: str + :ivar column_name: The column name. + :vartype column_name: str + :ivar label_name: The label name. + :vartype label_name: str + :ivar label_id: The label ID. + :vartype label_id: str + :ivar information_type: The information type. + :vartype information_type: str + :ivar information_type_id: The information type ID. + :vartype information_type_id: str + :ivar is_disabled: Is sensitivity recommendation disabled. Applicable for recommended + sensitivity label only. Specifies whether the sensitivity recommendation on this column is + disabled (dismissed) or not. + :vartype is_disabled: bool + :ivar rank: Known values are: "None", "Low", "Medium", "High", and "Critical". + :vartype rank: str or ~azure.mgmt.sql.models.SensitivityLabelRank + :ivar client_classification_source: Known values are: "None", "Native", "Recommended", and + "MIP". + :vartype client_classification_source: str or ~azure.mgmt.sql.models.ClientClassificationSource + """ + + schema_name: Optional[str] = rest_field(name="schemaName", visibility=["read"]) + """The schema name.""" + table_name: Optional[str] = rest_field(name="tableName", visibility=["read"]) + """The table name.""" + column_name: Optional[str] = rest_field(name="columnName", visibility=["read"]) + """The column name.""" + label_name: Optional[str] = rest_field(name="labelName", visibility=["read", "create", "update", "delete", "query"]) + """The label name.""" + label_id: Optional[str] = rest_field(name="labelId", visibility=["read", "create", "update", "delete", "query"]) + """The label ID.""" + information_type: Optional[str] = rest_field( + name="informationType", visibility=["read", "create", "update", "delete", "query"] + ) + """The information type.""" + information_type_id: Optional[str] = rest_field( + name="informationTypeId", visibility=["read", "create", "update", "delete", "query"] + ) + """The information type ID.""" + is_disabled: Optional[bool] = rest_field(name="isDisabled", visibility=["read"]) + """Is sensitivity recommendation disabled. Applicable for recommended sensitivity label only. + Specifies whether the sensitivity recommendation on this column is disabled (dismissed) or not.""" + rank: Optional[Union[str, "_models.SensitivityLabelRank"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Known values are: \"None\", \"Low\", \"Medium\", \"High\", and \"Critical\".""" + client_classification_source: Optional[Union[str, "_models.ClientClassificationSource"]] = rest_field( + name="clientClassificationSource", visibility=["read", "create", "update", "delete", "query"] + ) + """Known values are: \"None\", \"Native\", \"Recommended\", and \"MIP\".""" + + @overload + def __init__( + self, + *, + label_name: Optional[str] = None, + label_id: Optional[str] = None, + information_type: Optional[str] = None, + information_type_id: Optional[str] = None, + rank: Optional[Union[str, "_models.SensitivityLabelRank"]] = None, + client_classification_source: Optional[Union[str, "_models.ClientClassificationSource"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SensitivityLabelUpdate(ProxyResource): + """A sensitivity label update operation. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.SensitivityLabelUpdateProperties + """ + + properties: Optional["_models.SensitivityLabelUpdateProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["op", "schema", "table", "column", "sensitivity_label"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.SensitivityLabelUpdateProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class SensitivityLabelUpdateList(_Model): + """A list of sensitivity label update operations. + + :ivar operations: + :vartype operations: list[~azure.mgmt.sql.models.SensitivityLabelUpdate] + """ + + operations: Optional[list["_models.SensitivityLabelUpdate"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + operations: Optional[list["_models.SensitivityLabelUpdate"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SensitivityLabelUpdateProperties(_Model): + """Properties of an operation executed on a sensitivity label. + + :ivar op: Required. Known values are: "set" and "remove". + :vartype op: str or ~azure.mgmt.sql.models.SensitivityLabelUpdateKind + :ivar schema: Schema name of the column to update. Required. + :vartype schema: str + :ivar table: Table name of the column to update. Required. + :vartype table: str + :ivar column: Column name to update. Required. + :vartype column: str + :ivar sensitivity_label: The sensitivity label information to apply on a column. + :vartype sensitivity_label: ~azure.mgmt.sql.models.SensitivityLabel + """ + + op: Union[str, "_models.SensitivityLabelUpdateKind"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Required. Known values are: \"set\" and \"remove\".""" + schema: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Schema name of the column to update. Required.""" + table: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Table name of the column to update. Required.""" + column: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Column name to update. Required.""" + sensitivity_label: Optional["_models.SensitivityLabel"] = rest_field( + name="sensitivityLabel", visibility=["read", "create", "update", "delete", "query"] + ) + """The sensitivity label information to apply on a column.""" + + @overload + def __init__( + self, + *, + op: Union[str, "_models.SensitivityLabelUpdateKind"], + schema: str, + table: str, + column: str, + sensitivity_label: Optional["_models.SensitivityLabel"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Server(TrackedResource): + """An Azure SQL Database server. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ServerProperties + :ivar identity: The Azure Active Directory identity of the server. + :vartype identity: ~azure.mgmt.sql.models.ResourceIdentity + :ivar kind: Kind of sql server. This is metadata used for the Azure portal experience. + :vartype kind: str + """ + + properties: Optional["_models.ServerProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + identity: Optional["_models.ResourceIdentity"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The Azure Active Directory identity of the server.""" + kind: Optional[str] = rest_field(visibility=["read"]) + """Kind of sql server. This is metadata used for the Azure portal experience.""" + + __flattened_items = [ + "administrator_login", + "administrator_login_password", + "version", + "state", + "fully_qualified_domain_name", + "private_endpoint_connections", + "minimal_tls_version", + "public_network_access", + "workspace_feature", + "primary_user_assigned_identity_id", + "federated_client_id", + "key_id", + "administrators", + "restrict_outbound_network_access", + "is_i_pv6_enabled", + "external_governance_status", + "retention_days", + "create_mode", + ] + + @overload + def __init__( + self, + *, + location: str, + tags: Optional[dict[str, str]] = None, + properties: Optional["_models.ServerProperties"] = None, + identity: Optional["_models.ResourceIdentity"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ServerAdvancedThreatProtection(ProxyResource): + """A server Advanced Threat Protection. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.AdvancedThreatProtectionProperties + """ + + properties: Optional["_models.AdvancedThreatProtectionProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["state", "creation_time"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.AdvancedThreatProtectionProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ServerAutomaticTuning(ProxyResource): + """Server-level Automatic Tuning. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.AutomaticTuningServerProperties + """ + + properties: Optional["_models.AutomaticTuningServerProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["desired_state", "actual_state", "options"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.AutomaticTuningServerProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ServerAzureADAdministrator(ProxyResource): + """Azure Active Directory administrator. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.AdministratorProperties + """ + + properties: Optional["_models.AdministratorProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["administrator_type", "login", "sid", "tenant_id", "azure_ad_only_authentication"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.AdministratorProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ServerAzureADOnlyAuthentication(ProxyResource): + """Azure Active Directory only authentication. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.AzureADOnlyAuthProperties + """ + + properties: Optional["_models.AzureADOnlyAuthProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["azure_ad_only_authentication"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.AzureADOnlyAuthProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ServerBlobAuditingPolicy(ProxyResource): + """A server blob auditing policy. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ServerBlobAuditingPolicyProperties + """ + + properties: Optional["_models.ServerBlobAuditingPolicyProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "is_devops_audit_enabled", + "retention_days", + "audit_actions_and_groups", + "is_storage_secondary_key_in_use", + "is_azure_monitor_target_enabled", + "queue_delay_ms", + "is_managed_identity_in_use", + "state", + "storage_endpoint", + "storage_account_access_key", + "storage_account_subscription_id", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ServerBlobAuditingPolicyProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ServerBlobAuditingPolicyProperties(_Model): + """Properties of a server blob auditing policy. + + :ivar is_devops_audit_enabled: Specifies the state of devops audit. If state is Enabled, devops + logs will be sent to Azure Monitor. + In order to send the events to Azure Monitor, specify 'State' as 'Enabled', + 'IsAzureMonitorTargetEnabled' as true and 'IsDevopsAuditEnabled' as true + + When using REST API to configure auditing, Diagnostic Settings with 'DevOpsOperationsAudit' + diagnostic logs category on the master database should also be created. + + Diagnostic Settings URI format: + PUT + `https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/master/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + `_ + + For more information, see `Diagnostic Settings REST API + `_ + or `Diagnostic Settings PowerShell `_. + :vartype is_devops_audit_enabled: bool + :ivar retention_days: Specifies the number of days to keep in the audit logs in the storage + account. + :vartype retention_days: int + :ivar audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. + + The recommended set of action groups to use is the following combination - this will audit all + the queries and stored procedures executed against the database, as well as successful and + failed logins: + + BATCH_COMPLETED_GROUP, + SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, + FAILED_DATABASE_AUTHENTICATION_GROUP. + + This above combination is also the set that is configured by default when enabling auditing + from the Azure portal. + + The supported action groups to audit are (note: choose only specific groups that cover your + auditing needs. Using unnecessary groups could lead to very large quantities of audit records): + + APPLICATION_ROLE_CHANGE_PASSWORD_GROUP + BACKUP_RESTORE_GROUP + DATABASE_LOGOUT_GROUP + DATABASE_OBJECT_CHANGE_GROUP + DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP + DATABASE_OBJECT_PERMISSION_CHANGE_GROUP + DATABASE_OPERATION_GROUP + DATABASE_PERMISSION_CHANGE_GROUP + DATABASE_PRINCIPAL_CHANGE_GROUP + DATABASE_PRINCIPAL_IMPERSONATION_GROUP + DATABASE_ROLE_MEMBER_CHANGE_GROUP + FAILED_DATABASE_AUTHENTICATION_GROUP + SCHEMA_OBJECT_ACCESS_GROUP + SCHEMA_OBJECT_CHANGE_GROUP + SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP + SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP + SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP + USER_CHANGE_PASSWORD_GROUP + BATCH_STARTED_GROUP + BATCH_COMPLETED_GROUP + DBCC_GROUP + DATABASE_OWNERSHIP_CHANGE_GROUP + DATABASE_CHANGE_GROUP + LEDGER_OPERATION_GROUP + + These are groups that cover all sql statements and stored procedures executed against the + database, and should not be used in combination with other groups as this will result in + duplicate audit logs. + + For more information, see `Database-Level Audit Action Groups + `_. + + For Database auditing policy, specific Actions can also be specified (note that Actions cannot + be specified for Server auditing policy). The supported actions to audit are: + SELECT + UPDATE + INSERT + DELETE + EXECUTE + RECEIVE + REFERENCES + + The general form for defining an action to be audited is: + {action} ON {object} BY {principal} + + Note that in the above format can refer to an object like a table, view, or stored + procedure, or an entire database or schema. For the latter cases, the forms DATABASE::{db_name} + and SCHEMA::{schema_name} are used, respectively. + + For example: + SELECT on dbo.myTable by public + SELECT on DATABASE::myDatabase by public + SELECT on SCHEMA::mySchema by public + + For more information, see `Database-Level Audit Actions + `_. + :vartype audit_actions_and_groups: list[str] + :ivar is_storage_secondary_key_in_use: Specifies whether storageAccountAccessKey value is the + storage's secondary key. + :vartype is_storage_secondary_key_in_use: bool + :ivar is_azure_monitor_target_enabled: Specifies whether audit events are sent to Azure + Monitor. + In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and + 'IsAzureMonitorTargetEnabled' as true. + + When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' + diagnostic logs category on the database should be also created. + Note that for server level audit you should use the 'master' database as {databaseName}. + + Diagnostic Settings URI format: + PUT + `https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + `_ + + For more information, see `Diagnostic Settings REST API + `_ + or `Diagnostic Settings PowerShell `_. + :vartype is_azure_monitor_target_enabled: bool + :ivar queue_delay_ms: Specifies the amount of time in milliseconds that can elapse before audit + actions are forced to be processed. The default minimum value is 1000 (1 second). The maximum + is 2,147,483,647. + :vartype queue_delay_ms: int + :ivar is_managed_identity_in_use: Specifies whether Managed Identity is used to access blob + storage. + :vartype is_managed_identity_in_use: bool + :ivar state: Specifies the state of the audit. If state is Enabled, storageEndpoint or + isAzureMonitorTargetEnabled are required. Required. Known values are: "Enabled" and "Disabled". + :vartype state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState + :ivar storage_endpoint: Specifies the blob storage endpoint (e.g. + `https://MyAccount.blob.core.windows.net `_). If state + is Enabled, storageEndpoint or isAzureMonitorTargetEnabled is required. + :vartype storage_endpoint: str + :ivar storage_account_access_key: Specifies the identifier key of the auditing storage account. + If state is Enabled and storageEndpoint is specified, not specifying the + storageAccountAccessKey will use SQL server system-assigned managed identity to access the + storage. + Prerequisites for using managed identity authentication: + + 1. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). + 2. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data + Contributor' RBAC role to the server identity. + For more information, see [Auditing to storage using Managed Identity + authentication](https://go.microsoft.com/fwlink/?linkid=2114355). + :vartype storage_account_access_key: str + :ivar storage_account_subscription_id: Specifies the blob storage subscription Id. + :vartype storage_account_subscription_id: str + """ + + is_devops_audit_enabled: Optional[bool] = rest_field( + name="isDevopsAuditEnabled", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the state of devops audit. If state is Enabled, devops logs will be sent to Azure + Monitor. + In order to send the events to Azure Monitor, specify 'State' as 'Enabled', + 'IsAzureMonitorTargetEnabled' as true and 'IsDevopsAuditEnabled' as true + + When using REST API to configure auditing, Diagnostic Settings with 'DevOpsOperationsAudit' + diagnostic logs category on the master database should also be created. + + Diagnostic Settings URI format: + PUT + `https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/master/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + `_ + + For more information, see `Diagnostic Settings REST API + `_ + or `Diagnostic Settings PowerShell `_.""" + retention_days: Optional[int] = rest_field( + name="retentionDays", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the number of days to keep in the audit logs in the storage account.""" + audit_actions_and_groups: Optional[list[str]] = rest_field( + name="auditActionsAndGroups", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the Actions-Groups and Actions to audit. + + The recommended set of action groups to use is the following combination - this will audit all + the queries and stored procedures executed against the database, as well as successful and + failed logins: + + BATCH_COMPLETED_GROUP, + SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, + FAILED_DATABASE_AUTHENTICATION_GROUP. + + This above combination is also the set that is configured by default when enabling auditing + from the Azure portal. + + The supported action groups to audit are (note: choose only specific groups that cover your + auditing needs. Using unnecessary groups could lead to very large quantities of audit records): + + APPLICATION_ROLE_CHANGE_PASSWORD_GROUP + BACKUP_RESTORE_GROUP + DATABASE_LOGOUT_GROUP + DATABASE_OBJECT_CHANGE_GROUP + DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP + DATABASE_OBJECT_PERMISSION_CHANGE_GROUP + DATABASE_OPERATION_GROUP + DATABASE_PERMISSION_CHANGE_GROUP + DATABASE_PRINCIPAL_CHANGE_GROUP + DATABASE_PRINCIPAL_IMPERSONATION_GROUP + DATABASE_ROLE_MEMBER_CHANGE_GROUP + FAILED_DATABASE_AUTHENTICATION_GROUP + SCHEMA_OBJECT_ACCESS_GROUP + SCHEMA_OBJECT_CHANGE_GROUP + SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP + SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP + SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP + USER_CHANGE_PASSWORD_GROUP + BATCH_STARTED_GROUP + BATCH_COMPLETED_GROUP + DBCC_GROUP + DATABASE_OWNERSHIP_CHANGE_GROUP + DATABASE_CHANGE_GROUP + LEDGER_OPERATION_GROUP + + These are groups that cover all sql statements and stored procedures executed against the + database, and should not be used in combination with other groups as this will result in + duplicate audit logs. + + For more information, see `Database-Level Audit Action Groups + `_. + + For Database auditing policy, specific Actions can also be specified (note that Actions cannot + be specified for Server auditing policy). The supported actions to audit are: + SELECT + UPDATE + INSERT + DELETE + EXECUTE + RECEIVE + REFERENCES + + The general form for defining an action to be audited is: + {action} ON {object} BY {principal} + + Note that in the above format can refer to an object like a table, view, or stored + procedure, or an entire database or schema. For the latter cases, the forms DATABASE::{db_name} + and SCHEMA::{schema_name} are used, respectively. + + For example: + SELECT on dbo.myTable by public + SELECT on DATABASE::myDatabase by public + SELECT on SCHEMA::mySchema by public + + For more information, see `Database-Level Audit Actions + `_.""" + is_storage_secondary_key_in_use: Optional[bool] = rest_field( + name="isStorageSecondaryKeyInUse", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies whether storageAccountAccessKey value is the storage's secondary key.""" + is_azure_monitor_target_enabled: Optional[bool] = rest_field( + name="isAzureMonitorTargetEnabled", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies whether audit events are sent to Azure Monitor. + In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and + 'IsAzureMonitorTargetEnabled' as true. + + When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' + diagnostic logs category on the database should be also created. + Note that for server level audit you should use the 'master' database as {databaseName}. + + Diagnostic Settings URI format: + PUT + `https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + `_ + + For more information, see `Diagnostic Settings REST API + `_ + or `Diagnostic Settings PowerShell `_.""" + queue_delay_ms: Optional[int] = rest_field( + name="queueDelayMs", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the amount of time in milliseconds that can elapse before audit actions are forced to + be processed. The default minimum value is 1000 (1 second). The maximum is 2,147,483,647.""" + is_managed_identity_in_use: Optional[bool] = rest_field( + name="isManagedIdentityInUse", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies whether Managed Identity is used to access blob storage.""" + state: Union[str, "_models.BlobAuditingPolicyState"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the state of the audit. If state is Enabled, storageEndpoint or + isAzureMonitorTargetEnabled are required. Required. Known values are: \"Enabled\" and + \"Disabled\".""" + storage_endpoint: Optional[str] = rest_field( + name="storageEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the blob storage endpoint (e.g. `https://MyAccount.blob.core.windows.net + `_). If state is Enabled, storageEndpoint or + isAzureMonitorTargetEnabled is required.""" + storage_account_access_key: Optional[str] = rest_field( + name="storageAccountAccessKey", visibility=["create", "update"] + ) + """Specifies the identifier key of the auditing storage account. + If state is Enabled and storageEndpoint is specified, not specifying the + storageAccountAccessKey will use SQL server system-assigned managed identity to access the + storage. + Prerequisites for using managed identity authentication: + + 1. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). + 2. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data + Contributor' RBAC role to the server identity. + For more information, see [Auditing to storage using Managed Identity + authentication](https://go.microsoft.com/fwlink/?linkid=2114355).""" + storage_account_subscription_id: Optional[str] = rest_field( + name="storageAccountSubscriptionId", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the blob storage subscription Id.""" + + @overload + def __init__( + self, + *, + state: Union[str, "_models.BlobAuditingPolicyState"], + is_devops_audit_enabled: Optional[bool] = None, + retention_days: Optional[int] = None, + audit_actions_and_groups: Optional[list[str]] = None, + is_storage_secondary_key_in_use: Optional[bool] = None, + is_azure_monitor_target_enabled: Optional[bool] = None, + queue_delay_ms: Optional[int] = None, + is_managed_identity_in_use: Optional[bool] = None, + storage_endpoint: Optional[str] = None, + storage_account_access_key: Optional[str] = None, + storage_account_subscription_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ServerConfigurationOption(ProxyResource): + """A server configuration option. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ServerConfigurationOptionProperties + """ + + properties: Optional["_models.ServerConfigurationOptionProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["server_configuration_option_value", "provisioning_state"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ServerConfigurationOptionProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ServerConfigurationOptionProperties(_Model): + """The properties of server configuration option. + + :ivar server_configuration_option_value: Value of the server configuration option. Required. + :vartype server_configuration_option_value: int + :ivar provisioning_state: Provisioning state of server configuration option. Known values are: + "Created", "InProgress", "Succeeded", "Failed", and "Canceled". + :vartype provisioning_state: str or ~azure.mgmt.sql.models.ProvisioningState + """ + + server_configuration_option_value: int = rest_field( + name="serverConfigurationOptionValue", visibility=["read", "update"] + ) + """Value of the server configuration option. Required.""" + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning state of server configuration option. Known values are: \"Created\", + \"InProgress\", \"Succeeded\", \"Failed\", and \"Canceled\".""" + + @overload + def __init__( + self, + *, + server_configuration_option_value: int, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ServerConnectionPolicy(ProxyResource): + """A server connection policy. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ServerConnectionPolicyProperties + :ivar location: Resource location. + :vartype location: str + :ivar kind: Metadata used for the Azure portal experience. + :vartype kind: str + """ + + properties: Optional["_models.ServerConnectionPolicyProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + location: Optional[str] = rest_field(visibility=["read"]) + """Resource location.""" + kind: Optional[str] = rest_field(visibility=["read"]) + """Metadata used for the Azure portal experience.""" + + __flattened_items = ["connection_type"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ServerConnectionPolicyProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ServerConnectionPolicyProperties(_Model): + """The properties of a server connection policy. + + :ivar connection_type: The server connection type. Required. Known values are: "Default", + "Redirect", and "Proxy". + :vartype connection_type: str or ~azure.mgmt.sql.models.ServerConnectionType + """ + + connection_type: Union[str, "_models.ServerConnectionType"] = rest_field( + name="connectionType", visibility=["read", "create", "update", "delete", "query"] + ) + """The server connection type. Required. Known values are: \"Default\", \"Redirect\", and + \"Proxy\".""" + + @overload + def __init__( + self, + *, + connection_type: Union[str, "_models.ServerConnectionType"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ServerDevOpsAuditingSettings(ProxyResource): + """A server DevOps auditing settings. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ServerDevOpsAuditSettingsProperties + """ + + properties: Optional["_models.ServerDevOpsAuditSettingsProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "is_azure_monitor_target_enabled", + "is_managed_identity_in_use", + "state", + "storage_endpoint", + "storage_account_access_key", + "storage_account_subscription_id", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ServerDevOpsAuditSettingsProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ServerDevOpsAuditSettingsProperties(_Model): + """Properties of a server DevOps audit settings. + + :ivar is_azure_monitor_target_enabled: Specifies whether DevOps audit events are sent to Azure + Monitor. + In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and + 'IsAzureMonitorTargetEnabled' as true. + + When using REST API to configure DevOps audit, Diagnostic Settings with 'DevOpsOperationsAudit' + diagnostic logs category on the master database should be also created. + + Diagnostic Settings URI format: + PUT + `https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/master/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + `_ + + For more information, see `Diagnostic Settings REST API + `_ + or `Diagnostic Settings PowerShell `_. + :vartype is_azure_monitor_target_enabled: bool + :ivar is_managed_identity_in_use: Specifies whether Managed Identity is used to access blob + storage. + :vartype is_managed_identity_in_use: bool + :ivar state: Specifies the state of the audit. If state is Enabled, storageEndpoint or + isAzureMonitorTargetEnabled are required. Required. Known values are: "Enabled" and "Disabled". + :vartype state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState + :ivar storage_endpoint: Specifies the blob storage endpoint (e.g. + `https://MyAccount.blob.core.windows.net `_). If state + is Enabled, storageEndpoint or isAzureMonitorTargetEnabled is required. + :vartype storage_endpoint: str + :ivar storage_account_access_key: Specifies the identifier key of the auditing storage account. + If state is Enabled and storageEndpoint is specified, not specifying the + storageAccountAccessKey will use SQL server system-assigned managed identity to access the + storage. + Prerequisites for using managed identity authentication: + + 1. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). + 2. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data + Contributor' RBAC role to the server identity. + For more information, see [Auditing to storage using Managed Identity + authentication](https://go.microsoft.com/fwlink/?linkid=2114355). + :vartype storage_account_access_key: str + :ivar storage_account_subscription_id: Specifies the blob storage subscription Id. + :vartype storage_account_subscription_id: str + """ + + is_azure_monitor_target_enabled: Optional[bool] = rest_field( + name="isAzureMonitorTargetEnabled", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies whether DevOps audit events are sent to Azure Monitor. + In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and + 'IsAzureMonitorTargetEnabled' as true. + + When using REST API to configure DevOps audit, Diagnostic Settings with 'DevOpsOperationsAudit' + diagnostic logs category on the master database should be also created. + + Diagnostic Settings URI format: + PUT + `https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/master/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + `_ + + For more information, see `Diagnostic Settings REST API + `_ + or `Diagnostic Settings PowerShell `_.""" + is_managed_identity_in_use: Optional[bool] = rest_field( + name="isManagedIdentityInUse", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies whether Managed Identity is used to access blob storage.""" + state: Union[str, "_models.BlobAuditingPolicyState"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the state of the audit. If state is Enabled, storageEndpoint or + isAzureMonitorTargetEnabled are required. Required. Known values are: \"Enabled\" and + \"Disabled\".""" + storage_endpoint: Optional[str] = rest_field( + name="storageEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the blob storage endpoint (e.g. `https://MyAccount.blob.core.windows.net + `_). If state is Enabled, storageEndpoint or + isAzureMonitorTargetEnabled is required.""" + storage_account_access_key: Optional[str] = rest_field( + name="storageAccountAccessKey", visibility=["create", "update"] + ) + """Specifies the identifier key of the auditing storage account. + If state is Enabled and storageEndpoint is specified, not specifying the + storageAccountAccessKey will use SQL server system-assigned managed identity to access the + storage. + Prerequisites for using managed identity authentication: + + 1. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). + 2. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data + Contributor' RBAC role to the server identity. + For more information, see [Auditing to storage using Managed Identity + authentication](https://go.microsoft.com/fwlink/?linkid=2114355).""" + storage_account_subscription_id: Optional[str] = rest_field( + name="storageAccountSubscriptionId", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the blob storage subscription Id.""" + + @overload + def __init__( + self, + *, + state: Union[str, "_models.BlobAuditingPolicyState"], + is_azure_monitor_target_enabled: Optional[bool] = None, + is_managed_identity_in_use: Optional[bool] = None, + storage_endpoint: Optional[str] = None, + storage_account_access_key: Optional[str] = None, + storage_account_subscription_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ServerDnsAlias(ProxyResource): + """A server DNS alias. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ServerDnsAliasProperties + """ + + properties: Optional["_models.ServerDnsAliasProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["azure_dns_record"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ServerDnsAliasProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ServerDnsAliasAcquisition(_Model): + """A server dns alias acquisition request. + + :ivar old_server_dns_alias_id: The id of the server alias that will be acquired to point to + this server instead. Required. + :vartype old_server_dns_alias_id: str + """ + + old_server_dns_alias_id: str = rest_field( + name="oldServerDnsAliasId", visibility=["read", "create", "update", "delete", "query"] + ) + """The id of the server alias that will be acquired to point to this server instead. Required.""" + + @overload + def __init__( + self, + *, + old_server_dns_alias_id: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ServerDnsAliasProperties(_Model): + """Properties of a server DNS alias. + + :ivar azure_dns_record: The fully qualified DNS record for alias. + :vartype azure_dns_record: str + """ + + azure_dns_record: Optional[str] = rest_field(name="azureDnsRecord", visibility=["read"]) + """The fully qualified DNS record for alias.""" + + +class ServerExternalAdministrator(_Model): + """Properties of a active directory administrator. + + :ivar administrator_type: Type of the sever administrator. "ActiveDirectory" + :vartype administrator_type: str or ~azure.mgmt.sql.models.AdministratorType + :ivar principal_type: Principal Type of the sever administrator. Known values are: "User", + "Group", and "Application". + :vartype principal_type: str or ~azure.mgmt.sql.models.PrincipalType + :ivar login: Login name of the server administrator. + :vartype login: str + :ivar sid: SID (object ID) of the server administrator. + :vartype sid: str + :ivar tenant_id: Tenant ID of the administrator. + :vartype tenant_id: str + :ivar azure_ad_only_authentication: Azure Active Directory only Authentication enabled. + :vartype azure_ad_only_authentication: bool + """ + + administrator_type: Optional[Union[str, "_models.AdministratorType"]] = rest_field( + name="administratorType", visibility=["read", "create", "update", "delete", "query"] + ) + """Type of the sever administrator. \"ActiveDirectory\"""" + principal_type: Optional[Union[str, "_models.PrincipalType"]] = rest_field( + name="principalType", visibility=["read", "create", "update", "delete", "query"] + ) + """Principal Type of the sever administrator. Known values are: \"User\", \"Group\", and + \"Application\".""" + login: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Login name of the server administrator.""" + sid: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """SID (object ID) of the server administrator.""" + tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read", "create", "update", "delete", "query"]) + """Tenant ID of the administrator.""" + azure_ad_only_authentication: Optional[bool] = rest_field( + name="azureADOnlyAuthentication", visibility=["read", "create", "update", "delete", "query"] + ) + """Azure Active Directory only Authentication enabled.""" + + @overload + def __init__( + self, + *, + administrator_type: Optional[Union[str, "_models.AdministratorType"]] = None, + principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, + login: Optional[str] = None, + sid: Optional[str] = None, + tenant_id: Optional[str] = None, + azure_ad_only_authentication: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ServerFirewallRuleProperties(_Model): + """The properties of a server firewall rule. + + :ivar start_ip_address: The start IP address of the firewall rule. Must be IPv4 format. Use + value '0.0.0.0' for all Azure-internal IP addresses. + :vartype start_ip_address: str + :ivar end_ip_address: The end IP address of the firewall rule. Must be IPv4 format. Must be + greater than or equal to startIpAddress. Use value '0.0.0.0' for all Azure-internal IP + addresses. + :vartype end_ip_address: str + """ + + start_ip_address: Optional[str] = rest_field( + name="startIpAddress", visibility=["read", "create", "update", "delete", "query"] + ) + """The start IP address of the firewall rule. Must be IPv4 format. Use value '0.0.0.0' for all + Azure-internal IP addresses.""" + end_ip_address: Optional[str] = rest_field( + name="endIpAddress", visibility=["read", "create", "update", "delete", "query"] + ) + """The end IP address of the firewall rule. Must be IPv4 format. Must be greater than or equal to + startIpAddress. Use value '0.0.0.0' for all Azure-internal IP addresses.""" + + @overload + def __init__( + self, + *, + start_ip_address: Optional[str] = None, + end_ip_address: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ServerInfo(_Model): + """Server info for the server trust group. + + :ivar server_id: Server Id. Required. + :vartype server_id: str + """ + + server_id: str = rest_field(name="serverId", visibility=["read", "create", "update", "delete", "query"]) + """Server Id. Required.""" + + @overload + def __init__( + self, + *, + server_id: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ServerKey(ProxyResource): + """A server key. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ServerKeyProperties + :ivar kind: Kind of encryption protector. This is metadata used for the Azure portal + experience. + :vartype kind: str + :ivar location: Resource location. + :vartype location: str + """ + + properties: Optional["_models.ServerKeyProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + kind: Optional[str] = rest_field(visibility=["read"]) + """Kind of encryption protector. This is metadata used for the Azure portal experience.""" + location: Optional[str] = rest_field(visibility=["read"]) + """Resource location.""" + + __flattened_items = [ + "subregion", + "server_key_type", + "uri", + "thumbprint", + "creation_date", + "auto_rotation_enabled", + "key_version", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ServerKeyProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ServerKeyProperties(_Model): + """Properties for a server key execution. + + :ivar subregion: Subregion of the server key. + :vartype subregion: str + :ivar server_key_type: The server key type like 'ServiceManaged', 'AzureKeyVault'. Required. + Known values 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. The AKV URI is required to be in this format: + '`https://YourVaultName.vault.azure.net/keys/YourKeyName/YourKeyVersion + `_' or can be + '`https://YourVaultName.vault.azure.net/keys/YourKeyName + `_'. + :vartype uri: str + :ivar thumbprint: Thumbprint of the server key. + :vartype thumbprint: str + :ivar creation_date: The server key creation date. + :vartype creation_date: ~datetime.datetime + :ivar auto_rotation_enabled: Key auto rotation opt-in flag. Either true or false. + :vartype auto_rotation_enabled: bool + :ivar key_version: The version of the server key. + :vartype key_version: str + """ + + subregion: Optional[str] = rest_field(visibility=["read"]) + """Subregion of the server key.""" + server_key_type: Union[str, "_models.ServerKeyType"] = rest_field(name="serverKeyType", visibility=["create"]) + """The server key type like 'ServiceManaged', 'AzureKeyVault'. Required. Known values are: + \"ServiceManaged\" and \"AzureKeyVault\".""" + uri: Optional[str] = rest_field(visibility=["create"]) + """The URI of the server key. If the ServerKeyType is AzureKeyVault, then the URI is required. The + AKV URI is required to be in this format: + '`https://YourVaultName.vault.azure.net/keys/YourKeyName/YourKeyVersion + `_' or can be + '`https://YourVaultName.vault.azure.net/keys/YourKeyName + `_'.""" + thumbprint: Optional[str] = rest_field(visibility=["read"]) + """Thumbprint of the server key.""" + creation_date: Optional[datetime.datetime] = rest_field(name="creationDate", visibility=["read"], format="rfc3339") + """The server key creation date.""" + auto_rotation_enabled: Optional[bool] = rest_field(name="autoRotationEnabled", visibility=["read"]) + """Key auto rotation opt-in flag. Either true or false.""" + key_version: Optional[str] = rest_field(name="keyVersion", visibility=["read"]) + """The version of the server key.""" + + @overload + def __init__( + self, + *, + server_key_type: Union[str, "_models.ServerKeyType"], + uri: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ServerOperation(ProxyResource): + """A server operation. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ServerOperationProperties + """ + + properties: Optional["_models.ServerOperationProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "operation", + "operation_friendly_name", + "percent_complete", + "server_name", + "start_time", + "state", + "error_code", + "error_description", + "error_severity", + "is_user_error", + "estimated_completion_time", + "description", + "is_cancellable", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ServerOperationProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ServerOperationProperties(_Model): + """The properties of a server operation. + + :ivar operation: The name of operation. + :vartype operation: str + :ivar operation_friendly_name: The friendly name of operation. + :vartype operation_friendly_name: str + :ivar percent_complete: The percentage of the operation completed. + :vartype percent_complete: int + :ivar server_name: The name of the server. + :vartype server_name: str + :ivar start_time: The operation start time. + :vartype start_time: ~datetime.datetime + :ivar state: The operation state. Known values are: "Pending", "InProgress", "Succeeded", + "Failed", "CancelInProgress", and "Cancelled". + :vartype state: str or ~azure.mgmt.sql.models.ManagementOperationState + :ivar error_code: The operation error code. + :vartype error_code: int + :ivar error_description: The operation error description. + :vartype error_description: str + :ivar error_severity: The operation error severity. + :vartype error_severity: int + :ivar is_user_error: Whether or not the error is a user error. + :vartype is_user_error: bool + :ivar estimated_completion_time: The estimated completion time of the operation. + :vartype estimated_completion_time: ~datetime.datetime + :ivar description: The operation description. + :vartype description: str + :ivar is_cancellable: Whether the operation can be cancelled. + :vartype is_cancellable: bool + """ + + operation: Optional[str] = rest_field(visibility=["read"]) + """The name of operation.""" + operation_friendly_name: Optional[str] = rest_field(name="operationFriendlyName", visibility=["read"]) + """The friendly name of operation.""" + percent_complete: Optional[int] = rest_field(name="percentComplete", visibility=["read"]) + """The percentage of the operation completed.""" + server_name: Optional[str] = rest_field(name="serverName", visibility=["read"]) + """The name of the server.""" + start_time: Optional[datetime.datetime] = rest_field(name="startTime", visibility=["read"], format="rfc3339") + """The operation start time.""" + state: Optional[Union[str, "_models.ManagementOperationState"]] = rest_field(visibility=["read"]) + """The operation state. Known values are: \"Pending\", \"InProgress\", \"Succeeded\", \"Failed\", + \"CancelInProgress\", and \"Cancelled\".""" + error_code: Optional[int] = rest_field(name="errorCode", visibility=["read"]) + """The operation error code.""" + error_description: Optional[str] = rest_field(name="errorDescription", visibility=["read"]) + """The operation error description.""" + error_severity: Optional[int] = rest_field(name="errorSeverity", visibility=["read"]) + """The operation error severity.""" + is_user_error: Optional[bool] = rest_field(name="isUserError", visibility=["read"]) + """Whether or not the error is a user error.""" + estimated_completion_time: Optional[datetime.datetime] = rest_field( + name="estimatedCompletionTime", visibility=["read"], format="rfc3339" + ) + """The estimated completion time of the operation.""" + description: Optional[str] = rest_field(visibility=["read"]) + """The operation description.""" + is_cancellable: Optional[bool] = rest_field(name="isCancellable", visibility=["read"]) + """Whether the operation can be cancelled.""" + + +class ServerPrivateEndpointConnection(_Model): + """A private endpoint connection under a server. + + :ivar id: Resource ID. + :vartype id: str + :ivar properties: Private endpoint connection properties. + :vartype properties: ~azure.mgmt.sql.models.PrivateEndpointConnectionProperties + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """Resource ID.""" + properties: Optional["_models.PrivateEndpointConnectionProperties"] = rest_field(visibility=["read"]) + """Private endpoint connection properties.""" + + +class ServerProperties(_Model): + """The properties of a server. + + :ivar administrator_login: Administrator username for the server. Once created it cannot be + changed. + :vartype administrator_login: str + :ivar administrator_login_password: The administrator login password (required for server + creation). + :vartype administrator_login_password: str + :ivar version: The version of the server. + :vartype version: str + :ivar state: The state of the server. + :vartype state: str + :ivar fully_qualified_domain_name: The fully qualified domain name of the server. + :vartype fully_qualified_domain_name: str + :ivar private_endpoint_connections: List of private endpoint connections on a server. + :vartype private_endpoint_connections: + list[~azure.mgmt.sql.models.ServerPrivateEndpointConnection] + :ivar minimal_tls_version: Minimal TLS version. Allowed values: 'None', 1.0', '1.1', '1.2', + '1.3'. Known values are: "None", "1.0", "1.1", "1.2", and "1.3". + :vartype minimal_tls_version: str or ~azure.mgmt.sql.models.MinimalTlsVersion + :ivar public_network_access: Whether or not public endpoint access is allowed for this server. + Value is optional but if passed in, must be 'Enabled' or 'Disabled' or 'SecuredByPerimeter'. + Known values are: "Enabled", "Disabled", and "SecuredByPerimeter". + :vartype public_network_access: str or ~azure.mgmt.sql.models.ServerPublicNetworkAccessFlag + :ivar workspace_feature: Whether or not existing server has a workspace created and if it + allows connection from workspace. Known values are: "Connected" and "Disconnected". + :vartype workspace_feature: str or ~azure.mgmt.sql.models.ServerWorkspaceFeature + :ivar primary_user_assigned_identity_id: The resource id of a user assigned identity to be used + by default. + :vartype primary_user_assigned_identity_id: str + :ivar federated_client_id: The Client id used for cross tenant CMK scenario. + :vartype federated_client_id: str + :ivar key_id: A CMK URI of the key to use for encryption. + :vartype key_id: str + :ivar administrators: The Azure Active Directory administrator can be utilized during server + creation and for server updates, except for the azureADOnlyAuthentication property. To update + the azureADOnlyAuthentication property, individual API must be used. + :vartype administrators: ~azure.mgmt.sql.models.ServerExternalAdministrator + :ivar restrict_outbound_network_access: Whether or not to restrict outbound network access for + this server. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values + are: "Enabled" and "Disabled". + :vartype restrict_outbound_network_access: str or + ~azure.mgmt.sql.models.ServerNetworkAccessFlag + :ivar is_i_pv6_enabled: Whether or not to enable IPv6 support for this server. Value is + optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled" and + "Disabled". + :vartype is_i_pv6_enabled: str or ~azure.mgmt.sql.models.ServerNetworkAccessFlag + :ivar external_governance_status: Status of external governance. Known values are: "Enabled" + and "Disabled". + :vartype external_governance_status: str or ~azure.mgmt.sql.models.ExternalGovernanceStatus + :ivar retention_days: Number of days this server will stay soft-deleted. + :vartype retention_days: int + :ivar create_mode: Create mode for server, only valid values for this are Normal and Restore. + Known values are: "Normal" and "Restore". + :vartype create_mode: str or ~azure.mgmt.sql.models.ServerCreateMode + """ + + administrator_login: Optional[str] = rest_field(name="administratorLogin", visibility=["read", "create"]) + """Administrator username for the server. Once created it cannot be changed.""" + administrator_login_password: Optional[str] = rest_field( + name="administratorLoginPassword", visibility=["create", "update"] + ) + """The administrator login password (required for server creation).""" + version: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The version of the server.""" + state: Optional[str] = rest_field(visibility=["read"]) + """The state of the server.""" + fully_qualified_domain_name: Optional[str] = rest_field(name="fullyQualifiedDomainName", visibility=["read"]) + """The fully qualified domain name of the server.""" + private_endpoint_connections: Optional[list["_models.ServerPrivateEndpointConnection"]] = rest_field( + name="privateEndpointConnections", visibility=["read"] + ) + """List of private endpoint connections on a server.""" + minimal_tls_version: Optional[Union[str, "_models.MinimalTlsVersion"]] = rest_field( + name="minimalTlsVersion", visibility=["read", "create", "update", "delete", "query"] + ) + """Minimal TLS version. Allowed values: 'None', 1.0', '1.1', '1.2', '1.3'. Known values are: + \"None\", \"1.0\", \"1.1\", \"1.2\", and \"1.3\".""" + public_network_access: Optional[Union[str, "_models.ServerPublicNetworkAccessFlag"]] = rest_field( + name="publicNetworkAccess", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether or not public endpoint access is allowed for this server. Value is optional but if + passed in, must be 'Enabled' or 'Disabled' or 'SecuredByPerimeter'. Known values are: + \"Enabled\", \"Disabled\", and \"SecuredByPerimeter\".""" + workspace_feature: Optional[Union[str, "_models.ServerWorkspaceFeature"]] = rest_field( + name="workspaceFeature", visibility=["read"] + ) + """Whether or not existing server has a workspace created and if it allows connection from + workspace. Known values are: \"Connected\" and \"Disconnected\".""" + primary_user_assigned_identity_id: Optional[str] = rest_field( + name="primaryUserAssignedIdentityId", visibility=["read", "create", "update", "delete", "query"] + ) + """The resource id of a user assigned identity to be used by default.""" + federated_client_id: Optional[str] = rest_field( + name="federatedClientId", visibility=["read", "create", "update", "delete", "query"] + ) + """The Client id used for cross tenant CMK scenario.""" + key_id: Optional[str] = rest_field(name="keyId", visibility=["read", "create", "update", "delete", "query"]) + """A CMK URI of the key to use for encryption.""" + administrators: Optional["_models.ServerExternalAdministrator"] = rest_field(visibility=["read", "create"]) + """The Azure Active Directory administrator can be utilized during server creation and for server + updates, except for the azureADOnlyAuthentication property. To update the + azureADOnlyAuthentication property, individual API must be used.""" + restrict_outbound_network_access: Optional[Union[str, "_models.ServerNetworkAccessFlag"]] = rest_field( + name="restrictOutboundNetworkAccess", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether or not to restrict outbound network access for this server. Value is optional but if + passed in, must be 'Enabled' or 'Disabled'. Known values are: \"Enabled\" and \"Disabled\".""" + is_i_pv6_enabled: Optional[Union[str, "_models.ServerNetworkAccessFlag"]] = rest_field( + name="isIPv6Enabled", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether or not to enable IPv6 support for this server. Value is optional but if passed in, + must be 'Enabled' or 'Disabled'. Known values are: \"Enabled\" and \"Disabled\".""" + external_governance_status: Optional[Union[str, "_models.ExternalGovernanceStatus"]] = rest_field( + name="externalGovernanceStatus", visibility=["read"] + ) + """Status of external governance. Known values are: \"Enabled\" and \"Disabled\".""" + retention_days: Optional[int] = rest_field( + name="retentionDays", visibility=["read", "create", "update", "delete", "query"] + ) + """Number of days this server will stay soft-deleted.""" + create_mode: Optional[Union[str, "_models.ServerCreateMode"]] = rest_field( + name="createMode", visibility=["read", "create"] + ) + """Create mode for server, only valid values for this are Normal and Restore. Known values are: + \"Normal\" and \"Restore\".""" + + @overload + def __init__( + self, + *, + administrator_login: Optional[str] = None, + administrator_login_password: Optional[str] = None, + version: Optional[str] = None, + minimal_tls_version: Optional[Union[str, "_models.MinimalTlsVersion"]] = None, + public_network_access: Optional[Union[str, "_models.ServerPublicNetworkAccessFlag"]] = None, + primary_user_assigned_identity_id: Optional[str] = None, + federated_client_id: Optional[str] = None, + key_id: Optional[str] = None, + administrators: Optional["_models.ServerExternalAdministrator"] = None, + restrict_outbound_network_access: Optional[Union[str, "_models.ServerNetworkAccessFlag"]] = None, + is_i_pv6_enabled: Optional[Union[str, "_models.ServerNetworkAccessFlag"]] = None, + retention_days: Optional[int] = None, + create_mode: Optional[Union[str, "_models.ServerCreateMode"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ServerSecurityAlertPolicy(ProxyResource): + """A server security alert policy. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.SecurityAlertsPolicyProperties + """ + + properties: Optional["_models.SecurityAlertsPolicyProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "state", + "disabled_alerts", + "email_addresses", + "email_account_admins", + "storage_endpoint", + "storage_account_access_key", + "retention_days", + "creation_time", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.SecurityAlertsPolicyProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ServerTrustCertificate(ProxyResource): + """Server trust certificate imported from box to enable connection between box and Sql Managed + Instance. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ServerTrustCertificateProperties + """ + + properties: Optional["_models.ServerTrustCertificateProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["public_blob", "thumbprint", "certificate_name"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ServerTrustCertificateProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ServerTrustCertificateProperties(_Model): + """The properties of a server trust certificate. + + :ivar public_blob: The certificate public blob. + :vartype public_blob: str + :ivar thumbprint: The certificate thumbprint. + :vartype thumbprint: str + :ivar certificate_name: The certificate name. + :vartype certificate_name: str + """ + + public_blob: Optional[str] = rest_field( + name="publicBlob", visibility=["read", "create", "update", "delete", "query"] + ) + """The certificate public blob.""" + thumbprint: Optional[str] = rest_field(visibility=["read"]) + """The certificate thumbprint.""" + certificate_name: Optional[str] = rest_field(name="certificateName", visibility=["read"]) + """The certificate name.""" + + @overload + def __init__( + self, + *, + public_blob: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ServerTrustGroup(ProxyResource): + """A server trust group. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ServerTrustGroupProperties + """ + + properties: Optional["_models.ServerTrustGroupProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["group_members", "trust_scopes"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ServerTrustGroupProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ServerTrustGroupProperties(_Model): + """Properties of a server trust group. + + :ivar group_members: Group members information for the server trust group. Required. + :vartype group_members: list[~azure.mgmt.sql.models.ServerInfo] + :ivar trust_scopes: Trust scope of the server trust group. Required. + :vartype trust_scopes: list[str or + ~azure.mgmt.sql.models.ServerTrustGroupPropertiesTrustScopesItem] + """ + + group_members: list["_models.ServerInfo"] = rest_field( + name="groupMembers", visibility=["read", "create", "update", "delete", "query"] + ) + """Group members information for the server trust group. Required.""" + trust_scopes: list[Union[str, "_models.ServerTrustGroupPropertiesTrustScopesItem"]] = rest_field( + name="trustScopes", visibility=["read", "create", "update", "delete", "query"] + ) + """Trust scope of the server trust group. Required.""" + + @overload + def __init__( + self, + *, + group_members: list["_models.ServerInfo"], + trust_scopes: list[Union[str, "_models.ServerTrustGroupPropertiesTrustScopesItem"]], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ServerUpdate(_Model): + """An update request for an Azure SQL Database server. + + :ivar identity: Server identity. + :vartype identity: ~azure.mgmt.sql.models.ResourceIdentity + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ServerProperties + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + identity: Optional["_models.ResourceIdentity"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Server identity.""" + properties: Optional["_models.ServerProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource tags.""" + + __flattened_items = [ + "administrator_login", + "administrator_login_password", + "version", + "state", + "fully_qualified_domain_name", + "private_endpoint_connections", + "minimal_tls_version", + "public_network_access", + "workspace_feature", + "primary_user_assigned_identity_id", + "federated_client_id", + "key_id", + "administrators", + "restrict_outbound_network_access", + "is_i_pv6_enabled", + "external_governance_status", + "retention_days", + "create_mode", + ] + + @overload + def __init__( + self, + *, + identity: Optional["_models.ResourceIdentity"] = None, + properties: Optional["_models.ServerProperties"] = None, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ServerUsage(ProxyResource): + """Usage metric of a server. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ServerUsageProperties + """ + + properties: Optional["_models.ServerUsageProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["display_name", "current_value", "limit", "unit"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ServerUsageProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ServerUsageProperties(_Model): + """Properties of a server usage. + + :ivar display_name: User-readable name of the metric. + :vartype display_name: str + :ivar current_value: Current value of the metric. + :vartype current_value: float + :ivar limit: Boundary value of the metric. + :vartype limit: float + :ivar unit: Unit of the metric. + :vartype unit: str + """ + + display_name: Optional[str] = rest_field(name="displayName", visibility=["read"]) + """User-readable name of the metric.""" + current_value: Optional[float] = rest_field(name="currentValue", visibility=["read"]) + """Current value of the metric.""" + limit: Optional[float] = rest_field(visibility=["read"]) + """Boundary value of the metric.""" + unit: Optional[str] = rest_field(visibility=["read"]) + """Unit of the metric.""" + + +class ServerVersionCapability(_Model): + """The server capability. + + :ivar name: The server version name. + :vartype name: str + :ivar supported_editions: The list of supported database editions. + :vartype supported_editions: list[~azure.mgmt.sql.models.EditionCapability] + :ivar supported_elastic_pool_editions: The list of supported elastic pool editions. + :vartype supported_elastic_pool_editions: + list[~azure.mgmt.sql.models.ElasticPoolEditionCapability] + :ivar status: The status of the capability. 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 + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """The server version name.""" + supported_editions: Optional[list["_models.EditionCapability"]] = rest_field( + name="supportedEditions", visibility=["read"] + ) + """The list of supported database editions.""" + supported_elastic_pool_editions: Optional[list["_models.ElasticPoolEditionCapability"]] = rest_field( + name="supportedElasticPoolEditions", visibility=["read"] + ) + """The list of supported elastic pool editions.""" + status: Optional[Union[str, "_models.CapabilityStatus"]] = rest_field(visibility=["read"]) + """The status of the capability. Known values are: \"Visible\", \"Available\", \"Default\", and + \"Disabled\".""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for the capability not being available.""" + + @overload + def __init__( + self, + *, + reason: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ServerVulnerabilityAssessment(ProxyResource): + """A server vulnerability assessment. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.ServerVulnerabilityAssessmentProperties + """ + + properties: Optional["_models.ServerVulnerabilityAssessmentProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "storage_container_path", + "storage_container_sas_key", + "storage_account_access_key", + "recurring_scans", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ServerVulnerabilityAssessmentProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ServerVulnerabilityAssessmentProperties(_Model): + """Properties of a server Vulnerability Assessment. + + :ivar storage_container_path: A blob storage container path to hold the scan results (e.g. + `https://myStorage.blob.core.windows.net/VaScans/ + `_). Required. + :vartype storage_container_path: str + :ivar storage_container_sas_key: A shared access signature (SAS Key) that has write access to + the blob container specified in 'storageContainerPath' parameter. If 'storageAccountAccessKey' + isn't specified, StorageContainerSasKey is required. Applies only if the storage account is not + behind a Vnet or a firewall. + :vartype storage_container_sas_key: str + :ivar storage_account_access_key: Specifies the identifier key of the storage account for + vulnerability assessment scan results. If 'StorageContainerSasKey' isn't specified, + storageAccountAccessKey is required. Applies only if the storage account is not behind a Vnet + or a firewall. + :vartype storage_account_access_key: str + :ivar recurring_scans: The recurring scans settings. + :vartype recurring_scans: + ~azure.mgmt.sql.models.VulnerabilityAssessmentRecurringScansProperties + """ + + storage_container_path: str = rest_field(name="storageContainerPath", visibility=["create", "update"]) + """A blob storage container path to hold the scan results (e.g. + `https://myStorage.blob.core.windows.net/VaScans/ + `_). Required.""" + storage_container_sas_key: Optional[str] = rest_field( + name="storageContainerSasKey", visibility=["create", "update"] + ) + """A shared access signature (SAS Key) that has write access to the blob container specified in + 'storageContainerPath' parameter. If 'storageAccountAccessKey' isn't specified, + StorageContainerSasKey is required. Applies only if the storage account is not behind a Vnet or + a firewall.""" + storage_account_access_key: Optional[str] = rest_field( + name="storageAccountAccessKey", visibility=["create", "update"] + ) + """Specifies the identifier key of the storage account for vulnerability assessment scan results. + If 'StorageContainerSasKey' isn't specified, storageAccountAccessKey is required. Applies only + if the storage account is not behind a Vnet or a firewall.""" + recurring_scans: Optional["_models.VulnerabilityAssessmentRecurringScansProperties"] = rest_field( + name="recurringScans", visibility=["read", "create", "update", "delete", "query"] + ) + """The recurring scans settings.""" + + @overload + def __init__( + self, + *, + storage_container_path: str, + storage_container_sas_key: Optional[str] = None, + storage_account_access_key: Optional[str] = None, + recurring_scans: Optional["_models.VulnerabilityAssessmentRecurringScansProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ServiceObjectiveCapability(_Model): + """The service objectives capability. + + :ivar id: The unique ID of the service objective. + :vartype id: str + :ivar name: The service objective name. + :vartype name: str + :ivar supported_max_sizes: The list of supported maximum database sizes. + :vartype supported_max_sizes: list[~azure.mgmt.sql.models.MaxSizeRangeCapability] + :ivar performance_level: The performance level. + :vartype performance_level: ~azure.mgmt.sql.models.PerformanceLevelCapability + :ivar sku: The sku. + :vartype sku: ~azure.mgmt.sql.models.Sku + :ivar supported_license_types: List of supported license types. + :vartype supported_license_types: list[~azure.mgmt.sql.models.LicenseTypeCapability] + :ivar included_max_size: The included (free) max size. + :vartype included_max_size: ~azure.mgmt.sql.models.MaxSizeCapability + :ivar zone_redundant: Whether or not zone redundancy is supported for the service objective. + :vartype zone_redundant: bool + :ivar supported_auto_pause_delay: Supported time range for auto pause delay. + :vartype supported_auto_pause_delay: ~azure.mgmt.sql.models.AutoPauseDelayTimeRange + :ivar supported_min_capacities: List of supported min capacities. + :vartype supported_min_capacities: list[~azure.mgmt.sql.models.MinCapacityCapability] + :ivar compute_model: The compute model. + :vartype compute_model: str + :ivar supported_maintenance_configurations: List of supported maintenance configurations. + :vartype supported_maintenance_configurations: + list[~azure.mgmt.sql.models.MaintenanceConfigurationCapability] + :ivar zone_pinning: Whether or not zone pinning is supported. + :vartype zone_pinning: bool + :ivar supported_zones: List of supported availability zones. + :vartype supported_zones: list[~azure.mgmt.sql.models.ZonePinningCapability] + :ivar supported_free_limit_exhaustion_behaviors: List of supported free limit exhaustion + behaviors. + :vartype supported_free_limit_exhaustion_behaviors: + list[~azure.mgmt.sql.models.FreeLimitExhaustionBehaviorCapability] + :ivar status: The status of the capability. Known values are: "Visible", "Available", + "Default", and "Disabled". + :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus + :ivar reason: The reason for the capability not being available. + :vartype reason: str + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """The unique ID of the service objective.""" + name: Optional[str] = rest_field(visibility=["read"]) + """The service objective name.""" + supported_max_sizes: Optional[list["_models.MaxSizeRangeCapability"]] = rest_field( + name="supportedMaxSizes", visibility=["read"] + ) + """The list of supported maximum database sizes.""" + performance_level: Optional["_models.PerformanceLevelCapability"] = rest_field( + name="performanceLevel", visibility=["read"] + ) + """The performance level.""" + sku: Optional["_models.Sku"] = rest_field(visibility=["read"]) + """The sku.""" + supported_license_types: Optional[list["_models.LicenseTypeCapability"]] = rest_field( + name="supportedLicenseTypes", visibility=["read"] + ) + """List of supported license types.""" + included_max_size: Optional["_models.MaxSizeCapability"] = rest_field(name="includedMaxSize", visibility=["read"]) + """The included (free) max size.""" + zone_redundant: Optional[bool] = rest_field(name="zoneRedundant", visibility=["read"]) + """Whether or not zone redundancy is supported for the service objective.""" + supported_auto_pause_delay: Optional["_models.AutoPauseDelayTimeRange"] = rest_field( + name="supportedAutoPauseDelay", visibility=["read"] + ) + """Supported time range for auto pause delay.""" + supported_min_capacities: Optional[list["_models.MinCapacityCapability"]] = rest_field( + name="supportedMinCapacities", visibility=["read"] + ) + """List of supported min capacities.""" + compute_model: Optional[str] = rest_field(name="computeModel", visibility=["read"]) + """The compute model.""" + supported_maintenance_configurations: Optional[list["_models.MaintenanceConfigurationCapability"]] = rest_field( + name="supportedMaintenanceConfigurations", visibility=["read"] + ) + """List of supported maintenance configurations.""" + zone_pinning: Optional[bool] = rest_field(name="zonePinning", visibility=["read"]) + """Whether or not zone pinning is supported.""" + supported_zones: Optional[list["_models.ZonePinningCapability"]] = rest_field( + name="supportedZones", visibility=["read"] + ) + """List of supported availability zones.""" + supported_free_limit_exhaustion_behaviors: Optional[list["_models.FreeLimitExhaustionBehaviorCapability"]] = ( + rest_field(name="supportedFreeLimitExhaustionBehaviors", visibility=["read"]) + ) + """List of supported free limit exhaustion behaviors.""" + status: Optional[Union[str, "_models.CapabilityStatus"]] = rest_field(visibility=["read"]) + """The status of the capability. Known values are: \"Visible\", \"Available\", \"Default\", and + \"Disabled\".""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for the capability not being available.""" + + @overload + def __init__( + self, + *, + reason: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ServicePrincipal(_Model): + """The managed instance's service principal configuration for a resource. + + :ivar principal_id: The Azure Active Directory application object id. + :vartype principal_id: str + :ivar client_id: The Azure Active Directory application client id. + :vartype client_id: str + :ivar tenant_id: The Azure Active Directory tenant id. + :vartype tenant_id: str + :ivar type: Service principal type. Known values are: "None" and "SystemAssigned". + :vartype type: str or ~azure.mgmt.sql.models.ServicePrincipalType + """ + + principal_id: Optional[str] = rest_field(name="principalId", visibility=["read"]) + """The Azure Active Directory application object id.""" + client_id: Optional[str] = rest_field(name="clientId", visibility=["read"]) + """The Azure Active Directory application client id.""" + tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read"]) + """The Azure Active Directory tenant id.""" + type: Optional[Union[str, "_models.ServicePrincipalType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Service principal type. Known values are: \"None\" and \"SystemAssigned\".""" + + @overload + def __init__( + self, + *, + type: Optional[Union[str, "_models.ServicePrincipalType"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Sku(_Model): + """An ARM Resource SKU. + + :ivar name: The name of the SKU, typically, a letter + Number code, e.g. P3. Required. + :vartype name: str + :ivar tier: The tier or edition of the particular SKU, e.g. Basic, Premium. + :vartype tier: str + :ivar size: Size of the particular SKU. + :vartype size: str + :ivar family: If the service has different generations of hardware, for the same SKU, then that + can be captured here. + :vartype family: str + :ivar capacity: Capacity of the particular SKU. + :vartype capacity: int + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the SKU, typically, a letter + Number code, e.g. P3. Required.""" + tier: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The tier or edition of the particular SKU, e.g. Basic, Premium.""" + size: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Size of the particular SKU.""" + family: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """If the service has different generations of hardware, for the same SKU, then that can be + captured here.""" + capacity: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Capacity of the particular SKU.""" + + @overload + def __init__( + self, + *, + name: str, + tier: Optional[str] = None, + size: Optional[str] = None, + family: Optional[str] = None, + capacity: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SqlAgentConfiguration(ProxyResource): + """A recoverable managed database resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.SqlAgentConfigurationProperties + """ + + properties: Optional["_models.SqlAgentConfigurationProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["state"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.SqlAgentConfigurationProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class SqlAgentConfigurationProperties(_Model): + """Sql agent configuration properties. + + :ivar state: The state of Sql Agent. Known values are: "Enabled" and "Disabled". + :vartype state: str or ~azure.mgmt.sql.models.SqlAgentConfigurationPropertiesState + """ + + state: Optional[Union[str, "_models.SqlAgentConfigurationPropertiesState"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The state of Sql Agent. Known values are: \"Enabled\" and \"Disabled\".""" + + @overload + def __init__( + self, + *, + state: Optional[Union[str, "_models.SqlAgentConfigurationPropertiesState"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SqlVulnerabilityAssessment(ProxyResource): + """A SQL Vulnerability Assessment. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentPolicyProperties + """ + + properties: Optional["_models.SqlVulnerabilityAssessmentPolicyProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["state"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.SqlVulnerabilityAssessmentPolicyProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class SqlVulnerabilityAssessmentPolicyProperties(_Model): # pylint: disable=name-too-long + """SqlVulnerabilityAssessmentPolicyProperties. + + :ivar state: Specifies the state of the SQL Vulnerability Assessment, whether it is enabled or + disabled or a state has not been applied yet on the specific database or server. Known values + are: "Enabled" and "Disabled". + :vartype state: str or ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentState + """ + + state: Optional[Union[str, "_models.SqlVulnerabilityAssessmentState"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the state of the SQL Vulnerability Assessment, whether it is enabled or disabled or a + state has not been applied yet on the specific database or server. Known values are: + \"Enabled\" and \"Disabled\".""" + + @overload + def __init__( + self, + *, + state: Optional[Union[str, "_models.SqlVulnerabilityAssessmentState"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SqlVulnerabilityAssessmentScanError(_Model): + """Properties of a vulnerability assessment scan error. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + """ + + code: Optional[str] = rest_field(visibility=["read"]) + """The error code.""" + message: Optional[str] = rest_field(visibility=["read"]) + """The error message.""" + + +class SqlVulnerabilityAssessmentScanRecord(ProxyResource): + """A vulnerability assessment scan record. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanRecordProperties + """ + + properties: Optional["_models.SqlVulnerabilityAssessmentScanRecordProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "scan_id", + "trigger_type", + "state", + "start_time", + "end_time", + "errors", + "server", + "database", + "sql_version", + "high_severity_failed_rules_count", + "medium_severity_failed_rules_count", + "low_severity_failed_rules_count", + "total_passed_rules_count", + "total_failed_rules_count", + "total_rules_count", + "is_baseline_applied", + "last_scan_time", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.SqlVulnerabilityAssessmentScanRecordProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class SqlVulnerabilityAssessmentScanRecordProperties(_Model): # pylint: disable=name-too-long + """Properties of a vulnerability assessment scan record. + + :ivar scan_id: The scan ID. + :vartype scan_id: str + :ivar trigger_type: The scan trigger type. Known values are: "OnDemand" and "Recurring". + :vartype trigger_type: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentScanTriggerType + :ivar state: The scan status. Known values are: "Passed", "Failed", "FailedToRun", and + "InProgress". + :vartype state: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentScanState + :ivar start_time: The scan start time (UTC). + :vartype start_time: ~datetime.datetime + :ivar end_time: The scan end time (UTC). + :vartype end_time: ~datetime.datetime + :ivar errors: The scan errors. + :vartype errors: list[~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanError] + :ivar server: The server name. + :vartype server: str + :ivar database: The database name. + :vartype database: str + :ivar sql_version: The SQL version. + :vartype sql_version: str + :ivar high_severity_failed_rules_count: The number of failed rules with high severity. + :vartype high_severity_failed_rules_count: int + :ivar medium_severity_failed_rules_count: The number of failed rules with medium severity. + :vartype medium_severity_failed_rules_count: int + :ivar low_severity_failed_rules_count: The number of failed rules with low severity. + :vartype low_severity_failed_rules_count: int + :ivar total_passed_rules_count: The number of total passed rules. + :vartype total_passed_rules_count: int + :ivar total_failed_rules_count: The number of total failed rules. + :vartype total_failed_rules_count: int + :ivar total_rules_count: The number of total rules assessed. + :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 + """ + + scan_id: Optional[str] = rest_field(name="scanId", visibility=["read"]) + """The scan ID.""" + trigger_type: Optional[Union[str, "_models.VulnerabilityAssessmentScanTriggerType"]] = rest_field( + name="triggerType", visibility=["read"] + ) + """The scan trigger type. Known values are: \"OnDemand\" and \"Recurring\".""" + state: Optional[Union[str, "_models.VulnerabilityAssessmentScanState"]] = rest_field(visibility=["read"]) + """The scan status. Known values are: \"Passed\", \"Failed\", \"FailedToRun\", and \"InProgress\".""" + start_time: Optional[datetime.datetime] = rest_field(name="startTime", visibility=["read"], format="rfc3339") + """The scan start time (UTC).""" + end_time: Optional[datetime.datetime] = rest_field(name="endTime", visibility=["read"], format="rfc3339") + """The scan end time (UTC).""" + errors: Optional[list["_models.SqlVulnerabilityAssessmentScanError"]] = rest_field(visibility=["read"]) + """The scan errors.""" + server: Optional[str] = rest_field(visibility=["read"]) + """The server name.""" + database: Optional[str] = rest_field(visibility=["read"]) + """The database name.""" + sql_version: Optional[str] = rest_field(name="sqlVersion", visibility=["read"]) + """The SQL version.""" + high_severity_failed_rules_count: Optional[int] = rest_field( + name="highSeverityFailedRulesCount", visibility=["read"] + ) + """The number of failed rules with high severity.""" + medium_severity_failed_rules_count: Optional[int] = rest_field( + name="mediumSeverityFailedRulesCount", visibility=["read"] + ) + """The number of failed rules with medium severity.""" + low_severity_failed_rules_count: Optional[int] = rest_field(name="lowSeverityFailedRulesCount", visibility=["read"]) + """The number of failed rules with low severity.""" + total_passed_rules_count: Optional[int] = rest_field(name="totalPassedRulesCount", visibility=["read"]) + """The number of total passed rules.""" + total_failed_rules_count: Optional[int] = rest_field(name="totalFailedRulesCount", visibility=["read"]) + """The number of total failed rules.""" + total_rules_count: Optional[int] = rest_field(name="totalRulesCount", visibility=["read"]) + """The number of total rules assessed.""" + is_baseline_applied: Optional[bool] = rest_field(name="isBaselineApplied", visibility=["read"]) + """Baseline created for this database, and has one or more rules.""" + last_scan_time: Optional[datetime.datetime] = rest_field(name="lastScanTime", visibility=["read"], format="rfc3339") + """The last scan time.""" + + +class SqlVulnerabilityAssessmentScanResultProperties(_Model): # pylint: disable=name-too-long + """SQL Vulnerability Assessment scan result properties for a single rule. + + :ivar rule_id: SQL Vulnerability Assessment rule Id. + :vartype rule_id: str + :ivar status: SQL Vulnerability Assessment rule result status. Known values are: "NonFinding", + "Finding", and "InternalError". + :vartype status: str or ~azure.mgmt.sql.models.RuleStatus + :ivar error_message: SQL Vulnerability Assessment error message. + :vartype error_message: str + :ivar is_trimmed: SQL Vulnerability Assessment is the query results trimmed. + :vartype is_trimmed: bool + :ivar query_results: SQL Vulnerability Assessment query results that was run. + :vartype query_results: list[list[str]] + :ivar remediation: SQL Vulnerability Assessment the remediation details. + :vartype remediation: ~azure.mgmt.sql.models.Remediation + :ivar baseline_adjusted_result: SQL Vulnerability Assessment rule result adjusted with + baseline. + :vartype baseline_adjusted_result: ~azure.mgmt.sql.models.BaselineAdjustedResult + :ivar rule_metadata: SQL Vulnerability Assessment rule metadata. + :vartype rule_metadata: ~azure.mgmt.sql.models.VaRule + """ + + rule_id: Optional[str] = rest_field(name="ruleId", visibility=["read"]) + """SQL Vulnerability Assessment rule Id.""" + status: Optional[Union[str, "_models.RuleStatus"]] = rest_field(visibility=["read"]) + """SQL Vulnerability Assessment rule result status. Known values are: \"NonFinding\", \"Finding\", + and \"InternalError\".""" + error_message: Optional[str] = rest_field(name="errorMessage", visibility=["read"]) + """SQL Vulnerability Assessment error message.""" + is_trimmed: Optional[bool] = rest_field(name="isTrimmed", visibility=["read"]) + """SQL Vulnerability Assessment is the query results trimmed.""" + query_results: Optional[list[list[str]]] = rest_field(name="queryResults", visibility=["read"]) + """SQL Vulnerability Assessment query results that was run.""" + remediation: Optional["_models.Remediation"] = rest_field(visibility=["read"]) + """SQL Vulnerability Assessment the remediation details.""" + baseline_adjusted_result: Optional["_models.BaselineAdjustedResult"] = rest_field( + name="baselineAdjustedResult", visibility=["read"] + ) + """SQL Vulnerability Assessment rule result adjusted with baseline.""" + rule_metadata: Optional["_models.VaRule"] = rest_field(name="ruleMetadata", visibility=["read"]) + """SQL Vulnerability Assessment rule metadata.""" + + +class SqlVulnerabilityAssessmentScanResults(ProxyResource): + """Concrete proxy resource types can be created by aliasing this type using a specific property + type. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanResultProperties + """ + + properties: Optional["_models.SqlVulnerabilityAssessmentScanResultProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "rule_id", + "status", + "error_message", + "is_trimmed", + "query_results", + "remediation", + "baseline_adjusted_result", + "rule_metadata", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.SqlVulnerabilityAssessmentScanResultProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class StartStopManagedInstanceSchedule(ProxyResource): + """Managed instance's Start/Stop schedule. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.StartStopManagedInstanceScheduleProperties + """ + + properties: Optional["_models.StartStopManagedInstanceScheduleProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["description", "time_zone_id", "schedule_list", "next_run_action", "next_execution_time"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.StartStopManagedInstanceScheduleProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class StartStopManagedInstanceScheduleProperties(_Model): # pylint: disable=name-too-long + """Properties of managed instance's Start/Stop schedule. + + :ivar description: The description of the schedule. + :vartype description: str + :ivar time_zone_id: The time zone of the schedule. + :vartype time_zone_id: str + :ivar schedule_list: Schedule list. Required. + :vartype schedule_list: list[~azure.mgmt.sql.models.ScheduleItem] + :ivar next_run_action: Next action to be executed (Start or Stop). + :vartype next_run_action: str + :ivar next_execution_time: Timestamp when the next action will be executed in the corresponding + schedule time zone. + :vartype next_execution_time: str + """ + + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The description of the schedule.""" + time_zone_id: Optional[str] = rest_field( + name="timeZoneId", visibility=["read", "create", "update", "delete", "query"] + ) + """The time zone of the schedule.""" + schedule_list: list["_models.ScheduleItem"] = rest_field( + name="scheduleList", visibility=["read", "create", "update", "delete", "query"] + ) + """Schedule list. Required.""" + next_run_action: Optional[str] = rest_field(name="nextRunAction", visibility=["read"]) + """Next action to be executed (Start or Stop).""" + next_execution_time: Optional[str] = rest_field(name="nextExecutionTime", visibility=["read"]) + """Timestamp when the next action will be executed in the corresponding schedule time zone.""" + + @overload + def __init__( + self, + *, + schedule_list: list["_models.ScheduleItem"], + description: Optional[str] = None, + time_zone_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class StorageCapability(_Model): + """The storage account type capability. + + :ivar storage_account_type: The storage account type for the database's backups. Known values + 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", + "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 + """ + + storage_account_type: Optional[Union[str, "_models.StorageCapabilityStorageAccountType"]] = rest_field( + name="storageAccountType", visibility=["read"] + ) + """The storage account type for the database's backups. Known values are: \"GRS\", \"LRS\", + \"ZRS\", and \"GZRS\".""" + status: Optional[Union[str, "_models.CapabilityStatus"]] = rest_field(visibility=["read"]) + """The status of the capability. Known values are: \"Visible\", \"Available\", \"Default\", and + \"Disabled\".""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for the capability not being available.""" + + @overload + def __init__( + self, + *, + reason: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SubscriptionUsage(ProxyResource): + """Usage Metric of a Subscription in a Location. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.SubscriptionUsageProperties + """ + + properties: Optional["_models.SubscriptionUsageProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["display_name", "current_value", "limit", "unit"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.SubscriptionUsageProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class SubscriptionUsageProperties(_Model): + """Properties of a subscription usage. + + :ivar display_name: User-readable name of the metric. + :vartype display_name: str + :ivar current_value: Current value of the metric. + :vartype current_value: float + :ivar limit: Boundary value of the metric. + :vartype limit: float + :ivar unit: Unit of the metric. + :vartype unit: str + """ + + display_name: Optional[str] = rest_field(name="displayName", visibility=["read"]) + """User-readable name of the metric.""" + current_value: Optional[float] = rest_field(name="currentValue", visibility=["read"]) + """Current value of the metric.""" + limit: Optional[float] = rest_field(visibility=["read"]) + """Boundary value of the metric.""" + unit: Optional[str] = rest_field(visibility=["read"]) + """Unit of the metric.""" + + +class SynapseLinkWorkspace(ProxyResource): + """Synapse link workspace resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.SynapseLinkWorkspaceProperties + """ + + properties: Optional["_models.SynapseLinkWorkspaceProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["workspaces"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.SynapseLinkWorkspaceProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class SynapseLinkWorkspaceInfoProperties(_Model): + """Properties of a Synapse link workspaces. + + :ivar workspace_id: Synapse link workspace id. + :vartype workspace_id: str + :ivar link_connection_name: Link connection name. + :vartype link_connection_name: str + """ + + workspace_id: Optional[str] = rest_field( + name="workspaceId", visibility=["read", "create", "update", "delete", "query"] + ) + """Synapse link workspace id.""" + link_connection_name: Optional[str] = rest_field( + name="linkConnectionName", visibility=["read", "create", "update", "delete", "query"] + ) + """Link connection name.""" + + @overload + def __init__( + self, + *, + workspace_id: Optional[str] = None, + link_connection_name: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SynapseLinkWorkspaceProperties(_Model): + """Properties of a Synapse link workspaces. + + :ivar workspaces: List of all synapselink workspaces. + :vartype workspaces: list[~azure.mgmt.sql.models.SynapseLinkWorkspaceInfoProperties] + """ + + workspaces: Optional[list["_models.SynapseLinkWorkspaceInfoProperties"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of all synapselink workspaces.""" + + @overload + def __init__( + self, + *, + workspaces: Optional[list["_models.SynapseLinkWorkspaceInfoProperties"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SyncAgent(ProxyResource): + """An Azure SQL Database sync agent. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.SyncAgentProperties + """ + + properties: Optional["_models.SyncAgentProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "name", + "sync_database_id", + "last_alive_time", + "state", + "is_up_to_date", + "expiry_time", + "version", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.SyncAgentProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class SyncAgentKeyProperties(_Model): + """Properties of an Azure SQL Database sync agent key. + + :ivar sync_agent_key: Key of sync agent. + :vartype sync_agent_key: str + """ + + sync_agent_key: Optional[str] = rest_field(name="syncAgentKey", visibility=["read"]) + """Key of sync agent.""" + + +class SyncAgentLinkedDatabase(ProxyResource): + """An Azure SQL Database sync agent linked database. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.SyncAgentLinkedDatabaseProperties + """ + + properties: Optional["_models.SyncAgentLinkedDatabaseProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["database_type", "database_id", "description", "server_name", "database_name", "user_name"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.SyncAgentLinkedDatabaseProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class SyncAgentLinkedDatabaseProperties(_Model): + """Properties of an Azure SQL Database sync agent linked database. + + :ivar database_type: Type of the sync agent linked database. Known values are: + "AzureSqlDatabase" and "SqlServerDatabase". + :vartype database_type: str or ~azure.mgmt.sql.models.SyncMemberDbType + :ivar database_id: Id of the sync agent linked database. + :vartype database_id: str + :ivar description: Description of the sync agent linked database. + :vartype description: str + :ivar server_name: Server name of the sync agent linked database. + :vartype server_name: str + :ivar database_name: Database name of the sync agent linked database. + :vartype database_name: str + :ivar user_name: User name of the sync agent linked database. + :vartype user_name: str + """ + + database_type: Optional[Union[str, "_models.SyncMemberDbType"]] = rest_field( + name="databaseType", visibility=["read"] + ) + """Type of the sync agent linked database. Known values are: \"AzureSqlDatabase\" and + \"SqlServerDatabase\".""" + database_id: Optional[str] = rest_field(name="databaseId", visibility=["read"]) + """Id of the sync agent linked database.""" + description: Optional[str] = rest_field(visibility=["read"]) + """Description of the sync agent linked database.""" + server_name: Optional[str] = rest_field(name="serverName", visibility=["read"]) + """Server name of the sync agent linked database.""" + database_name: Optional[str] = rest_field(name="databaseName", visibility=["read"]) + """Database name of the sync agent linked database.""" + user_name: Optional[str] = rest_field(name="userName", visibility=["read"]) + """User name of the sync agent linked database.""" + + +class SyncAgentProperties(_Model): + """Properties of an Azure SQL Database sync agent. + + :ivar name: Name of the sync agent. + :vartype name: str + :ivar sync_database_id: ARM resource id of the sync database in the sync agent. + :vartype sync_database_id: str + :ivar last_alive_time: Last alive time of the sync agent. + :vartype last_alive_time: ~datetime.datetime + :ivar state: State of the sync agent. Known values are: "Online", "Offline", and + "NeverConnected". + :vartype state: str or ~azure.mgmt.sql.models.SyncAgentState + :ivar is_up_to_date: If the sync agent version is up to date. + :vartype is_up_to_date: bool + :ivar expiry_time: Expiration time of the sync agent version. + :vartype expiry_time: ~datetime.datetime + :ivar version: Version of the sync agent. + :vartype version: str + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """Name of the sync agent.""" + sync_database_id: Optional[str] = rest_field( + name="syncDatabaseId", visibility=["read", "create", "update", "delete", "query"] + ) + """ARM resource id of the sync database in the sync agent.""" + last_alive_time: Optional[datetime.datetime] = rest_field( + name="lastAliveTime", visibility=["read"], format="rfc3339" + ) + """Last alive time of the sync agent.""" + state: Optional[Union[str, "_models.SyncAgentState"]] = rest_field(visibility=["read"]) + """State of the sync agent. Known values are: \"Online\", \"Offline\", and \"NeverConnected\".""" + is_up_to_date: Optional[bool] = rest_field(name="isUpToDate", visibility=["read"]) + """If the sync agent version is up to date.""" + expiry_time: Optional[datetime.datetime] = rest_field(name="expiryTime", visibility=["read"], format="rfc3339") + """Expiration time of the sync agent version.""" + version: Optional[str] = rest_field(visibility=["read"]) + """Version of the sync agent.""" + + @overload + def __init__( + self, + *, + sync_database_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SyncDatabaseIdProperties(_Model): + """Properties of the sync database id. + + :ivar id: ARM resource id of sync database. + :vartype id: str + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """ARM resource id of sync database.""" + + +class SyncFullSchemaProperties(_Model): + """Properties of the database full schema. + + :ivar tables: List of tables in the database full schema. + :vartype tables: list[~azure.mgmt.sql.models.SyncFullSchemaTable] + :ivar last_update_time: Last update time of the database schema. + :vartype last_update_time: ~datetime.datetime + """ + + tables: Optional[list["_models.SyncFullSchemaTable"]] = rest_field(visibility=["read"]) + """List of tables in the database full schema.""" + last_update_time: Optional[datetime.datetime] = rest_field( + name="lastUpdateTime", visibility=["read"], format="rfc3339" + ) + """Last update time of the database schema.""" + + +class SyncFullSchemaTable(_Model): + """Properties of the table in the database full schema. + + :ivar columns: List of columns in the table of database full schema. + :vartype columns: list[~azure.mgmt.sql.models.SyncFullSchemaTableColumn] + :ivar error_id: Error id of the table. + :vartype error_id: str + :ivar has_error: If there is error in the table. + :vartype has_error: bool + :ivar name: Name of the table. + :vartype name: str + :ivar quoted_name: Quoted name of the table. + :vartype quoted_name: str + """ + + columns: Optional[list["_models.SyncFullSchemaTableColumn"]] = rest_field(visibility=["read"]) + """List of columns in the table of database full schema.""" + error_id: Optional[str] = rest_field(name="errorId", visibility=["read"]) + """Error id of the table.""" + has_error: Optional[bool] = rest_field(name="hasError", visibility=["read"]) + """If there is error in the table.""" + name: Optional[str] = rest_field(visibility=["read"]) + """Name of the table.""" + quoted_name: Optional[str] = rest_field(name="quotedName", visibility=["read"]) + """Quoted name of the table.""" + + +class SyncFullSchemaTableColumn(_Model): + """Properties of the column in the table of database full schema. + + :ivar data_size: Data size of the column. + :vartype data_size: str + :ivar data_type: Data type of the column. + :vartype data_type: str + :ivar error_id: Error id of the column. + :vartype error_id: str + :ivar has_error: If there is error in the table. + :vartype has_error: bool + :ivar is_primary_key: If it is the primary key of the table. + :vartype is_primary_key: bool + :ivar name: Name of the column. + :vartype name: str + :ivar quoted_name: Quoted name of the column. + :vartype quoted_name: str + """ + + data_size: Optional[str] = rest_field(name="dataSize", visibility=["read"]) + """Data size of the column.""" + data_type: Optional[str] = rest_field(name="dataType", visibility=["read"]) + """Data type of the column.""" + error_id: Optional[str] = rest_field(name="errorId", visibility=["read"]) + """Error id of the column.""" + has_error: Optional[bool] = rest_field(name="hasError", visibility=["read"]) + """If there is error in the table.""" + is_primary_key: Optional[bool] = rest_field(name="isPrimaryKey", visibility=["read"]) + """If it is the primary key of the table.""" + name: Optional[str] = rest_field(visibility=["read"]) + """Name of the column.""" + quoted_name: Optional[str] = rest_field(name="quotedName", visibility=["read"]) + """Quoted name of the column.""" + + +class SyncGroup(ProxyResource): + """An Azure SQL Database sync group. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.SyncGroupProperties + :ivar sku: The name and capacity of the SKU. + :vartype sku: ~azure.mgmt.sql.models.Sku + :ivar identity: Sync group authentication information. + :vartype identity: ~azure.mgmt.sql.models.DataSyncParticipantIdentity + """ + + properties: Optional["_models.SyncGroupProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + sku: Optional["_models.Sku"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name and capacity of the SKU.""" + identity: Optional["_models.DataSyncParticipantIdentity"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Sync group authentication information.""" + + __flattened_items = [ + "interval", + "last_sync_time", + "conflict_resolution_policy", + "sync_database_id", + "hub_database_user_name", + "hub_database_password", + "sync_state", + "schema", + "enable_conflict_logging", + "conflict_logging_retention_in_days", + "use_private_link_connection", + "private_endpoint_name", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.SyncGroupProperties"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.DataSyncParticipantIdentity"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class SyncGroupLogProperties(_Model): + """Properties of an Azure SQL Database sync group log. + + :ivar timestamp: Timestamp of the sync group log. + :vartype timestamp: ~datetime.datetime + :ivar type: Type of the sync group log. Known values are: "All", "Error", "Warning", and + "Success". + :vartype type: str or ~azure.mgmt.sql.models.SyncGroupLogType + :ivar source: Source of the sync group log. + :vartype source: str + :ivar details: Details of the sync group log. + :vartype details: str + :ivar tracing_id: TracingId of the sync group log. + :vartype tracing_id: str + :ivar operation_status: OperationStatus of the sync group log. + :vartype operation_status: str + """ + + timestamp: Optional[datetime.datetime] = rest_field(visibility=["read"], format="rfc3339") + """Timestamp of the sync group log.""" + type: Optional[Union[str, "_models.SyncGroupLogType"]] = rest_field(visibility=["read"]) + """Type of the sync group log. Known values are: \"All\", \"Error\", \"Warning\", and \"Success\".""" + source: Optional[str] = rest_field(visibility=["read"]) + """Source of the sync group log.""" + details: Optional[str] = rest_field(visibility=["read"]) + """Details of the sync group log.""" + tracing_id: Optional[str] = rest_field(name="tracingId", visibility=["read"]) + """TracingId of the sync group log.""" + operation_status: Optional[str] = rest_field(name="operationStatus", visibility=["read"]) + """OperationStatus of the sync group log.""" + + +class SyncGroupProperties(_Model): + """Properties of a sync group with support to MI. + + :ivar interval: Sync interval of the sync group. + :vartype interval: int + :ivar last_sync_time: Last sync time of the sync group. + :vartype last_sync_time: ~datetime.datetime + :ivar conflict_resolution_policy: Conflict resolution policy of the sync group. Known values + are: "HubWin" and "MemberWin". + :vartype conflict_resolution_policy: str or ~azure.mgmt.sql.models.SyncConflictResolutionPolicy + :ivar sync_database_id: ARM resource id of the sync database in the sync group. + :vartype sync_database_id: str + :ivar hub_database_user_name: User name for the sync group hub database credential. + :vartype hub_database_user_name: str + :ivar hub_database_password: Password for the sync group hub database credential. + :vartype hub_database_password: str + :ivar sync_state: Sync state of the sync group. Known values are: "NotReady", "Error", + "Warning", "Progressing", and "Good". + :vartype sync_state: str or ~azure.mgmt.sql.models.SyncGroupState + :ivar schema: Sync schema of the sync group. + :vartype schema: ~azure.mgmt.sql.models.SyncGroupSchema + :ivar enable_conflict_logging: If conflict logging is enabled. + :vartype enable_conflict_logging: bool + :ivar conflict_logging_retention_in_days: Conflict logging retention period. + :vartype conflict_logging_retention_in_days: int + :ivar use_private_link_connection: If use private link connection is enabled. + :vartype use_private_link_connection: bool + :ivar private_endpoint_name: Private endpoint name of the sync group if use private link + connection is enabled. + :vartype private_endpoint_name: str + """ + + interval: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Sync interval of the sync group.""" + last_sync_time: Optional[datetime.datetime] = rest_field(name="lastSyncTime", visibility=["read"], format="rfc3339") + """Last sync time of the sync group.""" + conflict_resolution_policy: Optional[Union[str, "_models.SyncConflictResolutionPolicy"]] = rest_field( + name="conflictResolutionPolicy", visibility=["read", "create", "update", "delete", "query"] + ) + """Conflict resolution policy of the sync group. Known values are: \"HubWin\" and \"MemberWin\".""" + sync_database_id: Optional[str] = rest_field( + name="syncDatabaseId", visibility=["read", "create", "update", "delete", "query"] + ) + """ARM resource id of the sync database in the sync group.""" + hub_database_user_name: Optional[str] = rest_field( + name="hubDatabaseUserName", visibility=["read", "create", "update", "delete", "query"] + ) + """User name for the sync group hub database credential.""" + hub_database_password: Optional[str] = rest_field(name="hubDatabasePassword", visibility=["create", "update"]) + """Password for the sync group hub database credential.""" + sync_state: Optional[Union[str, "_models.SyncGroupState"]] = rest_field(name="syncState", visibility=["read"]) + """Sync state of the sync group. Known values are: \"NotReady\", \"Error\", \"Warning\", + \"Progressing\", and \"Good\".""" + schema: Optional["_models.SyncGroupSchema"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Sync schema of the sync group.""" + enable_conflict_logging: Optional[bool] = rest_field( + name="enableConflictLogging", visibility=["read", "create", "update", "delete", "query"] + ) + """If conflict logging is enabled.""" + conflict_logging_retention_in_days: Optional[int] = rest_field( + name="conflictLoggingRetentionInDays", visibility=["read", "create", "update", "delete", "query"] + ) + """Conflict logging retention period.""" + use_private_link_connection: Optional[bool] = rest_field( + name="usePrivateLinkConnection", visibility=["read", "create", "update", "delete", "query"] + ) + """If use private link connection is enabled.""" + private_endpoint_name: Optional[str] = rest_field(name="privateEndpointName", visibility=["read"]) + """Private endpoint name of the sync group if use private link connection is enabled.""" + + @overload + def __init__( + self, + *, + interval: Optional[int] = None, + conflict_resolution_policy: Optional[Union[str, "_models.SyncConflictResolutionPolicy"]] = None, + sync_database_id: Optional[str] = None, + hub_database_user_name: Optional[str] = None, + hub_database_password: Optional[str] = None, + schema: Optional["_models.SyncGroupSchema"] = None, + enable_conflict_logging: Optional[bool] = None, + conflict_logging_retention_in_days: Optional[int] = None, + use_private_link_connection: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SyncGroupSchema(_Model): + """Properties of sync group schema. + + :ivar tables: List of tables in sync group schema. + :vartype tables: list[~azure.mgmt.sql.models.SyncGroupSchemaTable] + :ivar master_sync_member_name: Name of master sync member where the schema is from. + :vartype master_sync_member_name: str + """ + + tables: Optional[list["_models.SyncGroupSchemaTable"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of tables in sync group schema.""" + master_sync_member_name: Optional[str] = rest_field( + name="masterSyncMemberName", visibility=["read", "create", "update", "delete", "query"] + ) + """Name of master sync member where the schema is from.""" + + @overload + def __init__( + self, + *, + tables: Optional[list["_models.SyncGroupSchemaTable"]] = None, + master_sync_member_name: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SyncGroupSchemaTable(_Model): + """Properties of table in sync group schema. + + :ivar columns: List of columns in sync group schema. + :vartype columns: list[~azure.mgmt.sql.models.SyncGroupSchemaTableColumn] + :ivar quoted_name: Quoted name of sync group schema table. + :vartype quoted_name: str + """ + + columns: Optional[list["_models.SyncGroupSchemaTableColumn"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of columns in sync group schema.""" + quoted_name: Optional[str] = rest_field( + name="quotedName", visibility=["read", "create", "update", "delete", "query"] + ) + """Quoted name of sync group schema table.""" + + @overload + def __init__( + self, + *, + columns: Optional[list["_models.SyncGroupSchemaTableColumn"]] = None, + quoted_name: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SyncGroupSchemaTableColumn(_Model): + """Properties of column in sync group table. + + :ivar quoted_name: Quoted name of sync group table column. + :vartype quoted_name: str + :ivar data_size: Data size of the column. + :vartype data_size: str + :ivar data_type: Data type of the column. + :vartype data_type: str + """ + + quoted_name: Optional[str] = rest_field( + name="quotedName", visibility=["read", "create", "update", "delete", "query"] + ) + """Quoted name of sync group table column.""" + data_size: Optional[str] = rest_field(name="dataSize", visibility=["read", "create", "update", "delete", "query"]) + """Data size of the column.""" + data_type: Optional[str] = rest_field(name="dataType", visibility=["read", "create", "update", "delete", "query"]) + """Data type of the column.""" + + @overload + def __init__( + self, + *, + quoted_name: Optional[str] = None, + data_size: Optional[str] = None, + data_type: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SyncMember(ProxyResource): + """An Azure SQL Database sync member. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.SyncMemberProperties + :ivar identity: Sync member authentication information. + :vartype identity: ~azure.mgmt.sql.models.DataSyncParticipantIdentity + """ + + properties: Optional["_models.SyncMemberProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + identity: Optional["_models.DataSyncParticipantIdentity"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Sync member authentication information.""" + + __flattened_items = [ + "database_type", + "sync_agent_id", + "sql_server_database_id", + "sync_member_azure_database_resource_id", + "use_private_link_connection", + "private_endpoint_name", + "server_name", + "database_name", + "user_name", + "password", + "sync_direction", + "sync_state", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.SyncMemberProperties"] = None, + identity: Optional["_models.DataSyncParticipantIdentity"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class SyncMemberProperties(_Model): + """Properties of a sync member with support to MI. + + :ivar database_type: Database type of the sync member. Known values are: "AzureSqlDatabase" and + "SqlServerDatabase". + :vartype database_type: str or ~azure.mgmt.sql.models.SyncMemberDbType + :ivar sync_agent_id: ARM resource id of the sync agent in the sync member. + :vartype sync_agent_id: str + :ivar sql_server_database_id: SQL Server database id of the sync member. + :vartype sql_server_database_id: str + :ivar sync_member_azure_database_resource_id: ARM resource id of the sync member logical + database, for sync members in Azure. + :vartype sync_member_azure_database_resource_id: str + :ivar use_private_link_connection: Whether to use private link connection. + :vartype use_private_link_connection: bool + :ivar private_endpoint_name: Private endpoint name of the sync member if use private link + connection is enabled, for sync members in Azure. + :vartype private_endpoint_name: str + :ivar server_name: Server name of the member database in the sync member. + :vartype server_name: str + :ivar database_name: Database name of the member database in the sync member. + :vartype database_name: str + :ivar user_name: User name of the member database in the sync member. + :vartype user_name: str + :ivar password: Password of the member database in the sync member. + :vartype password: str + :ivar sync_direction: Sync direction of the sync member. Known values are: "Bidirectional", + "OneWayMemberToHub", and "OneWayHubToMember". + :vartype sync_direction: str or ~azure.mgmt.sql.models.SyncDirection + :ivar sync_state: Sync state of the sync member. Known values are: "SyncInProgress", + "SyncSucceeded", "SyncFailed", "DisabledTombstoneCleanup", "DisabledBackupRestore", + "SyncSucceededWithWarnings", "SyncCancelling", "SyncCancelled", "UnProvisioned", + "Provisioning", "Provisioned", "ProvisionFailed", "DeProvisioning", "DeProvisioned", + "DeProvisionFailed", "Reprovisioning", "ReprovisionFailed", and "UnReprovisioned". + :vartype sync_state: str or ~azure.mgmt.sql.models.SyncMemberState + """ + + database_type: Optional[Union[str, "_models.SyncMemberDbType"]] = rest_field( + name="databaseType", visibility=["read", "create", "update", "delete", "query"] + ) + """Database type of the sync member. Known values are: \"AzureSqlDatabase\" and + \"SqlServerDatabase\".""" + sync_agent_id: Optional[str] = rest_field( + name="syncAgentId", visibility=["read", "create", "update", "delete", "query"] + ) + """ARM resource id of the sync agent in the sync member.""" + sql_server_database_id: Optional[str] = rest_field( + name="sqlServerDatabaseId", visibility=["read", "create", "update", "delete", "query"] + ) + """SQL Server database id of the sync member.""" + sync_member_azure_database_resource_id: Optional[str] = rest_field( + name="syncMemberAzureDatabaseResourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """ARM resource id of the sync member logical database, for sync members in Azure.""" + use_private_link_connection: Optional[bool] = rest_field( + name="usePrivateLinkConnection", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether to use private link connection.""" + private_endpoint_name: Optional[str] = rest_field(name="privateEndpointName", visibility=["read"]) + """Private endpoint name of the sync member if use private link connection is enabled, for sync + members in Azure.""" + server_name: Optional[str] = rest_field( + name="serverName", visibility=["read", "create", "update", "delete", "query"] + ) + """Server name of the member database in the sync member.""" + database_name: Optional[str] = rest_field( + name="databaseName", visibility=["read", "create", "update", "delete", "query"] + ) + """Database name of the member database in the sync member.""" + user_name: Optional[str] = rest_field(name="userName", visibility=["read", "create", "update", "delete", "query"]) + """User name of the member database in the sync member.""" + password: Optional[str] = rest_field(visibility=["create", "update"]) + """Password of the member database in the sync member.""" + sync_direction: Optional[Union[str, "_models.SyncDirection"]] = rest_field( + name="syncDirection", visibility=["read", "create", "update", "delete", "query"] + ) + """Sync direction of the sync member. Known values are: \"Bidirectional\", \"OneWayMemberToHub\", + and \"OneWayHubToMember\".""" + sync_state: Optional[Union[str, "_models.SyncMemberState"]] = rest_field(name="syncState", visibility=["read"]) + """Sync state of the sync member. Known values are: \"SyncInProgress\", \"SyncSucceeded\", + \"SyncFailed\", \"DisabledTombstoneCleanup\", \"DisabledBackupRestore\", + \"SyncSucceededWithWarnings\", \"SyncCancelling\", \"SyncCancelled\", \"UnProvisioned\", + \"Provisioning\", \"Provisioned\", \"ProvisionFailed\", \"DeProvisioning\", \"DeProvisioned\", + \"DeProvisionFailed\", \"Reprovisioning\", \"ReprovisionFailed\", and \"UnReprovisioned\".""" + + @overload + def __init__( + self, + *, + database_type: Optional[Union[str, "_models.SyncMemberDbType"]] = None, + sync_agent_id: Optional[str] = None, + sql_server_database_id: Optional[str] = None, + sync_member_azure_database_resource_id: Optional[str] = None, + use_private_link_connection: Optional[bool] = None, + server_name: Optional[str] = None, + database_name: Optional[str] = None, + user_name: Optional[str] = None, + password: Optional[str] = None, + sync_direction: Optional[Union[str, "_models.SyncDirection"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SystemData(_Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.sql.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.sql.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + created_by: Optional[str] = rest_field(name="createdBy", visibility=["read", "create", "update", "delete", "query"]) + """The identity that created the resource.""" + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="createdByType", visibility=["read", "create", "update", "delete", "query"] + ) + """The type of identity that created the resource. Known values are: \"User\", \"Application\", + \"ManagedIdentity\", and \"Key\".""" + created_at: Optional[datetime.datetime] = rest_field( + name="createdAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The timestamp of resource creation (UTC).""" + last_modified_by: Optional[str] = rest_field( + name="lastModifiedBy", visibility=["read", "create", "update", "delete", "query"] + ) + """The identity that last modified the resource.""" + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="lastModifiedByType", visibility=["read", "create", "update", "delete", "query"] + ) + """The type of identity that last modified the resource. Known values are: \"User\", + \"Application\", \"ManagedIdentity\", and \"Key\".""" + last_modified_at: Optional[datetime.datetime] = rest_field( + name="lastModifiedAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The timestamp of resource last modification (UTC).""" + + @overload + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class TdeCertificate(ProxyResource): + """A TDE certificate that can be uploaded into a server. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.TdeCertificateProperties + """ + + properties: Optional["_models.TdeCertificateProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["private_blob", "cert_password"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.TdeCertificateProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class TdeCertificateProperties(_Model): + """Properties of a TDE certificate. + + :ivar private_blob: The base64 encoded certificate private blob. Required. + :vartype private_blob: str + :ivar cert_password: The certificate password. + :vartype cert_password: str + """ + + private_blob: str = rest_field(name="privateBlob", visibility=["create", "update"]) + """The base64 encoded certificate private blob. Required.""" + cert_password: Optional[str] = rest_field(name="certPassword", visibility=["create", "update"]) + """The certificate password.""" + + @overload + def __init__( + self, + *, + private_blob: str, + cert_password: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class TimeZone(ProxyResource): + """Time Zone property. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.TimeZoneProperties + """ + + properties: Optional["_models.TimeZoneProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["time_zone_id", "display_name"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.TimeZoneProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class TimeZoneProperties(_Model): + """The properties of a time zone. + + :ivar time_zone_id: The time zone id. + :vartype time_zone_id: str + :ivar display_name: The time zone display name. + :vartype display_name: str + """ + + time_zone_id: Optional[str] = rest_field(name="timeZoneId", visibility=["read"]) + """The time zone id.""" + display_name: Optional[str] = rest_field(name="displayName", visibility=["read"]) + """The time zone display name.""" + + +class TopQueries(_Model): + """TopQueries. + + :ivar number_of_queries: Requested number of top queries. + :vartype number_of_queries: int + :ivar aggregation_function: Aggregation function used to calculate query metrics. + :vartype aggregation_function: str + :ivar observation_metric: Metric used to rank queries. + :vartype observation_metric: str + :ivar interval_type: Interval type (length). Known values are: "PT1H" and "P1D". + :vartype interval_type: str or ~azure.mgmt.sql.models.QueryTimeGrainType + :ivar start_time: The start time for the metric (ISO-8601 format). + :vartype start_time: str + :ivar end_time: The end time for the metric (ISO-8601 format). + :vartype end_time: str + :ivar queries: List of top resource consuming queries with appropriate metric data. + :vartype queries: list[~azure.mgmt.sql.models.QueryStatisticsProperties] + """ + + number_of_queries: Optional[int] = rest_field(name="numberOfQueries", visibility=["read"]) + """Requested number of top queries.""" + aggregation_function: Optional[str] = rest_field(name="aggregationFunction", visibility=["read"]) + """Aggregation function used to calculate query metrics.""" + observation_metric: Optional[str] = rest_field(name="observationMetric", visibility=["read"]) + """Metric used to rank queries.""" + interval_type: Optional[Union[str, "_models.QueryTimeGrainType"]] = rest_field( + name="intervalType", visibility=["read"] + ) + """Interval type (length). Known values are: \"PT1H\" and \"P1D\".""" + start_time: Optional[str] = rest_field(name="startTime", visibility=["read"]) + """The start time for the metric (ISO-8601 format).""" + end_time: Optional[str] = rest_field(name="endTime", visibility=["read"]) + """The end time for the metric (ISO-8601 format).""" + queries: Optional[list["_models.QueryStatisticsProperties"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of top resource consuming queries with appropriate metric data.""" + + @overload + def __init__( + self, + *, + queries: Optional[list["_models.QueryStatisticsProperties"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class TransparentDataEncryptionProperties(_Model): + """Properties of a transparent data encryption scan. + + :ivar state: Specifies the state of the transparent data encryption. Required. Known values + are: "Enabled" and "Disabled". + :vartype state: str or ~azure.mgmt.sql.models.TransparentDataEncryptionState + :ivar scan_state: Specifies the encryption scan state of the transparent data encryption. Known + values are: "None", "Resume", "Running", "Suspend", "Aborted", and "Completed". + :vartype scan_state: str or ~azure.mgmt.sql.models.TransparentDataEncryptionScanState + """ + + state: Union[str, "_models.TransparentDataEncryptionState"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the state of the transparent data encryption. Required. Known values are: \"Enabled\" + and \"Disabled\".""" + scan_state: Optional[Union[str, "_models.TransparentDataEncryptionScanState"]] = rest_field( + name="scanState", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the encryption scan state of the transparent data encryption. Known values are: + \"None\", \"Resume\", \"Running\", \"Suspend\", \"Aborted\", and \"Completed\".""" + + @overload + def __init__( + self, + *, + state: Union[str, "_models.TransparentDataEncryptionState"], + scan_state: Optional[Union[str, "_models.TransparentDataEncryptionScanState"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class UpdateLongTermRetentionBackupParameters(_Model): + """Contains the information necessary to perform long term retention backup update operation. + + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParametersProperties + """ + + properties: Optional["_models.UpdateLongTermRetentionBackupParametersProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["requested_backup_storage_redundancy"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.UpdateLongTermRetentionBackupParametersProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class UpdateLongTermRetentionBackupParametersProperties(_Model): # pylint: disable=name-too-long + """Contains the properties to perform long term retention backup copy operation. + + :ivar requested_backup_storage_redundancy: The storage redundancy type of the copied backup. + Known values are: "Geo", "Local", "Zone", and "GeoZone". + :vartype requested_backup_storage_redundancy: str or + ~azure.mgmt.sql.models.BackupStorageRedundancy + """ + + requested_backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = rest_field( + name="requestedBackupStorageRedundancy", visibility=["create"] + ) + """The storage redundancy type of the copied backup. Known values are: \"Geo\", \"Local\", + \"Zone\", and \"GeoZone\".""" + + @overload + def __init__( + self, + *, + requested_backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class UpdateVirtualClusterDnsServersOperation(ProxyResource): + """A refresh DNS servers operation. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.VirtualClusterDnsServersProperties + """ + + properties: Optional["_models.VirtualClusterDnsServersProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["status"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.VirtualClusterDnsServersProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class UpsertManagedServerOperationParameters(_Model): + """UpsertManagedServerOperationParameters. + + :ivar family: + :vartype family: str + :ivar tier: + :vartype tier: str + :ivar v_cores: + :vartype v_cores: int + :ivar storage_size_in_gb: + :vartype storage_size_in_gb: int + """ + + family: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + tier: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + v_cores: Optional[int] = rest_field(name="vCores", visibility=["read", "create", "update", "delete", "query"]) + storage_size_in_gb: Optional[int] = rest_field( + name="storageSizeInGB", visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + family: Optional[str] = None, + tier: Optional[str] = None, + v_cores: Optional[int] = None, + storage_size_in_gb: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class UpsertManagedServerOperationStepWithEstimatesAndDuration(_Model): # pylint: disable=name-too-long + """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.UpsertManagedServerOperationStepWithEstimatesAndDurationStatus + """ + + step_start_time: Optional[datetime.datetime] = rest_field( + name="stepStartTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + step_end_time: Optional[datetime.datetime] = rest_field( + name="stepEndTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + time_elapsed: Optional[str] = rest_field( + name="timeElapsed", visibility=["read", "create", "update", "delete", "query"] + ) + order: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + status: Optional[Union[str, "_models.UpsertManagedServerOperationStepWithEstimatesAndDurationStatus"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Known values are: \"NotStarted\", \"InProgress\", \"SlowedDown\", \"Completed\", \"Failed\", + and \"Canceled\".""" + + @overload + 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.UpsertManagedServerOperationStepWithEstimatesAndDurationStatus"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Usage(_Model): + """ARM usage. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: ~azure.mgmt.sql.models.Name + :ivar type: Resource type. + :vartype type: str + :ivar unit: Usage unit. + :vartype unit: str + :ivar current_value: Usage current value. + :vartype current_value: int + :ivar limit: Usage limit. + :vartype limit: int + :ivar requested_limit: Usage requested limit. + :vartype requested_limit: int + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """Resource ID.""" + name: Optional["_models.Name"] = rest_field(visibility=["read"]) + """Resource name.""" + type: Optional[str] = rest_field(visibility=["read"]) + """Resource type.""" + unit: Optional[str] = rest_field(visibility=["read"]) + """Usage unit.""" + current_value: Optional[int] = rest_field(name="currentValue", visibility=["read"]) + """Usage current value.""" + limit: Optional[int] = rest_field(visibility=["read"]) + """Usage limit.""" + requested_limit: Optional[int] = rest_field(name="requestedLimit", visibility=["read"]) + """Usage requested limit.""" + + +class UserIdentity(_Model): + """Azure Active Directory identity configuration for a resource. + + :ivar principal_id: The Azure Active Directory principal id. + :vartype principal_id: str + :ivar client_id: The Azure Active Directory client id. + :vartype client_id: str + """ + + principal_id: Optional[str] = rest_field(name="principalId", visibility=["read"]) + """The Azure Active Directory principal id.""" + client_id: Optional[str] = rest_field(name="clientId", visibility=["read"]) + """The Azure Active Directory client id.""" + + +class VaRule(_Model): + """SQL Vulnerability Assessment rule metadata details. + + :ivar rule_id: SQL Vulnerability Assessment rule Id. + :vartype rule_id: str + :ivar severity: SQL Vulnerability Assessment rule severity. Known values are: "High", "Medium", + "Low", "Informational", and "Obsolete". + :vartype severity: str or ~azure.mgmt.sql.models.RuleSeverity + :ivar category: SQL Vulnerability Assessment rule category. + :vartype category: str + :ivar rule_type: SQL Vulnerability Assessment rule type. Known values are: "Binary", + "BaselineExpected", "PositiveList", and "NegativeList". + :vartype rule_type: str or ~azure.mgmt.sql.models.RuleType + :ivar title: SQL Vulnerability Assessment rule title. + :vartype title: str + :ivar description: SQL Vulnerability Assessment rule description. + :vartype description: str + :ivar rationale: SQL Vulnerability Assessment rule rationale. + :vartype rationale: str + :ivar query_check: SQL Vulnerability Assessment rule query details. + :vartype query_check: ~azure.mgmt.sql.models.QueryCheck + :ivar benchmark_references: SQL Vulnerability Assessment benchmark references. + :vartype benchmark_references: list[~azure.mgmt.sql.models.BenchmarkReference] + """ + + rule_id: Optional[str] = rest_field(name="ruleId", visibility=["read"]) + """SQL Vulnerability Assessment rule Id.""" + severity: Optional[Union[str, "_models.RuleSeverity"]] = rest_field(visibility=["read"]) + """SQL Vulnerability Assessment rule severity. Known values are: \"High\", \"Medium\", \"Low\", + \"Informational\", and \"Obsolete\".""" + category: Optional[str] = rest_field(visibility=["read"]) + """SQL Vulnerability Assessment rule category.""" + rule_type: Optional[Union[str, "_models.RuleType"]] = rest_field(name="ruleType", visibility=["read"]) + """SQL Vulnerability Assessment rule type. Known values are: \"Binary\", \"BaselineExpected\", + \"PositiveList\", and \"NegativeList\".""" + title: Optional[str] = rest_field(visibility=["read"]) + """SQL Vulnerability Assessment rule title.""" + description: Optional[str] = rest_field(visibility=["read"]) + """SQL Vulnerability Assessment rule description.""" + rationale: Optional[str] = rest_field(visibility=["read"]) + """SQL Vulnerability Assessment rule rationale.""" + query_check: Optional["_models.QueryCheck"] = rest_field(name="queryCheck", visibility=["read"]) + """SQL Vulnerability Assessment rule query details.""" + benchmark_references: Optional[list["_models.BenchmarkReference"]] = rest_field( + name="benchmarkReferences", visibility=["read"] + ) + """SQL Vulnerability Assessment benchmark references.""" + + +class VirtualCluster(TrackedResource): + """An Azure SQL virtual cluster. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.VirtualClusterProperties + """ + + properties: Optional["_models.VirtualClusterProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["subnet_id", "version", "child_resources"] + + @overload + def __init__( + self, + *, + location: str, + tags: Optional[dict[str, str]] = None, + properties: Optional["_models.VirtualClusterProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class VirtualClusterDnsServersProperties(_Model): + """The properties of dns servers on virtual cluster. + + :ivar status: The status of the DNS refresh operation. Known values are: "Succeeded", "Failed", + and "InProgress". + :vartype status: str or ~azure.mgmt.sql.models.DNSRefreshOperationStatus + """ + + status: Optional[Union[str, "_models.DNSRefreshOperationStatus"]] = rest_field(visibility=["read"]) + """The status of the DNS refresh operation. Known values are: \"Succeeded\", \"Failed\", and + \"InProgress\".""" + + +class VirtualClusterProperties(_Model): + """The properties of a virtual cluster. + + :ivar subnet_id: Subnet resource ID for the virtual cluster. + :vartype subnet_id: str + :ivar version: Virtual cluster version. + :vartype version: str + :ivar child_resources: List of resources in this virtual cluster. + :vartype child_resources: list[str] + """ + + subnet_id: Optional[str] = rest_field(name="subnetId", visibility=["read"]) + """Subnet resource ID for the virtual cluster.""" + version: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Virtual cluster version.""" + child_resources: Optional[list[str]] = rest_field(name="childResources", visibility=["read"]) + """List of resources in this virtual cluster.""" + + @overload + def __init__( + self, + *, + version: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VirtualClusterUpdate(_Model): + """An update request for virtual cluster. + + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.VirtualClusterProperties + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + properties: Optional["_models.VirtualClusterProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource tags.""" + + __flattened_items = ["subnet_id", "version", "child_resources"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.VirtualClusterProperties"] = None, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class VirtualNetworkRule(ProxyResource): + """A virtual network rule. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.VirtualNetworkRuleProperties + """ + + properties: Optional["_models.VirtualNetworkRuleProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["virtual_network_subnet_id", "ignore_missing_vnet_service_endpoint", "state"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.VirtualNetworkRuleProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class VirtualNetworkRuleProperties(_Model): + """Properties of a virtual network rule. + + :ivar virtual_network_subnet_id: The ARM resource id of the virtual network subnet. Required. + :vartype virtual_network_subnet_id: str + :ivar ignore_missing_vnet_service_endpoint: Create firewall rule before the virtual network has + vnet service endpoint enabled. + :vartype ignore_missing_vnet_service_endpoint: bool + :ivar state: Virtual Network Rule State. Known values are: "Initializing", "InProgress", + "Ready", "Failed", "Deleting", and "Unknown". + :vartype state: str or ~azure.mgmt.sql.models.VirtualNetworkRuleState + """ + + virtual_network_subnet_id: str = rest_field( + name="virtualNetworkSubnetId", visibility=["read", "create", "update", "delete", "query"] + ) + """The ARM resource id of the virtual network subnet. Required.""" + ignore_missing_vnet_service_endpoint: Optional[bool] = rest_field( + name="ignoreMissingVnetServiceEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """Create firewall rule before the virtual network has vnet service endpoint enabled.""" + state: Optional[Union[str, "_models.VirtualNetworkRuleState"]] = rest_field(visibility=["read"]) + """Virtual Network Rule State. Known values are: \"Initializing\", \"InProgress\", \"Ready\", + \"Failed\", \"Deleting\", and \"Unknown\".""" + + @overload + def __init__( + self, + *, + virtual_network_subnet_id: str, + ignore_missing_vnet_service_endpoint: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VulnerabilityAssessmentRecurringScansProperties(_Model): # pylint: disable=name-too-long + """Properties of a Vulnerability Assessment recurring scans. + + :ivar is_enabled: Recurring scans state. + :vartype is_enabled: bool + :ivar email_subscription_admins: Specifies that the schedule scan notification will be is sent + to the subscription administrators. + :vartype email_subscription_admins: bool + :ivar emails: Specifies an array of e-mail addresses to which the scan notification is sent. + :vartype emails: list[str] + """ + + is_enabled: Optional[bool] = rest_field( + name="isEnabled", visibility=["read", "create", "update", "delete", "query"] + ) + """Recurring scans state.""" + email_subscription_admins: Optional[bool] = rest_field( + name="emailSubscriptionAdmins", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies that the schedule scan notification will be is sent to the subscription + administrators.""" + emails: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Specifies an array of e-mail addresses to which the scan notification is sent.""" + + @overload + def __init__( + self, + *, + is_enabled: Optional[bool] = None, + email_subscription_admins: Optional[bool] = None, + emails: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VulnerabilityAssessmentScanError(_Model): + """Properties of a vulnerability assessment scan error. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + """ + + code: Optional[str] = rest_field(visibility=["read"]) + """The error code.""" + message: Optional[str] = rest_field(visibility=["read"]) + """The error message.""" + + +class VulnerabilityAssessmentScanRecord(ProxyResource): + """A vulnerability assessment scan record. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecordProperties + """ + + properties: Optional["_models.VulnerabilityAssessmentScanRecordProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "scan_id", + "trigger_type", + "state", + "start_time", + "end_time", + "errors", + "storage_container_path", + "number_of_failed_security_checks", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.VulnerabilityAssessmentScanRecordProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class VulnerabilityAssessmentScanRecordProperties(_Model): # pylint: disable=name-too-long + """Properties of a vulnerability assessment scan record. + + :ivar scan_id: The scan ID. + :vartype scan_id: str + :ivar trigger_type: The scan trigger type. Known values are: "OnDemand" and "Recurring". + :vartype trigger_type: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentScanTriggerType + :ivar state: The scan status. Known values are: "Passed", "Failed", "FailedToRun", and + "InProgress". + :vartype state: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentScanState + :ivar start_time: The scan start time (UTC). + :vartype start_time: ~datetime.datetime + :ivar end_time: The scan end time (UTC). + :vartype end_time: ~datetime.datetime + :ivar errors: The scan errors. + :vartype errors: list[~azure.mgmt.sql.models.VulnerabilityAssessmentScanError] + :ivar storage_container_path: The scan results storage container path. + :vartype storage_container_path: str + :ivar number_of_failed_security_checks: The number of failed security checks. + :vartype number_of_failed_security_checks: int + """ + + scan_id: Optional[str] = rest_field(name="scanId", visibility=["read"]) + """The scan ID.""" + trigger_type: Optional[Union[str, "_models.VulnerabilityAssessmentScanTriggerType"]] = rest_field( + name="triggerType", visibility=["read"] + ) + """The scan trigger type. Known values are: \"OnDemand\" and \"Recurring\".""" + state: Optional[Union[str, "_models.VulnerabilityAssessmentScanState"]] = rest_field(visibility=["read"]) + """The scan status. Known values are: \"Passed\", \"Failed\", \"FailedToRun\", and \"InProgress\".""" + start_time: Optional[datetime.datetime] = rest_field(name="startTime", visibility=["read"], format="rfc3339") + """The scan start time (UTC).""" + end_time: Optional[datetime.datetime] = rest_field(name="endTime", visibility=["read"], format="rfc3339") + """The scan end time (UTC).""" + errors: Optional[list["_models.VulnerabilityAssessmentScanError"]] = rest_field(visibility=["read"]) + """The scan errors.""" + storage_container_path: Optional[str] = rest_field(name="storageContainerPath", visibility=["read"]) + """The scan results storage container path.""" + number_of_failed_security_checks: Optional[int] = rest_field( + name="numberOfFailedSecurityChecks", visibility=["read"] + ) + """The number of failed security checks.""" + + +class WorkloadClassifier(ProxyResource): + """Workload classifier operations for a data warehouse. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.WorkloadClassifierProperties + """ + + properties: Optional["_models.WorkloadClassifierProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["member_name", "label", "context", "start_time", "end_time", "importance"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.WorkloadClassifierProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class WorkloadClassifierProperties(_Model): + """Workload classifier definition. For more information look at + sys.workload_management_workload_classifiers (DMV). + + :ivar member_name: The workload classifier member name. Required. + :vartype member_name: str + :ivar label: The workload classifier label. + :vartype label: str + :ivar context: The workload classifier context. + :vartype context: str + :ivar start_time: The workload classifier start time for classification. + :vartype start_time: str + :ivar end_time: The workload classifier end time for classification. + :vartype end_time: str + :ivar importance: The workload classifier importance. + :vartype importance: str + """ + + member_name: str = rest_field(name="memberName", visibility=["read", "create", "update", "delete", "query"]) + """The workload classifier member name. Required.""" + label: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The workload classifier label.""" + context: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The workload classifier context.""" + start_time: Optional[str] = rest_field(name="startTime", visibility=["read", "create", "update", "delete", "query"]) + """The workload classifier start time for classification.""" + end_time: Optional[str] = rest_field(name="endTime", visibility=["read", "create", "update", "delete", "query"]) + """The workload classifier end time for classification.""" + importance: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The workload classifier importance.""" + + @overload + def __init__( + self, + *, + member_name: str, + label: Optional[str] = None, + context: Optional[str] = None, + start_time: Optional[str] = None, + end_time: Optional[str] = None, + importance: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class WorkloadGroup(ProxyResource): + """Workload group operations for a data warehouse. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.sql.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.sql.models.WorkloadGroupProperties + """ + + properties: Optional["_models.WorkloadGroupProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = [ + "min_resource_percent", + "max_resource_percent", + "min_resource_percent_per_request", + "max_resource_percent_per_request", + "importance", + "query_execution_timeout", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.WorkloadGroupProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class WorkloadGroupProperties(_Model): + """Workload group definition. For more information look at sys.workload_management_workload_groups + (DMV). + + :ivar min_resource_percent: The workload group minimum percentage resource. Required. + :vartype min_resource_percent: int + :ivar max_resource_percent: The workload group cap percentage resource. Required. + :vartype max_resource_percent: int + :ivar min_resource_percent_per_request: The workload group request minimum grant percentage. + Required. + :vartype min_resource_percent_per_request: float + :ivar max_resource_percent_per_request: The workload group request maximum grant percentage. + :vartype max_resource_percent_per_request: float + :ivar importance: The workload group importance level. + :vartype importance: str + :ivar query_execution_timeout: The workload group query execution timeout. + :vartype query_execution_timeout: int + """ + + min_resource_percent: int = rest_field( + name="minResourcePercent", visibility=["read", "create", "update", "delete", "query"] + ) + """The workload group minimum percentage resource. Required.""" + max_resource_percent: int = rest_field( + name="maxResourcePercent", visibility=["read", "create", "update", "delete", "query"] + ) + """The workload group cap percentage resource. Required.""" + min_resource_percent_per_request: float = rest_field( + name="minResourcePercentPerRequest", visibility=["read", "create", "update", "delete", "query"] + ) + """The workload group request minimum grant percentage. Required.""" + max_resource_percent_per_request: Optional[float] = rest_field( + name="maxResourcePercentPerRequest", visibility=["read", "create", "update", "delete", "query"] + ) + """The workload group request maximum grant percentage.""" + importance: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The workload group importance level.""" + query_execution_timeout: Optional[int] = rest_field( + name="queryExecutionTimeout", visibility=["read", "create", "update", "delete", "query"] + ) + """The workload group query execution timeout.""" + + @overload + def __init__( + self, + *, + min_resource_percent: int, + max_resource_percent: int, + min_resource_percent_per_request: float, + max_resource_percent_per_request: Optional[float] = None, + importance: Optional[str] = None, + query_execution_timeout: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ZonePinningCapability(_Model): + """The zone pinning capability. + + :ivar availability_zone: Name of the availability zone. + :vartype availability_zone: str + :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 + """ + + availability_zone: Optional[str] = rest_field(name="availabilityZone", visibility=["read"]) + """Name of the availability zone.""" + status: Optional[Union[str, "_models.CapabilityStatus"]] = rest_field(visibility=["read"]) + """The status of the capability. Known values are: \"Visible\", \"Available\", \"Default\", and + \"Disabled\".""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for the capability not being available.""" + + @overload + def __init__( + self, + *, + reason: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) 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 deleted file mode 100644 index 57e0a2a0f2ab..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_models_py3.py +++ /dev/null @@ -1,23141 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,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 collections.abc import MutableMapping -import datetime -from typing import Any, Optional, TYPE_CHECKING, Union - -from .._utils import serialization as _serialization - -if TYPE_CHECKING: - from .. import models as _models -JSON = MutableMapping[str, Any] - - -class AdministratorListResult(_serialization.Model): - """A list of active directory administrators. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ServerAzureADAdministrator] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ServerAzureADAdministrator]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ServerAzureADAdministrator"]] = None - self.next_link: Optional[str] = None - - -class Resource(_serialization.Model): - """ARM resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.type: Optional[str] = None - - -class ProxyResource(Resource): - """ARM proxy resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - -class Advisor(ProxyResource): - """Database, Server or Elastic Pool Advisor. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar kind: Resource kind. - :vartype kind: str - :ivar location: Resource location. - :vartype location: str - :ivar advisor_status: Gets the status of availability of this advisor to customers. Possible - values are 'GA', 'PublicPreview', 'LimitedPublicPreview' and 'PrivatePreview'. Known values - are: "GA", "PublicPreview", "LimitedPublicPreview", and "PrivatePreview". - :vartype advisor_status: str or ~azure.mgmt.sql.models.AdvisorStatus - :ivar auto_execute_status: Gets the auto-execute status (whether to let the system execute the - recommendations) of this advisor. Possible values are 'Enabled' and 'Disabled'. Known values - are: "Enabled", "Disabled", and "Default". - :vartype auto_execute_status: str or ~azure.mgmt.sql.models.AutoExecuteStatus - :ivar auto_execute_status_inherited_from: Gets the resource from which current value of - auto-execute status is inherited. Auto-execute status can be set on (and inherited from) - different levels in the resource hierarchy. Possible values are 'Subscription', 'Server', - 'ElasticPool', 'Database' and 'Default' (when status is not explicitly set on any level). Known - values are: "Default", "Subscription", "Server", "ElasticPool", and "Database". - :vartype auto_execute_status_inherited_from: str or - ~azure.mgmt.sql.models.AutoExecuteStatusInheritedFrom - :ivar recommendations_status: Gets that status of recommendations for this advisor and reason - for not having any recommendations. Possible values include, but are not limited to, 'Ok' - (Recommendations available),LowActivity (not enough workload to analyze), 'DbSeemsTuned' - (Database is doing well), etc. - :vartype recommendations_status: str - :ivar last_checked: Gets the time when the current resource was analyzed for recommendations by - this advisor. - :vartype last_checked: ~datetime.datetime - :ivar recommended_actions: Gets the recommended actions for this advisor. - :vartype recommended_actions: list[~azure.mgmt.sql.models.RecommendedAction] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "kind": {"readonly": True}, - "location": {"readonly": True}, - "advisor_status": {"readonly": True}, - "auto_execute_status_inherited_from": {"readonly": True}, - "recommendations_status": {"readonly": True}, - "last_checked": {"readonly": True}, - "recommended_actions": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "advisor_status": {"key": "properties.advisorStatus", "type": "str"}, - "auto_execute_status": {"key": "properties.autoExecuteStatus", "type": "str"}, - "auto_execute_status_inherited_from": {"key": "properties.autoExecuteStatusInheritedFrom", "type": "str"}, - "recommendations_status": {"key": "properties.recommendationsStatus", "type": "str"}, - "last_checked": {"key": "properties.lastChecked", "type": "iso-8601"}, - "recommended_actions": {"key": "properties.recommendedActions", "type": "[RecommendedAction]"}, - } - - def __init__( - self, *, auto_execute_status: Optional[Union[str, "_models.AutoExecuteStatus"]] = None, **kwargs: Any - ) -> None: - """ - :keyword auto_execute_status: Gets the auto-execute status (whether to let the system execute - the recommendations) of this advisor. Possible values are 'Enabled' and 'Disabled'. Known - values are: "Enabled", "Disabled", and "Default". - :paramtype auto_execute_status: str or ~azure.mgmt.sql.models.AutoExecuteStatus - """ - super().__init__(**kwargs) - self.kind: Optional[str] = None - self.location: Optional[str] = None - self.advisor_status: Optional[Union[str, "_models.AdvisorStatus"]] = None - self.auto_execute_status = auto_execute_status - self.auto_execute_status_inherited_from: Optional[Union[str, "_models.AutoExecuteStatusInheritedFrom"]] = None - self.recommendations_status: Optional[str] = None - self.last_checked: Optional[datetime.datetime] = None - self.recommended_actions: Optional[list["_models.RecommendedAction"]] = None - - -class AutomaticTuningOptions(_serialization.Model): - """Automatic tuning properties for individual advisors. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar desired_state: Automatic tuning option desired state. Known values are: "Off", "On", and - "Default". - :vartype desired_state: str or ~azure.mgmt.sql.models.AutomaticTuningOptionModeDesired - :ivar actual_state: Automatic tuning option actual state. Known values are: "Off" and "On". - :vartype actual_state: str or ~azure.mgmt.sql.models.AutomaticTuningOptionModeActual - :ivar reason_code: Reason code if desired and actual state are different. - :vartype reason_code: int - :ivar reason_desc: Reason description if desired and actual state are different. Known values - are: "Default", "Disabled", "AutoConfigured", "InheritedFromServer", "QueryStoreOff", - "QueryStoreReadOnly", and "NotSupported". - :vartype reason_desc: str or ~azure.mgmt.sql.models.AutomaticTuningDisabledReason - """ - - _validation = { - "actual_state": {"readonly": True}, - "reason_code": {"readonly": True}, - "reason_desc": {"readonly": True}, - } - - _attribute_map = { - "desired_state": {"key": "desiredState", "type": "str"}, - "actual_state": {"key": "actualState", "type": "str"}, - "reason_code": {"key": "reasonCode", "type": "int"}, - "reason_desc": {"key": "reasonDesc", "type": "str"}, - } - - def __init__( - self, *, desired_state: Optional[Union[str, "_models.AutomaticTuningOptionModeDesired"]] = None, **kwargs: Any - ) -> None: - """ - :keyword desired_state: Automatic tuning option desired state. Known values are: "Off", "On", - and "Default". - :paramtype desired_state: str or ~azure.mgmt.sql.models.AutomaticTuningOptionModeDesired - """ - super().__init__(**kwargs) - self.desired_state = desired_state - self.actual_state: Optional[Union[str, "_models.AutomaticTuningOptionModeActual"]] = None - self.reason_code: Optional[int] = None - self.reason_desc: Optional[Union[str, "_models.AutomaticTuningDisabledReason"]] = None - - -class AutomaticTuningServerOptions(_serialization.Model): - """Automatic tuning properties for individual advisors. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar desired_state: Automatic tuning option desired state. Known values are: "Off", "On", and - "Default". - :vartype desired_state: str or ~azure.mgmt.sql.models.AutomaticTuningOptionModeDesired - :ivar actual_state: Automatic tuning option actual state. Known values are: "Off" and "On". - :vartype actual_state: str or ~azure.mgmt.sql.models.AutomaticTuningOptionModeActual - :ivar reason_code: Reason code if desired and actual state are different. - :vartype reason_code: int - :ivar reason_desc: Reason description if desired and actual state are different. Known values - are: "Default", "Disabled", and "AutoConfigured". - :vartype reason_desc: str or ~azure.mgmt.sql.models.AutomaticTuningServerReason - """ - - _validation = { - "actual_state": {"readonly": True}, - "reason_code": {"readonly": True}, - "reason_desc": {"readonly": True}, - } - - _attribute_map = { - "desired_state": {"key": "desiredState", "type": "str"}, - "actual_state": {"key": "actualState", "type": "str"}, - "reason_code": {"key": "reasonCode", "type": "int"}, - "reason_desc": {"key": "reasonDesc", "type": "str"}, - } - - def __init__( - self, *, desired_state: Optional[Union[str, "_models.AutomaticTuningOptionModeDesired"]] = None, **kwargs: Any - ) -> None: - """ - :keyword desired_state: Automatic tuning option desired state. Known values are: "Off", "On", - and "Default". - :paramtype desired_state: str or ~azure.mgmt.sql.models.AutomaticTuningOptionModeDesired - """ - super().__init__(**kwargs) - self.desired_state = desired_state - self.actual_state: Optional[Union[str, "_models.AutomaticTuningOptionModeActual"]] = None - self.reason_code: Optional[int] = None - self.reason_desc: Optional[Union[str, "_models.AutomaticTuningServerReason"]] = None - - -class AutoPauseDelayTimeRange(_serialization.Model): - """Supported auto pause delay time range. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar min_value: Minimum value. - :vartype min_value: int - :ivar max_value: Maximum value. - :vartype max_value: int - :ivar step_size: Step value for discrete values between the minimum value and the maximum - value. - :vartype step_size: int - :ivar default: Default value is no value is provided. - :vartype default: int - :ivar unit: Unit of time that delay is expressed in. "Minutes" - :vartype unit: str or ~azure.mgmt.sql.models.PauseDelayTimeUnit - :ivar do_not_pause_value: Value that is used to not pause (infinite delay before pause). - :vartype do_not_pause_value: int - """ - - _validation = { - "min_value": {"readonly": True}, - "max_value": {"readonly": True}, - "step_size": {"readonly": True}, - "default": {"readonly": True}, - "unit": {"readonly": True}, - "do_not_pause_value": {"readonly": True}, - } - - _attribute_map = { - "min_value": {"key": "minValue", "type": "int"}, - "max_value": {"key": "maxValue", "type": "int"}, - "step_size": {"key": "stepSize", "type": "int"}, - "default": {"key": "default", "type": "int"}, - "unit": {"key": "unit", "type": "str"}, - "do_not_pause_value": {"key": "doNotPauseValue", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.min_value: Optional[int] = None - self.max_value: Optional[int] = None - self.step_size: Optional[int] = None - self.default: Optional[int] = None - self.unit: Optional[Union[str, "_models.PauseDelayTimeUnit"]] = None - self.do_not_pause_value: Optional[int] = None - - -class AzureADOnlyAuthListResult(_serialization.Model): - """A list of active directory only authentications. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ServerAzureADOnlyAuthentication]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ServerAzureADOnlyAuthentication"]] = None - self.next_link: Optional[str] = None - - -class BackupShortTermRetentionPolicy(ProxyResource): - """A short term retention policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar retention_days: The backup retention period in days. This is how many days Point-in-Time - Restore will be supported. - :vartype retention_days: int - :ivar diff_backup_interval_in_hours: The differential backup interval in hours. This is how - many interval hours between each differential backup will be supported. This is only applicable - to live databases but not dropped databases. Known values are: 12 and 24. - :vartype diff_backup_interval_in_hours: int or ~azure.mgmt.sql.models.DiffBackupIntervalInHours - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "retention_days": {"key": "properties.retentionDays", "type": "int"}, - "diff_backup_interval_in_hours": {"key": "properties.diffBackupIntervalInHours", "type": "int"}, - } - - def __init__( - self, - *, - retention_days: Optional[int] = None, - diff_backup_interval_in_hours: Optional[Union[int, "_models.DiffBackupIntervalInHours"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword retention_days: The backup retention period in days. This is how many days - Point-in-Time Restore will be supported. - :paramtype retention_days: int - :keyword diff_backup_interval_in_hours: The differential backup interval in hours. This is how - many interval hours between each differential backup will be supported. This is only applicable - to live databases but not dropped databases. Known values are: 12 and 24. - :paramtype diff_backup_interval_in_hours: int or - ~azure.mgmt.sql.models.DiffBackupIntervalInHours - """ - super().__init__(**kwargs) - self.retention_days = retention_days - self.diff_backup_interval_in_hours = diff_backup_interval_in_hours - - -class BackupShortTermRetentionPolicyListResult(_serialization.Model): - """A list of short term retention policies. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[BackupShortTermRetentionPolicy]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.BackupShortTermRetentionPolicy"]] = None - self.next_link: Optional[str] = None - - -class Baseline(_serialization.Model): - """SQL Vulnerability Assessment baseline Details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar expected_results: SQL Vulnerability Assessment baseline expected results. - :vartype expected_results: list[list[str]] - :ivar updated_time: SQL Vulnerability Assessment baseline update time (UTC). - :vartype updated_time: ~datetime.datetime - """ - - _validation = { - "expected_results": {"readonly": True}, - "updated_time": {"readonly": True}, - } - - _attribute_map = { - "expected_results": {"key": "expectedResults", "type": "[[str]]"}, - "updated_time": {"key": "updatedTime", "type": "iso-8601"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.expected_results: Optional[list[list[str]]] = None - self.updated_time: Optional[datetime.datetime] = None - - -class BaselineAdjustedResult(_serialization.Model): - """SQL Vulnerability Assessment baseline adjusted results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar baseline: SQL Vulnerability Assessment baseline details. - :vartype baseline: ~azure.mgmt.sql.models.Baseline - :ivar status: SQL Vulnerability Assessment baseline status. Known values are: "NonFinding", - "Finding", and "InternalError". - :vartype status: str or ~azure.mgmt.sql.models.RuleStatus - :ivar results_not_in_baseline: SQL Vulnerability Assessment results that are not in baseline. - :vartype results_not_in_baseline: list[list[str]] - :ivar results_only_in_baseline: SQL Vulnerability Assessment results that are in baseline. - :vartype results_only_in_baseline: list[list[str]] - """ - - _validation = { - "baseline": {"readonly": True}, - "status": {"readonly": True}, - "results_not_in_baseline": {"readonly": True}, - "results_only_in_baseline": {"readonly": True}, - } - - _attribute_map = { - "baseline": {"key": "baseline", "type": "Baseline"}, - "status": {"key": "status", "type": "str"}, - "results_not_in_baseline": {"key": "resultsNotInBaseline", "type": "[[str]]"}, - "results_only_in_baseline": {"key": "resultsOnlyInBaseline", "type": "[[str]]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.baseline: Optional["_models.Baseline"] = None - self.status: Optional[Union[str, "_models.RuleStatus"]] = None - self.results_not_in_baseline: Optional[list[list[str]]] = None - self.results_only_in_baseline: Optional[list[list[str]]] = None - - -class BenchmarkReference(_serialization.Model): - """SQL Vulnerability Assessment benchmark reference. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar benchmark: SQL Vulnerability Assessment benchmark name. - :vartype benchmark: str - :ivar reference: SQL Vulnerability Assessment benchmark reference. - :vartype reference: str - """ - - _validation = { - "benchmark": {"readonly": True}, - "reference": {"readonly": True}, - } - - _attribute_map = { - "benchmark": {"key": "benchmark", "type": "str"}, - "reference": {"key": "reference", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.benchmark: Optional[str] = None - self.reference: Optional[str] = None - - -class CertificateInfo(_serialization.Model): - """Certificate information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar certificate_name: The certificate name. - :vartype certificate_name: str - :ivar expiry_date: The certificate expiry date. - :vartype expiry_date: ~datetime.datetime - """ - - _validation = { - "certificate_name": {"readonly": True}, - "expiry_date": {"readonly": True}, - } - - _attribute_map = { - "certificate_name": {"key": "certificateName", "type": "str"}, - "expiry_date": {"key": "expiryDate", "type": "iso-8601"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.certificate_name: Optional[str] = None - self.expiry_date: Optional[datetime.datetime] = None - - -class ChangeLongTermRetentionBackupAccessTierParameters(_serialization.Model): # pylint: disable=name-too-long - """Contains the information necessary to change long term retention backup access tier and related - operation mode. - - All required parameters must be populated in order to send to server. - - :ivar backup_storage_access_tier: The long term retention backup storage access tier. Required. - :vartype backup_storage_access_tier: str - :ivar operation_mode: The operation mode when updating ltr backup storage access tier. - Required. - :vartype operation_mode: str - """ - - _validation = { - "backup_storage_access_tier": {"required": True}, - "operation_mode": {"required": True}, - } - - _attribute_map = { - "backup_storage_access_tier": {"key": "backupStorageAccessTier", "type": "str"}, - "operation_mode": {"key": "operationMode", "type": "str"}, - } - - def __init__(self, *, backup_storage_access_tier: str, operation_mode: str, **kwargs: Any) -> None: - """ - :keyword backup_storage_access_tier: The long term retention backup storage access tier. - Required. - :paramtype backup_storage_access_tier: str - :keyword operation_mode: The operation mode when updating ltr backup storage access tier. - Required. - :paramtype operation_mode: str - """ - super().__init__(**kwargs) - self.backup_storage_access_tier = backup_storage_access_tier - self.operation_mode = operation_mode - - -class CheckNameAvailabilityRequest(_serialization.Model): - """A request to check whether the specified name for a resource is available. - - 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 server. - - :ivar name: Required. - :vartype name: str - :ivar type: Required. Default value is "Microsoft.Sql/servers". - :vartype type: str - """ - - _validation = { - "name": {"required": True}, - "type": {"required": True, "constant": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - type = "Microsoft.Sql/servers" - - def __init__(self, *, name: str, **kwargs: Any) -> None: - """ - :keyword name: Required. - :paramtype name: str - """ - super().__init__(**kwargs) - self.name = name - - -class CheckNameAvailabilityResponse(_serialization.Model): - """The result of a name availability check. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name whose availability was checked. - :vartype name: str - :ivar available: True if the name is available, otherwise false. - :vartype available: bool - :ivar reason: The reason code explaining why the name is unavailable. Will be undefined if the - name is available. Known values are: "Invalid" and "AlreadyExists". - :vartype reason: str or ~azure.mgmt.sql.models.CheckNameAvailabilityReason - :ivar message: A message explaining why the name is unavailable. Will be undefined if the name - is available. - :vartype message: str - """ - - _validation = { - "name": {"readonly": True}, - "available": {"readonly": True}, - "reason": {"readonly": True}, - "message": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "available": {"key": "available", "type": "bool"}, - "reason": {"key": "reason", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.available: Optional[bool] = None - self.reason: Optional[Union[str, "_models.CheckNameAvailabilityReason"]] = None - self.message: Optional[str] = None - - -class CompleteDatabaseRestoreDefinition(_serialization.Model): - """Contains the information necessary to perform a complete database restore operation. - - All required parameters must be populated in order to send to server. - - :ivar last_backup_name: The last backup name to apply. Required. - :vartype last_backup_name: str - """ - - _validation = { - "last_backup_name": {"required": True}, - } - - _attribute_map = { - "last_backup_name": {"key": "lastBackupName", "type": "str"}, - } - - def __init__(self, *, last_backup_name: str, **kwargs: Any) -> None: - """ - :keyword last_backup_name: The last backup name to apply. Required. - :paramtype last_backup_name: str - """ - super().__init__(**kwargs) - self.last_backup_name = last_backup_name - - -class CopyLongTermRetentionBackupParameters(_serialization.Model): - """Contains the information necessary to perform long term retention backup copy operation. - - :ivar target_subscription_id: The subscription that owns the target server. - :vartype target_subscription_id: str - :ivar target_resource_group: The resource group that owns the target server. - :vartype target_resource_group: str - :ivar target_server_resource_id: The resource Id of the target server that owns the database. - :vartype target_server_resource_id: str - :ivar target_server_fully_qualified_domain_name: The fully qualified domain name of the target - server. - :vartype target_server_fully_qualified_domain_name: str - :ivar target_database_name: The name of the database owns the copied backup. - :vartype target_database_name: str - :ivar target_backup_storage_redundancy: The storage redundancy type of the copied backup. Known - values are: "Geo", "Local", "Zone", and "GeoZone". - :vartype target_backup_storage_redundancy: str or - ~azure.mgmt.sql.models.BackupStorageRedundancy - """ - - _attribute_map = { - "target_subscription_id": {"key": "properties.targetSubscriptionId", "type": "str"}, - "target_resource_group": {"key": "properties.targetResourceGroup", "type": "str"}, - "target_server_resource_id": {"key": "properties.targetServerResourceId", "type": "str"}, - "target_server_fully_qualified_domain_name": { - "key": "properties.targetServerFullyQualifiedDomainName", - "type": "str", - }, - "target_database_name": {"key": "properties.targetDatabaseName", "type": "str"}, - "target_backup_storage_redundancy": {"key": "properties.targetBackupStorageRedundancy", "type": "str"}, - } - - def __init__( - self, - *, - target_subscription_id: Optional[str] = None, - target_resource_group: Optional[str] = None, - target_server_resource_id: Optional[str] = None, - target_server_fully_qualified_domain_name: Optional[str] = None, - target_database_name: Optional[str] = None, - target_backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword target_subscription_id: The subscription that owns the target server. - :paramtype target_subscription_id: str - :keyword target_resource_group: The resource group that owns the target server. - :paramtype target_resource_group: str - :keyword target_server_resource_id: The resource Id of the target server that owns the - database. - :paramtype target_server_resource_id: str - :keyword target_server_fully_qualified_domain_name: The fully qualified domain name of the - target server. - :paramtype target_server_fully_qualified_domain_name: str - :keyword target_database_name: The name of the database owns the copied backup. - :paramtype target_database_name: str - :keyword target_backup_storage_redundancy: The storage redundancy type of the copied backup. - Known values are: "Geo", "Local", "Zone", and "GeoZone". - :paramtype target_backup_storage_redundancy: str or - ~azure.mgmt.sql.models.BackupStorageRedundancy - """ - super().__init__(**kwargs) - self.target_subscription_id = target_subscription_id - self.target_resource_group = target_resource_group - self.target_server_resource_id = target_server_resource_id - self.target_server_fully_qualified_domain_name = target_server_fully_qualified_domain_name - self.target_database_name = target_database_name - self.target_backup_storage_redundancy = target_backup_storage_redundancy - - -class CreateDatabaseRestorePointDefinition(_serialization.Model): - """Contains the information necessary to perform a create database restore point operation. - - All required parameters must be populated in order to send to server. - - :ivar restore_point_label: The restore point label to apply. Required. - :vartype restore_point_label: str - """ - - _validation = { - "restore_point_label": {"required": True}, - } - - _attribute_map = { - "restore_point_label": {"key": "restorePointLabel", "type": "str"}, - } - - def __init__(self, *, restore_point_label: str, **kwargs: Any) -> None: - """ - :keyword restore_point_label: The restore point label to apply. Required. - :paramtype restore_point_label: str - """ - super().__init__(**kwargs) - self.restore_point_label = restore_point_label - - -class TrackedResource(Resource): - """ARM tracked top level resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, location: str, tags: Optional[dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.location = location - self.tags = tags - - -class Database(TrackedResource): - """A database resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: The database SKU. - - The list of SKUs may vary by region and support offer. To determine the SKUs (including the SKU - name, tier/edition, family, and capacity) that are available to your subscription in an Azure - region, use the ``Capabilities_ListByLocation`` REST API or one of the following commands: - - .. code-block:: azurecli - - az sql db list-editions -l -o table - ` - - .. code-block:: powershell - - Get-AzSqlServerServiceObjective -Location - `. - :vartype sku: ~azure.mgmt.sql.models.Sku - :ivar kind: Kind of database. This is metadata used for the Azure portal experience. - :vartype kind: str - :ivar managed_by: Resource that manages the database. - :vartype managed_by: str - :ivar identity: The Azure Active Directory identity of the database. - :vartype identity: ~azure.mgmt.sql.models.DatabaseIdentity - :ivar create_mode: Specifies the mode of database creation. - - Default: regular database creation. - - Copy: creates a database as a copy of an existing database. sourceDatabaseId must be specified - as the resource ID of the source database. - - Secondary: creates a database as a secondary replica of an existing database. sourceDatabaseId - must be specified as the resource ID of the existing primary database. - - PointInTimeRestore: Creates a database by restoring a point in time backup of an existing - database. sourceDatabaseId must be specified as the resource ID of the existing database, and - restorePointInTime must be specified. - - Recovery: Creates a database by restoring a geo-replicated backup. sourceDatabaseId must be - specified as the recoverable database resource ID to restore. - - Restore: Creates a database by restoring a backup of a deleted database. sourceDatabaseId must - be specified. If sourceDatabaseId is the database's original resource ID, then - sourceDatabaseDeletionDate must be specified. Otherwise sourceDatabaseId must be the restorable - dropped database resource ID and sourceDatabaseDeletionDate is ignored. restorePointInTime may - also be specified to restore from an earlier point in time. - - RestoreLongTermRetentionBackup: Creates a database by restoring from a long term retention - vault. recoveryServicesRecoveryPointResourceId must be specified as the recovery point resource - ID. - - Copy, Secondary, and RestoreLongTermRetentionBackup are not supported for DataWarehouse - edition. Known values are: "Default", "Copy", "Secondary", "PointInTimeRestore", "Restore", - "Recovery", "RestoreExternalBackup", "RestoreExternalBackupSecondary", - "RestoreLongTermRetentionBackup", and "OnlineSecondary". - :vartype create_mode: str or ~azure.mgmt.sql.models.CreateMode - :ivar collation: The collation of the database. - :vartype collation: str - :ivar max_size_bytes: The max size of the database expressed in bytes. - :vartype max_size_bytes: int - :ivar sample_name: The name of the sample schema to apply when creating this database. Known - values are: "AdventureWorksLT", "WideWorldImportersStd", and "WideWorldImportersFull". - :vartype sample_name: str or ~azure.mgmt.sql.models.SampleName - :ivar elastic_pool_id: The resource identifier of the elastic pool containing this database. - :vartype elastic_pool_id: str - :ivar source_database_id: The resource identifier of the source database associated with create - operation of this database. - :vartype source_database_id: str - :ivar status: The status of the database. Known values are: "Online", "Restoring", - "RecoveryPending", "Recovering", "Suspect", "Offline", "Standby", "Shutdown", "EmergencyMode", - "AutoClosed", "Copying", "Creating", "Inaccessible", "OfflineSecondary", "Pausing", "Paused", - "Resuming", "Scaling", "OfflineChangingDwPerformanceTiers", "OnlineChangingDwPerformanceTiers", - "Disabled", "Stopping", "Stopped", and "Starting". - :vartype status: str or ~azure.mgmt.sql.models.DatabaseStatus - :ivar database_id: The ID of the database. - :vartype database_id: str - :ivar creation_date: The creation date of the database (ISO8601 format). - :vartype creation_date: ~datetime.datetime - :ivar current_service_objective_name: The current service level objective name of the database. - :vartype current_service_objective_name: str - :ivar requested_service_objective_name: The requested service level objective name of the - database. - :vartype requested_service_objective_name: str - :ivar default_secondary_location: The default secondary region for this database. - :vartype default_secondary_location: str - :ivar failover_group_id: Failover Group resource identifier that this database belongs to. - :vartype failover_group_id: str - :ivar restore_point_in_time: Specifies the point in time (ISO8601 format) of the source - database that will be restored to create the new database. - :vartype restore_point_in_time: ~datetime.datetime - :ivar source_database_deletion_date: Specifies the time that the database was deleted. - :vartype source_database_deletion_date: ~datetime.datetime - :ivar recovery_services_recovery_point_id: The resource identifier of the recovery point - associated with create operation of this database. - :vartype recovery_services_recovery_point_id: str - :ivar long_term_retention_backup_resource_id: The resource identifier of the long term - retention backup associated with create operation of this database. - :vartype long_term_retention_backup_resource_id: str - :ivar recoverable_database_id: The resource identifier of the recoverable database associated - with create operation of this database. - :vartype recoverable_database_id: str - :ivar restorable_dropped_database_id: The resource identifier of the restorable dropped - database associated with create operation of this database. - :vartype restorable_dropped_database_id: str - :ivar catalog_collation: Collation of the metadata catalog. Known values are: - "DATABASE_DEFAULT" and "SQL_Latin1_General_CP1_CI_AS". - :vartype catalog_collation: str or ~azure.mgmt.sql.models.CatalogCollationType - :ivar zone_redundant: Whether or not this database is zone redundant, which means the replicas - of this database will be spread across multiple availability zones. - :vartype zone_redundant: bool - :ivar license_type: The license type to apply for this database. ``LicenseIncluded`` if you - need a license, or ``BasePrice`` if you have a license and are eligible for the Azure Hybrid - Benefit. Known values are: "LicenseIncluded" and "BasePrice". - :vartype license_type: str or ~azure.mgmt.sql.models.DatabaseLicenseType - :ivar max_log_size_bytes: The max log size for this database. - :vartype max_log_size_bytes: int - :ivar earliest_restore_date: This records the earliest start date and time that restore is - available for this database (ISO8601 format). - :vartype earliest_restore_date: ~datetime.datetime - :ivar read_scale: The state of read-only routing. If enabled, connections that have application - intent set to readonly in their connection string may be routed to a readonly secondary replica - in the same region. Not applicable to a Hyperscale database within an elastic pool. Known - values are: "Enabled" and "Disabled". - :vartype read_scale: str or ~azure.mgmt.sql.models.DatabaseReadScale - :ivar high_availability_replica_count: The number of secondary replicas associated with the - database that are used to provide high availability. Not applicable to a Hyperscale database - within an elastic pool. - :vartype high_availability_replica_count: int - :ivar secondary_type: The secondary type of the database if it is a secondary. Valid values - are Geo, Named and Standby. Known values are: "Geo", "Named", and "Standby". - :vartype secondary_type: str or ~azure.mgmt.sql.models.SecondaryType - :ivar current_sku: The name and tier of the SKU. - :vartype current_sku: ~azure.mgmt.sql.models.Sku - :ivar auto_pause_delay: Time in minutes after which database is automatically paused. A value - of -1 means that automatic pause is disabled. - :vartype auto_pause_delay: int - :ivar current_backup_storage_redundancy: The storage account type used to store backups for - this database. Known values are: "Geo", "Local", "Zone", and "GeoZone". - :vartype current_backup_storage_redundancy: str or - ~azure.mgmt.sql.models.BackupStorageRedundancy - :ivar requested_backup_storage_redundancy: The storage account type to be used to store backups - for this database. Known values are: "Geo", "Local", "Zone", and "GeoZone". - :vartype requested_backup_storage_redundancy: str or - ~azure.mgmt.sql.models.BackupStorageRedundancy - :ivar min_capacity: Minimal capacity that database will always have allocated, if not paused. - :vartype min_capacity: float - :ivar paused_date: The date when database was paused by user configuration or action(ISO8601 - format). Null if the database is ready. - :vartype paused_date: ~datetime.datetime - :ivar resumed_date: The date when database was resumed by user action or database login - (ISO8601 format). Null if the database is paused. - :vartype resumed_date: ~datetime.datetime - :ivar maintenance_configuration_id: Maintenance configuration id assigned to the database. This - configuration defines the period when the maintenance updates will occur. - :vartype maintenance_configuration_id: str - :ivar is_ledger_on: Whether or not this database is a ledger database, which means all tables - in the database are ledger tables. Note: the value of this property cannot be changed after the - database has been created. - :vartype is_ledger_on: bool - :ivar is_infra_encryption_enabled: Infra encryption is enabled for this database. - :vartype is_infra_encryption_enabled: bool - :ivar federated_client_id: The Client id used for cross tenant per database CMK scenario. - :vartype federated_client_id: str - :ivar keys: The resource ids of the user assigned identities to use. - :vartype keys: dict[str, ~azure.mgmt.sql.models.DatabaseKey] - :ivar encryption_protector: The azure key vault URI of the database if it's configured with per - Database Customer Managed Keys. - :vartype encryption_protector: str - :ivar preferred_enclave_type: Type of enclave requested on the database i.e. Default or VBS - enclaves. Known values are: "Default" and "VBS". - :vartype preferred_enclave_type: str or ~azure.mgmt.sql.models.AlwaysEncryptedEnclaveType - :ivar use_free_limit: Whether or not the database uses free monthly limits. Allowed on one - database in a subscription. - :vartype use_free_limit: bool - :ivar free_limit_exhaustion_behavior: Specifies the behavior when monthly free limits are - exhausted for the free database. - - AutoPause: The database will be auto paused upon exhaustion of free limits for remainder of the - month. - - BillForUsage: The database will continue to be online upon exhaustion of free limits and any - overage will be billed. Known values are: "AutoPause" and "BillOverUsage". - :vartype free_limit_exhaustion_behavior: str or - ~azure.mgmt.sql.models.FreeLimitExhaustionBehavior - :ivar source_resource_id: The resource identifier of the source associated with the create - operation of this database. - - This property is only supported for DataWarehouse edition and allows to restore across - subscriptions. - - When sourceResourceId is specified, sourceDatabaseId, recoverableDatabaseId, - restorableDroppedDatabaseId and sourceDatabaseDeletionDate must not be specified and CreateMode - must be PointInTimeRestore, Restore or Recover. - - When createMode is PointInTimeRestore, sourceResourceId must be the resource ID of the existing - database or existing sql pool, and restorePointInTime must be specified. - - When createMode is Restore, sourceResourceId must be the resource ID of restorable dropped - database or restorable dropped sql pool. - - When createMode is Recover, sourceResourceId must be the resource ID of recoverable database or - recoverable sql pool. - - When source subscription belongs to a different tenant than target subscription, - “x-ms-authorization-auxiliary” header must contain authentication token for the source tenant. - For more details about “x-ms-authorization-auxiliary” header see - https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/authenticate-multi-tenant. - :vartype source_resource_id: str - :ivar manual_cutover: Whether or not customer controlled manual cutover needs to be done during - Update Database operation to Hyperscale tier. - - This property is only applicable when scaling database from Business Critical/General - Purpose/Premium/Standard tier to Hyperscale tier. - - When manualCutover is specified, the scaling operation will wait for user input to trigger - cutover to Hyperscale database. - - To trigger cutover, please provide 'performCutover' parameter when the Scaling operation is in - Waiting state. - :vartype manual_cutover: bool - :ivar perform_cutover: To trigger customer controlled manual cutover during the wait state - while Scaling operation is in progress. - - This property parameter is only applicable for scaling operations that are initiated along with - 'manualCutover' parameter. - - This property is only applicable when scaling database from Business Critical/General - Purpose/Premium/Standard tier to Hyperscale tier is already in progress. - - When performCutover is specified, the scaling operation will trigger cutover and perform - role-change to Hyperscale database. - :vartype perform_cutover: bool - :ivar availability_zone: Specifies the availability zone the database is pinned to. Known - values are: "NoPreference", "1", "2", and "3". - :vartype availability_zone: str or ~azure.mgmt.sql.models.AvailabilityZoneType - :ivar encryption_protector_auto_rotation: The flag to enable or disable auto rotation of - database encryption protector AKV key. - :vartype encryption_protector_auto_rotation: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "kind": {"readonly": True}, - "managed_by": {"readonly": True}, - "status": {"readonly": True}, - "database_id": {"readonly": True}, - "creation_date": {"readonly": True}, - "current_service_objective_name": {"readonly": True}, - "requested_service_objective_name": {"readonly": True}, - "default_secondary_location": {"readonly": True}, - "failover_group_id": {"readonly": True}, - "max_log_size_bytes": {"readonly": True}, - "earliest_restore_date": {"readonly": True}, - "current_sku": {"readonly": True}, - "current_backup_storage_redundancy": {"readonly": True}, - "paused_date": {"readonly": True}, - "resumed_date": {"readonly": True}, - "is_infra_encryption_enabled": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "Sku"}, - "kind": {"key": "kind", "type": "str"}, - "managed_by": {"key": "managedBy", "type": "str"}, - "identity": {"key": "identity", "type": "DatabaseIdentity"}, - "create_mode": {"key": "properties.createMode", "type": "str"}, - "collation": {"key": "properties.collation", "type": "str"}, - "max_size_bytes": {"key": "properties.maxSizeBytes", "type": "int"}, - "sample_name": {"key": "properties.sampleName", "type": "str"}, - "elastic_pool_id": {"key": "properties.elasticPoolId", "type": "str"}, - "source_database_id": {"key": "properties.sourceDatabaseId", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "database_id": {"key": "properties.databaseId", "type": "str"}, - "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, - "current_service_objective_name": {"key": "properties.currentServiceObjectiveName", "type": "str"}, - "requested_service_objective_name": {"key": "properties.requestedServiceObjectiveName", "type": "str"}, - "default_secondary_location": {"key": "properties.defaultSecondaryLocation", "type": "str"}, - "failover_group_id": {"key": "properties.failoverGroupId", "type": "str"}, - "restore_point_in_time": {"key": "properties.restorePointInTime", "type": "iso-8601"}, - "source_database_deletion_date": {"key": "properties.sourceDatabaseDeletionDate", "type": "iso-8601"}, - "recovery_services_recovery_point_id": {"key": "properties.recoveryServicesRecoveryPointId", "type": "str"}, - "long_term_retention_backup_resource_id": { - "key": "properties.longTermRetentionBackupResourceId", - "type": "str", - }, - "recoverable_database_id": {"key": "properties.recoverableDatabaseId", "type": "str"}, - "restorable_dropped_database_id": {"key": "properties.restorableDroppedDatabaseId", "type": "str"}, - "catalog_collation": {"key": "properties.catalogCollation", "type": "str"}, - "zone_redundant": {"key": "properties.zoneRedundant", "type": "bool"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - "max_log_size_bytes": {"key": "properties.maxLogSizeBytes", "type": "int"}, - "earliest_restore_date": {"key": "properties.earliestRestoreDate", "type": "iso-8601"}, - "read_scale": {"key": "properties.readScale", "type": "str"}, - "high_availability_replica_count": {"key": "properties.highAvailabilityReplicaCount", "type": "int"}, - "secondary_type": {"key": "properties.secondaryType", "type": "str"}, - "current_sku": {"key": "properties.currentSku", "type": "Sku"}, - "auto_pause_delay": {"key": "properties.autoPauseDelay", "type": "int"}, - "current_backup_storage_redundancy": {"key": "properties.currentBackupStorageRedundancy", "type": "str"}, - "requested_backup_storage_redundancy": {"key": "properties.requestedBackupStorageRedundancy", "type": "str"}, - "min_capacity": {"key": "properties.minCapacity", "type": "float"}, - "paused_date": {"key": "properties.pausedDate", "type": "iso-8601"}, - "resumed_date": {"key": "properties.resumedDate", "type": "iso-8601"}, - "maintenance_configuration_id": {"key": "properties.maintenanceConfigurationId", "type": "str"}, - "is_ledger_on": {"key": "properties.isLedgerOn", "type": "bool"}, - "is_infra_encryption_enabled": {"key": "properties.isInfraEncryptionEnabled", "type": "bool"}, - "federated_client_id": {"key": "properties.federatedClientId", "type": "str"}, - "keys": {"key": "properties.keys", "type": "{DatabaseKey}"}, - "encryption_protector": {"key": "properties.encryptionProtector", "type": "str"}, - "preferred_enclave_type": {"key": "properties.preferredEnclaveType", "type": "str"}, - "use_free_limit": {"key": "properties.useFreeLimit", "type": "bool"}, - "free_limit_exhaustion_behavior": {"key": "properties.freeLimitExhaustionBehavior", "type": "str"}, - "source_resource_id": {"key": "properties.sourceResourceId", "type": "str"}, - "manual_cutover": {"key": "properties.manualCutover", "type": "bool"}, - "perform_cutover": {"key": "properties.performCutover", "type": "bool"}, - "availability_zone": {"key": "properties.availabilityZone", "type": "str"}, - "encryption_protector_auto_rotation": {"key": "properties.encryptionProtectorAutoRotation", "type": "bool"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - location: str, - tags: Optional[dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - identity: Optional["_models.DatabaseIdentity"] = None, - create_mode: Optional[Union[str, "_models.CreateMode"]] = None, - collation: Optional[str] = None, - max_size_bytes: Optional[int] = None, - sample_name: Optional[Union[str, "_models.SampleName"]] = None, - elastic_pool_id: Optional[str] = None, - source_database_id: Optional[str] = None, - restore_point_in_time: Optional[datetime.datetime] = None, - source_database_deletion_date: Optional[datetime.datetime] = None, - recovery_services_recovery_point_id: Optional[str] = None, - long_term_retention_backup_resource_id: Optional[str] = None, - recoverable_database_id: Optional[str] = None, - restorable_dropped_database_id: Optional[str] = None, - catalog_collation: Optional[Union[str, "_models.CatalogCollationType"]] = None, - zone_redundant: Optional[bool] = None, - license_type: Optional[Union[str, "_models.DatabaseLicenseType"]] = None, - read_scale: Optional[Union[str, "_models.DatabaseReadScale"]] = None, - high_availability_replica_count: Optional[int] = None, - secondary_type: Optional[Union[str, "_models.SecondaryType"]] = None, - auto_pause_delay: Optional[int] = None, - requested_backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = None, - min_capacity: Optional[float] = None, - maintenance_configuration_id: Optional[str] = None, - is_ledger_on: Optional[bool] = None, - federated_client_id: Optional[str] = None, - keys: Optional[dict[str, "_models.DatabaseKey"]] = None, - encryption_protector: Optional[str] = None, - preferred_enclave_type: Optional[Union[str, "_models.AlwaysEncryptedEnclaveType"]] = None, - use_free_limit: Optional[bool] = None, - free_limit_exhaustion_behavior: Optional[Union[str, "_models.FreeLimitExhaustionBehavior"]] = None, - source_resource_id: Optional[str] = None, - manual_cutover: Optional[bool] = None, - perform_cutover: Optional[bool] = None, - availability_zone: Optional[Union[str, "_models.AvailabilityZoneType"]] = None, - encryption_protector_auto_rotation: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The database SKU. - - The list of SKUs may vary by region and support offer. To determine the SKUs (including the SKU - name, tier/edition, family, and capacity) that are available to your subscription in an Azure - region, use the ``Capabilities_ListByLocation`` REST API or one of the following commands: - - .. code-block:: azurecli - - az sql db list-editions -l -o table - ` - - .. code-block:: powershell - - Get-AzSqlServerServiceObjective -Location - `. - :paramtype sku: ~azure.mgmt.sql.models.Sku - :keyword identity: The Azure Active Directory identity of the database. - :paramtype identity: ~azure.mgmt.sql.models.DatabaseIdentity - :keyword create_mode: Specifies the mode of database creation. - - Default: regular database creation. - - Copy: creates a database as a copy of an existing database. sourceDatabaseId must be specified - as the resource ID of the source database. - - Secondary: creates a database as a secondary replica of an existing database. sourceDatabaseId - must be specified as the resource ID of the existing primary database. - - PointInTimeRestore: Creates a database by restoring a point in time backup of an existing - database. sourceDatabaseId must be specified as the resource ID of the existing database, and - restorePointInTime must be specified. - - Recovery: Creates a database by restoring a geo-replicated backup. sourceDatabaseId must be - specified as the recoverable database resource ID to restore. - - Restore: Creates a database by restoring a backup of a deleted database. sourceDatabaseId must - be specified. If sourceDatabaseId is the database's original resource ID, then - sourceDatabaseDeletionDate must be specified. Otherwise sourceDatabaseId must be the restorable - dropped database resource ID and sourceDatabaseDeletionDate is ignored. restorePointInTime may - also be specified to restore from an earlier point in time. - - RestoreLongTermRetentionBackup: Creates a database by restoring from a long term retention - vault. recoveryServicesRecoveryPointResourceId must be specified as the recovery point resource - ID. - - Copy, Secondary, and RestoreLongTermRetentionBackup are not supported for DataWarehouse - edition. Known values are: "Default", "Copy", "Secondary", "PointInTimeRestore", "Restore", - "Recovery", "RestoreExternalBackup", "RestoreExternalBackupSecondary", - "RestoreLongTermRetentionBackup", and "OnlineSecondary". - :paramtype create_mode: str or ~azure.mgmt.sql.models.CreateMode - :keyword collation: The collation of the database. - :paramtype collation: str - :keyword max_size_bytes: The max size of the database expressed in bytes. - :paramtype max_size_bytes: int - :keyword sample_name: The name of the sample schema to apply when creating this database. Known - values are: "AdventureWorksLT", "WideWorldImportersStd", and "WideWorldImportersFull". - :paramtype sample_name: str or ~azure.mgmt.sql.models.SampleName - :keyword elastic_pool_id: The resource identifier of the elastic pool containing this database. - :paramtype elastic_pool_id: str - :keyword source_database_id: The resource identifier of the source database associated with - create operation of this database. - :paramtype source_database_id: str - :keyword restore_point_in_time: Specifies the point in time (ISO8601 format) of the source - database that will be restored to create the new database. - :paramtype restore_point_in_time: ~datetime.datetime - :keyword source_database_deletion_date: Specifies the time that the database was deleted. - :paramtype source_database_deletion_date: ~datetime.datetime - :keyword recovery_services_recovery_point_id: The resource identifier of the recovery point - associated with create operation of this database. - :paramtype recovery_services_recovery_point_id: str - :keyword long_term_retention_backup_resource_id: The resource identifier of the long term - retention backup associated with create operation of this database. - :paramtype long_term_retention_backup_resource_id: str - :keyword recoverable_database_id: The resource identifier of the recoverable database - associated with create operation of this database. - :paramtype recoverable_database_id: str - :keyword restorable_dropped_database_id: The resource identifier of the restorable dropped - database associated with create operation of this database. - :paramtype restorable_dropped_database_id: str - :keyword catalog_collation: Collation of the metadata catalog. Known values are: - "DATABASE_DEFAULT" and "SQL_Latin1_General_CP1_CI_AS". - :paramtype catalog_collation: str or ~azure.mgmt.sql.models.CatalogCollationType - :keyword zone_redundant: Whether or not this database is zone redundant, which means the - replicas of this database will be spread across multiple availability zones. - :paramtype zone_redundant: bool - :keyword license_type: The license type to apply for this database. ``LicenseIncluded`` if you - need a license, or ``BasePrice`` if you have a license and are eligible for the Azure Hybrid - Benefit. Known values are: "LicenseIncluded" and "BasePrice". - :paramtype license_type: str or ~azure.mgmt.sql.models.DatabaseLicenseType - :keyword read_scale: The state of read-only routing. If enabled, connections that have - application intent set to readonly in their connection string may be routed to a readonly - secondary replica in the same region. Not applicable to a Hyperscale database within an elastic - pool. Known values are: "Enabled" and "Disabled". - :paramtype read_scale: str or ~azure.mgmt.sql.models.DatabaseReadScale - :keyword high_availability_replica_count: The number of secondary replicas associated with the - database that are used to provide high availability. Not applicable to a Hyperscale database - within an elastic pool. - :paramtype high_availability_replica_count: int - :keyword secondary_type: The secondary type of the database if it is a secondary. Valid values - are Geo, Named and Standby. Known values are: "Geo", "Named", and "Standby". - :paramtype secondary_type: str or ~azure.mgmt.sql.models.SecondaryType - :keyword auto_pause_delay: Time in minutes after which database is automatically paused. A - value of -1 means that automatic pause is disabled. - :paramtype auto_pause_delay: int - :keyword requested_backup_storage_redundancy: The storage account type to be used to store - backups for this database. Known values are: "Geo", "Local", "Zone", and "GeoZone". - :paramtype requested_backup_storage_redundancy: str or - ~azure.mgmt.sql.models.BackupStorageRedundancy - :keyword min_capacity: Minimal capacity that database will always have allocated, if not - paused. - :paramtype min_capacity: float - :keyword maintenance_configuration_id: Maintenance configuration id assigned to the database. - This configuration defines the period when the maintenance updates will occur. - :paramtype maintenance_configuration_id: str - :keyword is_ledger_on: Whether or not this database is a ledger database, which means all - tables in the database are ledger tables. Note: the value of this property cannot be changed - after the database has been created. - :paramtype is_ledger_on: bool - :keyword federated_client_id: The Client id used for cross tenant per database CMK scenario. - :paramtype federated_client_id: str - :keyword keys: The resource ids of the user assigned identities to use. - :paramtype keys: dict[str, ~azure.mgmt.sql.models.DatabaseKey] - :keyword encryption_protector: The azure key vault URI of the database if it's configured with - per Database Customer Managed Keys. - :paramtype encryption_protector: str - :keyword preferred_enclave_type: Type of enclave requested on the database i.e. Default or VBS - enclaves. Known values are: "Default" and "VBS". - :paramtype preferred_enclave_type: str or ~azure.mgmt.sql.models.AlwaysEncryptedEnclaveType - :keyword use_free_limit: Whether or not the database uses free monthly limits. Allowed on one - database in a subscription. - :paramtype use_free_limit: bool - :keyword free_limit_exhaustion_behavior: Specifies the behavior when monthly free limits are - exhausted for the free database. - - AutoPause: The database will be auto paused upon exhaustion of free limits for remainder of the - month. - - BillForUsage: The database will continue to be online upon exhaustion of free limits and any - overage will be billed. Known values are: "AutoPause" and "BillOverUsage". - :paramtype free_limit_exhaustion_behavior: str or - ~azure.mgmt.sql.models.FreeLimitExhaustionBehavior - :keyword source_resource_id: The resource identifier of the source associated with the create - operation of this database. - - This property is only supported for DataWarehouse edition and allows to restore across - subscriptions. - - When sourceResourceId is specified, sourceDatabaseId, recoverableDatabaseId, - restorableDroppedDatabaseId and sourceDatabaseDeletionDate must not be specified and CreateMode - must be PointInTimeRestore, Restore or Recover. - - When createMode is PointInTimeRestore, sourceResourceId must be the resource ID of the existing - database or existing sql pool, and restorePointInTime must be specified. - - When createMode is Restore, sourceResourceId must be the resource ID of restorable dropped - database or restorable dropped sql pool. - - When createMode is Recover, sourceResourceId must be the resource ID of recoverable database or - recoverable sql pool. - - When source subscription belongs to a different tenant than target subscription, - “x-ms-authorization-auxiliary” header must contain authentication token for the source tenant. - For more details about “x-ms-authorization-auxiliary” header see - https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/authenticate-multi-tenant. - :paramtype source_resource_id: str - :keyword manual_cutover: Whether or not customer controlled manual cutover needs to be done - during Update Database operation to Hyperscale tier. - - This property is only applicable when scaling database from Business Critical/General - Purpose/Premium/Standard tier to Hyperscale tier. - - When manualCutover is specified, the scaling operation will wait for user input to trigger - cutover to Hyperscale database. - - To trigger cutover, please provide 'performCutover' parameter when the Scaling operation is in - Waiting state. - :paramtype manual_cutover: bool - :keyword perform_cutover: To trigger customer controlled manual cutover during the wait state - while Scaling operation is in progress. - - This property parameter is only applicable for scaling operations that are initiated along with - 'manualCutover' parameter. - - This property is only applicable when scaling database from Business Critical/General - Purpose/Premium/Standard tier to Hyperscale tier is already in progress. - - When performCutover is specified, the scaling operation will trigger cutover and perform - role-change to Hyperscale database. - :paramtype perform_cutover: bool - :keyword availability_zone: Specifies the availability zone the database is pinned to. Known - values are: "NoPreference", "1", "2", and "3". - :paramtype availability_zone: str or ~azure.mgmt.sql.models.AvailabilityZoneType - :keyword encryption_protector_auto_rotation: The flag to enable or disable auto rotation of - database encryption protector AKV key. - :paramtype encryption_protector_auto_rotation: bool - """ - super().__init__(location=location, tags=tags, **kwargs) - self.sku = sku - self.kind: Optional[str] = None - self.managed_by: Optional[str] = None - self.identity = identity - self.create_mode = create_mode - self.collation = collation - self.max_size_bytes = max_size_bytes - self.sample_name = sample_name - self.elastic_pool_id = elastic_pool_id - self.source_database_id = source_database_id - self.status: Optional[Union[str, "_models.DatabaseStatus"]] = None - self.database_id: Optional[str] = None - self.creation_date: Optional[datetime.datetime] = None - self.current_service_objective_name: Optional[str] = None - self.requested_service_objective_name: Optional[str] = None - self.default_secondary_location: Optional[str] = None - self.failover_group_id: Optional[str] = None - self.restore_point_in_time = restore_point_in_time - self.source_database_deletion_date = source_database_deletion_date - self.recovery_services_recovery_point_id = recovery_services_recovery_point_id - self.long_term_retention_backup_resource_id = long_term_retention_backup_resource_id - self.recoverable_database_id = recoverable_database_id - self.restorable_dropped_database_id = restorable_dropped_database_id - self.catalog_collation = catalog_collation - self.zone_redundant = zone_redundant - self.license_type = license_type - self.max_log_size_bytes: Optional[int] = None - self.earliest_restore_date: Optional[datetime.datetime] = None - self.read_scale = read_scale - self.high_availability_replica_count = high_availability_replica_count - self.secondary_type = secondary_type - self.current_sku: Optional["_models.Sku"] = None - self.auto_pause_delay = auto_pause_delay - self.current_backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = None - self.requested_backup_storage_redundancy = requested_backup_storage_redundancy - self.min_capacity = min_capacity - self.paused_date: Optional[datetime.datetime] = None - self.resumed_date: Optional[datetime.datetime] = None - self.maintenance_configuration_id = maintenance_configuration_id - self.is_ledger_on = is_ledger_on - self.is_infra_encryption_enabled: Optional[bool] = None - self.federated_client_id = federated_client_id - self.keys = keys - self.encryption_protector = encryption_protector - self.preferred_enclave_type = preferred_enclave_type - self.use_free_limit = use_free_limit - self.free_limit_exhaustion_behavior = free_limit_exhaustion_behavior - self.source_resource_id = source_resource_id - self.manual_cutover = manual_cutover - self.perform_cutover = perform_cutover - self.availability_zone = availability_zone - self.encryption_protector_auto_rotation = encryption_protector_auto_rotation - - -class DatabaseAdvancedThreatProtection(ProxyResource): - """A database Advanced Threat Protection. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: SystemData of AdvancedThreatProtectionResource. - :vartype system_data: ~azure.mgmt.sql.models.SystemData - :ivar state: Specifies the state of the Advanced Threat Protection, whether it is enabled or - disabled or a state has not been applied yet on the specific database or server. Known values - are: "New", "Enabled", and "Disabled". - :vartype state: str or ~azure.mgmt.sql.models.AdvancedThreatProtectionState - :ivar creation_time: Specifies the UTC creation time of the policy. - :vartype creation_time: ~datetime.datetime - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "creation_time": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "state": {"key": "properties.state", "type": "str"}, - "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, - } - - def __init__( - self, *, state: Optional[Union[str, "_models.AdvancedThreatProtectionState"]] = None, **kwargs: Any - ) -> None: - """ - :keyword state: Specifies the state of the Advanced Threat Protection, whether it is enabled or - disabled or a state has not been applied yet on the specific database or server. Known values - are: "New", "Enabled", and "Disabled". - :paramtype state: str or ~azure.mgmt.sql.models.AdvancedThreatProtectionState - """ - super().__init__(**kwargs) - self.system_data: Optional["_models.SystemData"] = None - self.state = state - self.creation_time: Optional[datetime.datetime] = None - - -class DatabaseAdvancedThreatProtectionListResult(_serialization.Model): # pylint: disable=name-too-long - """A list of the database's Advanced Threat Protection configurations. - - 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.DatabaseAdvancedThreatProtection] - :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": "[DatabaseAdvancedThreatProtection]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.DatabaseAdvancedThreatProtection"]] = None - self.next_link: Optional[str] = None - - -class DatabaseAutomaticTuning(ProxyResource): - """Database-level Automatic Tuning. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar desired_state: Automatic tuning desired state. Known values are: "Inherit", "Custom", - "Auto", and "Unspecified". - :vartype desired_state: str or ~azure.mgmt.sql.models.AutomaticTuningMode - :ivar actual_state: Automatic tuning actual state. Known values are: "Inherit", "Custom", - "Auto", and "Unspecified". - :vartype actual_state: str or ~azure.mgmt.sql.models.AutomaticTuningMode - :ivar options: Automatic tuning options definition. - :vartype options: dict[str, ~azure.mgmt.sql.models.AutomaticTuningOptions] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "actual_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "desired_state": {"key": "properties.desiredState", "type": "str"}, - "actual_state": {"key": "properties.actualState", "type": "str"}, - "options": {"key": "properties.options", "type": "{AutomaticTuningOptions}"}, - } - - def __init__( - self, - *, - desired_state: Optional[Union[str, "_models.AutomaticTuningMode"]] = None, - options: Optional[dict[str, "_models.AutomaticTuningOptions"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword desired_state: Automatic tuning desired state. Known values are: "Inherit", "Custom", - "Auto", and "Unspecified". - :paramtype desired_state: str or ~azure.mgmt.sql.models.AutomaticTuningMode - :keyword options: Automatic tuning options definition. - :paramtype options: dict[str, ~azure.mgmt.sql.models.AutomaticTuningOptions] - """ - super().__init__(**kwargs) - self.desired_state = desired_state - self.actual_state: Optional[Union[str, "_models.AutomaticTuningMode"]] = None - self.options = options - - -class DatabaseBlobAuditingPolicy(ProxyResource): - """A database blob auditing policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar kind: Resource kind. - :vartype kind: str - :ivar retention_days: Specifies the number of days to keep in the audit logs in the storage - account. - :vartype retention_days: int - :ivar audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. - - The recommended set of action groups to use is the following combination - this will audit all - the queries and stored procedures executed against the database, as well as successful and - failed logins: - - BATCH_COMPLETED_GROUP, - SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, - FAILED_DATABASE_AUTHENTICATION_GROUP. - - This above combination is also the set that is configured by default when enabling auditing - from the Azure portal. - - The supported action groups to audit are (note: choose only specific groups that cover your - auditing needs. Using unnecessary groups could lead to very large quantities of audit records): - - APPLICATION_ROLE_CHANGE_PASSWORD_GROUP - BACKUP_RESTORE_GROUP - DATABASE_LOGOUT_GROUP - DATABASE_OBJECT_CHANGE_GROUP - DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP - DATABASE_OBJECT_PERMISSION_CHANGE_GROUP - DATABASE_OPERATION_GROUP - DATABASE_PERMISSION_CHANGE_GROUP - DATABASE_PRINCIPAL_CHANGE_GROUP - DATABASE_PRINCIPAL_IMPERSONATION_GROUP - DATABASE_ROLE_MEMBER_CHANGE_GROUP - FAILED_DATABASE_AUTHENTICATION_GROUP - SCHEMA_OBJECT_ACCESS_GROUP - SCHEMA_OBJECT_CHANGE_GROUP - SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP - SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP - SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP - USER_CHANGE_PASSWORD_GROUP - BATCH_STARTED_GROUP - BATCH_COMPLETED_GROUP - DBCC_GROUP - DATABASE_OWNERSHIP_CHANGE_GROUP - DATABASE_CHANGE_GROUP - LEDGER_OPERATION_GROUP - - These are groups that cover all sql statements and stored procedures executed against the - database, and should not be used in combination with other groups as this will result in - duplicate audit logs. - - For more information, see `Database-Level Audit Action Groups - `_. - - For Database auditing policy, specific Actions can also be specified (note that Actions cannot - be specified for Server auditing policy). The supported actions to audit are: - SELECT - UPDATE - INSERT - DELETE - EXECUTE - RECEIVE - REFERENCES - - The general form for defining an action to be audited is: - {action} ON {object} BY {principal} - - Note that :code:`` in the above format can refer to an object like a table, view, or - stored procedure, or an entire database or schema. For the latter cases, the forms - DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. - - For example: - SELECT on dbo.myTable by public - SELECT on DATABASE::myDatabase by public - SELECT on SCHEMA::mySchema by public - - For more information, see `Database-Level Audit Actions - `_. - :vartype audit_actions_and_groups: list[str] - :ivar is_storage_secondary_key_in_use: Specifies whether storageAccountAccessKey value is the - storage's secondary key. - :vartype is_storage_secondary_key_in_use: bool - :ivar is_azure_monitor_target_enabled: Specifies whether audit events are sent to Azure - Monitor. - In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and - 'IsAzureMonitorTargetEnabled' as true. - - When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' - diagnostic logs category on the database should be also created. - Note that for server level audit you should use the 'master' database as {databaseName}. - - Diagnostic Settings URI format: - PUT - https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview - - For more information, see `Diagnostic Settings REST API - `_ - or `Diagnostic Settings PowerShell `_. - :vartype is_azure_monitor_target_enabled: bool - :ivar queue_delay_ms: Specifies the amount of time in milliseconds that can elapse before audit - actions are forced to be processed. - The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. - :vartype queue_delay_ms: int - :ivar is_managed_identity_in_use: Specifies whether Managed Identity is used to access blob - storage. - :vartype is_managed_identity_in_use: bool - :ivar state: Specifies the state of the audit. If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled are required. Known values are: "Enabled" and "Disabled". - :vartype state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState - :ivar storage_endpoint: Specifies the blob storage endpoint (e.g. - https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled is required. - :vartype storage_endpoint: str - :ivar storage_account_access_key: Specifies the identifier key of the auditing storage account. - If state is Enabled and storageEndpoint is specified, not specifying the - storageAccountAccessKey will use SQL server system-assigned managed identity to access the - storage. - Prerequisites for using managed identity authentication: - - - #. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). - #. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data - Contributor' RBAC role to the server identity. - For more information, see `Auditing to storage using Managed Identity authentication - `_. - :vartype storage_account_access_key: str - :ivar storage_account_subscription_id: Specifies the blob storage subscription Id. - :vartype storage_account_subscription_id: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "kind": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "retention_days": {"key": "properties.retentionDays", "type": "int"}, - "audit_actions_and_groups": {"key": "properties.auditActionsAndGroups", "type": "[str]"}, - "is_storage_secondary_key_in_use": {"key": "properties.isStorageSecondaryKeyInUse", "type": "bool"}, - "is_azure_monitor_target_enabled": {"key": "properties.isAzureMonitorTargetEnabled", "type": "bool"}, - "queue_delay_ms": {"key": "properties.queueDelayMs", "type": "int"}, - "is_managed_identity_in_use": {"key": "properties.isManagedIdentityInUse", "type": "bool"}, - "state": {"key": "properties.state", "type": "str"}, - "storage_endpoint": {"key": "properties.storageEndpoint", "type": "str"}, - "storage_account_access_key": {"key": "properties.storageAccountAccessKey", "type": "str"}, - "storage_account_subscription_id": {"key": "properties.storageAccountSubscriptionId", "type": "str"}, - } - - def __init__( - self, - *, - retention_days: Optional[int] = None, - audit_actions_and_groups: Optional[list[str]] = None, - is_storage_secondary_key_in_use: Optional[bool] = None, - is_azure_monitor_target_enabled: Optional[bool] = None, - queue_delay_ms: Optional[int] = None, - is_managed_identity_in_use: Optional[bool] = None, - state: Optional[Union[str, "_models.BlobAuditingPolicyState"]] = None, - storage_endpoint: Optional[str] = None, - storage_account_access_key: Optional[str] = None, - storage_account_subscription_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword retention_days: Specifies the number of days to keep in the audit logs in the storage - account. - :paramtype retention_days: int - :keyword audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. - - The recommended set of action groups to use is the following combination - this will audit all - the queries and stored procedures executed against the database, as well as successful and - failed logins: - - BATCH_COMPLETED_GROUP, - SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, - FAILED_DATABASE_AUTHENTICATION_GROUP. - - This above combination is also the set that is configured by default when enabling auditing - from the Azure portal. - - The supported action groups to audit are (note: choose only specific groups that cover your - auditing needs. Using unnecessary groups could lead to very large quantities of audit records): - - APPLICATION_ROLE_CHANGE_PASSWORD_GROUP - BACKUP_RESTORE_GROUP - DATABASE_LOGOUT_GROUP - DATABASE_OBJECT_CHANGE_GROUP - DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP - DATABASE_OBJECT_PERMISSION_CHANGE_GROUP - DATABASE_OPERATION_GROUP - DATABASE_PERMISSION_CHANGE_GROUP - DATABASE_PRINCIPAL_CHANGE_GROUP - DATABASE_PRINCIPAL_IMPERSONATION_GROUP - DATABASE_ROLE_MEMBER_CHANGE_GROUP - FAILED_DATABASE_AUTHENTICATION_GROUP - SCHEMA_OBJECT_ACCESS_GROUP - SCHEMA_OBJECT_CHANGE_GROUP - SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP - SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP - SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP - USER_CHANGE_PASSWORD_GROUP - BATCH_STARTED_GROUP - BATCH_COMPLETED_GROUP - DBCC_GROUP - DATABASE_OWNERSHIP_CHANGE_GROUP - DATABASE_CHANGE_GROUP - LEDGER_OPERATION_GROUP - - These are groups that cover all sql statements and stored procedures executed against the - database, and should not be used in combination with other groups as this will result in - duplicate audit logs. - - For more information, see `Database-Level Audit Action Groups - `_. - - For Database auditing policy, specific Actions can also be specified (note that Actions cannot - be specified for Server auditing policy). The supported actions to audit are: - SELECT - UPDATE - INSERT - DELETE - EXECUTE - RECEIVE - REFERENCES - - The general form for defining an action to be audited is: - {action} ON {object} BY {principal} - - Note that :code:`` in the above format can refer to an object like a table, view, or - stored procedure, or an entire database or schema. For the latter cases, the forms - DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. - - For example: - SELECT on dbo.myTable by public - SELECT on DATABASE::myDatabase by public - SELECT on SCHEMA::mySchema by public - - For more information, see `Database-Level Audit Actions - `_. - :paramtype audit_actions_and_groups: list[str] - :keyword is_storage_secondary_key_in_use: Specifies whether storageAccountAccessKey value is - the storage's secondary key. - :paramtype is_storage_secondary_key_in_use: bool - :keyword is_azure_monitor_target_enabled: Specifies whether audit events are sent to Azure - Monitor. - In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and - 'IsAzureMonitorTargetEnabled' as true. - - When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' - diagnostic logs category on the database should be also created. - Note that for server level audit you should use the 'master' database as {databaseName}. - - Diagnostic Settings URI format: - PUT - https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview - - For more information, see `Diagnostic Settings REST API - `_ - or `Diagnostic Settings PowerShell `_. - :paramtype is_azure_monitor_target_enabled: bool - :keyword queue_delay_ms: Specifies the amount of time in milliseconds that can elapse before - audit actions are forced to be processed. - The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. - :paramtype queue_delay_ms: int - :keyword is_managed_identity_in_use: Specifies whether Managed Identity is used to access blob - storage. - :paramtype is_managed_identity_in_use: bool - :keyword state: Specifies the state of the audit. If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled are required. Known values are: "Enabled" and "Disabled". - :paramtype state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState - :keyword storage_endpoint: Specifies the blob storage endpoint (e.g. - https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled is required. - :paramtype storage_endpoint: str - :keyword storage_account_access_key: Specifies the identifier key of the auditing storage - account. - If state is Enabled and storageEndpoint is specified, not specifying the - storageAccountAccessKey will use SQL server system-assigned managed identity to access the - storage. - Prerequisites for using managed identity authentication: - - - #. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). - #. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data - Contributor' RBAC role to the server identity. - For more information, see `Auditing to storage using Managed Identity authentication - `_. - :paramtype storage_account_access_key: str - :keyword storage_account_subscription_id: Specifies the blob storage subscription Id. - :paramtype storage_account_subscription_id: str - """ - super().__init__(**kwargs) - self.kind: Optional[str] = None - self.retention_days = retention_days - self.audit_actions_and_groups = audit_actions_and_groups - self.is_storage_secondary_key_in_use = is_storage_secondary_key_in_use - self.is_azure_monitor_target_enabled = is_azure_monitor_target_enabled - self.queue_delay_ms = queue_delay_ms - self.is_managed_identity_in_use = is_managed_identity_in_use - self.state = state - self.storage_endpoint = storage_endpoint - self.storage_account_access_key = storage_account_access_key - self.storage_account_subscription_id = storage_account_subscription_id - - -class DatabaseBlobAuditingPolicyListResult(_serialization.Model): - """A list of database auditing settings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.DatabaseBlobAuditingPolicy] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DatabaseBlobAuditingPolicy]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.DatabaseBlobAuditingPolicy"]] = None - self.next_link: Optional[str] = None - - -class DatabaseColumn(ProxyResource): - """A database column resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar column_type: The column data type. Known values are: "image", "text", "uniqueidentifier", - "date", "time", "datetime2", "datetimeoffset", "tinyint", "smallint", "int", "smalldatetime", - "real", "money", "datetime", "float", "sql_variant", "ntext", "bit", "decimal", "numeric", - "smallmoney", "bigint", "hierarchyid", "geometry", "geography", "varbinary", "varchar", - "binary", "char", "timestamp", "nvarchar", "nchar", "xml", "sysname", and "int". - :vartype column_type: str or ~azure.mgmt.sql.models.ColumnDataType - :ivar temporal_type: The table temporal type. Known values are: "NonTemporalTable", - "HistoryTable", and "SystemVersionedTemporalTable". - :vartype temporal_type: str or ~azure.mgmt.sql.models.TableTemporalType - :ivar memory_optimized: Whether or not the column belongs to a memory optimized table. - :vartype memory_optimized: bool - :ivar is_computed: Whether or not the column is computed. - :vartype is_computed: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "column_type": {"key": "properties.columnType", "type": "str"}, - "temporal_type": {"key": "properties.temporalType", "type": "str"}, - "memory_optimized": {"key": "properties.memoryOptimized", "type": "bool"}, - "is_computed": {"key": "properties.isComputed", "type": "bool"}, - } - - def __init__( - self, - *, - column_type: Optional[Union[str, "_models.ColumnDataType"]] = None, - temporal_type: Optional[Union[str, "_models.TableTemporalType"]] = None, - memory_optimized: Optional[bool] = None, - is_computed: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword column_type: The column data type. Known values are: "image", "text", - "uniqueidentifier", "date", "time", "datetime2", "datetimeoffset", "tinyint", "smallint", - "int", "smalldatetime", "real", "money", "datetime", "float", "sql_variant", "ntext", "bit", - "decimal", "numeric", "smallmoney", "bigint", "hierarchyid", "geometry", "geography", - "varbinary", "varchar", "binary", "char", "timestamp", "nvarchar", "nchar", "xml", "sysname", - and "int". - :paramtype column_type: str or ~azure.mgmt.sql.models.ColumnDataType - :keyword temporal_type: The table temporal type. Known values are: "NonTemporalTable", - "HistoryTable", and "SystemVersionedTemporalTable". - :paramtype temporal_type: str or ~azure.mgmt.sql.models.TableTemporalType - :keyword memory_optimized: Whether or not the column belongs to a memory optimized table. - :paramtype memory_optimized: bool - :keyword is_computed: Whether or not the column is computed. - :paramtype is_computed: bool - """ - super().__init__(**kwargs) - self.column_type = column_type - self.temporal_type = temporal_type - self.memory_optimized = memory_optimized - self.is_computed = is_computed - - -class DatabaseColumnListResult(_serialization.Model): - """A list of database columns. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.DatabaseColumn] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DatabaseColumn]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.DatabaseColumn"]] = None - self.next_link: Optional[str] = None - - -class DatabaseExtensions(ProxyResource): - """An export managed database operation result resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar operation_mode: Operation Mode. "PolybaseImport" - :vartype operation_mode: str or ~azure.mgmt.sql.models.OperationMode - :ivar storage_key_type: Storage key type. Known values are: "SharedAccessKey", - "StorageAccessKey", and "ManagedIdentity". - :vartype storage_key_type: str or ~azure.mgmt.sql.models.StorageKeyType - :ivar storage_key: Storage key. - :vartype storage_key: str - :ivar storage_uri: Storage Uri. - :vartype storage_uri: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "operation_mode": {"key": "properties.operationMode", "type": "str"}, - "storage_key_type": {"key": "properties.storageKeyType", "type": "str"}, - "storage_key": {"key": "properties.storageKey", "type": "str"}, - "storage_uri": {"key": "properties.storageUri", "type": "str"}, - } - - def __init__( - self, - *, - operation_mode: Optional[Union[str, "_models.OperationMode"]] = None, - storage_key_type: Optional[Union[str, "_models.StorageKeyType"]] = None, - storage_key: Optional[str] = None, - storage_uri: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword operation_mode: Operation Mode. "PolybaseImport" - :paramtype operation_mode: str or ~azure.mgmt.sql.models.OperationMode - :keyword storage_key_type: Storage key type. Known values are: "SharedAccessKey", - "StorageAccessKey", and "ManagedIdentity". - :paramtype storage_key_type: str or ~azure.mgmt.sql.models.StorageKeyType - :keyword storage_key: Storage key. - :paramtype storage_key: str - :keyword storage_uri: Storage Uri. - :paramtype storage_uri: str - """ - super().__init__(**kwargs) - self.operation_mode = operation_mode - self.storage_key_type = storage_key_type - self.storage_key = storage_key - self.storage_uri = storage_uri - - -class DatabaseIdentity(_serialization.Model): - """Azure Active Directory identity configuration for a resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The identity type. Known values are: "None" and "UserAssigned". - :vartype type: str or ~azure.mgmt.sql.models.DatabaseIdentityType - :ivar tenant_id: The Azure Active Directory tenant id. - :vartype tenant_id: str - :ivar user_assigned_identities: The resource ids of the user assigned identities to use. - :vartype user_assigned_identities: dict[str, ~azure.mgmt.sql.models.DatabaseUserIdentity] - """ - - _validation = { - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{DatabaseUserIdentity}"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.DatabaseIdentityType"]] = None, - user_assigned_identities: Optional[dict[str, "_models.DatabaseUserIdentity"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: The identity type. Known values are: "None" and "UserAssigned". - :paramtype type: str or ~azure.mgmt.sql.models.DatabaseIdentityType - :keyword user_assigned_identities: The resource ids of the user assigned identities to use. - :paramtype user_assigned_identities: dict[str, ~azure.mgmt.sql.models.DatabaseUserIdentity] - """ - super().__init__(**kwargs) - self.type = type - self.tenant_id: Optional[str] = None - self.user_assigned_identities = user_assigned_identities - - -class DatabaseKey(_serialization.Model): - """Database level key used for encryption at rest. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The database key type. Only supported value is 'AzureKeyVault'. "AzureKeyVault" - :vartype type: str or ~azure.mgmt.sql.models.DatabaseKeyType - :ivar thumbprint: Thumbprint of the database key. - :vartype thumbprint: str - :ivar creation_date: The database key creation date. - :vartype creation_date: ~datetime.datetime - :ivar subregion: Subregion of the server key. - :vartype subregion: str - """ - - _validation = { - "type": {"readonly": True}, - "thumbprint": {"readonly": True}, - "creation_date": {"readonly": True}, - "subregion": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "thumbprint": {"key": "thumbprint", "type": "str"}, - "creation_date": {"key": "creationDate", "type": "iso-8601"}, - "subregion": {"key": "subregion", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: Optional[Union[str, "_models.DatabaseKeyType"]] = None - self.thumbprint: Optional[str] = None - self.creation_date: Optional[datetime.datetime] = None - self.subregion: Optional[str] = None - - -class DatabaseListResult(_serialization.Model): - """A list of databases. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.Database] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Database]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.Database"]] = None - self.next_link: Optional[str] = None - - -class DatabaseOperation(ProxyResource): - """A database operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar database_name: The name of the database the operation is being performed on. - :vartype database_name: str - :ivar operation: The name of operation. - :vartype operation: str - :ivar operation_friendly_name: The friendly name of operation. - :vartype operation_friendly_name: str - :ivar percent_complete: The percentage of the operation completed. - :vartype percent_complete: int - :ivar server_name: The name of the server. - :vartype server_name: str - :ivar start_time: The operation start time. - :vartype start_time: ~datetime.datetime - :ivar state: The operation state. Known values are: "Pending", "InProgress", "Succeeded", - "Failed", "CancelInProgress", and "Cancelled". - :vartype state: str or ~azure.mgmt.sql.models.ManagementOperationState - :ivar error_code: The operation error code. - :vartype error_code: int - :ivar error_description: The operation error description. - :vartype error_description: str - :ivar error_severity: The operation error severity. - :vartype error_severity: int - :ivar is_user_error: Whether or not the error is a user error. - :vartype is_user_error: bool - :ivar estimated_completion_time: The estimated completion time of the operation. - :vartype estimated_completion_time: ~datetime.datetime - :ivar description: The operation description. - :vartype description: str - :ivar is_cancellable: Whether the operation can be cancelled. - :vartype is_cancellable: bool - :ivar operation_phase_details: The operation phase details. - :vartype operation_phase_details: ~azure.mgmt.sql.models.PhaseDetails - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "database_name": {"readonly": True}, - "operation": {"readonly": True}, - "operation_friendly_name": {"readonly": True}, - "percent_complete": {"readonly": True}, - "server_name": {"readonly": True}, - "start_time": {"readonly": True}, - "state": {"readonly": True}, - "error_code": {"readonly": True}, - "error_description": {"readonly": True}, - "error_severity": {"readonly": True}, - "is_user_error": {"readonly": True}, - "estimated_completion_time": {"readonly": True}, - "description": {"readonly": True}, - "is_cancellable": {"readonly": True}, - "operation_phase_details": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "database_name": {"key": "properties.databaseName", "type": "str"}, - "operation": {"key": "properties.operation", "type": "str"}, - "operation_friendly_name": {"key": "properties.operationFriendlyName", "type": "str"}, - "percent_complete": {"key": "properties.percentComplete", "type": "int"}, - "server_name": {"key": "properties.serverName", "type": "str"}, - "start_time": {"key": "properties.startTime", "type": "iso-8601"}, - "state": {"key": "properties.state", "type": "str"}, - "error_code": {"key": "properties.errorCode", "type": "int"}, - "error_description": {"key": "properties.errorDescription", "type": "str"}, - "error_severity": {"key": "properties.errorSeverity", "type": "int"}, - "is_user_error": {"key": "properties.isUserError", "type": "bool"}, - "estimated_completion_time": {"key": "properties.estimatedCompletionTime", "type": "iso-8601"}, - "description": {"key": "properties.description", "type": "str"}, - "is_cancellable": {"key": "properties.isCancellable", "type": "bool"}, - "operation_phase_details": {"key": "properties.operationPhaseDetails", "type": "PhaseDetails"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.database_name: Optional[str] = None - self.operation: Optional[str] = None - self.operation_friendly_name: Optional[str] = None - self.percent_complete: Optional[int] = None - self.server_name: Optional[str] = None - self.start_time: Optional[datetime.datetime] = None - self.state: Optional[Union[str, "_models.ManagementOperationState"]] = None - self.error_code: Optional[int] = None - self.error_description: Optional[str] = None - self.error_severity: Optional[int] = None - self.is_user_error: Optional[bool] = None - self.estimated_completion_time: Optional[datetime.datetime] = None - self.description: Optional[str] = None - self.is_cancellable: Optional[bool] = None - self.operation_phase_details: Optional["_models.PhaseDetails"] = None - - -class DatabaseOperationListResult(_serialization.Model): - """The response to a list database operations request. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.DatabaseOperation] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DatabaseOperation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.DatabaseOperation"]] = None - self.next_link: Optional[str] = None - - -class DatabaseSchema(ProxyResource): - """A database schema resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - -class DatabaseSchemaListResult(_serialization.Model): - """A list of database schemas. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.DatabaseSchema] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DatabaseSchema]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.DatabaseSchema"]] = None - self.next_link: Optional[str] = None - - -class DatabaseSecurityAlertListResult(_serialization.Model): - """A list of the database's security alert policies. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.DatabaseSecurityAlertPolicy] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DatabaseSecurityAlertPolicy]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.DatabaseSecurityAlertPolicy"]] = None - self.next_link: Optional[str] = None - - -class DatabaseSecurityAlertPolicy(ProxyResource): - """A database security alert policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: SystemData of SecurityAlertPolicyResource. - :vartype system_data: ~azure.mgmt.sql.models.SystemData - :ivar state: Specifies the state of the policy, whether it is enabled or disabled or a policy - has not been applied yet on the specific database. Known values are: "Enabled" and "Disabled". - :vartype state: str or ~azure.mgmt.sql.models.SecurityAlertsPolicyState - :ivar disabled_alerts: Specifies an array of alerts that are disabled. Allowed values are: - Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, Unsafe_Action, - Brute_Force. - :vartype disabled_alerts: list[str] - :ivar email_addresses: Specifies an array of e-mail addresses to which the alert is sent. - :vartype email_addresses: list[str] - :ivar email_account_admins: Specifies that the alert is sent to the account administrators. - :vartype email_account_admins: bool - :ivar storage_endpoint: Specifies the blob storage endpoint (e.g. - https://MyAccount.blob.core.windows.net). This blob storage will hold all Threat Detection - audit logs. - :vartype storage_endpoint: str - :ivar storage_account_access_key: Specifies the identifier key of the Threat Detection audit - storage account. - :vartype storage_account_access_key: str - :ivar retention_days: Specifies the number of days to keep in the Threat Detection audit logs. - :vartype retention_days: int - :ivar creation_time: Specifies the UTC creation time of the policy. - :vartype creation_time: ~datetime.datetime - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "creation_time": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "state": {"key": "properties.state", "type": "str"}, - "disabled_alerts": {"key": "properties.disabledAlerts", "type": "[str]"}, - "email_addresses": {"key": "properties.emailAddresses", "type": "[str]"}, - "email_account_admins": {"key": "properties.emailAccountAdmins", "type": "bool"}, - "storage_endpoint": {"key": "properties.storageEndpoint", "type": "str"}, - "storage_account_access_key": {"key": "properties.storageAccountAccessKey", "type": "str"}, - "retention_days": {"key": "properties.retentionDays", "type": "int"}, - "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, - } - - def __init__( - self, - *, - state: Optional[Union[str, "_models.SecurityAlertsPolicyState"]] = None, - disabled_alerts: Optional[list[str]] = None, - email_addresses: Optional[list[str]] = None, - email_account_admins: Optional[bool] = None, - storage_endpoint: Optional[str] = None, - storage_account_access_key: Optional[str] = None, - retention_days: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword state: Specifies the state of the policy, whether it is enabled or disabled or a - policy has not been applied yet on the specific database. Known values are: "Enabled" and - "Disabled". - :paramtype state: str or ~azure.mgmt.sql.models.SecurityAlertsPolicyState - :keyword disabled_alerts: Specifies an array of alerts that are disabled. Allowed values are: - Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, Unsafe_Action, - Brute_Force. - :paramtype disabled_alerts: list[str] - :keyword email_addresses: Specifies an array of e-mail addresses to which the alert is sent. - :paramtype email_addresses: list[str] - :keyword email_account_admins: Specifies that the alert is sent to the account administrators. - :paramtype email_account_admins: bool - :keyword storage_endpoint: Specifies the blob storage endpoint (e.g. - https://MyAccount.blob.core.windows.net). This blob storage will hold all Threat Detection - audit logs. - :paramtype storage_endpoint: str - :keyword storage_account_access_key: Specifies the identifier key of the Threat Detection audit - storage account. - :paramtype storage_account_access_key: str - :keyword retention_days: Specifies the number of days to keep in the Threat Detection audit - logs. - :paramtype retention_days: int - """ - super().__init__(**kwargs) - self.system_data: Optional["_models.SystemData"] = None - self.state = state - self.disabled_alerts = disabled_alerts - self.email_addresses = email_addresses - self.email_account_admins = email_account_admins - self.storage_endpoint = storage_endpoint - self.storage_account_access_key = storage_account_access_key - self.retention_days = retention_days - self.creation_time: Optional[datetime.datetime] = None - - -class DatabaseSqlVulnerabilityAssessmentBaselineSet(ProxyResource): # pylint: disable=name-too-long - """A database sql vulnerability assessment baseline set. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: SystemData of DatabaseSqlVulnerabilityAssessmentBaselineSetResource. - :vartype system_data: ~azure.mgmt.sql.models.SystemData - :ivar results: The baseline set result. - :vartype results: dict[str, list[list[str]]] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "results": {"key": "properties.results", "type": "{[[str]]}"}, - } - - def __init__(self, *, results: Optional[dict[str, list[list[str]]]] = None, **kwargs: Any) -> None: - """ - :keyword results: The baseline set result. - :paramtype results: dict[str, list[list[str]]] - """ - super().__init__(**kwargs) - self.system_data: Optional["_models.SystemData"] = None - self.results = results - - -class DatabaseSqlVulnerabilityAssessmentBaselineSetListResult(_serialization.Model): # pylint: disable=name-too-long - """A list of SQL Vulnerability Assessments baseline set. - - 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.DatabaseSqlVulnerabilityAssessmentBaselineSet] - :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": "[DatabaseSqlVulnerabilityAssessmentBaselineSet]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.DatabaseSqlVulnerabilityAssessmentBaselineSet"]] = None - self.next_link: Optional[str] = None - - -class DatabaseSqlVulnerabilityAssessmentRuleBaseline(ProxyResource): # pylint: disable=name-too-long - """A database sql 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 system_data: SystemData of DatabaseSqlVulnerabilityAssessmentRuleBaselineResource. - :vartype system_data: ~azure.mgmt.sql.models.SystemData - :ivar results: The rule baseline result. - :vartype results: list[list[str]] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "results": {"key": "properties.results", "type": "[[str]]"}, - } - - def __init__(self, *, results: Optional[list[list[str]]] = None, **kwargs: Any) -> None: - """ - :keyword results: The rule baseline result. - :paramtype results: list[list[str]] - """ - super().__init__(**kwargs) - self.system_data: Optional["_models.SystemData"] = None - self.results = results - - -class DatabaseSqlVulnerabilityAssessmentRuleBaselineInput(ProxyResource): # pylint: disable=name-too-long - """A database sql vulnerability assessment rule baseline input. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: SystemData of DatabaseSqlVulnerabilityAssessmentRuleBaselineInputResource. - :vartype system_data: ~azure.mgmt.sql.models.SystemData - :ivar latest_scan: The latest scan flag. - :vartype latest_scan: bool - :ivar results: The rule baseline result. - :vartype results: list[list[str]] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "latest_scan": {"key": "properties.latestScan", "type": "bool"}, - "results": {"key": "properties.results", "type": "[[str]]"}, - } - - def __init__( - self, *, latest_scan: Optional[bool] = None, results: Optional[list[list[str]]] = None, **kwargs: Any - ) -> None: - """ - :keyword latest_scan: The latest scan flag. - :paramtype latest_scan: bool - :keyword results: The rule baseline result. - :paramtype results: list[list[str]] - """ - super().__init__(**kwargs) - self.system_data: Optional["_models.SystemData"] = None - self.latest_scan = latest_scan - self.results = results - - -class DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput(ProxyResource): # pylint: disable=name-too-long - """A database sql vulnerability assessment rule baseline list input. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: SystemData of - DatabaseSqlVulnerabilityAssessmentRuleBaselineListInputResource. - :vartype system_data: ~azure.mgmt.sql.models.SystemData - :ivar latest_scan: The latest scan flag. - :vartype latest_scan: bool - :ivar results: The rule baseline result list. - :vartype results: dict[str, list[list[str]]] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "latest_scan": {"key": "properties.latestScan", "type": "bool"}, - "results": {"key": "properties.results", "type": "{[[str]]}"}, - } - - def __init__( - self, *, latest_scan: Optional[bool] = None, results: Optional[dict[str, list[list[str]]]] = None, **kwargs: Any - ) -> None: - """ - :keyword latest_scan: The latest scan flag. - :paramtype latest_scan: bool - :keyword results: The rule baseline result list. - :paramtype results: dict[str, list[list[str]]] - """ - super().__init__(**kwargs) - self.system_data: Optional["_models.SystemData"] = None - self.latest_scan = latest_scan - self.results = results - - -class DatabaseSqlVulnerabilityAssessmentRuleBaselineListResult(_serialization.Model): # pylint: disable=name-too-long - """A list of SQL Vulnerability Assessments rule baseline. - - 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.DatabaseSqlVulnerabilityAssessmentRuleBaseline] - :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": "[DatabaseSqlVulnerabilityAssessmentRuleBaseline]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline"]] = None - self.next_link: Optional[str] = None - - -class DatabaseTable(ProxyResource): - """A database table resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar temporal_type: The table temporal type. Known values are: "NonTemporalTable", - "HistoryTable", and "SystemVersionedTemporalTable". - :vartype temporal_type: str or ~azure.mgmt.sql.models.TableTemporalType - :ivar memory_optimized: Whether or not the table is memory optimized. - :vartype memory_optimized: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "temporal_type": {"key": "properties.temporalType", "type": "str"}, - "memory_optimized": {"key": "properties.memoryOptimized", "type": "bool"}, - } - - def __init__( - self, - *, - temporal_type: Optional[Union[str, "_models.TableTemporalType"]] = None, - memory_optimized: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword temporal_type: The table temporal type. Known values are: "NonTemporalTable", - "HistoryTable", and "SystemVersionedTemporalTable". - :paramtype temporal_type: str or ~azure.mgmt.sql.models.TableTemporalType - :keyword memory_optimized: Whether or not the table is memory optimized. - :paramtype memory_optimized: bool - """ - super().__init__(**kwargs) - self.temporal_type = temporal_type - self.memory_optimized = memory_optimized - - -class DatabaseTableListResult(_serialization.Model): - """A list of database tables. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.DatabaseTable] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DatabaseTable]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.DatabaseTable"]] = None - self.next_link: Optional[str] = None - - -class DatabaseUpdate(_serialization.Model): - """A database update resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar sku: The name and tier of the SKU. - :vartype sku: ~azure.mgmt.sql.models.Sku - :ivar identity: Database identity. - :vartype identity: ~azure.mgmt.sql.models.DatabaseIdentity - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar create_mode: Specifies the mode of database creation. - - Default: regular database creation. - - Copy: creates a database as a copy of an existing database. sourceDatabaseId must be specified - as the resource ID of the source database. - - Secondary: creates a database as a secondary replica of an existing database. sourceDatabaseId - must be specified as the resource ID of the existing primary database. - - PointInTimeRestore: Creates a database by restoring a point in time backup of an existing - database. sourceDatabaseId must be specified as the resource ID of the existing database, and - restorePointInTime must be specified. - - Recovery: Creates a database by restoring a geo-replicated backup. sourceDatabaseId must be - specified as the recoverable database resource ID to restore. - - Restore: Creates a database by restoring a backup of a deleted database. sourceDatabaseId must - be specified. If sourceDatabaseId is the database's original resource ID, then - sourceDatabaseDeletionDate must be specified. Otherwise sourceDatabaseId must be the restorable - dropped database resource ID and sourceDatabaseDeletionDate is ignored. restorePointInTime may - also be specified to restore from an earlier point in time. - - RestoreLongTermRetentionBackup: Creates a database by restoring from a long term retention - vault. recoveryServicesRecoveryPointResourceId must be specified as the recovery point resource - ID. - - Copy, Secondary, and RestoreLongTermRetentionBackup are not supported for DataWarehouse - edition. Known values are: "Default", "Copy", "Secondary", "PointInTimeRestore", "Restore", - "Recovery", "RestoreExternalBackup", "RestoreExternalBackupSecondary", - "RestoreLongTermRetentionBackup", and "OnlineSecondary". - :vartype create_mode: str or ~azure.mgmt.sql.models.CreateMode - :ivar collation: The collation of the database. - :vartype collation: str - :ivar max_size_bytes: The max size of the database expressed in bytes. - :vartype max_size_bytes: int - :ivar sample_name: The name of the sample schema to apply when creating this database. Known - values are: "AdventureWorksLT", "WideWorldImportersStd", and "WideWorldImportersFull". - :vartype sample_name: str or ~azure.mgmt.sql.models.SampleName - :ivar elastic_pool_id: The resource identifier of the elastic pool containing this database. - :vartype elastic_pool_id: str - :ivar source_database_id: The resource identifier of the source database associated with create - operation of this database. - :vartype source_database_id: str - :ivar status: The status of the database. Known values are: "Online", "Restoring", - "RecoveryPending", "Recovering", "Suspect", "Offline", "Standby", "Shutdown", "EmergencyMode", - "AutoClosed", "Copying", "Creating", "Inaccessible", "OfflineSecondary", "Pausing", "Paused", - "Resuming", "Scaling", "OfflineChangingDwPerformanceTiers", "OnlineChangingDwPerformanceTiers", - "Disabled", "Stopping", "Stopped", and "Starting". - :vartype status: str or ~azure.mgmt.sql.models.DatabaseStatus - :ivar database_id: The ID of the database. - :vartype database_id: str - :ivar creation_date: The creation date of the database (ISO8601 format). - :vartype creation_date: ~datetime.datetime - :ivar current_service_objective_name: The current service level objective name of the database. - :vartype current_service_objective_name: str - :ivar requested_service_objective_name: The requested service level objective name of the - database. - :vartype requested_service_objective_name: str - :ivar default_secondary_location: The default secondary region for this database. - :vartype default_secondary_location: str - :ivar failover_group_id: Failover Group resource identifier that this database belongs to. - :vartype failover_group_id: str - :ivar restore_point_in_time: Specifies the point in time (ISO8601 format) of the source - database that will be restored to create the new database. - :vartype restore_point_in_time: ~datetime.datetime - :ivar source_database_deletion_date: Specifies the time that the database was deleted. - :vartype source_database_deletion_date: ~datetime.datetime - :ivar recovery_services_recovery_point_id: The resource identifier of the recovery point - associated with create operation of this database. - :vartype recovery_services_recovery_point_id: str - :ivar long_term_retention_backup_resource_id: The resource identifier of the long term - retention backup associated with create operation of this database. - :vartype long_term_retention_backup_resource_id: str - :ivar recoverable_database_id: The resource identifier of the recoverable database associated - with create operation of this database. - :vartype recoverable_database_id: str - :ivar restorable_dropped_database_id: The resource identifier of the restorable dropped - database associated with create operation of this database. - :vartype restorable_dropped_database_id: str - :ivar catalog_collation: Collation of the metadata catalog. Known values are: - "DATABASE_DEFAULT" and "SQL_Latin1_General_CP1_CI_AS". - :vartype catalog_collation: str or ~azure.mgmt.sql.models.CatalogCollationType - :ivar zone_redundant: Whether or not this database is zone redundant, which means the replicas - of this database will be spread across multiple availability zones. - :vartype zone_redundant: bool - :ivar license_type: The license type to apply for this database. ``LicenseIncluded`` if you - need a license, or ``BasePrice`` if you have a license and are eligible for the Azure Hybrid - Benefit. Known values are: "LicenseIncluded" and "BasePrice". - :vartype license_type: str or ~azure.mgmt.sql.models.DatabaseLicenseType - :ivar max_log_size_bytes: The max log size for this database. - :vartype max_log_size_bytes: int - :ivar earliest_restore_date: This records the earliest start date and time that restore is - available for this database (ISO8601 format). - :vartype earliest_restore_date: ~datetime.datetime - :ivar read_scale: The state of read-only routing. If enabled, connections that have application - intent set to readonly in their connection string may be routed to a readonly secondary replica - in the same region. Not applicable to a Hyperscale database within an elastic pool. Known - values are: "Enabled" and "Disabled". - :vartype read_scale: str or ~azure.mgmt.sql.models.DatabaseReadScale - :ivar high_availability_replica_count: The number of secondary replicas associated with the - database that are used to provide high availability. Not applicable to a Hyperscale database - within an elastic pool. - :vartype high_availability_replica_count: int - :ivar secondary_type: The secondary type of the database if it is a secondary. Valid values - are Geo, Named and Standby. Known values are: "Geo", "Named", and "Standby". - :vartype secondary_type: str or ~azure.mgmt.sql.models.SecondaryType - :ivar current_sku: The name and tier of the SKU. - :vartype current_sku: ~azure.mgmt.sql.models.Sku - :ivar auto_pause_delay: Time in minutes after which database is automatically paused. A value - of -1 means that automatic pause is disabled. - :vartype auto_pause_delay: int - :ivar current_backup_storage_redundancy: The storage account type used to store backups for - this database. Known values are: "Geo", "Local", "Zone", and "GeoZone". - :vartype current_backup_storage_redundancy: str or - ~azure.mgmt.sql.models.BackupStorageRedundancy - :ivar requested_backup_storage_redundancy: The storage account type to be used to store backups - for this database. Known values are: "Geo", "Local", "Zone", and "GeoZone". - :vartype requested_backup_storage_redundancy: str or - ~azure.mgmt.sql.models.BackupStorageRedundancy - :ivar min_capacity: Minimal capacity that database will always have allocated, if not paused. - :vartype min_capacity: float - :ivar paused_date: The date when database was paused by user configuration or action(ISO8601 - format). Null if the database is ready. - :vartype paused_date: ~datetime.datetime - :ivar resumed_date: The date when database was resumed by user action or database login - (ISO8601 format). Null if the database is paused. - :vartype resumed_date: ~datetime.datetime - :ivar maintenance_configuration_id: Maintenance configuration id assigned to the database. This - configuration defines the period when the maintenance updates will occur. - :vartype maintenance_configuration_id: str - :ivar is_ledger_on: Whether or not this database is a ledger database, which means all tables - in the database are ledger tables. Note: the value of this property cannot be changed after the - database has been created. - :vartype is_ledger_on: bool - :ivar is_infra_encryption_enabled: Infra encryption is enabled for this database. - :vartype is_infra_encryption_enabled: bool - :ivar federated_client_id: The Client id used for cross tenant per database CMK scenario. - :vartype federated_client_id: str - :ivar keys: The resource ids of the user assigned identities to use. - :vartype keys: dict[str, ~azure.mgmt.sql.models.DatabaseKey] - :ivar encryption_protector: The azure key vault URI of the database if it's configured with per - Database Customer Managed Keys. - :vartype encryption_protector: str - :ivar preferred_enclave_type: Type of enclave requested on the database i.e. Default or VBS - enclaves. Known values are: "Default" and "VBS". - :vartype preferred_enclave_type: str or ~azure.mgmt.sql.models.AlwaysEncryptedEnclaveType - :ivar use_free_limit: Whether or not the database uses free monthly limits. Allowed on one - database in a subscription. - :vartype use_free_limit: bool - :ivar free_limit_exhaustion_behavior: Specifies the behavior when monthly free limits are - exhausted for the free database. - - AutoPause: The database will be auto paused upon exhaustion of free limits for remainder of the - month. - - BillForUsage: The database will continue to be online upon exhaustion of free limits and any - overage will be billed. Known values are: "AutoPause" and "BillOverUsage". - :vartype free_limit_exhaustion_behavior: str or - ~azure.mgmt.sql.models.FreeLimitExhaustionBehavior - :ivar manual_cutover: Whether or not customer controlled manual cutover needs to be done during - Update Database operation to Hyperscale tier. - - This property is only applicable when scaling database from Business Critical/General - Purpose/Premium/Standard tier to Hyperscale tier. - - When manualCutover is specified, the scaling operation will wait for user input to trigger - cutover to Hyperscale database. - - To trigger cutover, please provide 'performCutover' parameter when the Scaling operation is in - Waiting state. - :vartype manual_cutover: bool - :ivar perform_cutover: To trigger customer controlled manual cutover during the wait state - while Scaling operation is in progress. - - This property parameter is only applicable for scaling operations that are initiated along with - 'manualCutover' parameter. - - This property is only applicable when scaling database from Business Critical/General - Purpose/Premium/Standard tier to Hyperscale tier is already in progress. - - When performCutover is specified, the scaling operation will trigger cutover and perform - role-change to Hyperscale database. - :vartype perform_cutover: bool - :ivar encryption_protector_auto_rotation: The flag to enable or disable auto rotation of - database encryption protector AKV key. - :vartype encryption_protector_auto_rotation: bool - """ - - _validation = { - "status": {"readonly": True}, - "database_id": {"readonly": True}, - "creation_date": {"readonly": True}, - "current_service_objective_name": {"readonly": True}, - "requested_service_objective_name": {"readonly": True}, - "default_secondary_location": {"readonly": True}, - "failover_group_id": {"readonly": True}, - "max_log_size_bytes": {"readonly": True}, - "earliest_restore_date": {"readonly": True}, - "current_sku": {"readonly": True}, - "current_backup_storage_redundancy": {"readonly": True}, - "paused_date": {"readonly": True}, - "resumed_date": {"readonly": True}, - "is_infra_encryption_enabled": {"readonly": True}, - } - - _attribute_map = { - "sku": {"key": "sku", "type": "Sku"}, - "identity": {"key": "identity", "type": "DatabaseIdentity"}, - "tags": {"key": "tags", "type": "{str}"}, - "create_mode": {"key": "properties.createMode", "type": "str"}, - "collation": {"key": "properties.collation", "type": "str"}, - "max_size_bytes": {"key": "properties.maxSizeBytes", "type": "int"}, - "sample_name": {"key": "properties.sampleName", "type": "str"}, - "elastic_pool_id": {"key": "properties.elasticPoolId", "type": "str"}, - "source_database_id": {"key": "properties.sourceDatabaseId", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "database_id": {"key": "properties.databaseId", "type": "str"}, - "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, - "current_service_objective_name": {"key": "properties.currentServiceObjectiveName", "type": "str"}, - "requested_service_objective_name": {"key": "properties.requestedServiceObjectiveName", "type": "str"}, - "default_secondary_location": {"key": "properties.defaultSecondaryLocation", "type": "str"}, - "failover_group_id": {"key": "properties.failoverGroupId", "type": "str"}, - "restore_point_in_time": {"key": "properties.restorePointInTime", "type": "iso-8601"}, - "source_database_deletion_date": {"key": "properties.sourceDatabaseDeletionDate", "type": "iso-8601"}, - "recovery_services_recovery_point_id": {"key": "properties.recoveryServicesRecoveryPointId", "type": "str"}, - "long_term_retention_backup_resource_id": { - "key": "properties.longTermRetentionBackupResourceId", - "type": "str", - }, - "recoverable_database_id": {"key": "properties.recoverableDatabaseId", "type": "str"}, - "restorable_dropped_database_id": {"key": "properties.restorableDroppedDatabaseId", "type": "str"}, - "catalog_collation": {"key": "properties.catalogCollation", "type": "str"}, - "zone_redundant": {"key": "properties.zoneRedundant", "type": "bool"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - "max_log_size_bytes": {"key": "properties.maxLogSizeBytes", "type": "int"}, - "earliest_restore_date": {"key": "properties.earliestRestoreDate", "type": "iso-8601"}, - "read_scale": {"key": "properties.readScale", "type": "str"}, - "high_availability_replica_count": {"key": "properties.highAvailabilityReplicaCount", "type": "int"}, - "secondary_type": {"key": "properties.secondaryType", "type": "str"}, - "current_sku": {"key": "properties.currentSku", "type": "Sku"}, - "auto_pause_delay": {"key": "properties.autoPauseDelay", "type": "int"}, - "current_backup_storage_redundancy": {"key": "properties.currentBackupStorageRedundancy", "type": "str"}, - "requested_backup_storage_redundancy": {"key": "properties.requestedBackupStorageRedundancy", "type": "str"}, - "min_capacity": {"key": "properties.minCapacity", "type": "float"}, - "paused_date": {"key": "properties.pausedDate", "type": "iso-8601"}, - "resumed_date": {"key": "properties.resumedDate", "type": "iso-8601"}, - "maintenance_configuration_id": {"key": "properties.maintenanceConfigurationId", "type": "str"}, - "is_ledger_on": {"key": "properties.isLedgerOn", "type": "bool"}, - "is_infra_encryption_enabled": {"key": "properties.isInfraEncryptionEnabled", "type": "bool"}, - "federated_client_id": {"key": "properties.federatedClientId", "type": "str"}, - "keys": {"key": "properties.keys", "type": "{DatabaseKey}"}, - "encryption_protector": {"key": "properties.encryptionProtector", "type": "str"}, - "preferred_enclave_type": {"key": "properties.preferredEnclaveType", "type": "str"}, - "use_free_limit": {"key": "properties.useFreeLimit", "type": "bool"}, - "free_limit_exhaustion_behavior": {"key": "properties.freeLimitExhaustionBehavior", "type": "str"}, - "manual_cutover": {"key": "properties.manualCutover", "type": "bool"}, - "perform_cutover": {"key": "properties.performCutover", "type": "bool"}, - "encryption_protector_auto_rotation": {"key": "properties.encryptionProtectorAutoRotation", "type": "bool"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - sku: Optional["_models.Sku"] = None, - identity: Optional["_models.DatabaseIdentity"] = None, - tags: Optional[dict[str, str]] = None, - create_mode: Optional[Union[str, "_models.CreateMode"]] = None, - collation: Optional[str] = None, - max_size_bytes: Optional[int] = None, - sample_name: Optional[Union[str, "_models.SampleName"]] = None, - elastic_pool_id: Optional[str] = None, - source_database_id: Optional[str] = None, - restore_point_in_time: Optional[datetime.datetime] = None, - source_database_deletion_date: Optional[datetime.datetime] = None, - recovery_services_recovery_point_id: Optional[str] = None, - long_term_retention_backup_resource_id: Optional[str] = None, - recoverable_database_id: Optional[str] = None, - restorable_dropped_database_id: Optional[str] = None, - catalog_collation: Optional[Union[str, "_models.CatalogCollationType"]] = None, - zone_redundant: Optional[bool] = None, - license_type: Optional[Union[str, "_models.DatabaseLicenseType"]] = None, - read_scale: Optional[Union[str, "_models.DatabaseReadScale"]] = None, - high_availability_replica_count: Optional[int] = None, - secondary_type: Optional[Union[str, "_models.SecondaryType"]] = None, - auto_pause_delay: Optional[int] = None, - requested_backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = None, - min_capacity: Optional[float] = None, - maintenance_configuration_id: Optional[str] = None, - is_ledger_on: Optional[bool] = None, - federated_client_id: Optional[str] = None, - keys: Optional[dict[str, "_models.DatabaseKey"]] = None, - encryption_protector: Optional[str] = None, - preferred_enclave_type: Optional[Union[str, "_models.AlwaysEncryptedEnclaveType"]] = None, - use_free_limit: Optional[bool] = None, - free_limit_exhaustion_behavior: Optional[Union[str, "_models.FreeLimitExhaustionBehavior"]] = None, - manual_cutover: Optional[bool] = None, - perform_cutover: Optional[bool] = None, - encryption_protector_auto_rotation: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword sku: The name and tier of the SKU. - :paramtype sku: ~azure.mgmt.sql.models.Sku - :keyword identity: Database identity. - :paramtype identity: ~azure.mgmt.sql.models.DatabaseIdentity - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword create_mode: Specifies the mode of database creation. - - Default: regular database creation. - - Copy: creates a database as a copy of an existing database. sourceDatabaseId must be specified - as the resource ID of the source database. - - Secondary: creates a database as a secondary replica of an existing database. sourceDatabaseId - must be specified as the resource ID of the existing primary database. - - PointInTimeRestore: Creates a database by restoring a point in time backup of an existing - database. sourceDatabaseId must be specified as the resource ID of the existing database, and - restorePointInTime must be specified. - - Recovery: Creates a database by restoring a geo-replicated backup. sourceDatabaseId must be - specified as the recoverable database resource ID to restore. - - Restore: Creates a database by restoring a backup of a deleted database. sourceDatabaseId must - be specified. If sourceDatabaseId is the database's original resource ID, then - sourceDatabaseDeletionDate must be specified. Otherwise sourceDatabaseId must be the restorable - dropped database resource ID and sourceDatabaseDeletionDate is ignored. restorePointInTime may - also be specified to restore from an earlier point in time. - - RestoreLongTermRetentionBackup: Creates a database by restoring from a long term retention - vault. recoveryServicesRecoveryPointResourceId must be specified as the recovery point resource - ID. - - Copy, Secondary, and RestoreLongTermRetentionBackup are not supported for DataWarehouse - edition. Known values are: "Default", "Copy", "Secondary", "PointInTimeRestore", "Restore", - "Recovery", "RestoreExternalBackup", "RestoreExternalBackupSecondary", - "RestoreLongTermRetentionBackup", and "OnlineSecondary". - :paramtype create_mode: str or ~azure.mgmt.sql.models.CreateMode - :keyword collation: The collation of the database. - :paramtype collation: str - :keyword max_size_bytes: The max size of the database expressed in bytes. - :paramtype max_size_bytes: int - :keyword sample_name: The name of the sample schema to apply when creating this database. Known - values are: "AdventureWorksLT", "WideWorldImportersStd", and "WideWorldImportersFull". - :paramtype sample_name: str or ~azure.mgmt.sql.models.SampleName - :keyword elastic_pool_id: The resource identifier of the elastic pool containing this database. - :paramtype elastic_pool_id: str - :keyword source_database_id: The resource identifier of the source database associated with - create operation of this database. - :paramtype source_database_id: str - :keyword restore_point_in_time: Specifies the point in time (ISO8601 format) of the source - database that will be restored to create the new database. - :paramtype restore_point_in_time: ~datetime.datetime - :keyword source_database_deletion_date: Specifies the time that the database was deleted. - :paramtype source_database_deletion_date: ~datetime.datetime - :keyword recovery_services_recovery_point_id: The resource identifier of the recovery point - associated with create operation of this database. - :paramtype recovery_services_recovery_point_id: str - :keyword long_term_retention_backup_resource_id: The resource identifier of the long term - retention backup associated with create operation of this database. - :paramtype long_term_retention_backup_resource_id: str - :keyword recoverable_database_id: The resource identifier of the recoverable database - associated with create operation of this database. - :paramtype recoverable_database_id: str - :keyword restorable_dropped_database_id: The resource identifier of the restorable dropped - database associated with create operation of this database. - :paramtype restorable_dropped_database_id: str - :keyword catalog_collation: Collation of the metadata catalog. Known values are: - "DATABASE_DEFAULT" and "SQL_Latin1_General_CP1_CI_AS". - :paramtype catalog_collation: str or ~azure.mgmt.sql.models.CatalogCollationType - :keyword zone_redundant: Whether or not this database is zone redundant, which means the - replicas of this database will be spread across multiple availability zones. - :paramtype zone_redundant: bool - :keyword license_type: The license type to apply for this database. ``LicenseIncluded`` if you - need a license, or ``BasePrice`` if you have a license and are eligible for the Azure Hybrid - Benefit. Known values are: "LicenseIncluded" and "BasePrice". - :paramtype license_type: str or ~azure.mgmt.sql.models.DatabaseLicenseType - :keyword read_scale: The state of read-only routing. If enabled, connections that have - application intent set to readonly in their connection string may be routed to a readonly - secondary replica in the same region. Not applicable to a Hyperscale database within an elastic - pool. Known values are: "Enabled" and "Disabled". - :paramtype read_scale: str or ~azure.mgmt.sql.models.DatabaseReadScale - :keyword high_availability_replica_count: The number of secondary replicas associated with the - database that are used to provide high availability. Not applicable to a Hyperscale database - within an elastic pool. - :paramtype high_availability_replica_count: int - :keyword secondary_type: The secondary type of the database if it is a secondary. Valid values - are Geo, Named and Standby. Known values are: "Geo", "Named", and "Standby". - :paramtype secondary_type: str or ~azure.mgmt.sql.models.SecondaryType - :keyword auto_pause_delay: Time in minutes after which database is automatically paused. A - value of -1 means that automatic pause is disabled. - :paramtype auto_pause_delay: int - :keyword requested_backup_storage_redundancy: The storage account type to be used to store - backups for this database. Known values are: "Geo", "Local", "Zone", and "GeoZone". - :paramtype requested_backup_storage_redundancy: str or - ~azure.mgmt.sql.models.BackupStorageRedundancy - :keyword min_capacity: Minimal capacity that database will always have allocated, if not - paused. - :paramtype min_capacity: float - :keyword maintenance_configuration_id: Maintenance configuration id assigned to the database. - This configuration defines the period when the maintenance updates will occur. - :paramtype maintenance_configuration_id: str - :keyword is_ledger_on: Whether or not this database is a ledger database, which means all - tables in the database are ledger tables. Note: the value of this property cannot be changed - after the database has been created. - :paramtype is_ledger_on: bool - :keyword federated_client_id: The Client id used for cross tenant per database CMK scenario. - :paramtype federated_client_id: str - :keyword keys: The resource ids of the user assigned identities to use. - :paramtype keys: dict[str, ~azure.mgmt.sql.models.DatabaseKey] - :keyword encryption_protector: The azure key vault URI of the database if it's configured with - per Database Customer Managed Keys. - :paramtype encryption_protector: str - :keyword preferred_enclave_type: Type of enclave requested on the database i.e. Default or VBS - enclaves. Known values are: "Default" and "VBS". - :paramtype preferred_enclave_type: str or ~azure.mgmt.sql.models.AlwaysEncryptedEnclaveType - :keyword use_free_limit: Whether or not the database uses free monthly limits. Allowed on one - database in a subscription. - :paramtype use_free_limit: bool - :keyword free_limit_exhaustion_behavior: Specifies the behavior when monthly free limits are - exhausted for the free database. - - AutoPause: The database will be auto paused upon exhaustion of free limits for remainder of the - month. - - BillForUsage: The database will continue to be online upon exhaustion of free limits and any - overage will be billed. Known values are: "AutoPause" and "BillOverUsage". - :paramtype free_limit_exhaustion_behavior: str or - ~azure.mgmt.sql.models.FreeLimitExhaustionBehavior - :keyword manual_cutover: Whether or not customer controlled manual cutover needs to be done - during Update Database operation to Hyperscale tier. - - This property is only applicable when scaling database from Business Critical/General - Purpose/Premium/Standard tier to Hyperscale tier. - - When manualCutover is specified, the scaling operation will wait for user input to trigger - cutover to Hyperscale database. - - To trigger cutover, please provide 'performCutover' parameter when the Scaling operation is in - Waiting state. - :paramtype manual_cutover: bool - :keyword perform_cutover: To trigger customer controlled manual cutover during the wait state - while Scaling operation is in progress. - - This property parameter is only applicable for scaling operations that are initiated along with - 'manualCutover' parameter. - - This property is only applicable when scaling database from Business Critical/General - Purpose/Premium/Standard tier to Hyperscale tier is already in progress. - - When performCutover is specified, the scaling operation will trigger cutover and perform - role-change to Hyperscale database. - :paramtype perform_cutover: bool - :keyword encryption_protector_auto_rotation: The flag to enable or disable auto rotation of - database encryption protector AKV key. - :paramtype encryption_protector_auto_rotation: bool - """ - super().__init__(**kwargs) - self.sku = sku - self.identity = identity - self.tags = tags - self.create_mode = create_mode - self.collation = collation - self.max_size_bytes = max_size_bytes - self.sample_name = sample_name - self.elastic_pool_id = elastic_pool_id - self.source_database_id = source_database_id - self.status: Optional[Union[str, "_models.DatabaseStatus"]] = None - self.database_id: Optional[str] = None - self.creation_date: Optional[datetime.datetime] = None - self.current_service_objective_name: Optional[str] = None - self.requested_service_objective_name: Optional[str] = None - self.default_secondary_location: Optional[str] = None - self.failover_group_id: Optional[str] = None - self.restore_point_in_time = restore_point_in_time - self.source_database_deletion_date = source_database_deletion_date - self.recovery_services_recovery_point_id = recovery_services_recovery_point_id - self.long_term_retention_backup_resource_id = long_term_retention_backup_resource_id - self.recoverable_database_id = recoverable_database_id - self.restorable_dropped_database_id = restorable_dropped_database_id - self.catalog_collation = catalog_collation - self.zone_redundant = zone_redundant - self.license_type = license_type - self.max_log_size_bytes: Optional[int] = None - self.earliest_restore_date: Optional[datetime.datetime] = None - self.read_scale = read_scale - self.high_availability_replica_count = high_availability_replica_count - self.secondary_type = secondary_type - self.current_sku: Optional["_models.Sku"] = None - self.auto_pause_delay = auto_pause_delay - self.current_backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = None - self.requested_backup_storage_redundancy = requested_backup_storage_redundancy - self.min_capacity = min_capacity - self.paused_date: Optional[datetime.datetime] = None - self.resumed_date: Optional[datetime.datetime] = None - self.maintenance_configuration_id = maintenance_configuration_id - self.is_ledger_on = is_ledger_on - self.is_infra_encryption_enabled: Optional[bool] = None - self.federated_client_id = federated_client_id - self.keys = keys - self.encryption_protector = encryption_protector - self.preferred_enclave_type = preferred_enclave_type - self.use_free_limit = use_free_limit - self.free_limit_exhaustion_behavior = free_limit_exhaustion_behavior - self.manual_cutover = manual_cutover - self.perform_cutover = perform_cutover - self.encryption_protector_auto_rotation = encryption_protector_auto_rotation - - -class DatabaseUsage(ProxyResource): - """Usage metric of a database. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar display_name: User-readable name of the metric. - :vartype display_name: str - :ivar current_value: Current value of the metric. - :vartype current_value: float - :ivar limit: Boundary value of the metric. - :vartype limit: float - :ivar unit: Unit of the metric. - :vartype unit: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "display_name": {"readonly": True}, - "current_value": {"readonly": True}, - "limit": {"readonly": True}, - "unit": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "current_value": {"key": "properties.currentValue", "type": "float"}, - "limit": {"key": "properties.limit", "type": "float"}, - "unit": {"key": "properties.unit", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.display_name: Optional[str] = None - self.current_value: Optional[float] = None - self.limit: Optional[float] = None - self.unit: Optional[str] = None - - -class DatabaseUsageListResult(_serialization.Model): - """A list of database usage metrics. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.DatabaseUsage] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DatabaseUsage]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.DatabaseUsage"]] = None - self.next_link: Optional[str] = None - - -class DatabaseUserIdentity(_serialization.Model): - """Azure Active Directory identity configuration for a resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The Azure Active Directory principal id. - :vartype principal_id: str - :ivar client_id: The Azure Active Directory client id. - :vartype client_id: str - """ - - _validation = { - "principal_id": {"readonly": True}, - "client_id": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "client_id": {"key": "clientId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.principal_id: Optional[str] = None - self.client_id: Optional[str] = None - - -class DatabaseVulnerabilityAssessment(ProxyResource): - """A database vulnerability assessment. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar storage_container_path: A blob storage container path to hold the scan results (e.g. - https://myStorage.blob.core.windows.net/VaScans/). It is required if server level - vulnerability assessment policy doesn't set. - :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. - :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. - :vartype storage_account_access_key: str - :ivar recurring_scans: The recurring scans settings. - :vartype recurring_scans: - ~azure.mgmt.sql.models.VulnerabilityAssessmentRecurringScansProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "storage_container_path": {"key": "properties.storageContainerPath", "type": "str"}, - "storage_container_sas_key": {"key": "properties.storageContainerSasKey", "type": "str"}, - "storage_account_access_key": {"key": "properties.storageAccountAccessKey", "type": "str"}, - "recurring_scans": { - "key": "properties.recurringScans", - "type": "VulnerabilityAssessmentRecurringScansProperties", - }, - } - - def __init__( - self, - *, - storage_container_path: Optional[str] = None, - storage_container_sas_key: Optional[str] = None, - storage_account_access_key: Optional[str] = None, - recurring_scans: Optional["_models.VulnerabilityAssessmentRecurringScansProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword storage_container_path: A blob storage container path to hold the scan results (e.g. - https://myStorage.blob.core.windows.net/VaScans/). It is required if server level - vulnerability assessment policy doesn't set. - :paramtype storage_container_path: str - :keyword storage_container_sas_key: A shared access signature (SAS Key) that has write access - to the blob container specified in 'storageContainerPath' parameter. If - 'storageAccountAccessKey' isn't specified, StorageContainerSasKey is required. - :paramtype storage_container_sas_key: str - :keyword storage_account_access_key: Specifies the identifier key of the storage account for - vulnerability assessment scan results. If 'StorageContainerSasKey' isn't specified, - storageAccountAccessKey is required. - :paramtype storage_account_access_key: str - :keyword recurring_scans: The recurring scans settings. - :paramtype recurring_scans: - ~azure.mgmt.sql.models.VulnerabilityAssessmentRecurringScansProperties - """ - super().__init__(**kwargs) - self.storage_container_path = storage_container_path - self.storage_container_sas_key = storage_container_sas_key - self.storage_account_access_key = storage_account_access_key - self.recurring_scans = recurring_scans - - -class DatabaseVulnerabilityAssessmentListResult(_serialization.Model): # pylint: disable=name-too-long - """A list of the database's vulnerability assessments. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DatabaseVulnerabilityAssessment]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.DatabaseVulnerabilityAssessment"]] = None - self.next_link: Optional[str] = None - - -class DatabaseVulnerabilityAssessmentRuleBaseline(ProxyResource): # pylint: disable=name-too-long - """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): # pylint: disable=name-too-long - """Properties for an Azure SQL Database Vulnerability Assessment rule baseline's result. - - All required parameters must be populated in order to send to server. - - :ivar result: The rule baseline result. Required. - :vartype result: list[str] - """ - - _validation = { - "result": {"required": True}, - } - - _attribute_map = { - "result": {"key": "result", "type": "[str]"}, - } - - def __init__(self, *, result: list[str], **kwargs: Any) -> None: - """ - :keyword result: The rule baseline result. Required. - :paramtype result: list[str] - """ - super().__init__(**kwargs) - self.result = result - - -class DatabaseVulnerabilityAssessmentScansExport(ProxyResource): # pylint: disable=name-too-long - """A database Vulnerability Assessment scan export resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar exported_report_location: Location of the exported report (e.g. - https://myStorage.blob.core.windows.net/VaScans/scans/serverName/databaseName/scan_scanId.xlsx). - :vartype exported_report_location: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "exported_report_location": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "exported_report_location": {"key": "properties.exportedReportLocation", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.exported_report_location: Optional[str] = None - - -class DataMaskingPolicy(ProxyResource): - """Represents a database data masking policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar location: The location of the data masking policy. - :vartype location: str - :ivar kind: The kind of data masking policy. Metadata, used for Azure portal. - :vartype kind: str - :ivar data_masking_state: The state of the data masking policy. Known values are: "Disabled" - and "Enabled". - :vartype data_masking_state: str or ~azure.mgmt.sql.models.DataMaskingState - :ivar exempt_principals: The list of the exempt principals. Specifies the semicolon-separated - list of database users for which the data masking policy does not apply. The specified users - receive data results without masking for all of the database queries. - :vartype exempt_principals: str - :ivar application_principals: The list of the application principals. This is a legacy - parameter and is no longer used. - :vartype application_principals: str - :ivar masking_level: The masking level. This is a legacy parameter and is no longer used. - :vartype masking_level: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"readonly": True}, - "kind": {"readonly": True}, - "application_principals": {"readonly": True}, - "masking_level": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "data_masking_state": {"key": "properties.dataMaskingState", "type": "str"}, - "exempt_principals": {"key": "properties.exemptPrincipals", "type": "str"}, - "application_principals": {"key": "properties.applicationPrincipals", "type": "str"}, - "masking_level": {"key": "properties.maskingLevel", "type": "str"}, - } - - def __init__( - self, - *, - data_masking_state: Optional[Union[str, "_models.DataMaskingState"]] = None, - exempt_principals: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword data_masking_state: The state of the data masking policy. Known values are: "Disabled" - and "Enabled". - :paramtype data_masking_state: str or ~azure.mgmt.sql.models.DataMaskingState - :keyword exempt_principals: The list of the exempt principals. Specifies the - semicolon-separated list of database users for which the data masking policy does not apply. - The specified users receive data results without masking for all of the database queries. - :paramtype exempt_principals: str - """ - super().__init__(**kwargs) - self.location: Optional[str] = None - self.kind: Optional[str] = None - self.data_masking_state = data_masking_state - self.exempt_principals = exempt_principals - self.application_principals: Optional[str] = None - self.masking_level: Optional[str] = None - - -class DataMaskingRule(ProxyResource): - """Represents a database data masking rule. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar location: The location of the data masking rule. - :vartype location: str - :ivar kind: The kind of Data Masking Rule. Metadata, used for Azure portal. - :vartype kind: str - :ivar id_properties_id: The rule Id. - :vartype id_properties_id: str - :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". - :vartype rule_state: str or ~azure.mgmt.sql.models.DataMaskingRuleState - :ivar schema_name: The schema name on which the data masking rule is applied. - :vartype schema_name: str - :ivar table_name: The table name on which the data masking rule is applied. - :vartype table_name: str - :ivar column_name: The column name on which the data masking rule is applied. - :vartype column_name: str - :ivar masking_function: The masking function that is used for the data masking rule. Known - values are: "Default", "CCN", "Email", "Number", "SSN", and "Text". - :vartype masking_function: str or ~azure.mgmt.sql.models.DataMaskingFunction - :ivar number_from: The numberFrom property of the masking rule. Required if maskingFunction is - set to Number, otherwise this parameter will be ignored. - :vartype number_from: str - :ivar number_to: The numberTo property of the data masking rule. Required if maskingFunction is - set to Number, otherwise this parameter will be ignored. - :vartype number_to: str - :ivar prefix_size: If maskingFunction is set to Text, the number of characters to show unmasked - in the beginning of the string. Otherwise, this parameter will be ignored. - :vartype prefix_size: str - :ivar suffix_size: If maskingFunction is set to Text, the number of characters to show unmasked - at the end of the string. Otherwise, this parameter will be ignored. - :vartype suffix_size: str - :ivar replacement_string: If maskingFunction is set to Text, the character to use for masking - the unexposed part of the string. Otherwise, this parameter will be ignored. - :vartype replacement_string: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"readonly": True}, - "kind": {"readonly": True}, - "id_properties_id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "id_properties_id": {"key": "properties.id", "type": "str"}, - "alias_name": {"key": "properties.aliasName", "type": "str"}, - "rule_state": {"key": "properties.ruleState", "type": "str"}, - "schema_name": {"key": "properties.schemaName", "type": "str"}, - "table_name": {"key": "properties.tableName", "type": "str"}, - "column_name": {"key": "properties.columnName", "type": "str"}, - "masking_function": {"key": "properties.maskingFunction", "type": "str"}, - "number_from": {"key": "properties.numberFrom", "type": "str"}, - "number_to": {"key": "properties.numberTo", "type": "str"}, - "prefix_size": {"key": "properties.prefixSize", "type": "str"}, - "suffix_size": {"key": "properties.suffixSize", "type": "str"}, - "replacement_string": {"key": "properties.replacementString", "type": "str"}, - } - - def __init__( - self, - *, - 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, - masking_function: Optional[Union[str, "_models.DataMaskingFunction"]] = None, - number_from: Optional[str] = None, - number_to: Optional[str] = None, - prefix_size: Optional[str] = None, - suffix_size: Optional[str] = None, - replacement_string: Optional[str] = None, - **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". - :paramtype rule_state: str or ~azure.mgmt.sql.models.DataMaskingRuleState - :keyword schema_name: The schema name on which the data masking rule is applied. - :paramtype schema_name: str - :keyword table_name: The table name on which the data masking rule is applied. - :paramtype table_name: str - :keyword column_name: The column name on which the data masking rule is applied. - :paramtype column_name: str - :keyword masking_function: The masking function that is used for the data masking rule. Known - values are: "Default", "CCN", "Email", "Number", "SSN", and "Text". - :paramtype masking_function: str or ~azure.mgmt.sql.models.DataMaskingFunction - :keyword number_from: The numberFrom property of the masking rule. Required if maskingFunction - is set to Number, otherwise this parameter will be ignored. - :paramtype number_from: str - :keyword number_to: The numberTo property of the data masking rule. Required if maskingFunction - is set to Number, otherwise this parameter will be ignored. - :paramtype number_to: str - :keyword prefix_size: If maskingFunction is set to Text, the number of characters to show - unmasked in the beginning of the string. Otherwise, this parameter will be ignored. - :paramtype prefix_size: str - :keyword suffix_size: If maskingFunction is set to Text, the number of characters to show - unmasked at the end of the string. Otherwise, this parameter will be ignored. - :paramtype suffix_size: str - :keyword replacement_string: If maskingFunction is set to Text, the character to use for - masking the unexposed part of the string. Otherwise, this parameter will be ignored. - :paramtype replacement_string: str - """ - super().__init__(**kwargs) - self.location: Optional[str] = None - self.kind: Optional[str] = None - self.id_properties_id: Optional[str] = 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.masking_function = masking_function - self.number_from = number_from - self.number_to = number_to - self.prefix_size = prefix_size - self.suffix_size = suffix_size - self.replacement_string = replacement_string - - -class DataMaskingRuleListResult(_serialization.Model): - """The response to a list data masking rules request. - - :ivar value: The list of database data masking rules. - :vartype value: list[~azure.mgmt.sql.models.DataMaskingRule] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[DataMaskingRule]"}, - } - - 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] - """ - super().__init__(**kwargs) - self.value = value - - -class DataWarehouseUserActivities(ProxyResource): - """User activities of a data warehouse. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar active_queries_count: Count of running and suspended queries. - :vartype active_queries_count: int - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "active_queries_count": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "active_queries_count": {"key": "properties.activeQueriesCount", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.active_queries_count: Optional[int] = None - - -class DataWarehouseUserActivitiesListResult(_serialization.Model): - """User activities of a data warehouse. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.DataWarehouseUserActivities] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DataWarehouseUserActivities]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.DataWarehouseUserActivities"]] = None - self.next_link: Optional[str] = None - - -class DeletedServer(ProxyResource): - """A deleted server. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar version: The version of the deleted server. - :vartype version: str - :ivar deletion_time: The deletion time of the deleted server. - :vartype deletion_time: ~datetime.datetime - :ivar original_id: The original ID of the server before deletion. - :vartype original_id: str - :ivar fully_qualified_domain_name: The fully qualified domain name of the server. - :vartype fully_qualified_domain_name: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "version": {"readonly": True}, - "deletion_time": {"readonly": True}, - "original_id": {"readonly": True}, - "fully_qualified_domain_name": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "version": {"key": "properties.version", "type": "str"}, - "deletion_time": {"key": "properties.deletionTime", "type": "iso-8601"}, - "original_id": {"key": "properties.originalId", "type": "str"}, - "fully_qualified_domain_name": {"key": "properties.fullyQualifiedDomainName", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.version: Optional[str] = None - self.deletion_time: Optional[datetime.datetime] = None - self.original_id: Optional[str] = None - self.fully_qualified_domain_name: Optional[str] = None - - -class DeletedServerListResult(_serialization.Model): - """A list of deleted servers. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.DeletedServer] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DeletedServer]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.DeletedServer"]] = None - self.next_link: Optional[str] = None - - -class DistributedAvailabilityGroup(ProxyResource): - """Distributed availability group between box and Sql Managed Instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar distributed_availability_group_name: Name of the distributed availability group. - :vartype distributed_availability_group_name: str - :ivar distributed_availability_group_id: ID of the distributed availability group. - :vartype distributed_availability_group_id: str - :ivar replication_mode: Replication mode of the link. Known values are: "Async", "Sync", and - "Async". - :vartype replication_mode: str or ~azure.mgmt.sql.models.ReplicationModeType - :ivar partner_link_role: SQL server side link role. Known values are: "Primary" and - "Secondary". - :vartype partner_link_role: str or ~azure.mgmt.sql.models.LinkRole - :ivar partner_availability_group_name: SQL server side availability group name. - :vartype partner_availability_group_name: str - :ivar partner_endpoint: SQL server side endpoint - IP or DNS resolvable name. - :vartype partner_endpoint: str - :ivar instance_link_role: Managed instance side link role. Known values are: "Primary" and - "Secondary". - :vartype instance_link_role: str or ~azure.mgmt.sql.models.LinkRole - :ivar instance_availability_group_name: Managed instance side availability group name. - :vartype instance_availability_group_name: str - :ivar failover_mode: The link failover mode - can be Manual if intended to be used for two-way - failover with a supported SQL Server, or None for one-way failover to Azure. Known values are: - "None" and "Manual". - :vartype failover_mode: str or ~azure.mgmt.sql.models.FailoverModeType - :ivar seeding_mode: Database seeding mode – can be Automatic (default), or Manual for supported - scenarios. Known values are: "Automatic" and "Manual". - :vartype seeding_mode: str or ~azure.mgmt.sql.models.SeedingModeType - :ivar databases: Databases in the distributed availability group. - :vartype databases: list[~azure.mgmt.sql.models.DistributedAvailabilityGroupDatabase] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "distributed_availability_group_name": {"readonly": True}, - "distributed_availability_group_id": {"readonly": True}, - "partner_link_role": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "distributed_availability_group_name": {"key": "properties.distributedAvailabilityGroupName", "type": "str"}, - "distributed_availability_group_id": {"key": "properties.distributedAvailabilityGroupId", "type": "str"}, - "replication_mode": {"key": "properties.replicationMode", "type": "str"}, - "partner_link_role": {"key": "properties.partnerLinkRole", "type": "str"}, - "partner_availability_group_name": {"key": "properties.partnerAvailabilityGroupName", "type": "str"}, - "partner_endpoint": {"key": "properties.partnerEndpoint", "type": "str"}, - "instance_link_role": {"key": "properties.instanceLinkRole", "type": "str"}, - "instance_availability_group_name": {"key": "properties.instanceAvailabilityGroupName", "type": "str"}, - "failover_mode": {"key": "properties.failoverMode", "type": "str"}, - "seeding_mode": {"key": "properties.seedingMode", "type": "str"}, - "databases": {"key": "properties.databases", "type": "[DistributedAvailabilityGroupDatabase]"}, - } - - def __init__( - self, - *, - replication_mode: Optional[Union[str, "_models.ReplicationModeType"]] = None, - partner_availability_group_name: Optional[str] = None, - partner_endpoint: Optional[str] = None, - instance_link_role: Optional[Union[str, "_models.LinkRole"]] = None, - instance_availability_group_name: Optional[str] = None, - failover_mode: Optional[Union[str, "_models.FailoverModeType"]] = None, - seeding_mode: Optional[Union[str, "_models.SeedingModeType"]] = None, - databases: Optional[list["_models.DistributedAvailabilityGroupDatabase"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword replication_mode: Replication mode of the link. Known values are: "Async", "Sync", and - "Async". - :paramtype replication_mode: str or ~azure.mgmt.sql.models.ReplicationModeType - :keyword partner_availability_group_name: SQL server side availability group name. - :paramtype partner_availability_group_name: str - :keyword partner_endpoint: SQL server side endpoint - IP or DNS resolvable name. - :paramtype partner_endpoint: str - :keyword instance_link_role: Managed instance side link role. Known values are: "Primary" and - "Secondary". - :paramtype instance_link_role: str or ~azure.mgmt.sql.models.LinkRole - :keyword instance_availability_group_name: Managed instance side availability group name. - :paramtype instance_availability_group_name: str - :keyword failover_mode: The link failover mode - can be Manual if intended to be used for - two-way failover with a supported SQL Server, or None for one-way failover to Azure. Known - values are: "None" and "Manual". - :paramtype failover_mode: str or ~azure.mgmt.sql.models.FailoverModeType - :keyword seeding_mode: Database seeding mode – can be Automatic (default), or Manual for - supported scenarios. Known values are: "Automatic" and "Manual". - :paramtype seeding_mode: str or ~azure.mgmt.sql.models.SeedingModeType - :keyword databases: Databases in the distributed availability group. - :paramtype databases: list[~azure.mgmt.sql.models.DistributedAvailabilityGroupDatabase] - """ - super().__init__(**kwargs) - self.distributed_availability_group_name: Optional[str] = None - self.distributed_availability_group_id: Optional[str] = None - self.replication_mode = replication_mode - self.partner_link_role: Optional[Union[str, "_models.LinkRole"]] = None - self.partner_availability_group_name = partner_availability_group_name - self.partner_endpoint = partner_endpoint - self.instance_link_role = instance_link_role - self.instance_availability_group_name = instance_availability_group_name - self.failover_mode = failover_mode - self.seeding_mode = seeding_mode - self.databases = databases - - -class DistributedAvailabilityGroupDatabase(_serialization.Model): - """Database specific information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar database_name: The name of the database in link. - :vartype database_name: str - :ivar instance_replica_id: Managed instance replica id. - :vartype instance_replica_id: str - :ivar partner_replica_id: SQL server replica id. - :vartype partner_replica_id: str - :ivar replica_state: Current link state. - :vartype replica_state: str - :ivar seeding_progress: Seeding progress. - :vartype seeding_progress: str - :ivar synchronization_health: Link health state. Known values are: "NOT_HEALTHY", - "PARTIALLY_HEALTHY", and "HEALTHY". - :vartype synchronization_health: str or ~azure.mgmt.sql.models.ReplicaSynchronizationHealth - :ivar connected_state: Link connected state. Known values are: "DISCONNECTED" and "CONNECTED". - :vartype connected_state: str or ~azure.mgmt.sql.models.ReplicaConnectedState - :ivar last_received_lsn: Last received LSN. - :vartype last_received_lsn: str - :ivar last_received_time: Last received LSN time. - :vartype last_received_time: ~datetime.datetime - :ivar last_sent_lsn: Last sent LSN. - :vartype last_sent_lsn: str - :ivar last_sent_time: Last sent LSN time. - :vartype last_sent_time: ~datetime.datetime - :ivar last_commit_lsn: Last commit LSN. - :vartype last_commit_lsn: str - :ivar last_commit_time: Last commit LSN time. - :vartype last_commit_time: ~datetime.datetime - :ivar last_hardened_lsn: Last hardened LSN. - :vartype last_hardened_lsn: str - :ivar last_hardened_time: Last hardened LSN time. - :vartype last_hardened_time: ~datetime.datetime - :ivar last_backup_lsn: Last backup LSN. - :vartype last_backup_lsn: str - :ivar last_backup_time: Last backup LSN time. - :vartype last_backup_time: ~datetime.datetime - :ivar most_recent_link_error: The most recent link connection error description. - :vartype most_recent_link_error: str - :ivar partner_auth_cert_validity: SQL server certificate validity. - :vartype partner_auth_cert_validity: ~azure.mgmt.sql.models.CertificateInfo - :ivar instance_send_replication_lag_seconds: Replication lag when Managed Instance link side is - primary. - :vartype instance_send_replication_lag_seconds: int - :ivar instance_redo_replication_lag_seconds: Redo lag when Managed Instance link side is - primary. - :vartype instance_redo_replication_lag_seconds: int - """ - - _validation = { - "instance_replica_id": {"readonly": True}, - "partner_replica_id": {"readonly": True}, - "replica_state": {"readonly": True}, - "seeding_progress": {"readonly": True}, - "synchronization_health": {"readonly": True}, - "connected_state": {"readonly": True}, - "last_received_lsn": {"readonly": True}, - "last_received_time": {"readonly": True}, - "last_sent_lsn": {"readonly": True}, - "last_sent_time": {"readonly": True}, - "last_commit_lsn": {"readonly": True}, - "last_commit_time": {"readonly": True}, - "last_hardened_lsn": {"readonly": True}, - "last_hardened_time": {"readonly": True}, - "last_backup_lsn": {"readonly": True}, - "last_backup_time": {"readonly": True}, - "most_recent_link_error": {"readonly": True}, - "partner_auth_cert_validity": {"readonly": True}, - "instance_send_replication_lag_seconds": {"readonly": True}, - "instance_redo_replication_lag_seconds": {"readonly": True}, - } - - _attribute_map = { - "database_name": {"key": "databaseName", "type": "str"}, - "instance_replica_id": {"key": "instanceReplicaId", "type": "str"}, - "partner_replica_id": {"key": "partnerReplicaId", "type": "str"}, - "replica_state": {"key": "replicaState", "type": "str"}, - "seeding_progress": {"key": "seedingProgress", "type": "str"}, - "synchronization_health": {"key": "synchronizationHealth", "type": "str"}, - "connected_state": {"key": "connectedState", "type": "str"}, - "last_received_lsn": {"key": "lastReceivedLsn", "type": "str"}, - "last_received_time": {"key": "lastReceivedTime", "type": "iso-8601"}, - "last_sent_lsn": {"key": "lastSentLsn", "type": "str"}, - "last_sent_time": {"key": "lastSentTime", "type": "iso-8601"}, - "last_commit_lsn": {"key": "lastCommitLsn", "type": "str"}, - "last_commit_time": {"key": "lastCommitTime", "type": "iso-8601"}, - "last_hardened_lsn": {"key": "lastHardenedLsn", "type": "str"}, - "last_hardened_time": {"key": "lastHardenedTime", "type": "iso-8601"}, - "last_backup_lsn": {"key": "lastBackupLsn", "type": "str"}, - "last_backup_time": {"key": "lastBackupTime", "type": "iso-8601"}, - "most_recent_link_error": {"key": "mostRecentLinkError", "type": "str"}, - "partner_auth_cert_validity": {"key": "partnerAuthCertValidity", "type": "CertificateInfo"}, - "instance_send_replication_lag_seconds": {"key": "instanceSendReplicationLagSeconds", "type": "int"}, - "instance_redo_replication_lag_seconds": {"key": "instanceRedoReplicationLagSeconds", "type": "int"}, - } - - def __init__(self, *, database_name: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword database_name: The name of the database in link. - :paramtype database_name: str - """ - super().__init__(**kwargs) - self.database_name = database_name - self.instance_replica_id: Optional[str] = None - self.partner_replica_id: Optional[str] = None - self.replica_state: Optional[str] = None - self.seeding_progress: Optional[str] = None - self.synchronization_health: Optional[Union[str, "_models.ReplicaSynchronizationHealth"]] = None - self.connected_state: Optional[Union[str, "_models.ReplicaConnectedState"]] = None - self.last_received_lsn: Optional[str] = None - self.last_received_time: Optional[datetime.datetime] = None - self.last_sent_lsn: Optional[str] = None - self.last_sent_time: Optional[datetime.datetime] = None - self.last_commit_lsn: Optional[str] = None - self.last_commit_time: Optional[datetime.datetime] = None - self.last_hardened_lsn: Optional[str] = None - self.last_hardened_time: Optional[datetime.datetime] = None - self.last_backup_lsn: Optional[str] = None - self.last_backup_time: Optional[datetime.datetime] = None - self.most_recent_link_error: Optional[str] = None - self.partner_auth_cert_validity: Optional["_models.CertificateInfo"] = None - self.instance_send_replication_lag_seconds: Optional[int] = None - self.instance_redo_replication_lag_seconds: Optional[int] = None - - -class DistributedAvailabilityGroupSetRole(_serialization.Model): - """Distributed availability group failover request. - - All required parameters must be populated in order to send to server. - - :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 DistributedAvailabilityGroupsFailoverRequest(_serialization.Model): # pylint: disable=name-too-long - """Distributed availability group failover. - - All required parameters must be populated in order to send to server. - - :ivar failover_type: The failover type, can be ForcedAllowDataLoss or Planned. Required. Known - values are: "ForcedAllowDataLoss" and "Planned". - :vartype failover_type: str or ~azure.mgmt.sql.models.FailoverType - """ - - _validation = { - "failover_type": {"required": True}, - } - - _attribute_map = { - "failover_type": {"key": "failoverType", "type": "str"}, - } - - def __init__(self, *, failover_type: Union[str, "_models.FailoverType"], **kwargs: Any) -> None: - """ - :keyword failover_type: The failover type, can be ForcedAllowDataLoss or Planned. Required. - Known values are: "ForcedAllowDataLoss" and "Planned". - :paramtype failover_type: str or ~azure.mgmt.sql.models.FailoverType - """ - super().__init__(**kwargs) - self.failover_type = failover_type - - -class DistributedAvailabilityGroupsListResult(_serialization.Model): - """A list of distributed availability groups in instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.DistributedAvailabilityGroup] - :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": "[DistributedAvailabilityGroup]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.DistributedAvailabilityGroup"]] = None - self.next_link: Optional[str] = None - - -class EditionCapability(_serialization.Model): - """The edition capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The database edition name. - :vartype name: str - :ivar supported_service_level_objectives: The list of supported service objectives for the - edition. - :vartype supported_service_level_objectives: - list[~azure.mgmt.sql.models.ServiceObjectiveCapability] - :ivar zone_redundant: Whether or not zone redundancy is supported for the edition. - :vartype zone_redundant: bool - :ivar read_scale: The read scale capability for the edition. - :vartype read_scale: ~azure.mgmt.sql.models.ReadScaleCapability - :ivar supported_storage_capabilities: The list of supported storage capabilities for this - edition. - :vartype supported_storage_capabilities: list[~azure.mgmt.sql.models.StorageCapability] - :ivar status: The status of the capability. 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_service_level_objectives": {"readonly": True}, - "zone_redundant": {"readonly": True}, - "read_scale": {"readonly": True}, - "supported_storage_capabilities": {"readonly": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "supported_service_level_objectives": { - "key": "supportedServiceLevelObjectives", - "type": "[ServiceObjectiveCapability]", - }, - "zone_redundant": {"key": "zoneRedundant", "type": "bool"}, - "read_scale": {"key": "readScale", "type": "ReadScaleCapability"}, - "supported_storage_capabilities": {"key": "supportedStorageCapabilities", "type": "[StorageCapability]"}, - "status": {"key": "status", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - } - - def __init__(self, *, 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: Optional[str] = None - self.supported_service_level_objectives: Optional[list["_models.ServiceObjectiveCapability"]] = None - self.zone_redundant: Optional[bool] = None - self.read_scale: Optional["_models.ReadScaleCapability"] = None - self.supported_storage_capabilities: Optional[list["_models.StorageCapability"]] = None - self.status: Optional[Union[str, "_models.CapabilityStatus"]] = None - self.reason = reason - - -class ElasticPool(TrackedResource): - """An elastic pool. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: The elastic pool SKU. - - The list of SKUs may vary by region and support offer. To determine the SKUs (including the SKU - name, tier/edition, family, and capacity) that are available to your subscription in an Azure - region, use the ``Capabilities_ListByLocation`` REST API or the following command: - - .. code-block:: azurecli - - az sql elastic-pool list-editions -l -o table - `. - :vartype sku: ~azure.mgmt.sql.models.Sku - :ivar kind: Kind of elastic pool. This is metadata used for the Azure portal experience. - :vartype kind: str - :ivar state: The state of the elastic pool. Known values are: "Creating", "Ready", and - "Disabled". - :vartype state: str or ~azure.mgmt.sql.models.ElasticPoolState - :ivar creation_date: The creation date of the elastic pool (ISO8601 format). - :vartype creation_date: ~datetime.datetime - :ivar max_size_bytes: The storage limit for the database elastic pool in bytes. - :vartype max_size_bytes: int - :ivar min_capacity: Minimal capacity that serverless pool will not shrink below, if not paused. - :vartype min_capacity: float - :ivar per_database_settings: The per database settings for the elastic pool. - :vartype per_database_settings: ~azure.mgmt.sql.models.ElasticPoolPerDatabaseSettings - :ivar zone_redundant: Whether or not this elastic pool is zone redundant, which means the - replicas of this elastic pool will be spread across multiple availability zones. - :vartype zone_redundant: bool - :ivar license_type: The license type to apply for this elastic pool. Known values are: - "LicenseIncluded" and "BasePrice". - :vartype license_type: str or ~azure.mgmt.sql.models.ElasticPoolLicenseType - :ivar maintenance_configuration_id: Maintenance configuration id assigned to the elastic pool. - This configuration defines the period when the maintenance updates will will occur. - :vartype maintenance_configuration_id: str - :ivar high_availability_replica_count: The number of secondary replicas associated with the - elastic pool that are used to provide high availability. Applicable only to Hyperscale elastic - pools. - :vartype high_availability_replica_count: int - :ivar preferred_enclave_type: Type of enclave requested on the elastic pool. Known values are: - "Default" and "VBS". - :vartype preferred_enclave_type: str or ~azure.mgmt.sql.models.AlwaysEncryptedEnclaveType - :ivar availability_zone: Specifies the availability zone the pool's primary replica is pinned - to. Known values are: "NoPreference", "1", "2", and "3". - :vartype availability_zone: str or ~azure.mgmt.sql.models.AvailabilityZoneType - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "kind": {"readonly": True}, - "state": {"readonly": True}, - "creation_date": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "Sku"}, - "kind": {"key": "kind", "type": "str"}, - "state": {"key": "properties.state", "type": "str"}, - "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, - "max_size_bytes": {"key": "properties.maxSizeBytes", "type": "int"}, - "min_capacity": {"key": "properties.minCapacity", "type": "float"}, - "per_database_settings": {"key": "properties.perDatabaseSettings", "type": "ElasticPoolPerDatabaseSettings"}, - "zone_redundant": {"key": "properties.zoneRedundant", "type": "bool"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - "maintenance_configuration_id": {"key": "properties.maintenanceConfigurationId", "type": "str"}, - "high_availability_replica_count": {"key": "properties.highAvailabilityReplicaCount", "type": "int"}, - "preferred_enclave_type": {"key": "properties.preferredEnclaveType", "type": "str"}, - "availability_zone": {"key": "properties.availabilityZone", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - max_size_bytes: Optional[int] = None, - min_capacity: Optional[float] = None, - per_database_settings: Optional["_models.ElasticPoolPerDatabaseSettings"] = None, - zone_redundant: Optional[bool] = None, - license_type: Optional[Union[str, "_models.ElasticPoolLicenseType"]] = None, - maintenance_configuration_id: Optional[str] = None, - high_availability_replica_count: Optional[int] = None, - preferred_enclave_type: Optional[Union[str, "_models.AlwaysEncryptedEnclaveType"]] = None, - availability_zone: Optional[Union[str, "_models.AvailabilityZoneType"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The elastic pool SKU. - - The list of SKUs may vary by region and support offer. To determine the SKUs (including the SKU - name, tier/edition, family, and capacity) that are available to your subscription in an Azure - region, use the ``Capabilities_ListByLocation`` REST API or the following command: - - .. code-block:: azurecli - - az sql elastic-pool list-editions -l -o table - `. - :paramtype sku: ~azure.mgmt.sql.models.Sku - :keyword max_size_bytes: The storage limit for the database elastic pool in bytes. - :paramtype max_size_bytes: int - :keyword min_capacity: Minimal capacity that serverless pool will not shrink below, if not - paused. - :paramtype min_capacity: float - :keyword per_database_settings: The per database settings for the elastic pool. - :paramtype per_database_settings: ~azure.mgmt.sql.models.ElasticPoolPerDatabaseSettings - :keyword zone_redundant: Whether or not this elastic pool is zone redundant, which means the - replicas of this elastic pool will be spread across multiple availability zones. - :paramtype zone_redundant: bool - :keyword license_type: The license type to apply for this elastic pool. Known values are: - "LicenseIncluded" and "BasePrice". - :paramtype license_type: str or ~azure.mgmt.sql.models.ElasticPoolLicenseType - :keyword maintenance_configuration_id: Maintenance configuration id assigned to the elastic - pool. This configuration defines the period when the maintenance updates will will occur. - :paramtype maintenance_configuration_id: str - :keyword high_availability_replica_count: The number of secondary replicas associated with the - elastic pool that are used to provide high availability. Applicable only to Hyperscale elastic - pools. - :paramtype high_availability_replica_count: int - :keyword preferred_enclave_type: Type of enclave requested on the elastic pool. Known values - are: "Default" and "VBS". - :paramtype preferred_enclave_type: str or ~azure.mgmt.sql.models.AlwaysEncryptedEnclaveType - :keyword availability_zone: Specifies the availability zone the pool's primary replica is - pinned to. Known values are: "NoPreference", "1", "2", and "3". - :paramtype availability_zone: str or ~azure.mgmt.sql.models.AvailabilityZoneType - """ - super().__init__(location=location, tags=tags, **kwargs) - self.sku = sku - self.kind: Optional[str] = None - self.state: Optional[Union[str, "_models.ElasticPoolState"]] = None - self.creation_date: Optional[datetime.datetime] = None - self.max_size_bytes = max_size_bytes - self.min_capacity = min_capacity - self.per_database_settings = per_database_settings - self.zone_redundant = zone_redundant - self.license_type = license_type - self.maintenance_configuration_id = maintenance_configuration_id - self.high_availability_replica_count = high_availability_replica_count - self.preferred_enclave_type = preferred_enclave_type - self.availability_zone = availability_zone - - -class ElasticPoolActivity(ProxyResource): - """Represents the activity on an elastic pool. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :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 - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "end_time": {"readonly": True}, - "error_code": {"readonly": True}, - "error_message": {"readonly": True}, - "error_severity": {"readonly": True}, - "operation": {"readonly": True}, - "operation_id": {"readonly": True}, - "percent_complete": {"readonly": True}, - "requested_database_dtu_max": {"readonly": True}, - "requested_database_dtu_min": {"readonly": True}, - "requested_dtu": {"readonly": True}, - "requested_elastic_pool_name": {"readonly": True}, - "requested_storage_limit_in_gb": {"readonly": True}, - "elastic_pool_name": {"readonly": True}, - "server_name": {"readonly": True}, - "start_time": {"readonly": True}, - "state": {"readonly": True}, - "requested_storage_limit_in_mb": {"readonly": True}, - "requested_database_dtu_guarantee": {"readonly": True}, - "requested_database_dtu_cap": {"readonly": True}, - "requested_dtu_guarantee": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "end_time": {"key": "properties.endTime", "type": "iso-8601"}, - "error_code": {"key": "properties.errorCode", "type": "int"}, - "error_message": {"key": "properties.errorMessage", "type": "str"}, - "error_severity": {"key": "properties.errorSeverity", "type": "int"}, - "operation": {"key": "properties.operation", "type": "str"}, - "operation_id": {"key": "properties.operationId", "type": "str"}, - "percent_complete": {"key": "properties.percentComplete", "type": "int"}, - "requested_database_dtu_max": {"key": "properties.requestedDatabaseDtuMax", "type": "int"}, - "requested_database_dtu_min": {"key": "properties.requestedDatabaseDtuMin", "type": "int"}, - "requested_dtu": {"key": "properties.requestedDtu", "type": "int"}, - "requested_elastic_pool_name": {"key": "properties.requestedElasticPoolName", "type": "str"}, - "requested_storage_limit_in_gb": {"key": "properties.requestedStorageLimitInGB", "type": "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"}, - } - - def __init__(self, *, location: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=too-many-locals - """ - :keyword location: The geo-location where the resource lives. - :paramtype location: str - """ - super().__init__(**kwargs) - self.location = location - self.end_time: Optional[datetime.datetime] = None - self.error_code: Optional[int] = None - self.error_message: Optional[str] = None - self.error_severity: Optional[int] = None - self.operation: Optional[str] = None - self.operation_id: Optional[str] = None - self.percent_complete: Optional[int] = None - self.requested_database_dtu_max: Optional[int] = None - self.requested_database_dtu_min: Optional[int] = None - self.requested_dtu: Optional[int] = None - self.requested_elastic_pool_name: Optional[str] = None - self.requested_storage_limit_in_gb: Optional[int] = None - self.elastic_pool_name: Optional[str] = None - self.server_name: Optional[str] = None - self.start_time: Optional[datetime.datetime] = None - self.state: Optional[str] = None - self.requested_storage_limit_in_mb: Optional[int] = None - self.requested_database_dtu_guarantee: Optional[int] = None - self.requested_database_dtu_cap: Optional[int] = None - self.requested_dtu_guarantee: Optional[int] = None - - -class ElasticPoolActivityListResult(_serialization.Model): - """Represents the response to a list elastic pool activity request. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of elastic pool activities. Required. - :vartype value: list[~azure.mgmt.sql.models.ElasticPoolActivity] - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ElasticPoolActivity]"}, - } - - def __init__(self, *, value: list["_models.ElasticPoolActivity"], **kwargs: Any) -> None: - """ - :keyword value: The list of elastic pool activities. Required. - :paramtype value: list[~azure.mgmt.sql.models.ElasticPoolActivity] - """ - super().__init__(**kwargs) - self.value = value - - -class ElasticPoolDatabaseActivity(ProxyResource): - """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: Optional[str] = None - self.end_time: Optional[datetime.datetime] = None - self.error_code: Optional[int] = None - self.error_message: Optional[str] = None - self.error_severity: Optional[int] = None - self.operation: Optional[str] = None - self.operation_id: Optional[str] = None - self.percent_complete: Optional[int] = None - self.requested_elastic_pool_name: Optional[str] = None - self.current_elastic_pool_name: Optional[str] = None - self.current_service_objective: Optional[str] = None - self.requested_service_objective: Optional[str] = None - self.server_name: Optional[str] = None - self.start_time: Optional[datetime.datetime] = None - self.state: Optional[str] = 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 server. - - :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: Optional[str] = None - self.supported_elastic_pool_performance_levels: Optional[ - list["_models.ElasticPoolPerformanceLevelCapability"] - ] = None - self.zone_redundant: Optional[bool] = None - self.status: Optional[Union[str, "_models.CapabilityStatus"]] = 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: Optional[list["_models.ElasticPool"]] = None - self.next_link: Optional[str] = None - - -class ElasticPoolOperation(ProxyResource): - """A elastic pool operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar elastic_pool_name: The name of the elastic pool the operation is being performed on. - :vartype elastic_pool_name: str - :ivar operation: The name of operation. - :vartype operation: str - :ivar operation_friendly_name: The friendly name of operation. - :vartype operation_friendly_name: str - :ivar percent_complete: The percentage of the operation completed. - :vartype percent_complete: int - :ivar server_name: The name of the server. - :vartype server_name: str - :ivar start_time: The operation start time. - :vartype start_time: ~datetime.datetime - :ivar state: The operation state. - :vartype state: str - :ivar error_code: The operation error code. - :vartype error_code: int - :ivar error_description: The operation error description. - :vartype error_description: str - :ivar error_severity: The operation error severity. - :vartype error_severity: int - :ivar is_user_error: Whether or not the error is a user error. - :vartype is_user_error: bool - :ivar estimated_completion_time: The estimated completion time of the operation. - :vartype estimated_completion_time: ~datetime.datetime - :ivar description: The operation description. - :vartype description: str - :ivar is_cancellable: Whether the operation can be cancelled. - :vartype is_cancellable: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "elastic_pool_name": {"readonly": True}, - "operation": {"readonly": True}, - "operation_friendly_name": {"readonly": True}, - "percent_complete": {"readonly": True}, - "server_name": {"readonly": True}, - "start_time": {"readonly": True}, - "state": {"readonly": True}, - "error_code": {"readonly": True}, - "error_description": {"readonly": True}, - "error_severity": {"readonly": True}, - "is_user_error": {"readonly": True}, - "estimated_completion_time": {"readonly": True}, - "description": {"readonly": True}, - "is_cancellable": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "elastic_pool_name": {"key": "properties.elasticPoolName", "type": "str"}, - "operation": {"key": "properties.operation", "type": "str"}, - "operation_friendly_name": {"key": "properties.operationFriendlyName", "type": "str"}, - "percent_complete": {"key": "properties.percentComplete", "type": "int"}, - "server_name": {"key": "properties.serverName", "type": "str"}, - "start_time": {"key": "properties.startTime", "type": "iso-8601"}, - "state": {"key": "properties.state", "type": "str"}, - "error_code": {"key": "properties.errorCode", "type": "int"}, - "error_description": {"key": "properties.errorDescription", "type": "str"}, - "error_severity": {"key": "properties.errorSeverity", "type": "int"}, - "is_user_error": {"key": "properties.isUserError", "type": "bool"}, - "estimated_completion_time": {"key": "properties.estimatedCompletionTime", "type": "iso-8601"}, - "description": {"key": "properties.description", "type": "str"}, - "is_cancellable": {"key": "properties.isCancellable", "type": "bool"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.elastic_pool_name: Optional[str] = None - self.operation: Optional[str] = None - self.operation_friendly_name: Optional[str] = None - self.percent_complete: Optional[int] = None - self.server_name: Optional[str] = None - self.start_time: Optional[datetime.datetime] = None - self.state: Optional[str] = None - self.error_code: Optional[int] = None - self.error_description: Optional[str] = None - self.error_severity: Optional[int] = None - self.is_user_error: Optional[bool] = None - self.estimated_completion_time: Optional[datetime.datetime] = None - self.description: Optional[str] = None - self.is_cancellable: Optional[bool] = None - - -class ElasticPoolOperationListResult(_serialization.Model): - """The response to a list elastic pool operations request. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ElasticPoolOperation] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ElasticPoolOperation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ElasticPoolOperation"]] = None - self.next_link: Optional[str] = None - - -class ElasticPoolPerDatabaseMaxPerformanceLevelCapability(_serialization.Model): # pylint: disable=name-too-long - """The max per-database performance level capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar limit: The maximum performance level per database. - :vartype limit: float - :ivar unit: Unit type used to measure performance level. Known values are: "DTU" and "VCores". - :vartype unit: str or ~azure.mgmt.sql.models.PerformanceLevelUnit - :ivar supported_per_database_min_performance_levels: The list of supported min database - performance levels. - :vartype supported_per_database_min_performance_levels: - list[~azure.mgmt.sql.models.ElasticPoolPerDatabaseMinPerformanceLevelCapability] - :ivar status: The status of the capability. 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 = { - "limit": {"readonly": True}, - "unit": {"readonly": True}, - "supported_per_database_min_performance_levels": {"readonly": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "limit": {"key": "limit", "type": "float"}, - "unit": {"key": "unit", "type": "str"}, - "supported_per_database_min_performance_levels": { - "key": "supportedPerDatabaseMinPerformanceLevels", - "type": "[ElasticPoolPerDatabaseMinPerformanceLevelCapability]", - }, - "status": {"key": "status", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - } - - def __init__(self, *, reason: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword reason: The reason for the capability not being available. - :paramtype reason: str - """ - super().__init__(**kwargs) - self.limit: Optional[float] = None - self.unit: Optional[Union[str, "_models.PerformanceLevelUnit"]] = None - self.supported_per_database_min_performance_levels: Optional[ - list["_models.ElasticPoolPerDatabaseMinPerformanceLevelCapability"] - ] = None - self.status: Optional[Union[str, "_models.CapabilityStatus"]] = None - self.reason = reason - - -class ElasticPoolPerDatabaseMinPerformanceLevelCapability(_serialization.Model): # pylint: disable=name-too-long - """The minimum per-database performance level capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar limit: The minimum performance level per database. - :vartype limit: float - :ivar unit: Unit type used to measure performance level. Known values are: "DTU" and "VCores". - :vartype unit: str or ~azure.mgmt.sql.models.PerformanceLevelUnit - :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 = { - "limit": {"readonly": True}, - "unit": {"readonly": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "limit": {"key": "limit", "type": "float"}, - "unit": {"key": "unit", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - } - - def __init__(self, *, reason: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword reason: The reason for the capability not being available. - :paramtype reason: str - """ - super().__init__(**kwargs) - self.limit: Optional[float] = None - self.unit: Optional[Union[str, "_models.PerformanceLevelUnit"]] = None - self.status: Optional[Union[str, "_models.CapabilityStatus"]] = None - self.reason = reason - - -class ElasticPoolPerDatabaseSettings(_serialization.Model): - """Per database settings of an elastic pool. - - :ivar min_capacity: The minimum capacity all databases are guaranteed. - :vartype min_capacity: float - :ivar max_capacity: The maximum capacity any one database can consume. - :vartype max_capacity: float - """ - - _attribute_map = { - "min_capacity": {"key": "minCapacity", "type": "float"}, - "max_capacity": {"key": "maxCapacity", "type": "float"}, - } - - def __init__( - self, *, min_capacity: Optional[float] = None, max_capacity: Optional[float] = None, **kwargs: Any - ) -> None: - """ - :keyword min_capacity: The minimum capacity all databases are guaranteed. - :paramtype min_capacity: float - :keyword max_capacity: The maximum capacity any one database can consume. - :paramtype max_capacity: float - """ - super().__init__(**kwargs) - self.min_capacity = min_capacity - self.max_capacity = max_capacity - - -class ElasticPoolPerformanceLevelCapability(_serialization.Model): - """The Elastic Pool performance level capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar performance_level: The performance level for the pool. - :vartype performance_level: ~azure.mgmt.sql.models.PerformanceLevelCapability - :ivar sku: The sku. - :vartype sku: ~azure.mgmt.sql.models.Sku - :ivar supported_license_types: List of supported license types. - :vartype supported_license_types: list[~azure.mgmt.sql.models.LicenseTypeCapability] - :ivar max_database_count: The maximum number of databases supported. - :vartype max_database_count: int - :ivar included_max_size: The included (free) max size for this performance level. - :vartype included_max_size: ~azure.mgmt.sql.models.MaxSizeCapability - :ivar supported_max_sizes: The list of supported max sizes. - :vartype supported_max_sizes: list[~azure.mgmt.sql.models.MaxSizeRangeCapability] - :ivar supported_per_database_max_sizes: The list of supported per database max sizes. - :vartype supported_per_database_max_sizes: list[~azure.mgmt.sql.models.MaxSizeRangeCapability] - :ivar supported_per_database_max_performance_levels: The list of supported per database max - performance levels. - :vartype supported_per_database_max_performance_levels: - list[~azure.mgmt.sql.models.ElasticPoolPerDatabaseMaxPerformanceLevelCapability] - :ivar zone_redundant: Whether or not zone redundancy is supported for the performance level. - :vartype zone_redundant: bool - :ivar supported_maintenance_configurations: List of supported maintenance configurations. - :vartype supported_maintenance_configurations: - list[~azure.mgmt.sql.models.MaintenanceConfigurationCapability] - :ivar status: The status of the capability. 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 = { - "performance_level": {"readonly": True}, - "sku": {"readonly": True}, - "supported_license_types": {"readonly": True}, - "max_database_count": {"readonly": True}, - "included_max_size": {"readonly": True}, - "supported_max_sizes": {"readonly": True}, - "supported_per_database_max_sizes": {"readonly": True}, - "supported_per_database_max_performance_levels": {"readonly": True}, - "zone_redundant": {"readonly": True}, - "supported_maintenance_configurations": {"readonly": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "performance_level": {"key": "performanceLevel", "type": "PerformanceLevelCapability"}, - "sku": {"key": "sku", "type": "Sku"}, - "supported_license_types": {"key": "supportedLicenseTypes", "type": "[LicenseTypeCapability]"}, - "max_database_count": {"key": "maxDatabaseCount", "type": "int"}, - "included_max_size": {"key": "includedMaxSize", "type": "MaxSizeCapability"}, - "supported_max_sizes": {"key": "supportedMaxSizes", "type": "[MaxSizeRangeCapability]"}, - "supported_per_database_max_sizes": {"key": "supportedPerDatabaseMaxSizes", "type": "[MaxSizeRangeCapability]"}, - "supported_per_database_max_performance_levels": { - "key": "supportedPerDatabaseMaxPerformanceLevels", - "type": "[ElasticPoolPerDatabaseMaxPerformanceLevelCapability]", - }, - "zone_redundant": {"key": "zoneRedundant", "type": "bool"}, - "supported_maintenance_configurations": { - "key": "supportedMaintenanceConfigurations", - "type": "[MaintenanceConfigurationCapability]", - }, - "status": {"key": "status", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - } - - def __init__(self, *, reason: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword reason: The reason for the capability not being available. - :paramtype reason: str - """ - super().__init__(**kwargs) - self.performance_level: Optional["_models.PerformanceLevelCapability"] = None - self.sku: Optional["_models.Sku"] = None - self.supported_license_types: Optional[list["_models.LicenseTypeCapability"]] = None - self.max_database_count: Optional[int] = None - self.included_max_size: Optional["_models.MaxSizeCapability"] = None - self.supported_max_sizes: Optional[list["_models.MaxSizeRangeCapability"]] = None - self.supported_per_database_max_sizes: Optional[list["_models.MaxSizeRangeCapability"]] = None - self.supported_per_database_max_performance_levels: Optional[ - list["_models.ElasticPoolPerDatabaseMaxPerformanceLevelCapability"] - ] = None - self.zone_redundant: Optional[bool] = None - self.supported_maintenance_configurations: Optional[list["_models.MaintenanceConfigurationCapability"]] = None - self.status: Optional[Union[str, "_models.CapabilityStatus"]] = None - self.reason = reason - - -class ElasticPoolUpdate(_serialization.Model): - """An elastic pool update. - - :ivar sku: An ARM Resource SKU. - :vartype sku: ~azure.mgmt.sql.models.Sku - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar max_size_bytes: The storage limit for the database elastic pool in bytes. - :vartype max_size_bytes: int - :ivar min_capacity: Minimal capacity that serverless pool will not shrink below, if not paused. - :vartype min_capacity: float - :ivar per_database_settings: The per database settings for the elastic pool. - :vartype per_database_settings: ~azure.mgmt.sql.models.ElasticPoolPerDatabaseSettings - :ivar zone_redundant: Whether or not this elastic pool is zone redundant, which means the - replicas of this elastic pool will be spread across multiple availability zones. - :vartype zone_redundant: bool - :ivar license_type: The license type to apply for this elastic pool. Known values are: - "LicenseIncluded" and "BasePrice". - :vartype license_type: str or ~azure.mgmt.sql.models.ElasticPoolLicenseType - :ivar maintenance_configuration_id: Maintenance configuration id assigned to the elastic pool. - This configuration defines the period when the maintenance updates will will occur. - :vartype maintenance_configuration_id: str - :ivar high_availability_replica_count: The number of secondary replicas associated with the - elastic pool that are used to provide high availability. Applicable only to Hyperscale elastic - pools. - :vartype high_availability_replica_count: int - :ivar preferred_enclave_type: Type of enclave requested on the elastic pool. Known values are: - "Default" and "VBS". - :vartype preferred_enclave_type: str or ~azure.mgmt.sql.models.AlwaysEncryptedEnclaveType - :ivar availability_zone: Specifies the availability zone the pool's primary replica is pinned - to. Known values are: "NoPreference", "1", "2", and "3". - :vartype availability_zone: str or ~azure.mgmt.sql.models.AvailabilityZoneType - """ - - _attribute_map = { - "sku": {"key": "sku", "type": "Sku"}, - "tags": {"key": "tags", "type": "{str}"}, - "max_size_bytes": {"key": "properties.maxSizeBytes", "type": "int"}, - "min_capacity": {"key": "properties.minCapacity", "type": "float"}, - "per_database_settings": {"key": "properties.perDatabaseSettings", "type": "ElasticPoolPerDatabaseSettings"}, - "zone_redundant": {"key": "properties.zoneRedundant", "type": "bool"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - "maintenance_configuration_id": {"key": "properties.maintenanceConfigurationId", "type": "str"}, - "high_availability_replica_count": {"key": "properties.highAvailabilityReplicaCount", "type": "int"}, - "preferred_enclave_type": {"key": "properties.preferredEnclaveType", "type": "str"}, - "availability_zone": {"key": "properties.availabilityZone", "type": "str"}, - } - - def __init__( - self, - *, - sku: Optional["_models.Sku"] = None, - tags: Optional[dict[str, str]] = None, - max_size_bytes: Optional[int] = None, - min_capacity: Optional[float] = None, - per_database_settings: Optional["_models.ElasticPoolPerDatabaseSettings"] = None, - zone_redundant: Optional[bool] = None, - license_type: Optional[Union[str, "_models.ElasticPoolLicenseType"]] = None, - maintenance_configuration_id: Optional[str] = None, - high_availability_replica_count: Optional[int] = None, - preferred_enclave_type: Optional[Union[str, "_models.AlwaysEncryptedEnclaveType"]] = None, - availability_zone: Optional[Union[str, "_models.AvailabilityZoneType"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword sku: An ARM Resource SKU. - :paramtype sku: ~azure.mgmt.sql.models.Sku - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword max_size_bytes: The storage limit for the database elastic pool in bytes. - :paramtype max_size_bytes: int - :keyword min_capacity: Minimal capacity that serverless pool will not shrink below, if not - paused. - :paramtype min_capacity: float - :keyword per_database_settings: The per database settings for the elastic pool. - :paramtype per_database_settings: ~azure.mgmt.sql.models.ElasticPoolPerDatabaseSettings - :keyword zone_redundant: Whether or not this elastic pool is zone redundant, which means the - replicas of this elastic pool will be spread across multiple availability zones. - :paramtype zone_redundant: bool - :keyword license_type: The license type to apply for this elastic pool. Known values are: - "LicenseIncluded" and "BasePrice". - :paramtype license_type: str or ~azure.mgmt.sql.models.ElasticPoolLicenseType - :keyword maintenance_configuration_id: Maintenance configuration id assigned to the elastic - pool. This configuration defines the period when the maintenance updates will will occur. - :paramtype maintenance_configuration_id: str - :keyword high_availability_replica_count: The number of secondary replicas associated with the - elastic pool that are used to provide high availability. Applicable only to Hyperscale elastic - pools. - :paramtype high_availability_replica_count: int - :keyword preferred_enclave_type: Type of enclave requested on the elastic pool. Known values - are: "Default" and "VBS". - :paramtype preferred_enclave_type: str or ~azure.mgmt.sql.models.AlwaysEncryptedEnclaveType - :keyword availability_zone: Specifies the availability zone the pool's primary replica is - pinned to. Known values are: "NoPreference", "1", "2", and "3". - :paramtype availability_zone: str or ~azure.mgmt.sql.models.AvailabilityZoneType - """ - super().__init__(**kwargs) - self.sku = sku - self.tags = tags - self.max_size_bytes = max_size_bytes - self.min_capacity = min_capacity - self.per_database_settings = per_database_settings - self.zone_redundant = zone_redundant - self.license_type = license_type - self.maintenance_configuration_id = maintenance_configuration_id - self.high_availability_replica_count = high_availability_replica_count - self.preferred_enclave_type = preferred_enclave_type - self.availability_zone = availability_zone - - -class EncryptionProtector(ProxyResource): - """The server encryption protector. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar kind: Kind of encryption protector. This is metadata used for the Azure portal - experience. - :vartype kind: str - :ivar location: Resource location. - :vartype location: str - :ivar subregion: Subregion of the encryption protector. - :vartype subregion: str - :ivar server_key_name: The name of the server key. - :vartype server_key_name: str - :ivar server_key_type: The encryption protector type like 'ServiceManaged', 'AzureKeyVault'. - Known values are: "ServiceManaged" and "AzureKeyVault". - :vartype server_key_type: str or ~azure.mgmt.sql.models.ServerKeyType - :ivar uri: The URI of the server key. - :vartype uri: str - :ivar thumbprint: Thumbprint of the server key. - :vartype thumbprint: str - :ivar auto_rotation_enabled: Key auto rotation opt-in flag. Either true or false. - :vartype auto_rotation_enabled: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "kind": {"readonly": True}, - "location": {"readonly": True}, - "subregion": {"readonly": True}, - "uri": {"readonly": True}, - "thumbprint": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "subregion": {"key": "properties.subregion", "type": "str"}, - "server_key_name": {"key": "properties.serverKeyName", "type": "str"}, - "server_key_type": {"key": "properties.serverKeyType", "type": "str"}, - "uri": {"key": "properties.uri", "type": "str"}, - "thumbprint": {"key": "properties.thumbprint", "type": "str"}, - "auto_rotation_enabled": {"key": "properties.autoRotationEnabled", "type": "bool"}, - } - - def __init__( - self, - *, - server_key_name: Optional[str] = None, - server_key_type: Optional[Union[str, "_models.ServerKeyType"]] = None, - auto_rotation_enabled: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword server_key_name: The name of the server key. - :paramtype server_key_name: str - :keyword server_key_type: The encryption protector type like 'ServiceManaged', 'AzureKeyVault'. - Known values are: "ServiceManaged" and "AzureKeyVault". - :paramtype server_key_type: str or ~azure.mgmt.sql.models.ServerKeyType - :keyword auto_rotation_enabled: Key auto rotation opt-in flag. Either true or false. - :paramtype auto_rotation_enabled: bool - """ - super().__init__(**kwargs) - self.kind: Optional[str] = None - self.location: Optional[str] = None - self.subregion: Optional[str] = None - self.server_key_name = server_key_name - self.server_key_type = server_key_type - self.uri: Optional[str] = None - self.thumbprint: Optional[str] = None - self.auto_rotation_enabled = auto_rotation_enabled - - -class EncryptionProtectorListResult(_serialization.Model): - """A list of server encryption protectors. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.EncryptionProtector] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[EncryptionProtector]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.EncryptionProtector"]] = None - self.next_link: Optional[str] = None - - -class EndpointCertificate(ProxyResource): - """Certificate used on an endpoint on the Managed Instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar public_blob: The certificate public blob. - :vartype public_blob: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "public_blob": {"key": "properties.publicBlob", "type": "str"}, - } - - def __init__(self, *, public_blob: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword public_blob: The certificate public blob. - :paramtype public_blob: str - """ - super().__init__(**kwargs) - self.public_blob = public_blob - - -class EndpointCertificateListResult(_serialization.Model): - """A list of endpoint certificates on the target instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.EndpointCertificate] - :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": "[EndpointCertificate]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.EndpointCertificate"]] = None - self.next_link: Optional[str] = None - - -class EndpointDependency(_serialization.Model): - """A domain name that the managed instance service needs to communicate with, along with - additional details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar domain_name: The domain name of the dependency. - :vartype domain_name: str - :ivar endpoint_details: The IP Addresses and Ports used when connecting to DomainName. - :vartype endpoint_details: list[~azure.mgmt.sql.models.EndpointDetail] - """ - - _validation = { - "domain_name": {"readonly": True}, - "endpoint_details": {"readonly": True}, - } - - _attribute_map = { - "domain_name": {"key": "domainName", "type": "str"}, - "endpoint_details": {"key": "endpointDetails", "type": "[EndpointDetail]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.domain_name: Optional[str] = None - self.endpoint_details: Optional[list["_models.EndpointDetail"]] = None - - -class EndpointDetail(_serialization.Model): - """A domain name that the managed instance service needs to communicate with, along with - additional details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar port: The port an endpoint is connected to. - :vartype port: int - """ - - _validation = { - "port": {"readonly": True}, - } - - _attribute_map = { - "port": {"key": "port", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.port: Optional[int] = 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: Optional[str] = None - self.info: Optional[JSON] = 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: Optional[str] = None - self.message: Optional[str] = None - self.target: Optional[str] = None - self.details: Optional[list["_models.ErrorDetail"]] = None - self.additional_info: Optional[list["_models.ErrorAdditionalInfo"]] = 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. - - All required parameters must be populated in order to send to server. - - :ivar storage_key_type: Storage key type. Required. Known values are: "SharedAccessKey", - "StorageAccessKey", and "ManagedIdentity". - :vartype storage_key_type: str or ~azure.mgmt.sql.models.StorageKeyType - :ivar storage_key: Storage key. Required. - :vartype storage_key: str - :ivar storage_uri: Storage Uri. Required. - :vartype storage_uri: str - :ivar administrator_login: Administrator login name. Required. - :vartype administrator_login: str - :ivar administrator_login_password: Administrator login password. Required. - :vartype administrator_login_password: str - :ivar authentication_type: Authentication type. - :vartype authentication_type: str - :ivar network_isolation: Optional resource information to enable network isolation for request. - :vartype network_isolation: ~azure.mgmt.sql.models.NetworkIsolationSettings - """ - - _validation = { - "storage_key_type": {"required": True}, - "storage_key": {"required": True}, - "storage_uri": {"required": True}, - "administrator_login": {"required": True}, - "administrator_login_password": {"required": True}, - } - - _attribute_map = { - "storage_key_type": {"key": "storageKeyType", "type": "str"}, - "storage_key": {"key": "storageKey", "type": "str"}, - "storage_uri": {"key": "storageUri", "type": "str"}, - "administrator_login": {"key": "administratorLogin", "type": "str"}, - "administrator_login_password": {"key": "administratorLoginPassword", "type": "str"}, - "authentication_type": {"key": "authenticationType", "type": "str"}, - "network_isolation": {"key": "networkIsolation", "type": "NetworkIsolationSettings"}, - } - - def __init__( - self, - *, - storage_key_type: Union[str, "_models.StorageKeyType"], - storage_key: str, - storage_uri: str, - administrator_login: str, - administrator_login_password: str, - authentication_type: Optional[str] = None, - network_isolation: Optional["_models.NetworkIsolationSettings"] = None, - **kwargs: Any - ) -> None: - """ - :keyword storage_key_type: Storage key type. Required. Known values are: "SharedAccessKey", - "StorageAccessKey", and "ManagedIdentity". - :paramtype storage_key_type: str or ~azure.mgmt.sql.models.StorageKeyType - :keyword storage_key: Storage key. Required. - :paramtype storage_key: str - :keyword storage_uri: Storage Uri. Required. - :paramtype storage_uri: str - :keyword administrator_login: Administrator login name. Required. - :paramtype administrator_login: str - :keyword administrator_login_password: Administrator login password. Required. - :paramtype administrator_login_password: str - :keyword authentication_type: Authentication type. - :paramtype authentication_type: str - :keyword network_isolation: Optional resource information to enable network isolation for - request. - :paramtype network_isolation: ~azure.mgmt.sql.models.NetworkIsolationSettings - """ - super().__init__(**kwargs) - 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.network_isolation = network_isolation - - -class ExtendedDatabaseBlobAuditingPolicy(ProxyResource): - """An extended database blob auditing policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar predicate_expression: Specifies condition of where clause when creating an audit. - :vartype predicate_expression: str - :ivar retention_days: Specifies the number of days to keep in the audit logs in the storage - account. - :vartype retention_days: int - :ivar audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. - - The recommended set of action groups to use is the following combination - this will audit all - the queries and stored procedures executed against the database, as well as successful and - failed logins: - - BATCH_COMPLETED_GROUP, - SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, - FAILED_DATABASE_AUTHENTICATION_GROUP. - - This above combination is also the set that is configured by default when enabling auditing - from the Azure portal. - - The supported action groups to audit are (note: choose only specific groups that cover your - auditing needs. Using unnecessary groups could lead to very large quantities of audit records): - - APPLICATION_ROLE_CHANGE_PASSWORD_GROUP - BACKUP_RESTORE_GROUP - DATABASE_LOGOUT_GROUP - DATABASE_OBJECT_CHANGE_GROUP - DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP - DATABASE_OBJECT_PERMISSION_CHANGE_GROUP - DATABASE_OPERATION_GROUP - DATABASE_PERMISSION_CHANGE_GROUP - DATABASE_PRINCIPAL_CHANGE_GROUP - DATABASE_PRINCIPAL_IMPERSONATION_GROUP - DATABASE_ROLE_MEMBER_CHANGE_GROUP - FAILED_DATABASE_AUTHENTICATION_GROUP - SCHEMA_OBJECT_ACCESS_GROUP - SCHEMA_OBJECT_CHANGE_GROUP - SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP - SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP - SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP - USER_CHANGE_PASSWORD_GROUP - BATCH_STARTED_GROUP - BATCH_COMPLETED_GROUP - DBCC_GROUP - DATABASE_OWNERSHIP_CHANGE_GROUP - DATABASE_CHANGE_GROUP - LEDGER_OPERATION_GROUP - - These are groups that cover all sql statements and stored procedures executed against the - database, and should not be used in combination with other groups as this will result in - duplicate audit logs. - - For more information, see `Database-Level Audit Action Groups - `_. - - For Database auditing policy, specific Actions can also be specified (note that Actions cannot - be specified for Server auditing policy). The supported actions to audit are: - SELECT - UPDATE - INSERT - DELETE - EXECUTE - RECEIVE - REFERENCES - - The general form for defining an action to be audited is: - {action} ON {object} BY {principal} - - Note that :code:`` in the above format can refer to an object like a table, view, or - stored procedure, or an entire database or schema. For the latter cases, the forms - DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. - - For example: - SELECT on dbo.myTable by public - SELECT on DATABASE::myDatabase by public - SELECT on SCHEMA::mySchema by public - - For more information, see `Database-Level Audit Actions - `_. - :vartype audit_actions_and_groups: list[str] - :ivar is_storage_secondary_key_in_use: Specifies whether storageAccountAccessKey value is the - storage's secondary key. - :vartype is_storage_secondary_key_in_use: bool - :ivar is_azure_monitor_target_enabled: Specifies whether audit events are sent to Azure - Monitor. - In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and - 'IsAzureMonitorTargetEnabled' as true. - - When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' - diagnostic logs category on the database should be also created. - Note that for server level audit you should use the 'master' database as {databaseName}. - - Diagnostic Settings URI format: - PUT - https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview - - For more information, see `Diagnostic Settings REST API - `_ - or `Diagnostic Settings PowerShell `_. - :vartype is_azure_monitor_target_enabled: bool - :ivar queue_delay_ms: Specifies the amount of time in milliseconds that can elapse before audit - actions are forced to be processed. - The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. - :vartype queue_delay_ms: int - :ivar is_managed_identity_in_use: Specifies whether Managed Identity is used to access blob - storage. - :vartype is_managed_identity_in_use: bool - :ivar state: Specifies the state of the audit. If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled are required. Known values are: "Enabled" and "Disabled". - :vartype state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState - :ivar storage_endpoint: Specifies the blob storage endpoint (e.g. - https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled is required. - :vartype storage_endpoint: str - :ivar storage_account_access_key: Specifies the identifier key of the auditing storage account. - If state is Enabled and storageEndpoint is specified, not specifying the - storageAccountAccessKey will use SQL server system-assigned managed identity to access the - storage. - Prerequisites for using managed identity authentication: - - - #. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). - #. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data - Contributor' RBAC role to the server identity. - For more information, see `Auditing to storage using Managed Identity authentication - `_. - :vartype storage_account_access_key: str - :ivar storage_account_subscription_id: Specifies the blob storage subscription Id. - :vartype storage_account_subscription_id: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "predicate_expression": {"key": "properties.predicateExpression", "type": "str"}, - "retention_days": {"key": "properties.retentionDays", "type": "int"}, - "audit_actions_and_groups": {"key": "properties.auditActionsAndGroups", "type": "[str]"}, - "is_storage_secondary_key_in_use": {"key": "properties.isStorageSecondaryKeyInUse", "type": "bool"}, - "is_azure_monitor_target_enabled": {"key": "properties.isAzureMonitorTargetEnabled", "type": "bool"}, - "queue_delay_ms": {"key": "properties.queueDelayMs", "type": "int"}, - "is_managed_identity_in_use": {"key": "properties.isManagedIdentityInUse", "type": "bool"}, - "state": {"key": "properties.state", "type": "str"}, - "storage_endpoint": {"key": "properties.storageEndpoint", "type": "str"}, - "storage_account_access_key": {"key": "properties.storageAccountAccessKey", "type": "str"}, - "storage_account_subscription_id": {"key": "properties.storageAccountSubscriptionId", "type": "str"}, - } - - def __init__( - self, - *, - predicate_expression: Optional[str] = None, - retention_days: Optional[int] = None, - audit_actions_and_groups: Optional[list[str]] = None, - is_storage_secondary_key_in_use: Optional[bool] = None, - is_azure_monitor_target_enabled: Optional[bool] = None, - queue_delay_ms: Optional[int] = None, - is_managed_identity_in_use: Optional[bool] = None, - state: Optional[Union[str, "_models.BlobAuditingPolicyState"]] = None, - storage_endpoint: Optional[str] = None, - storage_account_access_key: Optional[str] = None, - storage_account_subscription_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword predicate_expression: Specifies condition of where clause when creating an audit. - :paramtype predicate_expression: str - :keyword retention_days: Specifies the number of days to keep in the audit logs in the storage - account. - :paramtype retention_days: int - :keyword audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. - - The recommended set of action groups to use is the following combination - this will audit all - the queries and stored procedures executed against the database, as well as successful and - failed logins: - - BATCH_COMPLETED_GROUP, - SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, - FAILED_DATABASE_AUTHENTICATION_GROUP. - - This above combination is also the set that is configured by default when enabling auditing - from the Azure portal. - - The supported action groups to audit are (note: choose only specific groups that cover your - auditing needs. Using unnecessary groups could lead to very large quantities of audit records): - - APPLICATION_ROLE_CHANGE_PASSWORD_GROUP - BACKUP_RESTORE_GROUP - DATABASE_LOGOUT_GROUP - DATABASE_OBJECT_CHANGE_GROUP - DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP - DATABASE_OBJECT_PERMISSION_CHANGE_GROUP - DATABASE_OPERATION_GROUP - DATABASE_PERMISSION_CHANGE_GROUP - DATABASE_PRINCIPAL_CHANGE_GROUP - DATABASE_PRINCIPAL_IMPERSONATION_GROUP - DATABASE_ROLE_MEMBER_CHANGE_GROUP - FAILED_DATABASE_AUTHENTICATION_GROUP - SCHEMA_OBJECT_ACCESS_GROUP - SCHEMA_OBJECT_CHANGE_GROUP - SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP - SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP - SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP - USER_CHANGE_PASSWORD_GROUP - BATCH_STARTED_GROUP - BATCH_COMPLETED_GROUP - DBCC_GROUP - DATABASE_OWNERSHIP_CHANGE_GROUP - DATABASE_CHANGE_GROUP - LEDGER_OPERATION_GROUP - - These are groups that cover all sql statements and stored procedures executed against the - database, and should not be used in combination with other groups as this will result in - duplicate audit logs. - - For more information, see `Database-Level Audit Action Groups - `_. - - For Database auditing policy, specific Actions can also be specified (note that Actions cannot - be specified for Server auditing policy). The supported actions to audit are: - SELECT - UPDATE - INSERT - DELETE - EXECUTE - RECEIVE - REFERENCES - - The general form for defining an action to be audited is: - {action} ON {object} BY {principal} - - Note that :code:`` in the above format can refer to an object like a table, view, or - stored procedure, or an entire database or schema. For the latter cases, the forms - DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. - - For example: - SELECT on dbo.myTable by public - SELECT on DATABASE::myDatabase by public - SELECT on SCHEMA::mySchema by public - - For more information, see `Database-Level Audit Actions - `_. - :paramtype audit_actions_and_groups: list[str] - :keyword is_storage_secondary_key_in_use: Specifies whether storageAccountAccessKey value is - the storage's secondary key. - :paramtype is_storage_secondary_key_in_use: bool - :keyword is_azure_monitor_target_enabled: Specifies whether audit events are sent to Azure - Monitor. - In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and - 'IsAzureMonitorTargetEnabled' as true. - - When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' - diagnostic logs category on the database should be also created. - Note that for server level audit you should use the 'master' database as {databaseName}. - - Diagnostic Settings URI format: - PUT - https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview - - For more information, see `Diagnostic Settings REST API - `_ - or `Diagnostic Settings PowerShell `_. - :paramtype is_azure_monitor_target_enabled: bool - :keyword queue_delay_ms: Specifies the amount of time in milliseconds that can elapse before - audit actions are forced to be processed. - The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. - :paramtype queue_delay_ms: int - :keyword is_managed_identity_in_use: Specifies whether Managed Identity is used to access blob - storage. - :paramtype is_managed_identity_in_use: bool - :keyword state: Specifies the state of the audit. If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled are required. Known values are: "Enabled" and "Disabled". - :paramtype state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState - :keyword storage_endpoint: Specifies the blob storage endpoint (e.g. - https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled is required. - :paramtype storage_endpoint: str - :keyword storage_account_access_key: Specifies the identifier key of the auditing storage - account. - If state is Enabled and storageEndpoint is specified, not specifying the - storageAccountAccessKey will use SQL server system-assigned managed identity to access the - storage. - Prerequisites for using managed identity authentication: - - - #. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). - #. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data - Contributor' RBAC role to the server identity. - For more information, see `Auditing to storage using Managed Identity authentication - `_. - :paramtype storage_account_access_key: str - :keyword storage_account_subscription_id: Specifies the blob storage subscription Id. - :paramtype storage_account_subscription_id: str - """ - super().__init__(**kwargs) - self.predicate_expression = predicate_expression - self.retention_days = retention_days - self.audit_actions_and_groups = audit_actions_and_groups - self.is_storage_secondary_key_in_use = is_storage_secondary_key_in_use - self.is_azure_monitor_target_enabled = is_azure_monitor_target_enabled - self.queue_delay_ms = queue_delay_ms - self.is_managed_identity_in_use = is_managed_identity_in_use - self.state = state - self.storage_endpoint = storage_endpoint - self.storage_account_access_key = storage_account_access_key - self.storage_account_subscription_id = storage_account_subscription_id - - -class ExtendedDatabaseBlobAuditingPolicyListResult(_serialization.Model): # pylint: disable=name-too-long - """A list of database extended auditing settings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicy] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ExtendedDatabaseBlobAuditingPolicy]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ExtendedDatabaseBlobAuditingPolicy"]] = None - self.next_link: Optional[str] = None - - -class ExtendedServerBlobAuditingPolicy(ProxyResource): - """An extended server blob auditing policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar is_devops_audit_enabled: Specifies the state of devops audit. If state is Enabled, devops - logs will be sent to Azure Monitor. - In order to send the events to Azure Monitor, specify 'State' as 'Enabled', - 'IsAzureMonitorTargetEnabled' as true and 'IsDevopsAuditEnabled' as true - - When using REST API to configure auditing, Diagnostic Settings with 'DevOpsOperationsAudit' - diagnostic logs category on the master database should also be created. - - Diagnostic Settings URI format: - PUT - https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/master/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview - - For more information, see `Diagnostic Settings REST API - `_ - or `Diagnostic Settings PowerShell `_. - :vartype is_devops_audit_enabled: bool - :ivar predicate_expression: Specifies condition of where clause when creating an audit. - :vartype predicate_expression: str - :ivar retention_days: Specifies the number of days to keep in the audit logs in the storage - account. - :vartype retention_days: int - :ivar audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. - - The recommended set of action groups to use is the following combination - this will audit all - the queries and stored procedures executed against the database, as well as successful and - failed logins: - - BATCH_COMPLETED_GROUP, - SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, - FAILED_DATABASE_AUTHENTICATION_GROUP. - - This above combination is also the set that is configured by default when enabling auditing - from the Azure portal. - - The supported action groups to audit are (note: choose only specific groups that cover your - auditing needs. Using unnecessary groups could lead to very large quantities of audit records): - - APPLICATION_ROLE_CHANGE_PASSWORD_GROUP - BACKUP_RESTORE_GROUP - DATABASE_LOGOUT_GROUP - DATABASE_OBJECT_CHANGE_GROUP - DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP - DATABASE_OBJECT_PERMISSION_CHANGE_GROUP - DATABASE_OPERATION_GROUP - DATABASE_PERMISSION_CHANGE_GROUP - DATABASE_PRINCIPAL_CHANGE_GROUP - DATABASE_PRINCIPAL_IMPERSONATION_GROUP - DATABASE_ROLE_MEMBER_CHANGE_GROUP - FAILED_DATABASE_AUTHENTICATION_GROUP - SCHEMA_OBJECT_ACCESS_GROUP - SCHEMA_OBJECT_CHANGE_GROUP - SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP - SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP - SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP - USER_CHANGE_PASSWORD_GROUP - BATCH_STARTED_GROUP - BATCH_COMPLETED_GROUP - DBCC_GROUP - DATABASE_OWNERSHIP_CHANGE_GROUP - DATABASE_CHANGE_GROUP - LEDGER_OPERATION_GROUP - - These are groups that cover all sql statements and stored procedures executed against the - database, and should not be used in combination with other groups as this will result in - duplicate audit logs. - - For more information, see `Database-Level Audit Action Groups - `_. - - For Database auditing policy, specific Actions can also be specified (note that Actions cannot - be specified for Server auditing policy). The supported actions to audit are: - SELECT - UPDATE - INSERT - DELETE - EXECUTE - RECEIVE - REFERENCES - - The general form for defining an action to be audited is: - {action} ON {object} BY {principal} - - Note that :code:`` in the above format can refer to an object like a table, view, or - stored procedure, or an entire database or schema. For the latter cases, the forms - DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. - - For example: - SELECT on dbo.myTable by public - SELECT on DATABASE::myDatabase by public - SELECT on SCHEMA::mySchema by public - - For more information, see `Database-Level Audit Actions - `_. - :vartype audit_actions_and_groups: list[str] - :ivar is_storage_secondary_key_in_use: Specifies whether storageAccountAccessKey value is the - storage's secondary key. - :vartype is_storage_secondary_key_in_use: bool - :ivar is_azure_monitor_target_enabled: Specifies whether audit events are sent to Azure - Monitor. - In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and - 'IsAzureMonitorTargetEnabled' as true. - - When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' - diagnostic logs category on the database should be also created. - Note that for server level audit you should use the 'master' database as {databaseName}. - - Diagnostic Settings URI format: - PUT - https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview - - For more information, see `Diagnostic Settings REST API - `_ - or `Diagnostic Settings PowerShell `_. - :vartype is_azure_monitor_target_enabled: bool - :ivar queue_delay_ms: Specifies the amount of time in milliseconds that can elapse before audit - actions are forced to be processed. - The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. - :vartype queue_delay_ms: int - :ivar is_managed_identity_in_use: Specifies whether Managed Identity is used to access blob - storage. - :vartype is_managed_identity_in_use: bool - :ivar state: Specifies the state of the audit. If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled are required. Known values are: "Enabled" and "Disabled". - :vartype state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState - :ivar storage_endpoint: Specifies the blob storage endpoint (e.g. - https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled is required. - :vartype storage_endpoint: str - :ivar storage_account_access_key: Specifies the identifier key of the auditing storage account. - If state is Enabled and storageEndpoint is specified, not specifying the - storageAccountAccessKey will use SQL server system-assigned managed identity to access the - storage. - Prerequisites for using managed identity authentication: - - - #. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). - #. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data - Contributor' RBAC role to the server identity. - For more information, see `Auditing to storage using Managed Identity authentication - `_. - :vartype storage_account_access_key: str - :ivar storage_account_subscription_id: Specifies the blob storage subscription Id. - :vartype storage_account_subscription_id: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "is_devops_audit_enabled": {"key": "properties.isDevopsAuditEnabled", "type": "bool"}, - "predicate_expression": {"key": "properties.predicateExpression", "type": "str"}, - "retention_days": {"key": "properties.retentionDays", "type": "int"}, - "audit_actions_and_groups": {"key": "properties.auditActionsAndGroups", "type": "[str]"}, - "is_storage_secondary_key_in_use": {"key": "properties.isStorageSecondaryKeyInUse", "type": "bool"}, - "is_azure_monitor_target_enabled": {"key": "properties.isAzureMonitorTargetEnabled", "type": "bool"}, - "queue_delay_ms": {"key": "properties.queueDelayMs", "type": "int"}, - "is_managed_identity_in_use": {"key": "properties.isManagedIdentityInUse", "type": "bool"}, - "state": {"key": "properties.state", "type": "str"}, - "storage_endpoint": {"key": "properties.storageEndpoint", "type": "str"}, - "storage_account_access_key": {"key": "properties.storageAccountAccessKey", "type": "str"}, - "storage_account_subscription_id": {"key": "properties.storageAccountSubscriptionId", "type": "str"}, - } - - def __init__( - self, - *, - is_devops_audit_enabled: Optional[bool] = None, - predicate_expression: Optional[str] = None, - retention_days: Optional[int] = None, - audit_actions_and_groups: Optional[list[str]] = None, - is_storage_secondary_key_in_use: Optional[bool] = None, - is_azure_monitor_target_enabled: Optional[bool] = None, - queue_delay_ms: Optional[int] = None, - is_managed_identity_in_use: Optional[bool] = None, - state: Optional[Union[str, "_models.BlobAuditingPolicyState"]] = None, - storage_endpoint: Optional[str] = None, - storage_account_access_key: Optional[str] = None, - storage_account_subscription_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword is_devops_audit_enabled: Specifies the state of devops audit. If state is Enabled, - devops logs will be sent to Azure Monitor. - In order to send the events to Azure Monitor, specify 'State' as 'Enabled', - 'IsAzureMonitorTargetEnabled' as true and 'IsDevopsAuditEnabled' as true - - When using REST API to configure auditing, Diagnostic Settings with 'DevOpsOperationsAudit' - diagnostic logs category on the master database should also be created. - - Diagnostic Settings URI format: - PUT - https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/master/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview - - For more information, see `Diagnostic Settings REST API - `_ - or `Diagnostic Settings PowerShell `_. - :paramtype is_devops_audit_enabled: bool - :keyword predicate_expression: Specifies condition of where clause when creating an audit. - :paramtype predicate_expression: str - :keyword retention_days: Specifies the number of days to keep in the audit logs in the storage - account. - :paramtype retention_days: int - :keyword audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. - - The recommended set of action groups to use is the following combination - this will audit all - the queries and stored procedures executed against the database, as well as successful and - failed logins: - - BATCH_COMPLETED_GROUP, - SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, - FAILED_DATABASE_AUTHENTICATION_GROUP. - - This above combination is also the set that is configured by default when enabling auditing - from the Azure portal. - - The supported action groups to audit are (note: choose only specific groups that cover your - auditing needs. Using unnecessary groups could lead to very large quantities of audit records): - - APPLICATION_ROLE_CHANGE_PASSWORD_GROUP - BACKUP_RESTORE_GROUP - DATABASE_LOGOUT_GROUP - DATABASE_OBJECT_CHANGE_GROUP - DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP - DATABASE_OBJECT_PERMISSION_CHANGE_GROUP - DATABASE_OPERATION_GROUP - DATABASE_PERMISSION_CHANGE_GROUP - DATABASE_PRINCIPAL_CHANGE_GROUP - DATABASE_PRINCIPAL_IMPERSONATION_GROUP - DATABASE_ROLE_MEMBER_CHANGE_GROUP - FAILED_DATABASE_AUTHENTICATION_GROUP - SCHEMA_OBJECT_ACCESS_GROUP - SCHEMA_OBJECT_CHANGE_GROUP - SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP - SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP - SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP - USER_CHANGE_PASSWORD_GROUP - BATCH_STARTED_GROUP - BATCH_COMPLETED_GROUP - DBCC_GROUP - DATABASE_OWNERSHIP_CHANGE_GROUP - DATABASE_CHANGE_GROUP - LEDGER_OPERATION_GROUP - - These are groups that cover all sql statements and stored procedures executed against the - database, and should not be used in combination with other groups as this will result in - duplicate audit logs. - - For more information, see `Database-Level Audit Action Groups - `_. - - For Database auditing policy, specific Actions can also be specified (note that Actions cannot - be specified for Server auditing policy). The supported actions to audit are: - SELECT - UPDATE - INSERT - DELETE - EXECUTE - RECEIVE - REFERENCES - - The general form for defining an action to be audited is: - {action} ON {object} BY {principal} - - Note that :code:`` in the above format can refer to an object like a table, view, or - stored procedure, or an entire database or schema. For the latter cases, the forms - DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. - - For example: - SELECT on dbo.myTable by public - SELECT on DATABASE::myDatabase by public - SELECT on SCHEMA::mySchema by public - - For more information, see `Database-Level Audit Actions - `_. - :paramtype audit_actions_and_groups: list[str] - :keyword is_storage_secondary_key_in_use: Specifies whether storageAccountAccessKey value is - the storage's secondary key. - :paramtype is_storage_secondary_key_in_use: bool - :keyword is_azure_monitor_target_enabled: Specifies whether audit events are sent to Azure - Monitor. - In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and - 'IsAzureMonitorTargetEnabled' as true. - - When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' - diagnostic logs category on the database should be also created. - Note that for server level audit you should use the 'master' database as {databaseName}. - - Diagnostic Settings URI format: - PUT - https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview - - For more information, see `Diagnostic Settings REST API - `_ - or `Diagnostic Settings PowerShell `_. - :paramtype is_azure_monitor_target_enabled: bool - :keyword queue_delay_ms: Specifies the amount of time in milliseconds that can elapse before - audit actions are forced to be processed. - The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. - :paramtype queue_delay_ms: int - :keyword is_managed_identity_in_use: Specifies whether Managed Identity is used to access blob - storage. - :paramtype is_managed_identity_in_use: bool - :keyword state: Specifies the state of the audit. If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled are required. Known values are: "Enabled" and "Disabled". - :paramtype state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState - :keyword storage_endpoint: Specifies the blob storage endpoint (e.g. - https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled is required. - :paramtype storage_endpoint: str - :keyword storage_account_access_key: Specifies the identifier key of the auditing storage - account. - If state is Enabled and storageEndpoint is specified, not specifying the - storageAccountAccessKey will use SQL server system-assigned managed identity to access the - storage. - Prerequisites for using managed identity authentication: - - - #. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). - #. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data - Contributor' RBAC role to the server identity. - For more information, see `Auditing to storage using Managed Identity authentication - `_. - :paramtype storage_account_access_key: str - :keyword storage_account_subscription_id: Specifies the blob storage subscription Id. - :paramtype storage_account_subscription_id: str - """ - super().__init__(**kwargs) - self.is_devops_audit_enabled = is_devops_audit_enabled - self.predicate_expression = predicate_expression - self.retention_days = retention_days - self.audit_actions_and_groups = audit_actions_and_groups - self.is_storage_secondary_key_in_use = is_storage_secondary_key_in_use - self.is_azure_monitor_target_enabled = is_azure_monitor_target_enabled - self.queue_delay_ms = queue_delay_ms - self.is_managed_identity_in_use = is_managed_identity_in_use - self.state = state - self.storage_endpoint = storage_endpoint - self.storage_account_access_key = storage_account_access_key - self.storage_account_subscription_id = storage_account_subscription_id - - -class ExtendedServerBlobAuditingPolicyListResult(_serialization.Model): # pylint: disable=name-too-long - """A list of server extended auditing settings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ExtendedServerBlobAuditingPolicy]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ExtendedServerBlobAuditingPolicy"]] = None - self.next_link: Optional[str] = None - - -class FailoverGroup(ProxyResource): - """A failover group. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar location: Resource location. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar read_write_endpoint: Read-write endpoint of the failover group instance. - :vartype read_write_endpoint: ~azure.mgmt.sql.models.FailoverGroupReadWriteEndpoint - :ivar read_only_endpoint: Read-only endpoint of the failover group instance. - :vartype read_only_endpoint: ~azure.mgmt.sql.models.FailoverGroupReadOnlyEndpoint - :ivar replication_role: Local replication role of the failover group instance. Known values - are: "Primary" and "Secondary". - :vartype replication_role: str or ~azure.mgmt.sql.models.FailoverGroupReplicationRole - :ivar replication_state: Replication state of the failover group instance. - :vartype replication_state: str - :ivar partner_servers: List of partner server information for the failover group. - :vartype partner_servers: list[~azure.mgmt.sql.models.PartnerInfo] - :ivar databases: List of databases in the failover group. - :vartype databases: list[str] - :ivar secondary_type: Databases secondary type on partner server. Known values are: "Geo" and - "Standby". - :vartype secondary_type: str or ~azure.mgmt.sql.models.FailoverGroupDatabasesSecondaryType - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"readonly": True}, - "replication_role": {"readonly": True}, - "replication_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "read_write_endpoint": {"key": "properties.readWriteEndpoint", "type": "FailoverGroupReadWriteEndpoint"}, - "read_only_endpoint": {"key": "properties.readOnlyEndpoint", "type": "FailoverGroupReadOnlyEndpoint"}, - "replication_role": {"key": "properties.replicationRole", "type": "str"}, - "replication_state": {"key": "properties.replicationState", "type": "str"}, - "partner_servers": {"key": "properties.partnerServers", "type": "[PartnerInfo]"}, - "databases": {"key": "properties.databases", "type": "[str]"}, - "secondary_type": {"key": "properties.secondaryType", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[dict[str, str]] = None, - read_write_endpoint: Optional["_models.FailoverGroupReadWriteEndpoint"] = None, - read_only_endpoint: Optional["_models.FailoverGroupReadOnlyEndpoint"] = None, - partner_servers: Optional[list["_models.PartnerInfo"]] = None, - databases: Optional[list[str]] = None, - secondary_type: Optional[Union[str, "_models.FailoverGroupDatabasesSecondaryType"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword read_write_endpoint: Read-write endpoint of the failover group instance. - :paramtype read_write_endpoint: ~azure.mgmt.sql.models.FailoverGroupReadWriteEndpoint - :keyword read_only_endpoint: Read-only endpoint of the failover group instance. - :paramtype read_only_endpoint: ~azure.mgmt.sql.models.FailoverGroupReadOnlyEndpoint - :keyword partner_servers: List of partner server information for the failover group. - :paramtype partner_servers: list[~azure.mgmt.sql.models.PartnerInfo] - :keyword databases: List of databases in the failover group. - :paramtype databases: list[str] - :keyword secondary_type: Databases secondary type on partner server. Known values are: "Geo" - and "Standby". - :paramtype secondary_type: str or ~azure.mgmt.sql.models.FailoverGroupDatabasesSecondaryType - """ - super().__init__(**kwargs) - self.location: Optional[str] = None - self.tags = tags - self.read_write_endpoint = read_write_endpoint - self.read_only_endpoint = read_only_endpoint - self.replication_role: Optional[Union[str, "_models.FailoverGroupReplicationRole"]] = None - self.replication_state: Optional[str] = None - self.partner_servers = partner_servers - self.databases = databases - self.secondary_type = secondary_type - - -class FailoverGroupListResult(_serialization.Model): - """A list of failover groups. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.FailoverGroup] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[FailoverGroup]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.FailoverGroup"]] = None - self.next_link: Optional[str] = None - - -class FailoverGroupReadOnlyEndpoint(_serialization.Model): - """Read-only endpoint of the failover group instance. - - :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, - 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): - """Read-write endpoint of the failover group instance. - - All required parameters must be populated in order to send to server. - - :ivar failover_policy: Failover policy of the read-write endpoint for the failover group. If - failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. Required. - Known values are: "Manual" and "Automatic". - :vartype failover_policy: str or ~azure.mgmt.sql.models.ReadWriteEndpointFailoverPolicy - :ivar failover_with_data_loss_grace_period_minutes: Grace period before failover with data loss - is attempted for the read-write endpoint. If failoverPolicy is Automatic then - failoverWithDataLossGracePeriodMinutes is required. - :vartype failover_with_data_loss_grace_period_minutes: int - """ - - _validation = { - "failover_policy": {"required": True}, - } - - _attribute_map = { - "failover_policy": {"key": "failoverPolicy", "type": "str"}, - "failover_with_data_loss_grace_period_minutes": { - "key": "failoverWithDataLossGracePeriodMinutes", - "type": "int", - }, - } - - def __init__( - self, - *, - failover_policy: Union[str, "_models.ReadWriteEndpointFailoverPolicy"], - failover_with_data_loss_grace_period_minutes: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword failover_policy: Failover policy of the read-write endpoint for the failover group. If - failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. Required. - Known values are: "Manual" and "Automatic". - :paramtype failover_policy: str or ~azure.mgmt.sql.models.ReadWriteEndpointFailoverPolicy - :keyword failover_with_data_loss_grace_period_minutes: Grace period before failover with data - loss is attempted for the read-write endpoint. If failoverPolicy is Automatic then - failoverWithDataLossGracePeriodMinutes is required. - :paramtype failover_with_data_loss_grace_period_minutes: int - """ - super().__init__(**kwargs) - self.failover_policy = failover_policy - self.failover_with_data_loss_grace_period_minutes = failover_with_data_loss_grace_period_minutes - - -class FailoverGroupUpdate(_serialization.Model): - """A failover group update request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar read_write_endpoint: Read-write endpoint of the failover group instance. - :vartype read_write_endpoint: ~azure.mgmt.sql.models.FailoverGroupReadWriteEndpoint - :ivar read_only_endpoint: Read-only endpoint of the failover group instance. - :vartype read_only_endpoint: ~azure.mgmt.sql.models.FailoverGroupReadOnlyEndpoint - :ivar databases: List of databases in the failover group. - :vartype databases: list[str] - :ivar partner_servers: List of partner server information for the failover group. - :vartype partner_servers: list[~azure.mgmt.sql.models.PartnerInfo] - :ivar secondary_type: Databases secondary type on partner server. Known values are: "Geo" and - "Standby". - :vartype secondary_type: str or ~azure.mgmt.sql.models.FailoverGroupDatabasesSecondaryType - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "read_write_endpoint": {"key": "properties.readWriteEndpoint", "type": "FailoverGroupReadWriteEndpoint"}, - "read_only_endpoint": {"key": "properties.readOnlyEndpoint", "type": "FailoverGroupReadOnlyEndpoint"}, - "databases": {"key": "properties.databases", "type": "[str]"}, - "partner_servers": {"key": "properties.partnerServers", "type": "[PartnerInfo]"}, - "secondary_type": {"key": "properties.secondaryType", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[dict[str, str]] = None, - 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, - secondary_type: Optional[Union[str, "_models.FailoverGroupDatabasesSecondaryType"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword read_write_endpoint: Read-write endpoint of the failover group instance. - :paramtype read_write_endpoint: ~azure.mgmt.sql.models.FailoverGroupReadWriteEndpoint - :keyword read_only_endpoint: Read-only endpoint of the failover group instance. - :paramtype read_only_endpoint: ~azure.mgmt.sql.models.FailoverGroupReadOnlyEndpoint - :keyword databases: List of databases in the failover group. - :paramtype databases: list[str] - :keyword partner_servers: List of partner server information for the failover group. - :paramtype partner_servers: list[~azure.mgmt.sql.models.PartnerInfo] - :keyword secondary_type: Databases secondary type on partner server. Known values are: "Geo" - and "Standby". - :paramtype secondary_type: str or ~azure.mgmt.sql.models.FailoverGroupDatabasesSecondaryType - """ - 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 - self.secondary_type = secondary_type - - -class ResourceWithWritableName(_serialization.Model): - """ARM resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, *, name: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword name: Resource name. - :paramtype name: str - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name = name - self.type: Optional[str] = None - - -class ProxyResourceWithWritableName(ResourceWithWritableName): - """ARM proxy resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - -class FirewallRule(ProxyResourceWithWritableName): - """A server firewall rule. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar start_ip_address: The start IP address of the firewall rule. Must be IPv4 format. Use - value '0.0.0.0' for all Azure-internal IP addresses. - :vartype start_ip_address: str - :ivar end_ip_address: The end IP address of the firewall rule. Must be IPv4 format. Must be - greater than or equal to startIpAddress. Use value '0.0.0.0' for all Azure-internal IP - addresses. - :vartype end_ip_address: str - """ - - _validation = { - "id": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "start_ip_address": {"key": "properties.startIpAddress", "type": "str"}, - "end_ip_address": {"key": "properties.endIpAddress", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - start_ip_address: Optional[str] = None, - end_ip_address: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Resource name. - :paramtype name: str - :keyword start_ip_address: The start IP address of the firewall rule. Must be IPv4 format. Use - value '0.0.0.0' for all Azure-internal IP addresses. - :paramtype start_ip_address: str - :keyword end_ip_address: The end IP address of the firewall rule. Must be IPv4 format. Must be - greater than or equal to startIpAddress. Use value '0.0.0.0' for all Azure-internal IP - addresses. - :paramtype end_ip_address: str - """ - super().__init__(name=name, **kwargs) - self.start_ip_address = start_ip_address - self.end_ip_address = end_ip_address - - -class FirewallRuleList(_serialization.Model): - """A list of server firewall rules. - - :ivar values: - :vartype values: list[~azure.mgmt.sql.models.FirewallRule] - """ - - _attribute_map = { - "values": {"key": "values", "type": "[FirewallRule]"}, - } - - def __init__(self, *, values: Optional[list["_models.FirewallRule"]] = None, **kwargs: Any) -> None: - """ - :keyword values: - :paramtype values: list[~azure.mgmt.sql.models.FirewallRule] - """ - super().__init__(**kwargs) - self.values = values - - -class FirewallRuleListResult(_serialization.Model): - """The response to a list firewall rules request. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.FirewallRule] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[FirewallRule]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.FirewallRule"]] = None - self.next_link: Optional[str] = None - - -class GeoBackupPolicy(ProxyResource): - """A database geo backup policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar kind: Kind of geo backup policy. This is metadata used for the Azure portal experience. - :vartype kind: str - :ivar location: Backup policy location. - :vartype location: str - :ivar state: The state of the geo backup policy. Required. Known values are: "Disabled" and - "Enabled". - :vartype state: str or ~azure.mgmt.sql.models.GeoBackupPolicyState - :ivar storage_type: The storage type of the geo backup policy. - :vartype storage_type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "kind": {"readonly": True}, - "location": {"readonly": True}, - "state": {"required": True}, - "storage_type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "state": {"key": "properties.state", "type": "str"}, - "storage_type": {"key": "properties.storageType", "type": "str"}, - } - - def __init__(self, *, state: Union[str, "_models.GeoBackupPolicyState"], **kwargs: Any) -> None: - """ - :keyword state: The state of the geo backup policy. Required. Known values are: "Disabled" and - "Enabled". - :paramtype state: str or ~azure.mgmt.sql.models.GeoBackupPolicyState - """ - super().__init__(**kwargs) - self.kind: Optional[str] = None - self.location: Optional[str] = None - self.state = state - self.storage_type: Optional[str] = None - - -class GeoBackupPolicyListResult(_serialization.Model): - """The response to a list geo backup policies request. - - :ivar value: The list of geo backup policies. - :vartype value: list[~azure.mgmt.sql.models.GeoBackupPolicy] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[GeoBackupPolicy]"}, - } - - 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] - """ - super().__init__(**kwargs) - self.value = value - - -class ImportExistingDatabaseDefinition(_serialization.Model): - """Contains the information necessary to perform import operation for existing database. - - All required parameters must be populated in order to send to server. - - :ivar storage_key_type: Storage key type. Required. Known values are: "SharedAccessKey", - "StorageAccessKey", and "ManagedIdentity". - :vartype storage_key_type: str or ~azure.mgmt.sql.models.StorageKeyType - :ivar storage_key: Storage key. Required. - :vartype storage_key: str - :ivar storage_uri: Storage Uri. Required. - :vartype storage_uri: str - :ivar administrator_login: Administrator login name. Required. - :vartype administrator_login: str - :ivar administrator_login_password: Administrator login password. Required. - :vartype administrator_login_password: str - :ivar authentication_type: Authentication type. - :vartype authentication_type: str - :ivar network_isolation: Optional resource information to enable network isolation for request. - :vartype network_isolation: ~azure.mgmt.sql.models.NetworkIsolationSettings - """ - - _validation = { - "storage_key_type": {"required": True}, - "storage_key": {"required": True}, - "storage_uri": {"required": True}, - "administrator_login": {"required": True}, - "administrator_login_password": {"required": True}, - } - - _attribute_map = { - "storage_key_type": {"key": "storageKeyType", "type": "str"}, - "storage_key": {"key": "storageKey", "type": "str"}, - "storage_uri": {"key": "storageUri", "type": "str"}, - "administrator_login": {"key": "administratorLogin", "type": "str"}, - "administrator_login_password": {"key": "administratorLoginPassword", "type": "str"}, - "authentication_type": {"key": "authenticationType", "type": "str"}, - "network_isolation": {"key": "networkIsolation", "type": "NetworkIsolationSettings"}, - } - - def __init__( - self, - *, - storage_key_type: Union[str, "_models.StorageKeyType"], - storage_key: str, - storage_uri: str, - administrator_login: str, - administrator_login_password: str, - authentication_type: Optional[str] = None, - network_isolation: Optional["_models.NetworkIsolationSettings"] = None, - **kwargs: Any - ) -> None: - """ - :keyword storage_key_type: Storage key type. Required. Known values are: "SharedAccessKey", - "StorageAccessKey", and "ManagedIdentity". - :paramtype storage_key_type: str or ~azure.mgmt.sql.models.StorageKeyType - :keyword storage_key: Storage key. Required. - :paramtype storage_key: str - :keyword storage_uri: Storage Uri. Required. - :paramtype storage_uri: str - :keyword administrator_login: Administrator login name. Required. - :paramtype administrator_login: str - :keyword administrator_login_password: Administrator login password. Required. - :paramtype administrator_login_password: str - :keyword authentication_type: Authentication type. - :paramtype authentication_type: str - :keyword network_isolation: Optional resource information to enable network isolation for - request. - :paramtype network_isolation: ~azure.mgmt.sql.models.NetworkIsolationSettings - """ - super().__init__(**kwargs) - 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.network_isolation = network_isolation - - -class ImportExportExtensionsOperationListResult(_serialization.Model): # pylint: disable=name-too-long - """Import export operation extensions list. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ImportExportExtensionsOperationResult] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ImportExportExtensionsOperationResult]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ImportExportExtensionsOperationResult"]] = None - self.next_link: Optional[str] = None - - -class ImportExportExtensionsOperationResult(ProxyResource): - """An Extension operation result resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar request_id: Request Id. - :vartype request_id: str - :ivar request_type: Request type. - :vartype request_type: str - :ivar last_modified_time: Last modified time. - :vartype last_modified_time: str - :ivar server_name: Server name. - :vartype server_name: str - :ivar database_name: Database name. - :vartype database_name: str - :ivar status: Operation status. - :vartype status: str - :ivar error_message: Error message. - :vartype error_message: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "request_id": {"readonly": True}, - "request_type": {"readonly": True}, - "last_modified_time": {"readonly": True}, - "server_name": {"readonly": True}, - "database_name": {"readonly": True}, - "status": {"readonly": True}, - "error_message": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "request_id": {"key": "properties.requestId", "type": "str"}, - "request_type": {"key": "properties.requestType", "type": "str"}, - "last_modified_time": {"key": "properties.lastModifiedTime", "type": "str"}, - "server_name": {"key": "properties.serverName", "type": "str"}, - "database_name": {"key": "properties.databaseName", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "error_message": {"key": "properties.errorMessage", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.request_id: Optional[str] = None - self.request_type: Optional[str] = None - self.last_modified_time: Optional[str] = None - self.server_name: Optional[str] = None - self.database_name: Optional[str] = None - self.status: Optional[str] = None - self.error_message: Optional[str] = None - - -class ImportExportOperationResult(ProxyResource): - """An ImportExport operation result resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar request_id: Request Id. - :vartype request_id: str - :ivar request_type: Request type. - :vartype request_type: str - :ivar queued_time: Queued time. - :vartype queued_time: str - :ivar last_modified_time: Last modified time. - :vartype last_modified_time: str - :ivar blob_uri: Blob Uri. - :vartype blob_uri: str - :ivar server_name: Server name. - :vartype server_name: str - :ivar database_name: Database name. - :vartype database_name: str - :ivar status: Operation status. - :vartype status: str - :ivar error_message: Error message. - :vartype error_message: str - :ivar private_endpoint_connections: Gets the status of private endpoints associated with this - request. - :vartype private_endpoint_connections: - list[~azure.mgmt.sql.models.PrivateEndpointConnectionRequestStatus] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "request_id": {"readonly": True}, - "request_type": {"readonly": True}, - "queued_time": {"readonly": True}, - "last_modified_time": {"readonly": True}, - "blob_uri": {"readonly": True}, - "server_name": {"readonly": True}, - "database_name": {"readonly": True}, - "status": {"readonly": True}, - "error_message": {"readonly": True}, - "private_endpoint_connections": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "request_id": {"key": "properties.requestId", "type": "str"}, - "request_type": {"key": "properties.requestType", "type": "str"}, - "queued_time": {"key": "properties.queuedTime", "type": "str"}, - "last_modified_time": {"key": "properties.lastModifiedTime", "type": "str"}, - "blob_uri": {"key": "properties.blobUri", "type": "str"}, - "server_name": {"key": "properties.serverName", "type": "str"}, - "database_name": {"key": "properties.databaseName", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "error_message": {"key": "properties.errorMessage", "type": "str"}, - "private_endpoint_connections": { - "key": "properties.privateEndpointConnections", - "type": "[PrivateEndpointConnectionRequestStatus]", - }, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.request_id: Optional[str] = None - self.request_type: Optional[str] = None - self.queued_time: Optional[str] = None - self.last_modified_time: Optional[str] = None - self.blob_uri: Optional[str] = None - self.server_name: Optional[str] = None - self.database_name: Optional[str] = None - self.status: Optional[str] = None - self.error_message: Optional[str] = None - self.private_endpoint_connections: Optional[list["_models.PrivateEndpointConnectionRequestStatus"]] = None - - -class ImportNewDatabaseDefinition(_serialization.Model): - """Contains the information necessary to perform import operation for new database. - - All required parameters must be populated in order to send to server. - - :ivar database_name: Name of the import database. - :vartype database_name: str - :ivar edition: Edition of the import database. - :vartype edition: str - :ivar service_objective_name: Service level objective name of the import database. - :vartype service_objective_name: str - :ivar max_size_bytes: Max size in bytes for the import database. - :vartype max_size_bytes: str - :ivar storage_key_type: Storage key type: StorageAccessKey, SharedAccessKey, or - ManagedIdentity. Required. Known values are: "SharedAccessKey", "StorageAccessKey", and - "ManagedIdentity". - :vartype storage_key_type: str or ~azure.mgmt.sql.models.StorageKeyType - :ivar storage_key: Storage key for the storage account. If StorageKeyType is ManagedIdentity, - this field should specify the Managed Identity's resource ID. Required. - :vartype storage_key: str - :ivar storage_uri: Storage Uri. Required. - :vartype storage_uri: str - :ivar administrator_login: Administrator login name. If AuthenticationType is ManagedIdentity, - this field should specify the Managed Identity's resource ID. Required. - :vartype administrator_login: str - :ivar administrator_login_password: Administrator login password. If AuthenticationType is - ManagedIdentity, this field should not be specified. - :vartype administrator_login_password: str - :ivar authentication_type: Type of credentials provided for access to the target SQL server: - SQL, ADPassword or ManagedIdentity. - :vartype authentication_type: str - :ivar network_isolation: Optional resource information to enable network isolation for request. - :vartype network_isolation: ~azure.mgmt.sql.models.NetworkIsolationSettings - """ - - _validation = { - "storage_key_type": {"required": True}, - "storage_key": {"required": True}, - "storage_uri": {"required": True}, - "administrator_login": {"required": True}, - } - - _attribute_map = { - "database_name": {"key": "databaseName", "type": "str"}, - "edition": {"key": "edition", "type": "str"}, - "service_objective_name": {"key": "serviceObjectiveName", "type": "str"}, - "max_size_bytes": {"key": "maxSizeBytes", "type": "str"}, - "storage_key_type": {"key": "storageKeyType", "type": "str"}, - "storage_key": {"key": "storageKey", "type": "str"}, - "storage_uri": {"key": "storageUri", "type": "str"}, - "administrator_login": {"key": "administratorLogin", "type": "str"}, - "administrator_login_password": {"key": "administratorLoginPassword", "type": "str"}, - "authentication_type": {"key": "authenticationType", "type": "str"}, - "network_isolation": {"key": "networkIsolation", "type": "NetworkIsolationSettings"}, - } - - def __init__( - self, - *, - storage_key_type: Union[str, "_models.StorageKeyType"], - storage_key: str, - storage_uri: str, - administrator_login: str, - database_name: Optional[str] = None, - edition: Optional[str] = None, - service_objective_name: Optional[str] = None, - max_size_bytes: Optional[str] = None, - administrator_login_password: Optional[str] = None, - authentication_type: Optional[str] = None, - network_isolation: Optional["_models.NetworkIsolationSettings"] = None, - **kwargs: Any - ) -> None: - """ - :keyword database_name: Name of the import database. - :paramtype database_name: str - :keyword edition: Edition of the import database. - :paramtype edition: str - :keyword service_objective_name: Service level objective name of the import database. - :paramtype service_objective_name: str - :keyword max_size_bytes: Max size in bytes for the import database. - :paramtype max_size_bytes: str - :keyword storage_key_type: Storage key type: StorageAccessKey, SharedAccessKey, or - ManagedIdentity. Required. Known values are: "SharedAccessKey", "StorageAccessKey", and - "ManagedIdentity". - :paramtype storage_key_type: str or ~azure.mgmt.sql.models.StorageKeyType - :keyword storage_key: Storage key for the storage account. If StorageKeyType is - ManagedIdentity, this field should specify the Managed Identity's resource ID. Required. - :paramtype storage_key: str - :keyword storage_uri: Storage Uri. Required. - :paramtype storage_uri: str - :keyword administrator_login: Administrator login name. If AuthenticationType is - ManagedIdentity, this field should specify the Managed Identity's resource ID. Required. - :paramtype administrator_login: str - :keyword administrator_login_password: Administrator login password. If AuthenticationType is - ManagedIdentity, this field should not be specified. - :paramtype administrator_login_password: str - :keyword authentication_type: Type of credentials provided for access to the target SQL server: - SQL, ADPassword or ManagedIdentity. - :paramtype authentication_type: str - :keyword network_isolation: Optional resource information to enable network isolation for - request. - :paramtype network_isolation: ~azure.mgmt.sql.models.NetworkIsolationSettings - """ - super().__init__(**kwargs) - self.database_name = database_name - self.edition = edition - self.service_objective_name = service_objective_name - self.max_size_bytes = max_size_bytes - 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.network_isolation = network_isolation - - -class InstanceFailoverGroup(ProxyResource): - """An instance failover group. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar secondary_type: Type of the geo-secondary instance. Set 'Standby' if the instance is used - as a DR option only. Known values are: "Geo" and "Standby". - :vartype secondary_type: str or ~azure.mgmt.sql.models.SecondaryInstanceType - :ivar read_write_endpoint: Read-write endpoint of the failover group instance. - :vartype read_write_endpoint: ~azure.mgmt.sql.models.InstanceFailoverGroupReadWriteEndpoint - :ivar read_only_endpoint: Read-only endpoint of the failover group instance. - :vartype read_only_endpoint: ~azure.mgmt.sql.models.InstanceFailoverGroupReadOnlyEndpoint - :ivar replication_role: Local replication role of the failover group instance. Known values - are: "Primary" and "Secondary". - :vartype replication_role: str or ~azure.mgmt.sql.models.InstanceFailoverGroupReplicationRole - :ivar replication_state: Replication state of the failover group instance. - :vartype replication_state: str - :ivar partner_regions: Partner region information for the failover group. - :vartype partner_regions: list[~azure.mgmt.sql.models.PartnerRegionInfo] - :ivar managed_instance_pairs: List of managed instance pairs in the failover group. - :vartype managed_instance_pairs: list[~azure.mgmt.sql.models.ManagedInstancePairInfo] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "replication_role": {"readonly": True}, - "replication_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "secondary_type": {"key": "properties.secondaryType", "type": "str"}, - "read_write_endpoint": { - "key": "properties.readWriteEndpoint", - "type": "InstanceFailoverGroupReadWriteEndpoint", - }, - "read_only_endpoint": {"key": "properties.readOnlyEndpoint", "type": "InstanceFailoverGroupReadOnlyEndpoint"}, - "replication_role": {"key": "properties.replicationRole", "type": "str"}, - "replication_state": {"key": "properties.replicationState", "type": "str"}, - "partner_regions": {"key": "properties.partnerRegions", "type": "[PartnerRegionInfo]"}, - "managed_instance_pairs": {"key": "properties.managedInstancePairs", "type": "[ManagedInstancePairInfo]"}, - } - - def __init__( - self, - *, - secondary_type: Optional[Union[str, "_models.SecondaryInstanceType"]] = None, - read_write_endpoint: Optional["_models.InstanceFailoverGroupReadWriteEndpoint"] = None, - read_only_endpoint: Optional["_models.InstanceFailoverGroupReadOnlyEndpoint"] = None, - partner_regions: Optional[list["_models.PartnerRegionInfo"]] = None, - managed_instance_pairs: Optional[list["_models.ManagedInstancePairInfo"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword secondary_type: Type of the geo-secondary instance. Set 'Standby' if the instance is - used as a DR option only. Known values are: "Geo" and "Standby". - :paramtype secondary_type: str or ~azure.mgmt.sql.models.SecondaryInstanceType - :keyword read_write_endpoint: Read-write endpoint of the failover group instance. - :paramtype read_write_endpoint: ~azure.mgmt.sql.models.InstanceFailoverGroupReadWriteEndpoint - :keyword read_only_endpoint: Read-only endpoint of the failover group instance. - :paramtype read_only_endpoint: ~azure.mgmt.sql.models.InstanceFailoverGroupReadOnlyEndpoint - :keyword partner_regions: Partner region information for the failover group. - :paramtype partner_regions: list[~azure.mgmt.sql.models.PartnerRegionInfo] - :keyword managed_instance_pairs: List of managed instance pairs in the failover group. - :paramtype managed_instance_pairs: list[~azure.mgmt.sql.models.ManagedInstancePairInfo] - """ - super().__init__(**kwargs) - self.secondary_type = secondary_type - self.read_write_endpoint = read_write_endpoint - self.read_only_endpoint = read_only_endpoint - self.replication_role: Optional[Union[str, "_models.InstanceFailoverGroupReplicationRole"]] = None - self.replication_state: Optional[str] = None - self.partner_regions = partner_regions - self.managed_instance_pairs = managed_instance_pairs - - -class InstanceFailoverGroupListResult(_serialization.Model): - """A list of instance failover groups. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.InstanceFailoverGroup] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[InstanceFailoverGroup]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.InstanceFailoverGroup"]] = None - self.next_link: Optional[str] = None - - -class InstanceFailoverGroupReadOnlyEndpoint(_serialization.Model): - """Read-only endpoint of the failover group instance. - - :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 - """ - - _attribute_map = { - "failover_policy": {"key": "failoverPolicy", "type": "str"}, - } - - def __init__( - self, *, failover_policy: Optional[Union[str, "_models.ReadOnlyEndpointFailoverPolicy"]] = 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 - """ - super().__init__(**kwargs) - self.failover_policy = failover_policy - - -class InstanceFailoverGroupReadWriteEndpoint(_serialization.Model): - """Read-write endpoint of the failover group instance. - - All required parameters must be populated in order to send to server. - - :ivar failover_policy: Failover policy of the read-write endpoint for the failover group. If - failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. Required. - Known values are: "Manual" and "Automatic". - :vartype failover_policy: str or ~azure.mgmt.sql.models.ReadWriteEndpointFailoverPolicy - :ivar failover_with_data_loss_grace_period_minutes: Grace period before failover with data loss - is attempted for the read-write endpoint. If failoverPolicy is Automatic then - failoverWithDataLossGracePeriodMinutes is required. - :vartype failover_with_data_loss_grace_period_minutes: int - """ - - _validation = { - "failover_policy": {"required": True}, - } - - _attribute_map = { - "failover_policy": {"key": "failoverPolicy", "type": "str"}, - "failover_with_data_loss_grace_period_minutes": { - "key": "failoverWithDataLossGracePeriodMinutes", - "type": "int", - }, - } - - def __init__( - self, - *, - failover_policy: Union[str, "_models.ReadWriteEndpointFailoverPolicy"], - failover_with_data_loss_grace_period_minutes: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword failover_policy: Failover policy of the read-write endpoint for the failover group. If - failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required. Required. - Known values are: "Manual" and "Automatic". - :paramtype failover_policy: str or ~azure.mgmt.sql.models.ReadWriteEndpointFailoverPolicy - :keyword failover_with_data_loss_grace_period_minutes: Grace period before failover with data - loss is attempted for the read-write endpoint. If failoverPolicy is Automatic then - failoverWithDataLossGracePeriodMinutes is required. - :paramtype failover_with_data_loss_grace_period_minutes: int - """ - super().__init__(**kwargs) - self.failover_policy = failover_policy - self.failover_with_data_loss_grace_period_minutes = failover_with_data_loss_grace_period_minutes - - -class InstancePool(TrackedResource): - """An Azure SQL instance pool. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: The name and tier of the SKU. - :vartype sku: ~azure.mgmt.sql.models.Sku - :ivar subnet_id: Resource ID of the subnet to place this instance pool in. - :vartype subnet_id: str - :ivar v_cores: Count of vCores belonging to this instance pool. - :vartype v_cores: int - :ivar license_type: The license type. Possible values are 'LicenseIncluded' (price for SQL - license is included) and 'BasePrice' (without SQL license price). Known values are: - "LicenseIncluded" and "BasePrice". - :vartype license_type: str or ~azure.mgmt.sql.models.InstancePoolLicenseType - :ivar dns_zone: The Dns Zone that the managed instance pool is in. - :vartype dns_zone: str - :ivar maintenance_configuration_id: Specifies maintenance configuration id to apply to this - managed instance. - :vartype maintenance_configuration_id: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "dns_zone": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "Sku"}, - "subnet_id": {"key": "properties.subnetId", "type": "str"}, - "v_cores": {"key": "properties.vCores", "type": "int"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - "dns_zone": {"key": "properties.dnsZone", "type": "str"}, - "maintenance_configuration_id": {"key": "properties.maintenanceConfigurationId", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - subnet_id: Optional[str] = None, - v_cores: Optional[int] = None, - license_type: Optional[Union[str, "_models.InstancePoolLicenseType"]] = None, - maintenance_configuration_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The name and tier of the SKU. - :paramtype sku: ~azure.mgmt.sql.models.Sku - :keyword subnet_id: Resource ID of the subnet to place this instance pool in. - :paramtype subnet_id: str - :keyword v_cores: Count of vCores belonging to this instance pool. - :paramtype v_cores: int - :keyword license_type: The license type. Possible values are 'LicenseIncluded' (price for SQL - license is included) and 'BasePrice' (without SQL license price). Known values are: - "LicenseIncluded" and "BasePrice". - :paramtype license_type: str or ~azure.mgmt.sql.models.InstancePoolLicenseType - :keyword maintenance_configuration_id: Specifies maintenance configuration id to apply to this - managed instance. - :paramtype maintenance_configuration_id: str - """ - super().__init__(location=location, tags=tags, **kwargs) - self.sku = sku - self.subnet_id = subnet_id - self.v_cores = v_cores - self.license_type = license_type - self.dns_zone: Optional[str] = None - self.maintenance_configuration_id = maintenance_configuration_id - - -class InstancePoolEditionCapability(_serialization.Model): - """The instance pool capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The instance pool version name. - :vartype name: str - :ivar supported_families: The supported families. - :vartype supported_families: list[~azure.mgmt.sql.models.InstancePoolFamilyCapability] - :ivar status: The status of the capability. 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_families": {"readonly": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "supported_families": {"key": "supportedFamilies", "type": "[InstancePoolFamilyCapability]"}, - "status": {"key": "status", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - } - - def __init__(self, *, 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: Optional[str] = None - self.supported_families: Optional[list["_models.InstancePoolFamilyCapability"]] = None - self.status: Optional[Union[str, "_models.CapabilityStatus"]] = None - self.reason = reason - - -class InstancePoolFamilyCapability(_serialization.Model): - """The instance pool family capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Family name. - :vartype name: str - :ivar supported_license_types: List of supported license types. - :vartype supported_license_types: list[~azure.mgmt.sql.models.LicenseTypeCapability] - :ivar supported_vcores_values: List of supported virtual cores values. - :vartype supported_vcores_values: list[~azure.mgmt.sql.models.InstancePoolVcoresCapability] - :ivar status: The status of the capability. 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_license_types": {"readonly": True}, - "supported_vcores_values": {"readonly": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "supported_license_types": {"key": "supportedLicenseTypes", "type": "[LicenseTypeCapability]"}, - "supported_vcores_values": {"key": "supportedVcoresValues", "type": "[InstancePoolVcoresCapability]"}, - "status": {"key": "status", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - } - - def __init__(self, *, 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: Optional[str] = None - self.supported_license_types: Optional[list["_models.LicenseTypeCapability"]] = None - self.supported_vcores_values: Optional[list["_models.InstancePoolVcoresCapability"]] = None - self.status: Optional[Union[str, "_models.CapabilityStatus"]] = None - self.reason = reason - - -class InstancePoolListResult(_serialization.Model): - """A list of Azure SQL instance pools. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.InstancePool] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[InstancePool]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.InstancePool"]] = None - self.next_link: Optional[str] = None - - -class InstancePoolUpdate(_serialization.Model): - """An update to an Instance pool. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar sku: The name and tier of the SKU. - :vartype sku: ~azure.mgmt.sql.models.Sku - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar subnet_id: Resource ID of the subnet to place this instance pool in. - :vartype subnet_id: str - :ivar v_cores: Count of vCores belonging to this instance pool. - :vartype v_cores: int - :ivar license_type: The license type. Possible values are 'LicenseIncluded' (price for SQL - license is included) and 'BasePrice' (without SQL license price). Known values are: - "LicenseIncluded" and "BasePrice". - :vartype license_type: str or ~azure.mgmt.sql.models.InstancePoolLicenseType - :ivar dns_zone: The Dns Zone that the managed instance pool is in. - :vartype dns_zone: str - :ivar maintenance_configuration_id: Specifies maintenance configuration id to apply to this - managed instance. - :vartype maintenance_configuration_id: str - """ - - _validation = { - "dns_zone": {"readonly": True}, - } - - _attribute_map = { - "sku": {"key": "sku", "type": "Sku"}, - "tags": {"key": "tags", "type": "{str}"}, - "subnet_id": {"key": "properties.subnetId", "type": "str"}, - "v_cores": {"key": "properties.vCores", "type": "int"}, - "license_type": {"key": "properties.licenseType", "type": "str"}, - "dns_zone": {"key": "properties.dnsZone", "type": "str"}, - "maintenance_configuration_id": {"key": "properties.maintenanceConfigurationId", "type": "str"}, - } - - def __init__( - self, - *, - sku: Optional["_models.Sku"] = None, - tags: Optional[dict[str, str]] = None, - subnet_id: Optional[str] = None, - v_cores: Optional[int] = None, - license_type: Optional[Union[str, "_models.InstancePoolLicenseType"]] = None, - maintenance_configuration_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword sku: The name and tier of the SKU. - :paramtype sku: ~azure.mgmt.sql.models.Sku - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword subnet_id: Resource ID of the subnet to place this instance pool in. - :paramtype subnet_id: str - :keyword v_cores: Count of vCores belonging to this instance pool. - :paramtype v_cores: int - :keyword license_type: The license type. Possible values are 'LicenseIncluded' (price for SQL - license is included) and 'BasePrice' (without SQL license price). Known values are: - "LicenseIncluded" and "BasePrice". - :paramtype license_type: str or ~azure.mgmt.sql.models.InstancePoolLicenseType - :keyword maintenance_configuration_id: Specifies maintenance configuration id to apply to this - managed instance. - :paramtype maintenance_configuration_id: str - """ - super().__init__(**kwargs) - self.sku = sku - self.tags = tags - self.subnet_id = subnet_id - self.v_cores = v_cores - self.license_type = license_type - self.dns_zone: Optional[str] = None - self.maintenance_configuration_id = maintenance_configuration_id - - -class InstancePoolVcoresCapability(_serialization.Model): - """The managed instance virtual cores capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The virtual cores identifier. - :vartype name: str - :ivar value: The virtual cores value. - :vartype value: int - :ivar storage_limit: Storage limit. - :vartype storage_limit: ~azure.mgmt.sql.models.MaxSizeCapability - :ivar status: The status of the capability. 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}, - "value": {"readonly": True}, - "storage_limit": {"readonly": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "value": {"key": "value", "type": "int"}, - "storage_limit": {"key": "storageLimit", "type": "MaxSizeCapability"}, - "status": {"key": "status", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - } - - def __init__(self, *, 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: Optional[str] = None - self.value: Optional[int] = None - self.storage_limit: Optional["_models.MaxSizeCapability"] = None - self.status: Optional[Union[str, "_models.CapabilityStatus"]] = None - self.reason = reason - - -class IPv6FirewallRule(ProxyResourceWithWritableName): - """An IPv6 server firewall rule. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar start_i_pv6_address: The start IP address of the firewall rule. Must be IPv6 format. - :vartype start_i_pv6_address: str - :ivar end_i_pv6_address: The end IP address of the firewall rule. Must be IPv6 format. Must be - greater than or equal to startIpv6Address. - :vartype end_i_pv6_address: str - """ - - _validation = { - "id": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "start_i_pv6_address": {"key": "properties.startIPv6Address", "type": "str"}, - "end_i_pv6_address": {"key": "properties.endIPv6Address", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - start_i_pv6_address: Optional[str] = None, - end_i_pv6_address: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Resource name. - :paramtype name: str - :keyword start_i_pv6_address: The start IP address of the firewall rule. Must be IPv6 format. - :paramtype start_i_pv6_address: str - :keyword end_i_pv6_address: The end IP address of the firewall rule. Must be IPv6 format. Must - be greater than or equal to startIpv6Address. - :paramtype end_i_pv6_address: str - """ - super().__init__(name=name, **kwargs) - self.start_i_pv6_address = start_i_pv6_address - self.end_i_pv6_address = end_i_pv6_address - - -class IPv6FirewallRuleListResult(_serialization.Model): - """The response to a list IPv6 firewall rules request. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.IPv6FirewallRule] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[IPv6FirewallRule]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.IPv6FirewallRule"]] = None - self.next_link: Optional[str] = None - - -class Job(ProxyResource): - """A job. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar description: User-defined description of the job. - :vartype description: str - :ivar version: The job version number. - :vartype version: int - :ivar schedule: Schedule properties of the job. - :vartype schedule: ~azure.mgmt.sql.models.JobSchedule - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "version": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "version": {"key": "properties.version", "type": "int"}, - "schedule": {"key": "properties.schedule", "type": "JobSchedule"}, - } - - def __init__( - self, *, description: str = "", schedule: Optional["_models.JobSchedule"] = None, **kwargs: Any - ) -> None: - """ - :keyword description: User-defined description of the job. - :paramtype description: str - :keyword schedule: Schedule properties of the job. - :paramtype schedule: ~azure.mgmt.sql.models.JobSchedule - """ - super().__init__(**kwargs) - self.description = description - self.version: Optional[int] = None - self.schedule = schedule - - -class JobAgent(TrackedResource): - """An Azure SQL job agent. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: The name and tier of the SKU. - :vartype sku: ~azure.mgmt.sql.models.Sku - :ivar database_id: Resource ID of the database to store job metadata in. - :vartype database_id: str - :ivar state: The state of the job agent. Known values are: "Creating", "Ready", "Updating", - "Deleting", and "Disabled". - :vartype state: str or ~azure.mgmt.sql.models.JobAgentState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "Sku"}, - "database_id": {"key": "properties.databaseId", "type": "str"}, - "state": {"key": "properties.state", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - database_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The name and tier of the SKU. - :paramtype sku: ~azure.mgmt.sql.models.Sku - :keyword database_id: Resource ID of the database to store job metadata in. - :paramtype database_id: str - """ - super().__init__(location=location, tags=tags, **kwargs) - self.sku = sku - self.database_id = database_id - self.state: Optional[Union[str, "_models.JobAgentState"]] = None - - -class JobAgentListResult(_serialization.Model): - """A list of Azure SQL job agents. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.JobAgent] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[JobAgent]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.JobAgent"]] = None - self.next_link: Optional[str] = None - - -class JobAgentUpdate(_serialization.Model): - """An update to an Azure SQL job agent. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -class JobCredential(ProxyResource): - """A stored credential that can be used by a job to connect to target databases. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar username: The credential user name. - :vartype username: str - :ivar password: The credential password. - :vartype password: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "username": {"key": "properties.username", "type": "str"}, - "password": {"key": "properties.password", "type": "str"}, - } - - def __init__(self, *, username: Optional[str] = None, password: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword username: The credential user name. - :paramtype username: str - :keyword password: The credential password. - :paramtype password: str - """ - super().__init__(**kwargs) - self.username = username - self.password = password - - -class JobCredentialListResult(_serialization.Model): - """A list of job credentials. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.JobCredential] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[JobCredential]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.JobCredential"]] = None - self.next_link: Optional[str] = None - - -class JobExecution(ProxyResource): - """An execution of a job. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar job_version: The job version number. - :vartype job_version: int - :ivar step_name: The job step name. - :vartype step_name: str - :ivar step_id: The job step id. - :vartype step_id: int - :ivar job_execution_id: The unique identifier of the job execution. - :vartype job_execution_id: str - :ivar lifecycle: The detailed state of the job execution. Known values are: "Created", - "InProgress", "WaitingForChildJobExecutions", "WaitingForRetry", "Succeeded", - "SucceededWithSkipped", "Failed", "TimedOut", "Canceled", and "Skipped". - :vartype lifecycle: str or ~azure.mgmt.sql.models.JobExecutionLifecycle - :ivar provisioning_state: The ARM provisioning state of the job execution. Known values are: - "Created", "InProgress", "Succeeded", "Failed", and "Canceled". - :vartype provisioning_state: str or ~azure.mgmt.sql.models.ProvisioningState - :ivar create_time: The time that the job execution was created. - :vartype create_time: ~datetime.datetime - :ivar start_time: The time that the job execution started. - :vartype start_time: ~datetime.datetime - :ivar end_time: The time that the job execution completed. - :vartype end_time: ~datetime.datetime - :ivar current_attempts: Number of times the job execution has been attempted. - :vartype current_attempts: int - :ivar current_attempt_start_time: Start time of the current attempt. - :vartype current_attempt_start_time: ~datetime.datetime - :ivar last_message: The last status or error message. - :vartype last_message: str - :ivar target: The target that this execution is executed on. - :vartype target: ~azure.mgmt.sql.models.JobExecutionTarget - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "job_version": {"readonly": True}, - "step_name": {"readonly": True}, - "step_id": {"readonly": True}, - "job_execution_id": {"readonly": True}, - "lifecycle": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "create_time": {"readonly": True}, - "start_time": {"readonly": True}, - "end_time": {"readonly": True}, - "current_attempt_start_time": {"readonly": True}, - "last_message": {"readonly": True}, - "target": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "job_version": {"key": "properties.jobVersion", "type": "int"}, - "step_name": {"key": "properties.stepName", "type": "str"}, - "step_id": {"key": "properties.stepId", "type": "int"}, - "job_execution_id": {"key": "properties.jobExecutionId", "type": "str"}, - "lifecycle": {"key": "properties.lifecycle", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "create_time": {"key": "properties.createTime", "type": "iso-8601"}, - "start_time": {"key": "properties.startTime", "type": "iso-8601"}, - "end_time": {"key": "properties.endTime", "type": "iso-8601"}, - "current_attempts": {"key": "properties.currentAttempts", "type": "int"}, - "current_attempt_start_time": {"key": "properties.currentAttemptStartTime", "type": "iso-8601"}, - "last_message": {"key": "properties.lastMessage", "type": "str"}, - "target": {"key": "properties.target", "type": "JobExecutionTarget"}, - } - - def __init__(self, *, current_attempts: Optional[int] = None, **kwargs: Any) -> None: - """ - :keyword current_attempts: Number of times the job execution has been attempted. - :paramtype current_attempts: int - """ - super().__init__(**kwargs) - self.job_version: Optional[int] = None - self.step_name: Optional[str] = None - self.step_id: Optional[int] = None - self.job_execution_id: Optional[str] = None - self.lifecycle: Optional[Union[str, "_models.JobExecutionLifecycle"]] = None - self.provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None - self.create_time: Optional[datetime.datetime] = None - self.start_time: Optional[datetime.datetime] = None - self.end_time: Optional[datetime.datetime] = None - self.current_attempts = current_attempts - self.current_attempt_start_time: Optional[datetime.datetime] = None - self.last_message: Optional[str] = None - self.target: Optional["_models.JobExecutionTarget"] = None - - -class JobExecutionListResult(_serialization.Model): - """A list of job executions. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.JobExecution] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[JobExecution]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.JobExecution"]] = None - self.next_link: Optional[str] = None - - -class JobExecutionTarget(_serialization.Model): - """The target that a job execution is executed on. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The type of the target. Known values are: "TargetGroup", "SqlDatabase", - "SqlElasticPool", "SqlShardMap", and "SqlServer". - :vartype type: str or ~azure.mgmt.sql.models.JobTargetType - :ivar server_name: The server name. - :vartype server_name: str - :ivar database_name: The database name. - :vartype database_name: str - """ - - _validation = { - "type": {"readonly": True}, - "server_name": {"readonly": True}, - "database_name": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "server_name": {"key": "serverName", "type": "str"}, - "database_name": {"key": "databaseName", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: Optional[Union[str, "_models.JobTargetType"]] = None - self.server_name: Optional[str] = None - self.database_name: Optional[str] = None - - -class JobListResult(_serialization.Model): - """A list of jobs. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.Job] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Job]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.Job"]] = None - self.next_link: Optional[str] = None - - -class JobPrivateEndpoint(ProxyResource): - """A job agent private endpoint. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar target_server_azure_resource_id: ARM resource id of the server the private endpoint will - target. - :vartype target_server_azure_resource_id: str - :ivar private_endpoint_id: Private endpoint id of the private endpoint. - :vartype private_endpoint_id: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "private_endpoint_id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "target_server_azure_resource_id": {"key": "properties.targetServerAzureResourceId", "type": "str"}, - "private_endpoint_id": {"key": "properties.privateEndpointId", "type": "str"}, - } - - def __init__(self, *, target_server_azure_resource_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword target_server_azure_resource_id: ARM resource id of the server the private endpoint - will target. - :paramtype target_server_azure_resource_id: str - """ - super().__init__(**kwargs) - self.target_server_azure_resource_id = target_server_azure_resource_id - self.private_endpoint_id: Optional[str] = None - - -class JobPrivateEndpointListResult(_serialization.Model): - """A list of job agent private endpoints. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.JobPrivateEndpoint] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[JobPrivateEndpoint]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.JobPrivateEndpoint"]] = None - self.next_link: Optional[str] = None - - -class JobSchedule(_serialization.Model): - """Scheduling properties of a job. - - :ivar start_time: Schedule start time. - :vartype start_time: ~datetime.datetime - :ivar end_time: Schedule end time. - :vartype end_time: ~datetime.datetime - :ivar type: Schedule interval type. Known values are: "Once" and "Recurring". - :vartype type: str or ~azure.mgmt.sql.models.JobScheduleType - :ivar enabled: Whether or not the schedule is enabled. - :vartype enabled: bool - :ivar interval: Value of the schedule's recurring interval, if the ScheduleType is recurring. - ISO8601 duration format. - :vartype interval: str - """ - - _attribute_map = { - "start_time": {"key": "startTime", "type": "iso-8601"}, - "end_time": {"key": "endTime", "type": "iso-8601"}, - "type": {"key": "type", "type": "str"}, - "enabled": {"key": "enabled", "type": "bool"}, - "interval": {"key": "interval", "type": "str"}, - } - - def __init__( - self, - *, - start_time: datetime.datetime = "0001-01-01T00:00:00+00:00", - end_time: datetime.datetime = "9999-12-31T11:59:59+00:00", - type: Union[str, "_models.JobScheduleType"] = "Once", - enabled: Optional[bool] = None, - interval: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword start_time: Schedule start time. - :paramtype start_time: ~datetime.datetime - :keyword end_time: Schedule end time. - :paramtype end_time: ~datetime.datetime - :keyword type: Schedule interval type. Known values are: "Once" and "Recurring". - :paramtype type: str or ~azure.mgmt.sql.models.JobScheduleType - :keyword enabled: Whether or not the schedule is enabled. - :paramtype enabled: bool - :keyword interval: Value of the schedule's recurring interval, if the ScheduleType is - recurring. ISO8601 duration format. - :paramtype interval: str - """ - super().__init__(**kwargs) - self.start_time = start_time - self.end_time = end_time - self.type = type - self.enabled = enabled - self.interval = interval - - -class JobStep(ProxyResource): - """A job step. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar step_id: The job step's index within the job. If not specified when creating the job - step, it will be created as the last step. If not specified when updating the job step, the - step id is not modified. - :vartype step_id: int - :ivar target_group: The resource ID of the target group that the job step will be executed on. - :vartype target_group: str - :ivar credential: The resource ID of the job credential that will be used to connect to the - targets. - :vartype credential: str - :ivar action: The action payload of the job step. - :vartype action: ~azure.mgmt.sql.models.JobStepAction - :ivar output: Output destination properties of the job step. - :vartype output: ~azure.mgmt.sql.models.JobStepOutput - :ivar execution_options: Execution options for the job step. - :vartype execution_options: ~azure.mgmt.sql.models.JobStepExecutionOptions - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "step_id": {"key": "properties.stepId", "type": "int"}, - "target_group": {"key": "properties.targetGroup", "type": "str"}, - "credential": {"key": "properties.credential", "type": "str"}, - "action": {"key": "properties.action", "type": "JobStepAction"}, - "output": {"key": "properties.output", "type": "JobStepOutput"}, - "execution_options": {"key": "properties.executionOptions", "type": "JobStepExecutionOptions"}, - } - - def __init__( - self, - *, - step_id: Optional[int] = None, - target_group: Optional[str] = None, - credential: Optional[str] = None, - action: Optional["_models.JobStepAction"] = None, - output: Optional["_models.JobStepOutput"] = None, - execution_options: Optional["_models.JobStepExecutionOptions"] = None, - **kwargs: Any - ) -> None: - """ - :keyword step_id: The job step's index within the job. If not specified when creating the job - step, it will be created as the last step. If not specified when updating the job step, the - step id is not modified. - :paramtype step_id: int - :keyword target_group: The resource ID of the target group that the job step will be executed - on. - :paramtype target_group: str - :keyword credential: The resource ID of the job credential that will be used to connect to the - targets. - :paramtype credential: str - :keyword action: The action payload of the job step. - :paramtype action: ~azure.mgmt.sql.models.JobStepAction - :keyword output: Output destination properties of the job step. - :paramtype output: ~azure.mgmt.sql.models.JobStepOutput - :keyword execution_options: Execution options for the job step. - :paramtype execution_options: ~azure.mgmt.sql.models.JobStepExecutionOptions - """ - super().__init__(**kwargs) - self.step_id = step_id - self.target_group = target_group - self.credential = credential - self.action = action - self.output = output - self.execution_options = execution_options - - -class JobStepAction(_serialization.Model): - """The action to be executed by a job step. - - All required parameters must be populated in order to send to server. - - :ivar type: Type of action being executed by the job step. "TSql" - :vartype type: str or ~azure.mgmt.sql.models.JobStepActionType - :ivar source: The source of the action to execute. "Inline" - :vartype source: str or ~azure.mgmt.sql.models.JobStepActionSource - :ivar value: The action value, for example the text of the T-SQL script to execute. Required. - :vartype value: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "source": {"key": "source", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__( - self, - *, - value: str, - type: Union[str, "_models.JobStepActionType"] = "TSql", - source: Union[str, "_models.JobStepActionSource"] = "Inline", - **kwargs: Any - ) -> None: - """ - :keyword type: Type of action being executed by the job step. "TSql" - :paramtype type: str or ~azure.mgmt.sql.models.JobStepActionType - :keyword source: The source of the action to execute. "Inline" - :paramtype source: str or ~azure.mgmt.sql.models.JobStepActionSource - :keyword value: The action value, for example the text of the T-SQL script to execute. - Required. - :paramtype value: str - """ - super().__init__(**kwargs) - self.type = type - self.source = source - self.value = value - - -class JobStepExecutionOptions(_serialization.Model): - """The execution options of a job step. - - :ivar timeout_seconds: Execution timeout for the job step. - :vartype timeout_seconds: int - :ivar retry_attempts: Maximum number of times the job step will be reattempted if the first - attempt fails. - :vartype retry_attempts: int - :ivar initial_retry_interval_seconds: Initial delay between retries for job step execution. - :vartype initial_retry_interval_seconds: int - :ivar maximum_retry_interval_seconds: The maximum amount of time to wait between retries for - job step execution. - :vartype maximum_retry_interval_seconds: int - :ivar retry_interval_backoff_multiplier: The backoff multiplier for the time between retries. - :vartype retry_interval_backoff_multiplier: float - """ - - _attribute_map = { - "timeout_seconds": {"key": "timeoutSeconds", "type": "int"}, - "retry_attempts": {"key": "retryAttempts", "type": "int"}, - "initial_retry_interval_seconds": {"key": "initialRetryIntervalSeconds", "type": "int"}, - "maximum_retry_interval_seconds": {"key": "maximumRetryIntervalSeconds", "type": "int"}, - "retry_interval_backoff_multiplier": {"key": "retryIntervalBackoffMultiplier", "type": "float"}, - } - - def __init__( - self, - *, - timeout_seconds: int = 43200, - retry_attempts: int = 10, - initial_retry_interval_seconds: int = 1, - maximum_retry_interval_seconds: int = 120, - retry_interval_backoff_multiplier: float = 2, - **kwargs: Any - ) -> None: - """ - :keyword timeout_seconds: Execution timeout for the job step. - :paramtype timeout_seconds: int - :keyword retry_attempts: Maximum number of times the job step will be reattempted if the first - attempt fails. - :paramtype retry_attempts: int - :keyword initial_retry_interval_seconds: Initial delay between retries for job step execution. - :paramtype initial_retry_interval_seconds: int - :keyword maximum_retry_interval_seconds: The maximum amount of time to wait between retries for - job step execution. - :paramtype maximum_retry_interval_seconds: int - :keyword retry_interval_backoff_multiplier: The backoff multiplier for the time between - retries. - :paramtype retry_interval_backoff_multiplier: float - """ - super().__init__(**kwargs) - self.timeout_seconds = timeout_seconds - self.retry_attempts = retry_attempts - self.initial_retry_interval_seconds = initial_retry_interval_seconds - self.maximum_retry_interval_seconds = maximum_retry_interval_seconds - self.retry_interval_backoff_multiplier = retry_interval_backoff_multiplier - - -class JobStepListResult(_serialization.Model): - """A list of job steps. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.JobStep] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[JobStep]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.JobStep"]] = None - self.next_link: Optional[str] = None - - -class JobStepOutput(_serialization.Model): - """The output configuration of a job step. - - All required parameters must be populated in order to send to server. - - :ivar type: The output destination type. "SqlDatabase" - :vartype type: str or ~azure.mgmt.sql.models.JobStepOutputType - :ivar subscription_id: The output destination subscription id. - :vartype subscription_id: str - :ivar resource_group_name: The output destination resource group. - :vartype resource_group_name: str - :ivar server_name: The output destination server name. Required. - :vartype server_name: str - :ivar database_name: The output destination database. Required. - :vartype database_name: str - :ivar schema_name: The output destination schema. - :vartype schema_name: str - :ivar table_name: The output destination table. Required. - :vartype table_name: str - :ivar credential: The resource ID of the credential to use to connect to the output - destination. Required. - :vartype credential: str - """ - - _validation = { - "server_name": {"required": True}, - "database_name": {"required": True}, - "table_name": {"required": True}, - "credential": {"required": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "subscription_id": {"key": "subscriptionId", "type": "str"}, - "resource_group_name": {"key": "resourceGroupName", "type": "str"}, - "server_name": {"key": "serverName", "type": "str"}, - "database_name": {"key": "databaseName", "type": "str"}, - "schema_name": {"key": "schemaName", "type": "str"}, - "table_name": {"key": "tableName", "type": "str"}, - "credential": {"key": "credential", "type": "str"}, - } - - def __init__( - self, - *, - server_name: str, - database_name: str, - table_name: str, - credential: str, - type: Union[str, "_models.JobStepOutputType"] = "SqlDatabase", - subscription_id: Optional[str] = None, - resource_group_name: Optional[str] = None, - schema_name: str = "dbo", - **kwargs: Any - ) -> None: - """ - :keyword type: The output destination type. "SqlDatabase" - :paramtype type: str or ~azure.mgmt.sql.models.JobStepOutputType - :keyword subscription_id: The output destination subscription id. - :paramtype subscription_id: str - :keyword resource_group_name: The output destination resource group. - :paramtype resource_group_name: str - :keyword server_name: The output destination server name. Required. - :paramtype server_name: str - :keyword database_name: The output destination database. Required. - :paramtype database_name: str - :keyword schema_name: The output destination schema. - :paramtype schema_name: str - :keyword table_name: The output destination table. Required. - :paramtype table_name: str - :keyword credential: The resource ID of the credential to use to connect to the output - destination. Required. - :paramtype credential: str - """ - super().__init__(**kwargs) - self.type = type - self.subscription_id = subscription_id - self.resource_group_name = resource_group_name - self.server_name = server_name - self.database_name = database_name - self.schema_name = schema_name - self.table_name = table_name - self.credential = credential - - -class JobTarget(_serialization.Model): - """A job target, for example a specific database or a container of databases that is evaluated - during job execution. - - All required parameters must be populated in order to send to server. - - :ivar membership_type: Whether the target is included or excluded from the group. Known values - are: "Include" and "Exclude". - :vartype membership_type: str or ~azure.mgmt.sql.models.JobTargetGroupMembershipType - :ivar type: The target type. Required. Known values are: "TargetGroup", "SqlDatabase", - "SqlElasticPool", "SqlShardMap", and "SqlServer". - :vartype type: str or ~azure.mgmt.sql.models.JobTargetType - :ivar server_name: The target server name. - :vartype server_name: str - :ivar database_name: The target database name. - :vartype database_name: str - :ivar elastic_pool_name: The target elastic pool name. - :vartype elastic_pool_name: str - :ivar shard_map_name: The target shard map. - :vartype shard_map_name: str - :ivar refresh_credential: The resource ID of the credential that is used during job execution - to connect to the target and determine the list of databases inside the target. - :vartype refresh_credential: str - """ - - _validation = { - "type": {"required": True}, - } - - _attribute_map = { - "membership_type": {"key": "membershipType", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "server_name": {"key": "serverName", "type": "str"}, - "database_name": {"key": "databaseName", "type": "str"}, - "elastic_pool_name": {"key": "elasticPoolName", "type": "str"}, - "shard_map_name": {"key": "shardMapName", "type": "str"}, - "refresh_credential": {"key": "refreshCredential", "type": "str"}, - } - - def __init__( - self, - *, - type: Union[str, "_models.JobTargetType"], - membership_type: Union[str, "_models.JobTargetGroupMembershipType"] = "Include", - server_name: Optional[str] = None, - database_name: Optional[str] = None, - elastic_pool_name: Optional[str] = None, - shard_map_name: Optional[str] = None, - refresh_credential: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword membership_type: Whether the target is included or excluded from the group. Known - values are: "Include" and "Exclude". - :paramtype membership_type: str or ~azure.mgmt.sql.models.JobTargetGroupMembershipType - :keyword type: The target type. Required. Known values are: "TargetGroup", "SqlDatabase", - "SqlElasticPool", "SqlShardMap", and "SqlServer". - :paramtype type: str or ~azure.mgmt.sql.models.JobTargetType - :keyword server_name: The target server name. - :paramtype server_name: str - :keyword database_name: The target database name. - :paramtype database_name: str - :keyword elastic_pool_name: The target elastic pool name. - :paramtype elastic_pool_name: str - :keyword shard_map_name: The target shard map. - :paramtype shard_map_name: str - :keyword refresh_credential: The resource ID of the credential that is used during job - execution to connect to the target and determine the list of databases inside the target. - :paramtype refresh_credential: str - """ - super().__init__(**kwargs) - self.membership_type = membership_type - self.type = type - self.server_name = server_name - self.database_name = database_name - self.elastic_pool_name = elastic_pool_name - self.shard_map_name = shard_map_name - self.refresh_credential = refresh_credential - - -class JobTargetGroup(ProxyResource): - """A group of job targets. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar members: Members of the target group. - :vartype members: list[~azure.mgmt.sql.models.JobTarget] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "members": {"key": "properties.members", "type": "[JobTarget]"}, - } - - def __init__(self, *, members: Optional[list["_models.JobTarget"]] = None, **kwargs: Any) -> None: - """ - :keyword members: Members of the target group. - :paramtype members: list[~azure.mgmt.sql.models.JobTarget] - """ - super().__init__(**kwargs) - self.members = members - - -class JobTargetGroupListResult(_serialization.Model): - """A list of target groups. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.JobTargetGroup] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[JobTargetGroup]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.JobTargetGroup"]] = None - self.next_link: Optional[str] = None - - -class JobVersion(ProxyResource): - """A job version. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - -class JobVersionListResult(_serialization.Model): - """A list of job versions. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.JobVersion] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[JobVersion]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.JobVersion"]] = None - self.next_link: Optional[str] = None - - -class LedgerDigestUploads(ProxyResource): - """Azure SQL Database ledger digest upload settings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar digest_storage_endpoint: The digest storage endpoint, which must be either an Azure blob - storage endpoint or an URI for Azure Confidential Ledger. - :vartype digest_storage_endpoint: str - :ivar state: Specifies the state of ledger digest upload. Known values are: "Enabled" and - "Disabled". - :vartype state: str or ~azure.mgmt.sql.models.LedgerDigestUploadsState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "digest_storage_endpoint": {"key": "properties.digestStorageEndpoint", "type": "str"}, - "state": {"key": "properties.state", "type": "str"}, - } - - def __init__(self, *, digest_storage_endpoint: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword digest_storage_endpoint: The digest storage endpoint, which must be either an Azure - blob storage endpoint or an URI for Azure Confidential Ledger. - :paramtype digest_storage_endpoint: str - """ - super().__init__(**kwargs) - self.digest_storage_endpoint = digest_storage_endpoint - self.state: Optional[Union[str, "_models.LedgerDigestUploadsState"]] = None - - -class LedgerDigestUploadsListResult(_serialization.Model): - """A list of ledger digest upload settings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.LedgerDigestUploads] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[LedgerDigestUploads]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.LedgerDigestUploads"]] = None - self.next_link: Optional[str] = None - - -class LicenseTypeCapability(_serialization.Model): - """The license type capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: License type identifier. - :vartype name: str - :ivar status: The status of the capability. 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}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "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: Optional[str] = None - self.status: Optional[Union[str, "_models.CapabilityStatus"]] = None - self.reason = reason - - -class LocationCapabilities(_serialization.Model): - """The location capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The location name. - :vartype name: str - :ivar supported_server_versions: The list of supported server versions. - :vartype supported_server_versions: list[~azure.mgmt.sql.models.ServerVersionCapability] - :ivar supported_managed_instance_versions: The list of supported managed instance versions. - :vartype supported_managed_instance_versions: - list[~azure.mgmt.sql.models.ManagedInstanceVersionCapability] - :ivar status: The status of the capability. 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_server_versions": {"readonly": True}, - "supported_managed_instance_versions": {"readonly": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "supported_server_versions": {"key": "supportedServerVersions", "type": "[ServerVersionCapability]"}, - "supported_managed_instance_versions": { - "key": "supportedManagedInstanceVersions", - "type": "[ManagedInstanceVersionCapability]", - }, - "status": {"key": "status", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - } - - def __init__(self, *, 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: Optional[str] = None - self.supported_server_versions: Optional[list["_models.ServerVersionCapability"]] = None - self.supported_managed_instance_versions: Optional[list["_models.ManagedInstanceVersionCapability"]] = None - self.status: Optional[Union[str, "_models.CapabilityStatus"]] = None - self.reason = reason - - -class LogicalDatabaseTransparentDataEncryption(ProxyResource): - """A logical database transparent data encryption state. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar state: Specifies the state of the transparent data encryption. Known values are: - "Enabled" and "Disabled". - :vartype state: str or ~azure.mgmt.sql.models.TransparentDataEncryptionState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "state": {"key": "properties.state", "type": "str"}, - } - - def __init__( - self, *, state: Optional[Union[str, "_models.TransparentDataEncryptionState"]] = None, **kwargs: Any - ) -> None: - """ - :keyword state: Specifies the state of the transparent data encryption. Known values are: - "Enabled" and "Disabled". - :paramtype state: str or ~azure.mgmt.sql.models.TransparentDataEncryptionState - """ - super().__init__(**kwargs) - self.state = state - - -class LogicalDatabaseTransparentDataEncryptionListResult(_serialization.Model): # pylint: disable=name-too-long - """A list of transparent data encryptions. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[LogicalDatabaseTransparentDataEncryption]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.LogicalDatabaseTransparentDataEncryption"]] = None - self.next_link: Optional[str] = None - - -class LogicalServerAdvancedThreatProtectionListResult(_serialization.Model): # pylint: disable=name-too-long - """A list of the server's Advanced Threat Protection configurations. - - 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.ServerAdvancedThreatProtection] - :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": "[ServerAdvancedThreatProtection]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ServerAdvancedThreatProtection"]] = None - self.next_link: Optional[str] = None - - -class LogicalServerSecurityAlertPolicyListResult(_serialization.Model): # pylint: disable=name-too-long - """A list of the server's security alert policies. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ServerSecurityAlertPolicy] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ServerSecurityAlertPolicy]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ServerSecurityAlertPolicy"]] = None - self.next_link: Optional[str] = None - - -class LogSizeCapability(_serialization.Model): - """The log size capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar limit: The log size limit (see 'unit' for the units). - :vartype limit: int - :ivar unit: The units that the limit is expressed in. Known values are: "Megabytes", - "Gigabytes", "Terabytes", "Petabytes", and "Percent". - :vartype unit: str or ~azure.mgmt.sql.models.LogSizeUnit - """ - - _validation = { - "limit": {"readonly": True}, - "unit": {"readonly": True}, - } - - _attribute_map = { - "limit": {"key": "limit", "type": "int"}, - "unit": {"key": "unit", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.limit: Optional[int] = None - self.unit: Optional[Union[str, "_models.LogSizeUnit"]] = None - - -class LongTermRetentionBackup(ProxyResource): - """A long term retention backup. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar server_name: The server name that the backup database belong to. - :vartype server_name: str - :ivar server_create_time: The create time of the server. - :vartype server_create_time: ~datetime.datetime - :ivar database_name: The name of the database the backup belong to. - :vartype database_name: str - :ivar database_deletion_time: The delete time of the database. - :vartype database_deletion_time: ~datetime.datetime - :ivar backup_time: The time the backup was taken. - :vartype backup_time: ~datetime.datetime - :ivar backup_expiration_time: The time the long term retention backup will expire. - :vartype backup_expiration_time: ~datetime.datetime - :ivar backup_storage_redundancy: The storage redundancy type of the backup. Known values are: - "Geo", "Local", "Zone", and "GeoZone". - :vartype backup_storage_redundancy: str or ~azure.mgmt.sql.models.BackupStorageRedundancy - :ivar requested_backup_storage_redundancy: The storage redundancy type of the backup. Known - values are: "Geo", "Local", "Zone", and "GeoZone". - :vartype requested_backup_storage_redundancy: str or - ~azure.mgmt.sql.models.BackupStorageRedundancy - :ivar is_backup_immutable: The setting whether the LTR backup is immutable. - :vartype is_backup_immutable: bool - :ivar time_based_immutability: The setting for whether or not time-based immutability is - enabled for the LTR backup. When time-based immutability is enabled and locked, the backup - cannot be deleted until BackupExpirationTime. Known values are: "Enabled" and "Disabled". - :vartype time_based_immutability: str or ~azure.mgmt.sql.models.TimeBasedImmutability - :ivar time_based_immutability_mode: The time-based immutability mode. Only applicable if - time-based immutability is enabled. Known values are: "Locked" and "Unlocked". - :vartype time_based_immutability_mode: str or ~azure.mgmt.sql.models.TimeBasedImmutabilityMode - :ivar legal_hold_immutability: The setting for whether LegalHold is enabled or disabled on the - LTR backup. When LegalHold is enabled, the backup cannot be deleted until the LegalHold is - removed. Known values are: "Enabled" and "Disabled". - :vartype legal_hold_immutability: str or ~azure.mgmt.sql.models.SetLegalHoldImmutability - :ivar backup_storage_access_tier: The BackupStorageAccessTier for the LTR backup. Known values - are: "Hot" and "Archive". - :vartype backup_storage_access_tier: str or ~azure.mgmt.sql.models.BackupStorageAccessTier - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "server_name": {"readonly": True}, - "server_create_time": {"readonly": True}, - "database_name": {"readonly": True}, - "database_deletion_time": {"readonly": True}, - "backup_time": {"readonly": True}, - "backup_expiration_time": {"readonly": True}, - "backup_storage_redundancy": {"readonly": True}, - "backup_storage_access_tier": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "server_name": {"key": "properties.serverName", "type": "str"}, - "server_create_time": {"key": "properties.serverCreateTime", "type": "iso-8601"}, - "database_name": {"key": "properties.databaseName", "type": "str"}, - "database_deletion_time": {"key": "properties.databaseDeletionTime", "type": "iso-8601"}, - "backup_time": {"key": "properties.backupTime", "type": "iso-8601"}, - "backup_expiration_time": {"key": "properties.backupExpirationTime", "type": "iso-8601"}, - "backup_storage_redundancy": {"key": "properties.backupStorageRedundancy", "type": "str"}, - "requested_backup_storage_redundancy": {"key": "properties.requestedBackupStorageRedundancy", "type": "str"}, - "is_backup_immutable": {"key": "properties.isBackupImmutable", "type": "bool"}, - "time_based_immutability": {"key": "properties.timeBasedImmutability", "type": "str"}, - "time_based_immutability_mode": {"key": "properties.timeBasedImmutabilityMode", "type": "str"}, - "legal_hold_immutability": {"key": "properties.legalHoldImmutability", "type": "str"}, - "backup_storage_access_tier": {"key": "properties.backupStorageAccessTier", "type": "str"}, - } - - def __init__( - self, - *, - requested_backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = None, - is_backup_immutable: Optional[bool] = None, - time_based_immutability: Optional[Union[str, "_models.TimeBasedImmutability"]] = None, - time_based_immutability_mode: Optional[Union[str, "_models.TimeBasedImmutabilityMode"]] = None, - legal_hold_immutability: Optional[Union[str, "_models.SetLegalHoldImmutability"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword requested_backup_storage_redundancy: The storage redundancy type of the backup. Known - 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 - :keyword time_based_immutability: The setting for whether or not time-based immutability is - enabled for the LTR backup. When time-based immutability is enabled and locked, the backup - cannot be deleted until BackupExpirationTime. Known values are: "Enabled" and "Disabled". - :paramtype time_based_immutability: str or ~azure.mgmt.sql.models.TimeBasedImmutability - :keyword time_based_immutability_mode: The time-based immutability mode. Only applicable if - time-based immutability is enabled. Known values are: "Locked" and "Unlocked". - :paramtype time_based_immutability_mode: str or - ~azure.mgmt.sql.models.TimeBasedImmutabilityMode - :keyword legal_hold_immutability: The setting for whether LegalHold is enabled or disabled on - the LTR backup. When LegalHold is enabled, the backup cannot be deleted until the LegalHold is - removed. Known values are: "Enabled" and "Disabled". - :paramtype legal_hold_immutability: str or ~azure.mgmt.sql.models.SetLegalHoldImmutability - """ - super().__init__(**kwargs) - self.server_name: Optional[str] = None - self.server_create_time: Optional[datetime.datetime] = None - self.database_name: Optional[str] = None - self.database_deletion_time: Optional[datetime.datetime] = None - self.backup_time: Optional[datetime.datetime] = None - self.backup_expiration_time: Optional[datetime.datetime] = None - self.backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = None - self.requested_backup_storage_redundancy = requested_backup_storage_redundancy - self.is_backup_immutable = is_backup_immutable - self.time_based_immutability = time_based_immutability - self.time_based_immutability_mode = time_based_immutability_mode - self.legal_hold_immutability = legal_hold_immutability - self.backup_storage_access_tier: Optional[Union[str, "_models.BackupStorageAccessTier"]] = None - - -class LongTermRetentionBackupListResult(_serialization.Model): - """A list of long term retention backups. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.LongTermRetentionBackup] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[LongTermRetentionBackup]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.LongTermRetentionBackup"]] = None - self.next_link: Optional[str] = None - - -class LongTermRetentionBackupOperationResult(ProxyResource): - """A LongTermRetentionBackup operation result resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar request_id: Request Id. - :vartype request_id: str - :ivar operation_type: Operation type. - :vartype operation_type: str - :ivar from_backup_resource_id: Source backup resource id. - :vartype from_backup_resource_id: str - :ivar to_backup_resource_id: Target backup resource id. - :vartype to_backup_resource_id: str - :ivar target_backup_storage_redundancy: The storage redundancy type of the copied backup. Known - values are: "Geo", "Local", "Zone", and "GeoZone". - :vartype target_backup_storage_redundancy: str or - ~azure.mgmt.sql.models.BackupStorageRedundancy - :ivar status: Operation status. - :vartype status: str - :ivar message: Progress message. - :vartype message: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "request_id": {"readonly": True}, - "operation_type": {"readonly": True}, - "from_backup_resource_id": {"readonly": True}, - "to_backup_resource_id": {"readonly": True}, - "target_backup_storage_redundancy": {"readonly": True}, - "status": {"readonly": True}, - "message": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "request_id": {"key": "properties.requestId", "type": "str"}, - "operation_type": {"key": "properties.operationType", "type": "str"}, - "from_backup_resource_id": {"key": "properties.fromBackupResourceId", "type": "str"}, - "to_backup_resource_id": {"key": "properties.toBackupResourceId", "type": "str"}, - "target_backup_storage_redundancy": {"key": "properties.targetBackupStorageRedundancy", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "message": {"key": "properties.message", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.request_id: Optional[str] = None - self.operation_type: Optional[str] = None - self.from_backup_resource_id: Optional[str] = None - self.to_backup_resource_id: Optional[str] = None - self.target_backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = None - self.status: Optional[str] = None - self.message: Optional[str] = None - - -class LongTermRetentionPolicy(ProxyResource): - """A long term retention policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar time_based_immutability: The setting for whether to enable time-based immutability for - future backups. When set, future backups will have TimeBasedImmutability enabled. Known values - are: "Enabled" and "Disabled". - :vartype time_based_immutability: str or ~azure.mgmt.sql.models.TimeBasedImmutability - :ivar time_based_immutability_mode: The setting for time-based immutability mode for future - backup (Value can be either Locked or UnLocked. Only effective if TimeBasedImmutability is - enabled). Caution: Immutability of LTR backup cannot be removed if TimeBasedImmutabilityMode is - Locked. Known values are: "Locked" and "Unlocked". - :vartype time_based_immutability_mode: str or ~azure.mgmt.sql.models.TimeBasedImmutabilityMode - :ivar weekly_retention: The weekly retention policy for an LTR backup in an ISO 8601 format. - :vartype weekly_retention: str - :ivar monthly_retention: The monthly retention policy for an LTR backup in an ISO 8601 format. - :vartype monthly_retention: str - :ivar yearly_retention: The yearly retention policy for an LTR backup in an ISO 8601 format. - :vartype yearly_retention: str - :ivar week_of_year: The week of year to take the yearly backup in an ISO 8601 format. - :vartype week_of_year: int - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "time_based_immutability": {"key": "properties.timeBasedImmutability", "type": "str"}, - "time_based_immutability_mode": {"key": "properties.timeBasedImmutabilityMode", "type": "str"}, - "weekly_retention": {"key": "properties.weeklyRetention", "type": "str"}, - "monthly_retention": {"key": "properties.monthlyRetention", "type": "str"}, - "yearly_retention": {"key": "properties.yearlyRetention", "type": "str"}, - "week_of_year": {"key": "properties.weekOfYear", "type": "int"}, - } - - def __init__( - self, - *, - time_based_immutability: Optional[Union[str, "_models.TimeBasedImmutability"]] = None, - time_based_immutability_mode: Optional[Union[str, "_models.TimeBasedImmutabilityMode"]] = None, - weekly_retention: Optional[str] = None, - monthly_retention: Optional[str] = None, - yearly_retention: Optional[str] = None, - week_of_year: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword time_based_immutability: The setting for whether to enable time-based immutability for - future backups. When set, future backups will have TimeBasedImmutability enabled. Known values - are: "Enabled" and "Disabled". - :paramtype time_based_immutability: str or ~azure.mgmt.sql.models.TimeBasedImmutability - :keyword time_based_immutability_mode: The setting for time-based immutability mode for future - backup (Value can be either Locked or UnLocked. Only effective if TimeBasedImmutability is - enabled). Caution: Immutability of LTR backup cannot be removed if TimeBasedImmutabilityMode is - Locked. Known values are: "Locked" and "Unlocked". - :paramtype time_based_immutability_mode: str or - ~azure.mgmt.sql.models.TimeBasedImmutabilityMode - :keyword weekly_retention: The weekly retention policy for an LTR backup in an ISO 8601 format. - :paramtype weekly_retention: str - :keyword monthly_retention: The monthly retention policy for an LTR backup in an ISO 8601 - format. - :paramtype monthly_retention: str - :keyword yearly_retention: The yearly retention policy for an LTR backup in an ISO 8601 format. - :paramtype yearly_retention: str - :keyword week_of_year: The week of year to take the yearly backup in an ISO 8601 format. - :paramtype week_of_year: int - """ - super().__init__(**kwargs) - self.time_based_immutability = time_based_immutability - self.time_based_immutability_mode = time_based_immutability_mode - self.weekly_retention = weekly_retention - self.monthly_retention = monthly_retention - self.yearly_retention = yearly_retention - self.week_of_year = week_of_year - - -class LongTermRetentionPolicyListResult(_serialization.Model): - """A list of long term retention policies. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.LongTermRetentionPolicy] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[LongTermRetentionPolicy]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.LongTermRetentionPolicy"]] = None - self.next_link: Optional[str] = None - - -class MaintenanceConfigurationCapability(_serialization.Model): - """The maintenance configuration capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Maintenance configuration name. - :vartype name: str - :ivar zone_redundant: Whether or not zone redundancy is supported for the maintenance - configuration. - :vartype zone_redundant: bool - :ivar status: The status of the capability. 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}, - "zone_redundant": {"readonly": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "zone_redundant": {"key": "zoneRedundant", "type": "bool"}, - "status": {"key": "status", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - } - - def __init__(self, *, 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: Optional[str] = None - self.zone_redundant: Optional[bool] = None - self.status: Optional[Union[str, "_models.CapabilityStatus"]] = None - self.reason = reason - - -class MaintenanceWindowOptions(ProxyResource): - """Maintenance window options. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar is_enabled: Whether maintenance windows are enabled for the database. - :vartype is_enabled: bool - :ivar maintenance_window_cycles: Available maintenance cycles e.g. {Saturday, 0, 48\\ *60}, - {Wednesday, 0, 24*\\ 60}. - :vartype maintenance_window_cycles: list[~azure.mgmt.sql.models.MaintenanceWindowTimeRange] - :ivar min_duration_in_minutes: Minimum duration of maintenance window. - :vartype min_duration_in_minutes: int - :ivar default_duration_in_minutes: Default duration for maintenance window. - :vartype default_duration_in_minutes: int - :ivar min_cycles: Minimum number of maintenance windows cycles to be set on the database. - :vartype min_cycles: int - :ivar time_granularity_in_minutes: Time granularity in minutes for maintenance windows. - :vartype time_granularity_in_minutes: int - :ivar allow_multiple_maintenance_windows_per_cycle: Whether we allow multiple maintenance - windows per cycle. - :vartype allow_multiple_maintenance_windows_per_cycle: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "is_enabled": {"key": "properties.isEnabled", "type": "bool"}, - "maintenance_window_cycles": { - "key": "properties.maintenanceWindowCycles", - "type": "[MaintenanceWindowTimeRange]", - }, - "min_duration_in_minutes": {"key": "properties.minDurationInMinutes", "type": "int"}, - "default_duration_in_minutes": {"key": "properties.defaultDurationInMinutes", "type": "int"}, - "min_cycles": {"key": "properties.minCycles", "type": "int"}, - "time_granularity_in_minutes": {"key": "properties.timeGranularityInMinutes", "type": "int"}, - "allow_multiple_maintenance_windows_per_cycle": { - "key": "properties.allowMultipleMaintenanceWindowsPerCycle", - "type": "bool", - }, - } - - def __init__( - self, - *, - is_enabled: Optional[bool] = None, - maintenance_window_cycles: Optional[list["_models.MaintenanceWindowTimeRange"]] = None, - min_duration_in_minutes: Optional[int] = None, - default_duration_in_minutes: Optional[int] = None, - min_cycles: Optional[int] = None, - time_granularity_in_minutes: Optional[int] = None, - allow_multiple_maintenance_windows_per_cycle: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword is_enabled: Whether maintenance windows are enabled for the database. - :paramtype is_enabled: bool - :keyword maintenance_window_cycles: Available maintenance cycles e.g. {Saturday, 0, 48\\ *60}, - {Wednesday, 0, 24*\\ 60}. - :paramtype maintenance_window_cycles: list[~azure.mgmt.sql.models.MaintenanceWindowTimeRange] - :keyword min_duration_in_minutes: Minimum duration of maintenance window. - :paramtype min_duration_in_minutes: int - :keyword default_duration_in_minutes: Default duration for maintenance window. - :paramtype default_duration_in_minutes: int - :keyword min_cycles: Minimum number of maintenance windows cycles to be set on the database. - :paramtype min_cycles: int - :keyword time_granularity_in_minutes: Time granularity in minutes for maintenance windows. - :paramtype time_granularity_in_minutes: int - :keyword allow_multiple_maintenance_windows_per_cycle: Whether we allow multiple maintenance - windows per cycle. - :paramtype allow_multiple_maintenance_windows_per_cycle: bool - """ - super().__init__(**kwargs) - self.is_enabled = is_enabled - self.maintenance_window_cycles = maintenance_window_cycles - self.min_duration_in_minutes = min_duration_in_minutes - self.default_duration_in_minutes = default_duration_in_minutes - self.min_cycles = min_cycles - self.time_granularity_in_minutes = time_granularity_in_minutes - self.allow_multiple_maintenance_windows_per_cycle = allow_multiple_maintenance_windows_per_cycle - - -class MaintenanceWindows(ProxyResource): - """Maintenance windows. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar time_ranges: - :vartype time_ranges: list[~azure.mgmt.sql.models.MaintenanceWindowTimeRange] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "time_ranges": {"key": "properties.timeRanges", "type": "[MaintenanceWindowTimeRange]"}, - } - - def __init__( - self, *, time_ranges: Optional[list["_models.MaintenanceWindowTimeRange"]] = None, **kwargs: Any - ) -> None: - """ - :keyword time_ranges: - :paramtype time_ranges: list[~azure.mgmt.sql.models.MaintenanceWindowTimeRange] - """ - super().__init__(**kwargs) - self.time_ranges = time_ranges - - -class MaintenanceWindowTimeRange(_serialization.Model): - """Maintenance window time range. - - :ivar day_of_week: Day of maintenance window. Known values are: "Sunday", "Monday", "Tuesday", - "Wednesday", "Thursday", "Friday", and "Saturday". - :vartype day_of_week: str or ~azure.mgmt.sql.models.DayOfWeek - :ivar start_time: Start time minutes offset from 12am. - :vartype start_time: str - :ivar duration: Duration of maintenance window in minutes. - :vartype duration: str - """ - - _attribute_map = { - "day_of_week": {"key": "dayOfWeek", "type": "str"}, - "start_time": {"key": "startTime", "type": "str"}, - "duration": {"key": "duration", "type": "str"}, - } - - def __init__( - self, - *, - day_of_week: Optional[Union[str, "_models.DayOfWeek"]] = None, - start_time: Optional[str] = None, - duration: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword day_of_week: Day of maintenance window. Known values are: "Sunday", "Monday", - "Tuesday", "Wednesday", "Thursday", "Friday", and "Saturday". - :paramtype day_of_week: str or ~azure.mgmt.sql.models.DayOfWeek - :keyword start_time: Start time minutes offset from 12am. - :paramtype start_time: str - :keyword duration: Duration of maintenance window in minutes. - :paramtype duration: str - """ - super().__init__(**kwargs) - self.day_of_week = day_of_week - self.start_time = start_time - self.duration = duration - - -class ManagedBackupShortTermRetentionPolicy(ProxyResource): - """A short term retention policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar retention_days: The backup retention period in days. This is how many days Point-in-Time - Restore will be supported. - :vartype retention_days: int - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "retention_days": {"key": "properties.retentionDays", "type": "int"}, - } - - def __init__(self, *, retention_days: Optional[int] = None, **kwargs: Any) -> None: - """ - :keyword retention_days: The backup retention period in days. This is how many days - Point-in-Time Restore will be supported. - :paramtype retention_days: int - """ - super().__init__(**kwargs) - self.retention_days = retention_days - - -class ManagedBackupShortTermRetentionPolicyListResult(_serialization.Model): # pylint: disable=name-too-long - """A list of short term retention policies. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ManagedBackupShortTermRetentionPolicy]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ManagedBackupShortTermRetentionPolicy"]] = None - self.next_link: Optional[str] = None - - -class ManagedDatabase(TrackedResource): - """A managed database resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar collation: Collation of the managed database. - :vartype collation: str - :ivar status: Status of the database. Known values are: "Online", "Offline", "Shutdown", - "Creating", "Inaccessible", "Restoring", "Updating", "Stopping", "Stopped", "Starting", - "DbMoving", and "DbCopying". - :vartype status: str or ~azure.mgmt.sql.models.ManagedDatabaseStatus - :ivar creation_date: Creation date of the database. - :vartype creation_date: ~datetime.datetime - :ivar earliest_restore_point: Earliest restore point in time for point in time restore. - :vartype earliest_restore_point: ~datetime.datetime - :ivar restore_point_in_time: Conditional. If createMode is PointInTimeRestore, this value is - required. Specifies the point in time (ISO8601 format) of the source database that will be - restored to create the new database. - :vartype restore_point_in_time: ~datetime.datetime - :ivar default_secondary_location: Geo paired region. - :vartype default_secondary_location: str - :ivar catalog_collation: Collation of the metadata catalog. Known values are: - "DATABASE_DEFAULT" and "SQL_Latin1_General_CP1_CI_AS". - :vartype catalog_collation: str or ~azure.mgmt.sql.models.CatalogCollationType - :ivar create_mode: Managed database create mode. PointInTimeRestore: Create a database by - restoring a point in time backup of an existing database. SourceDatabaseName, - SourceManagedInstanceName and PointInTime must be specified. RestoreExternalBackup: Create a - database by restoring from external backup files. Collation, StorageContainerUri and - StorageContainerSasToken must be specified. Recovery: Creates a database by restoring a - geo-replicated backup. RecoverableDatabaseId must be specified as the recoverable database - resource ID to restore. RestoreLongTermRetentionBackup: Create a database by restoring from a - long term retention backup (longTermRetentionBackupResourceId required). Known values are: - "Default", "RestoreExternalBackup", "PointInTimeRestore", "Recovery", and - "RestoreLongTermRetentionBackup". - :vartype create_mode: str or ~azure.mgmt.sql.models.ManagedDatabaseCreateMode - :ivar storage_container_uri: Conditional. If createMode is RestoreExternalBackup, this value is - required. Specifies the uri of the storage container where backups for this restore are stored. - :vartype storage_container_uri: str - :ivar source_database_id: The resource identifier of the source database associated with create - operation of this database. - :vartype source_database_id: str - :ivar cross_subscription_source_database_id: The resource identifier of the cross-subscription - source database associated with create operation of this database. - :vartype cross_subscription_source_database_id: str - :ivar restorable_dropped_database_id: The restorable dropped database resource id to restore - when creating this database. - :vartype restorable_dropped_database_id: str - :ivar cross_subscription_restorable_dropped_database_id: The restorable cross-subscription - dropped database resource id to restore when creating this database. - :vartype cross_subscription_restorable_dropped_database_id: str - :ivar storage_container_identity: Conditional. If createMode is RestoreExternalBackup, this - value is used. Specifies the identity used for storage container authentication. Can be - 'SharedAccessSignature' or 'ManagedIdentity'; if not specified 'SharedAccessSignature' is - assumed. - :vartype storage_container_identity: str - :ivar storage_container_sas_token: Conditional. If createMode is RestoreExternalBackup and - storageContainerIdentity is not ManagedIdentity, this value is required. Specifies the storage - container sas token. - :vartype storage_container_sas_token: str - :ivar failover_group_id: Instance Failover Group resource identifier that this managed database - belongs to. - :vartype failover_group_id: str - :ivar recoverable_database_id: The resource identifier of the recoverable database associated - with create operation of this database. - :vartype recoverable_database_id: str - :ivar long_term_retention_backup_resource_id: The name of the Long Term Retention backup to be - used for restore of this managed database. - :vartype long_term_retention_backup_resource_id: str - :ivar auto_complete_restore: Whether to auto complete restore of this managed database. - :vartype auto_complete_restore: bool - :ivar last_backup_name: Last backup file name for restore of this managed database. - :vartype last_backup_name: str - :ivar cross_subscription_target_managed_instance_id: Target managed instance id used in - cross-subscription restore. - :vartype cross_subscription_target_managed_instance_id: str - :ivar is_ledger_on: Whether or not this database is a ledger database, which means all tables - in the database are ledger tables. Note: the value of this property cannot be changed after the - database has been created. - :vartype is_ledger_on: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "status": {"readonly": True}, - "creation_date": {"readonly": True}, - "earliest_restore_point": {"readonly": True}, - "default_secondary_location": {"readonly": True}, - "failover_group_id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "collation": {"key": "properties.collation", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, - "earliest_restore_point": {"key": "properties.earliestRestorePoint", "type": "iso-8601"}, - "restore_point_in_time": {"key": "properties.restorePointInTime", "type": "iso-8601"}, - "default_secondary_location": {"key": "properties.defaultSecondaryLocation", "type": "str"}, - "catalog_collation": {"key": "properties.catalogCollation", "type": "str"}, - "create_mode": {"key": "properties.createMode", "type": "str"}, - "storage_container_uri": {"key": "properties.storageContainerUri", "type": "str"}, - "source_database_id": {"key": "properties.sourceDatabaseId", "type": "str"}, - "cross_subscription_source_database_id": {"key": "properties.crossSubscriptionSourceDatabaseId", "type": "str"}, - "restorable_dropped_database_id": {"key": "properties.restorableDroppedDatabaseId", "type": "str"}, - "cross_subscription_restorable_dropped_database_id": { - "key": "properties.crossSubscriptionRestorableDroppedDatabaseId", - "type": "str", - }, - "storage_container_identity": {"key": "properties.storageContainerIdentity", "type": "str"}, - "storage_container_sas_token": {"key": "properties.storageContainerSasToken", "type": "str"}, - "failover_group_id": {"key": "properties.failoverGroupId", "type": "str"}, - "recoverable_database_id": {"key": "properties.recoverableDatabaseId", "type": "str"}, - "long_term_retention_backup_resource_id": { - "key": "properties.longTermRetentionBackupResourceId", - "type": "str", - }, - "auto_complete_restore": {"key": "properties.autoCompleteRestore", "type": "bool"}, - "last_backup_name": {"key": "properties.lastBackupName", "type": "str"}, - "cross_subscription_target_managed_instance_id": { - "key": "properties.crossSubscriptionTargetManagedInstanceId", - "type": "str", - }, - "is_ledger_on": {"key": "properties.isLedgerOn", "type": "bool"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - location: str, - tags: Optional[dict[str, str]] = None, - collation: Optional[str] = None, - restore_point_in_time: Optional[datetime.datetime] = None, - catalog_collation: Optional[Union[str, "_models.CatalogCollationType"]] = None, - create_mode: Optional[Union[str, "_models.ManagedDatabaseCreateMode"]] = None, - storage_container_uri: Optional[str] = None, - source_database_id: Optional[str] = None, - cross_subscription_source_database_id: Optional[str] = None, - restorable_dropped_database_id: Optional[str] = None, - cross_subscription_restorable_dropped_database_id: Optional[str] = None, - storage_container_identity: Optional[str] = None, - storage_container_sas_token: Optional[str] = None, - recoverable_database_id: Optional[str] = None, - long_term_retention_backup_resource_id: Optional[str] = None, - auto_complete_restore: Optional[bool] = None, - last_backup_name: Optional[str] = None, - cross_subscription_target_managed_instance_id: Optional[str] = None, - is_ledger_on: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword collation: Collation of the managed database. - :paramtype collation: str - :keyword restore_point_in_time: Conditional. If createMode is PointInTimeRestore, this value is - required. Specifies the point in time (ISO8601 format) of the source database that will be - restored to create the new database. - :paramtype restore_point_in_time: ~datetime.datetime - :keyword catalog_collation: Collation of the metadata catalog. Known values are: - "DATABASE_DEFAULT" and "SQL_Latin1_General_CP1_CI_AS". - :paramtype catalog_collation: str or ~azure.mgmt.sql.models.CatalogCollationType - :keyword create_mode: Managed database create mode. PointInTimeRestore: Create a database by - restoring a point in time backup of an existing database. SourceDatabaseName, - SourceManagedInstanceName and PointInTime must be specified. RestoreExternalBackup: Create a - database by restoring from external backup files. Collation, StorageContainerUri and - StorageContainerSasToken must be specified. Recovery: Creates a database by restoring a - geo-replicated backup. RecoverableDatabaseId must be specified as the recoverable database - resource ID to restore. RestoreLongTermRetentionBackup: Create a database by restoring from a - long term retention backup (longTermRetentionBackupResourceId required). Known values are: - "Default", "RestoreExternalBackup", "PointInTimeRestore", "Recovery", and - "RestoreLongTermRetentionBackup". - :paramtype create_mode: str or ~azure.mgmt.sql.models.ManagedDatabaseCreateMode - :keyword storage_container_uri: Conditional. If createMode is RestoreExternalBackup, this value - is required. Specifies the uri of the storage container where backups for this restore are - stored. - :paramtype storage_container_uri: str - :keyword source_database_id: The resource identifier of the source database associated with - create operation of this database. - :paramtype source_database_id: str - :keyword cross_subscription_source_database_id: The resource identifier of the - cross-subscription source database associated with create operation of this database. - :paramtype cross_subscription_source_database_id: str - :keyword restorable_dropped_database_id: The restorable dropped database resource id to restore - when creating this database. - :paramtype restorable_dropped_database_id: str - :keyword cross_subscription_restorable_dropped_database_id: The restorable cross-subscription - dropped database resource id to restore when creating this database. - :paramtype cross_subscription_restorable_dropped_database_id: str - :keyword storage_container_identity: Conditional. If createMode is RestoreExternalBackup, this - value is used. Specifies the identity used for storage container authentication. Can be - 'SharedAccessSignature' or 'ManagedIdentity'; if not specified 'SharedAccessSignature' is - assumed. - :paramtype storage_container_identity: str - :keyword storage_container_sas_token: Conditional. If createMode is RestoreExternalBackup and - storageContainerIdentity is not ManagedIdentity, this value is required. Specifies the storage - container sas token. - :paramtype storage_container_sas_token: str - :keyword recoverable_database_id: The resource identifier of the recoverable database - associated with create operation of this database. - :paramtype recoverable_database_id: str - :keyword long_term_retention_backup_resource_id: The name of the Long Term Retention backup to - be used for restore of this managed database. - :paramtype long_term_retention_backup_resource_id: str - :keyword auto_complete_restore: Whether to auto complete restore of this managed database. - :paramtype auto_complete_restore: bool - :keyword last_backup_name: Last backup file name for restore of this managed database. - :paramtype last_backup_name: str - :keyword cross_subscription_target_managed_instance_id: Target managed instance id used in - cross-subscription restore. - :paramtype cross_subscription_target_managed_instance_id: str - :keyword is_ledger_on: Whether or not this database is a ledger database, which means all - tables in the database are ledger tables. Note: the value of this property cannot be changed - after the database has been created. - :paramtype is_ledger_on: bool - """ - super().__init__(location=location, tags=tags, **kwargs) - self.collation = collation - self.status: Optional[Union[str, "_models.ManagedDatabaseStatus"]] = None - self.creation_date: Optional[datetime.datetime] = None - self.earliest_restore_point: Optional[datetime.datetime] = None - self.restore_point_in_time = restore_point_in_time - self.default_secondary_location: Optional[str] = None - self.catalog_collation = catalog_collation - self.create_mode = create_mode - self.storage_container_uri = storage_container_uri - self.source_database_id = source_database_id - self.cross_subscription_source_database_id = cross_subscription_source_database_id - self.restorable_dropped_database_id = restorable_dropped_database_id - self.cross_subscription_restorable_dropped_database_id = cross_subscription_restorable_dropped_database_id - self.storage_container_identity = storage_container_identity - self.storage_container_sas_token = storage_container_sas_token - self.failover_group_id: Optional[str] = None - self.recoverable_database_id = recoverable_database_id - self.long_term_retention_backup_resource_id = long_term_retention_backup_resource_id - self.auto_complete_restore = auto_complete_restore - self.last_backup_name = last_backup_name - self.cross_subscription_target_managed_instance_id = cross_subscription_target_managed_instance_id - self.is_ledger_on = is_ledger_on - - -class ManagedDatabaseAdvancedThreatProtection(ProxyResource): - """A managed database Advanced Threat Protection. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: SystemData of AdvancedThreatProtectionResource. - :vartype system_data: ~azure.mgmt.sql.models.SystemData - :ivar state: Specifies the state of the Advanced Threat Protection, whether it is enabled or - disabled or a state has not been applied yet on the specific database or server. Known values - are: "New", "Enabled", and "Disabled". - :vartype state: str or ~azure.mgmt.sql.models.AdvancedThreatProtectionState - :ivar creation_time: Specifies the UTC creation time of the policy. - :vartype creation_time: ~datetime.datetime - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "creation_time": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "state": {"key": "properties.state", "type": "str"}, - "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, - } - - def __init__( - self, *, state: Optional[Union[str, "_models.AdvancedThreatProtectionState"]] = None, **kwargs: Any - ) -> None: - """ - :keyword state: Specifies the state of the Advanced Threat Protection, whether it is enabled or - disabled or a state has not been applied yet on the specific database or server. Known values - are: "New", "Enabled", and "Disabled". - :paramtype state: str or ~azure.mgmt.sql.models.AdvancedThreatProtectionState - """ - super().__init__(**kwargs) - self.system_data: Optional["_models.SystemData"] = None - self.state = state - self.creation_time: Optional[datetime.datetime] = None - - -class ManagedDatabaseAdvancedThreatProtectionListResult(_serialization.Model): # pylint: disable=name-too-long - """A list of the managed database's Advanced Threat Protection settings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ManagedDatabaseAdvancedThreatProtection]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ManagedDatabaseAdvancedThreatProtection"]] = None - self.next_link: Optional[str] = None - - -class ManagedDatabaseListResult(_serialization.Model): - """A list of managed databases. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ManagedDatabase] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ManagedDatabase]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ManagedDatabase"]] = None - self.next_link: Optional[str] = None - - -class ManagedDatabaseMoveDefinition(_serialization.Model): - """Contains the information necessary to perform a managed database move. - - All required parameters must be populated in order to send to server. - - :ivar destination_managed_database_id: The destination managed database ID. Required. - :vartype destination_managed_database_id: str - """ - - _validation = { - "destination_managed_database_id": {"required": True}, - } - - _attribute_map = { - "destination_managed_database_id": {"key": "destinationManagedDatabaseId", "type": "str"}, - } - - def __init__(self, *, destination_managed_database_id: str, **kwargs: Any) -> None: - """ - :keyword destination_managed_database_id: The destination managed database ID. Required. - :paramtype destination_managed_database_id: str - """ - super().__init__(**kwargs) - self.destination_managed_database_id = destination_managed_database_id - - -class ManagedDatabaseMoveOperationListResult(_serialization.Model): - """List of managed database move operations. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ManagedDatabaseMoveOperationResult] - :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": "[ManagedDatabaseMoveOperationResult]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ManagedDatabaseMoveOperationResult"]] = None - self.next_link: Optional[str] = None - - -class ManagedDatabaseMoveOperationResult(ProxyResource): - """A managed database move operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar operation: The name of operation. - :vartype operation: str - :ivar operation_friendly_name: The friendly name of operation. - :vartype operation_friendly_name: str - :ivar start_time: The operation start time. - :vartype start_time: ~datetime.datetime - :ivar state: The operation state. Known values are: "Pending", "InProgress", "Succeeded", - "Failed", "CancelInProgress", and "Cancelled". - :vartype state: str or ~azure.mgmt.sql.models.ManagementOperationState - :ivar operation_mode: Operation mode. Known values are: "Move" and "Copy". - :vartype operation_mode: str or ~azure.mgmt.sql.models.MoveOperationMode - :ivar source_managed_instance_name: Source Managed Instance name. - :vartype source_managed_instance_name: str - :ivar target_managed_instance_name: Target Managed Instance name. - :vartype target_managed_instance_name: str - :ivar source_managed_instance_id: Source Managed Instance resource id. - :vartype source_managed_instance_id: str - :ivar target_managed_instance_id: Target Managed instance resource id. - :vartype target_managed_instance_id: str - :ivar source_database_name: Source database name. - :vartype source_database_name: str - :ivar target_database_name: Target database name. - :vartype target_database_name: str - :ivar is_cancellable: Is move operation cancellable. - :vartype is_cancellable: bool - :ivar error_code: The operation error code. - :vartype error_code: int - :ivar error_description: The operation error description. - :vartype error_description: str - :ivar error_severity: The operation error severity. - :vartype error_severity: int - :ivar is_user_error: Whether or not the error is a user error. - :vartype is_user_error: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "operation": {"readonly": True}, - "operation_friendly_name": {"readonly": True}, - "start_time": {"readonly": True}, - "state": {"readonly": True}, - "operation_mode": {"readonly": True}, - "source_managed_instance_name": {"readonly": True}, - "target_managed_instance_name": {"readonly": True}, - "source_managed_instance_id": {"readonly": True}, - "target_managed_instance_id": {"readonly": True}, - "source_database_name": {"readonly": True}, - "target_database_name": {"readonly": True}, - "is_cancellable": {"readonly": True}, - "error_code": {"readonly": True}, - "error_description": {"readonly": True}, - "error_severity": {"readonly": True}, - "is_user_error": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "operation": {"key": "properties.operation", "type": "str"}, - "operation_friendly_name": {"key": "properties.operationFriendlyName", "type": "str"}, - "start_time": {"key": "properties.startTime", "type": "iso-8601"}, - "state": {"key": "properties.state", "type": "str"}, - "operation_mode": {"key": "properties.operationMode", "type": "str"}, - "source_managed_instance_name": {"key": "properties.sourceManagedInstanceName", "type": "str"}, - "target_managed_instance_name": {"key": "properties.targetManagedInstanceName", "type": "str"}, - "source_managed_instance_id": {"key": "properties.sourceManagedInstanceId", "type": "str"}, - "target_managed_instance_id": {"key": "properties.targetManagedInstanceId", "type": "str"}, - "source_database_name": {"key": "properties.sourceDatabaseName", "type": "str"}, - "target_database_name": {"key": "properties.targetDatabaseName", "type": "str"}, - "is_cancellable": {"key": "properties.isCancellable", "type": "bool"}, - "error_code": {"key": "properties.errorCode", "type": "int"}, - "error_description": {"key": "properties.errorDescription", "type": "str"}, - "error_severity": {"key": "properties.errorSeverity", "type": "int"}, - "is_user_error": {"key": "properties.isUserError", "type": "bool"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.operation: Optional[str] = None - self.operation_friendly_name: Optional[str] = None - self.start_time: Optional[datetime.datetime] = None - self.state: Optional[Union[str, "_models.ManagementOperationState"]] = None - self.operation_mode: Optional[Union[str, "_models.MoveOperationMode"]] = None - self.source_managed_instance_name: Optional[str] = None - self.target_managed_instance_name: Optional[str] = None - self.source_managed_instance_id: Optional[str] = None - self.target_managed_instance_id: Optional[str] = None - self.source_database_name: Optional[str] = None - self.target_database_name: Optional[str] = None - self.is_cancellable: Optional[bool] = None - self.error_code: Optional[int] = None - self.error_description: Optional[str] = None - self.error_severity: Optional[int] = None - self.is_user_error: Optional[bool] = None - - -class ManagedDatabaseRestoreDetailsBackupSetProperties(_serialization.Model): # pylint: disable=name-too-long - """The managed database's restore details backup set properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: Backup set status. - :vartype status: str - :ivar first_stripe_name: First stripe name. - :vartype first_stripe_name: str - :ivar number_of_stripes: Number of stripes. - :vartype number_of_stripes: int - :ivar backup_size_mb: Backup size. - :vartype backup_size_mb: int - :ivar restore_started_timestamp_utc: Last restored file time. - :vartype restore_started_timestamp_utc: ~datetime.datetime - :ivar restore_finished_timestamp_utc: Last restored file time. - :vartype restore_finished_timestamp_utc: ~datetime.datetime - """ - - _validation = { - "status": {"readonly": True}, - "first_stripe_name": {"readonly": True}, - "number_of_stripes": {"readonly": True}, - "backup_size_mb": {"readonly": True}, - "restore_started_timestamp_utc": {"readonly": True}, - "restore_finished_timestamp_utc": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "first_stripe_name": {"key": "firstStripeName", "type": "str"}, - "number_of_stripes": {"key": "numberOfStripes", "type": "int"}, - "backup_size_mb": {"key": "backupSizeMB", "type": "int"}, - "restore_started_timestamp_utc": {"key": "restoreStartedTimestampUtc", "type": "iso-8601"}, - "restore_finished_timestamp_utc": {"key": "restoreFinishedTimestampUtc", "type": "iso-8601"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.status: Optional[str] = None - self.first_stripe_name: Optional[str] = None - self.number_of_stripes: Optional[int] = None - self.backup_size_mb: Optional[int] = None - self.restore_started_timestamp_utc: Optional[datetime.datetime] = None - self.restore_finished_timestamp_utc: Optional[datetime.datetime] = None - - -class ManagedDatabaseRestoreDetailsResult(ProxyResource): - """A managed database restore details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar type_properties_type: Restore type. - :vartype type_properties_type: str - :ivar status: Restore status. - :vartype status: str - :ivar block_reason: The reason why restore is in Blocked state. - :vartype block_reason: str - :ivar last_uploaded_file_name: Last uploaded file name. - :vartype last_uploaded_file_name: str - :ivar last_uploaded_file_time: Last uploaded file time. - :vartype last_uploaded_file_time: ~datetime.datetime - :ivar last_restored_file_name: Last restored file name. - :vartype last_restored_file_name: str - :ivar last_restored_file_time: Last restored file time. - :vartype last_restored_file_time: ~datetime.datetime - :ivar percent_completed: Percent completed. - :vartype percent_completed: int - :ivar current_restored_size_mb: Current restored size MB. - :vartype current_restored_size_mb: int - :ivar current_restore_plan_size_mb: Current restore plan size MB. - :vartype current_restore_plan_size_mb: int - :ivar current_backup_type: Current backup type. - :vartype current_backup_type: str - :ivar current_restoring_file_name: Current restoring file name. - :vartype current_restoring_file_name: str - :ivar number_of_files_detected: Number of files detected. - :vartype number_of_files_detected: int - :ivar number_of_files_queued: Number of files queued. - :vartype number_of_files_queued: int - :ivar number_of_files_skipped: Number of files skipped. - :vartype number_of_files_skipped: int - :ivar number_of_files_restoring: Number of files restoring. - :vartype number_of_files_restoring: int - :ivar number_of_files_restored: Number of files restored. - :vartype number_of_files_restored: int - :ivar number_of_files_unrestorable: Number of files unrestorable. - :vartype number_of_files_unrestorable: int - :ivar full_backup_sets: Full backup sets. - :vartype full_backup_sets: - list[~azure.mgmt.sql.models.ManagedDatabaseRestoreDetailsBackupSetProperties] - :ivar diff_backup_sets: Diff backup sets. - :vartype diff_backup_sets: - list[~azure.mgmt.sql.models.ManagedDatabaseRestoreDetailsBackupSetProperties] - :ivar log_backup_sets: Log backup sets. - :vartype log_backup_sets: - list[~azure.mgmt.sql.models.ManagedDatabaseRestoreDetailsBackupSetProperties] - :ivar unrestorable_files: Unrestorable files. - :vartype unrestorable_files: - list[~azure.mgmt.sql.models.ManagedDatabaseRestoreDetailsUnrestorableFileProperties] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "type_properties_type": {"readonly": True}, - "status": {"readonly": True}, - "block_reason": {"readonly": True}, - "last_uploaded_file_name": {"readonly": True}, - "last_uploaded_file_time": {"readonly": True}, - "last_restored_file_name": {"readonly": True}, - "last_restored_file_time": {"readonly": True}, - "percent_completed": {"readonly": True}, - "current_restored_size_mb": {"readonly": True}, - "current_restore_plan_size_mb": {"readonly": True}, - "current_backup_type": {"readonly": True}, - "current_restoring_file_name": {"readonly": True}, - "number_of_files_detected": {"readonly": True}, - "number_of_files_queued": {"readonly": True}, - "number_of_files_skipped": {"readonly": True}, - "number_of_files_restoring": {"readonly": True}, - "number_of_files_restored": {"readonly": True}, - "number_of_files_unrestorable": {"readonly": True}, - "full_backup_sets": {"readonly": True}, - "diff_backup_sets": {"readonly": True}, - "log_backup_sets": {"readonly": True}, - "unrestorable_files": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "type_properties_type": {"key": "properties.type", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "block_reason": {"key": "properties.blockReason", "type": "str"}, - "last_uploaded_file_name": {"key": "properties.lastUploadedFileName", "type": "str"}, - "last_uploaded_file_time": {"key": "properties.lastUploadedFileTime", "type": "iso-8601"}, - "last_restored_file_name": {"key": "properties.lastRestoredFileName", "type": "str"}, - "last_restored_file_time": {"key": "properties.lastRestoredFileTime", "type": "iso-8601"}, - "percent_completed": {"key": "properties.percentCompleted", "type": "int"}, - "current_restored_size_mb": {"key": "properties.currentRestoredSizeMB", "type": "int"}, - "current_restore_plan_size_mb": {"key": "properties.currentRestorePlanSizeMB", "type": "int"}, - "current_backup_type": {"key": "properties.currentBackupType", "type": "str"}, - "current_restoring_file_name": {"key": "properties.currentRestoringFileName", "type": "str"}, - "number_of_files_detected": {"key": "properties.numberOfFilesDetected", "type": "int"}, - "number_of_files_queued": {"key": "properties.numberOfFilesQueued", "type": "int"}, - "number_of_files_skipped": {"key": "properties.numberOfFilesSkipped", "type": "int"}, - "number_of_files_restoring": {"key": "properties.numberOfFilesRestoring", "type": "int"}, - "number_of_files_restored": {"key": "properties.numberOfFilesRestored", "type": "int"}, - "number_of_files_unrestorable": {"key": "properties.numberOfFilesUnrestorable", "type": "int"}, - "full_backup_sets": { - "key": "properties.fullBackupSets", - "type": "[ManagedDatabaseRestoreDetailsBackupSetProperties]", - }, - "diff_backup_sets": { - "key": "properties.diffBackupSets", - "type": "[ManagedDatabaseRestoreDetailsBackupSetProperties]", - }, - "log_backup_sets": { - "key": "properties.logBackupSets", - "type": "[ManagedDatabaseRestoreDetailsBackupSetProperties]", - }, - "unrestorable_files": { - "key": "properties.unrestorableFiles", - "type": "[ManagedDatabaseRestoreDetailsUnrestorableFileProperties]", - }, - } - - def __init__(self, **kwargs: Any) -> None: # pylint: disable=too-many-locals - """ """ - super().__init__(**kwargs) - self.type_properties_type: Optional[str] = None - self.status: Optional[str] = None - self.block_reason: Optional[str] = None - self.last_uploaded_file_name: Optional[str] = None - self.last_uploaded_file_time: Optional[datetime.datetime] = None - self.last_restored_file_name: Optional[str] = None - self.last_restored_file_time: Optional[datetime.datetime] = None - self.percent_completed: Optional[int] = None - self.current_restored_size_mb: Optional[int] = None - self.current_restore_plan_size_mb: Optional[int] = None - self.current_backup_type: Optional[str] = None - self.current_restoring_file_name: Optional[str] = None - self.number_of_files_detected: Optional[int] = None - self.number_of_files_queued: Optional[int] = None - self.number_of_files_skipped: Optional[int] = None - self.number_of_files_restoring: Optional[int] = None - self.number_of_files_restored: Optional[int] = None - self.number_of_files_unrestorable: Optional[int] = None - self.full_backup_sets: Optional[list["_models.ManagedDatabaseRestoreDetailsBackupSetProperties"]] = None - self.diff_backup_sets: Optional[list["_models.ManagedDatabaseRestoreDetailsBackupSetProperties"]] = None - self.log_backup_sets: Optional[list["_models.ManagedDatabaseRestoreDetailsBackupSetProperties"]] = None - self.unrestorable_files: Optional[list["_models.ManagedDatabaseRestoreDetailsUnrestorableFileProperties"]] = ( - None - ) - - -class ManagedDatabaseRestoreDetailsUnrestorableFileProperties(_serialization.Model): # pylint: disable=name-too-long - """The managed database's restore details unrestorable file properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: File name. - :vartype name: str - """ - - _validation = { - "name": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - - -class ManagedDatabaseSecurityAlertPolicy(ProxyResource): - """A managed database security alert policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar state: Specifies the state of the policy, whether it is enabled or disabled or a policy - has not been applied yet on the specific database. Known values are: "New", "Enabled", and - "Disabled". - :vartype state: str or ~azure.mgmt.sql.models.SecurityAlertPolicyState - :ivar disabled_alerts: Specifies an array of alerts that are disabled. Allowed values are: - Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, Unsafe_Action, - Brute_Force. - :vartype disabled_alerts: list[str] - :ivar email_addresses: Specifies an array of e-mail addresses to which the alert is sent. - :vartype email_addresses: list[str] - :ivar email_account_admins: Specifies that the alert is sent to the account administrators. - :vartype email_account_admins: bool - :ivar storage_endpoint: Specifies the blob storage endpoint (e.g. - https://MyAccount.blob.core.windows.net). This blob storage will hold all Threat Detection - audit logs. - :vartype storage_endpoint: str - :ivar storage_account_access_key: Specifies the identifier key of the Threat Detection audit - storage account. - :vartype storage_account_access_key: str - :ivar retention_days: Specifies the number of days to keep in the Threat Detection audit logs. - :vartype retention_days: int - :ivar creation_time: Specifies the UTC creation time of the policy. - :vartype creation_time: ~datetime.datetime - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "creation_time": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "state": {"key": "properties.state", "type": "str"}, - "disabled_alerts": {"key": "properties.disabledAlerts", "type": "[str]"}, - "email_addresses": {"key": "properties.emailAddresses", "type": "[str]"}, - "email_account_admins": {"key": "properties.emailAccountAdmins", "type": "bool"}, - "storage_endpoint": {"key": "properties.storageEndpoint", "type": "str"}, - "storage_account_access_key": {"key": "properties.storageAccountAccessKey", "type": "str"}, - "retention_days": {"key": "properties.retentionDays", "type": "int"}, - "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, - } - - def __init__( - self, - *, - state: Optional[Union[str, "_models.SecurityAlertPolicyState"]] = None, - disabled_alerts: Optional[list[str]] = None, - email_addresses: Optional[list[str]] = None, - email_account_admins: Optional[bool] = None, - storage_endpoint: Optional[str] = None, - storage_account_access_key: Optional[str] = None, - retention_days: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword state: Specifies the state of the policy, whether it is enabled or disabled or a - policy has not been applied yet on the specific database. Known values are: "New", "Enabled", - and "Disabled". - :paramtype state: str or ~azure.mgmt.sql.models.SecurityAlertPolicyState - :keyword disabled_alerts: Specifies an array of alerts that are disabled. Allowed values are: - Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, Unsafe_Action, - Brute_Force. - :paramtype disabled_alerts: list[str] - :keyword email_addresses: Specifies an array of e-mail addresses to which the alert is sent. - :paramtype email_addresses: list[str] - :keyword email_account_admins: Specifies that the alert is sent to the account administrators. - :paramtype email_account_admins: bool - :keyword storage_endpoint: Specifies the blob storage endpoint (e.g. - https://MyAccount.blob.core.windows.net). This blob storage will hold all Threat Detection - audit logs. - :paramtype storage_endpoint: str - :keyword storage_account_access_key: Specifies the identifier key of the Threat Detection audit - storage account. - :paramtype storage_account_access_key: str - :keyword retention_days: Specifies the number of days to keep in the Threat Detection audit - logs. - :paramtype retention_days: int - """ - super().__init__(**kwargs) - self.state = state - self.disabled_alerts = disabled_alerts - self.email_addresses = email_addresses - self.email_account_admins = email_account_admins - self.storage_endpoint = storage_endpoint - self.storage_account_access_key = storage_account_access_key - self.retention_days = retention_days - self.creation_time: Optional[datetime.datetime] = None - - -class ManagedDatabaseSecurityAlertPolicyListResult(_serialization.Model): # pylint: disable=name-too-long - """A list of the managed database's security alert policies. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ManagedDatabaseSecurityAlertPolicy]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ManagedDatabaseSecurityAlertPolicy"]] = None - self.next_link: Optional[str] = None - - -class ManagedDatabaseStartMoveDefinition(_serialization.Model): - """Contains the information necessary to start a managed database move. - - All required parameters must be populated in order to send to server. - - :ivar destination_managed_database_id: The destination managed database ID. Required. - :vartype destination_managed_database_id: str - :ivar operation_mode: The move operation mode. Known values are: "Move" and "Copy". - :vartype operation_mode: str or ~azure.mgmt.sql.models.MoveOperationMode - """ - - _validation = { - "destination_managed_database_id": {"required": True}, - } - - _attribute_map = { - "destination_managed_database_id": {"key": "destinationManagedDatabaseId", "type": "str"}, - "operation_mode": {"key": "operationMode", "type": "str"}, - } - - def __init__( - self, - *, - destination_managed_database_id: str, - operation_mode: Optional[Union[str, "_models.MoveOperationMode"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword destination_managed_database_id: The destination managed database ID. Required. - :paramtype destination_managed_database_id: str - :keyword operation_mode: The move operation mode. Known values are: "Move" and "Copy". - :paramtype operation_mode: str or ~azure.mgmt.sql.models.MoveOperationMode - """ - super().__init__(**kwargs) - self.destination_managed_database_id = destination_managed_database_id - self.operation_mode = operation_mode - - -class ManagedDatabaseUpdate(_serialization.Model): - """An managed database update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar collation: Collation of the managed database. - :vartype collation: str - :ivar status: Status of the database. Known values are: "Online", "Offline", "Shutdown", - "Creating", "Inaccessible", "Restoring", "Updating", "Stopping", "Stopped", "Starting", - "DbMoving", and "DbCopying". - :vartype status: str or ~azure.mgmt.sql.models.ManagedDatabaseStatus - :ivar creation_date: Creation date of the database. - :vartype creation_date: ~datetime.datetime - :ivar earliest_restore_point: Earliest restore point in time for point in time restore. - :vartype earliest_restore_point: ~datetime.datetime - :ivar restore_point_in_time: Conditional. If createMode is PointInTimeRestore, this value is - required. Specifies the point in time (ISO8601 format) of the source database that will be - restored to create the new database. - :vartype restore_point_in_time: ~datetime.datetime - :ivar default_secondary_location: Geo paired region. - :vartype default_secondary_location: str - :ivar catalog_collation: Collation of the metadata catalog. Known values are: - "DATABASE_DEFAULT" and "SQL_Latin1_General_CP1_CI_AS". - :vartype catalog_collation: str or ~azure.mgmt.sql.models.CatalogCollationType - :ivar create_mode: Managed database create mode. PointInTimeRestore: Create a database by - restoring a point in time backup of an existing database. SourceDatabaseName, - SourceManagedInstanceName and PointInTime must be specified. RestoreExternalBackup: Create a - database by restoring from external backup files. Collation, StorageContainerUri and - StorageContainerSasToken must be specified. Recovery: Creates a database by restoring a - geo-replicated backup. RecoverableDatabaseId must be specified as the recoverable database - resource ID to restore. RestoreLongTermRetentionBackup: Create a database by restoring from a - long term retention backup (longTermRetentionBackupResourceId required). Known values are: - "Default", "RestoreExternalBackup", "PointInTimeRestore", "Recovery", and - "RestoreLongTermRetentionBackup". - :vartype create_mode: str or ~azure.mgmt.sql.models.ManagedDatabaseCreateMode - :ivar storage_container_uri: Conditional. If createMode is RestoreExternalBackup, this value is - required. Specifies the uri of the storage container where backups for this restore are stored. - :vartype storage_container_uri: str - :ivar source_database_id: The resource identifier of the source database associated with create - operation of this database. - :vartype source_database_id: str - :ivar cross_subscription_source_database_id: The resource identifier of the cross-subscription - source database associated with create operation of this database. - :vartype cross_subscription_source_database_id: str - :ivar restorable_dropped_database_id: The restorable dropped database resource id to restore - when creating this database. - :vartype restorable_dropped_database_id: str - :ivar cross_subscription_restorable_dropped_database_id: The restorable cross-subscription - dropped database resource id to restore when creating this database. - :vartype cross_subscription_restorable_dropped_database_id: str - :ivar storage_container_identity: Conditional. If createMode is RestoreExternalBackup, this - value is used. Specifies the identity used for storage container authentication. Can be - 'SharedAccessSignature' or 'ManagedIdentity'; if not specified 'SharedAccessSignature' is - assumed. - :vartype storage_container_identity: str - :ivar storage_container_sas_token: Conditional. If createMode is RestoreExternalBackup and - storageContainerIdentity is not ManagedIdentity, this value is required. Specifies the storage - container sas token. - :vartype storage_container_sas_token: str - :ivar failover_group_id: Instance Failover Group resource identifier that this managed database - belongs to. - :vartype failover_group_id: str - :ivar recoverable_database_id: The resource identifier of the recoverable database associated - with create operation of this database. - :vartype recoverable_database_id: str - :ivar long_term_retention_backup_resource_id: The name of the Long Term Retention backup to be - used for restore of this managed database. - :vartype long_term_retention_backup_resource_id: str - :ivar auto_complete_restore: Whether to auto complete restore of this managed database. - :vartype auto_complete_restore: bool - :ivar last_backup_name: Last backup file name for restore of this managed database. - :vartype last_backup_name: str - :ivar cross_subscription_target_managed_instance_id: Target managed instance id used in - cross-subscription restore. - :vartype cross_subscription_target_managed_instance_id: str - :ivar is_ledger_on: Whether or not this database is a ledger database, which means all tables - in the database are ledger tables. Note: the value of this property cannot be changed after the - database has been created. - :vartype is_ledger_on: bool - """ - - _validation = { - "status": {"readonly": True}, - "creation_date": {"readonly": True}, - "earliest_restore_point": {"readonly": True}, - "default_secondary_location": {"readonly": True}, - "failover_group_id": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "collation": {"key": "properties.collation", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, - "earliest_restore_point": {"key": "properties.earliestRestorePoint", "type": "iso-8601"}, - "restore_point_in_time": {"key": "properties.restorePointInTime", "type": "iso-8601"}, - "default_secondary_location": {"key": "properties.defaultSecondaryLocation", "type": "str"}, - "catalog_collation": {"key": "properties.catalogCollation", "type": "str"}, - "create_mode": {"key": "properties.createMode", "type": "str"}, - "storage_container_uri": {"key": "properties.storageContainerUri", "type": "str"}, - "source_database_id": {"key": "properties.sourceDatabaseId", "type": "str"}, - "cross_subscription_source_database_id": {"key": "properties.crossSubscriptionSourceDatabaseId", "type": "str"}, - "restorable_dropped_database_id": {"key": "properties.restorableDroppedDatabaseId", "type": "str"}, - "cross_subscription_restorable_dropped_database_id": { - "key": "properties.crossSubscriptionRestorableDroppedDatabaseId", - "type": "str", - }, - "storage_container_identity": {"key": "properties.storageContainerIdentity", "type": "str"}, - "storage_container_sas_token": {"key": "properties.storageContainerSasToken", "type": "str"}, - "failover_group_id": {"key": "properties.failoverGroupId", "type": "str"}, - "recoverable_database_id": {"key": "properties.recoverableDatabaseId", "type": "str"}, - "long_term_retention_backup_resource_id": { - "key": "properties.longTermRetentionBackupResourceId", - "type": "str", - }, - "auto_complete_restore": {"key": "properties.autoCompleteRestore", "type": "bool"}, - "last_backup_name": {"key": "properties.lastBackupName", "type": "str"}, - "cross_subscription_target_managed_instance_id": { - "key": "properties.crossSubscriptionTargetManagedInstanceId", - "type": "str", - }, - "is_ledger_on": {"key": "properties.isLedgerOn", "type": "bool"}, - } - - def __init__( - self, - *, - tags: Optional[dict[str, str]] = None, - collation: Optional[str] = None, - restore_point_in_time: Optional[datetime.datetime] = None, - catalog_collation: Optional[Union[str, "_models.CatalogCollationType"]] = None, - create_mode: Optional[Union[str, "_models.ManagedDatabaseCreateMode"]] = None, - storage_container_uri: Optional[str] = None, - source_database_id: Optional[str] = None, - cross_subscription_source_database_id: Optional[str] = None, - restorable_dropped_database_id: Optional[str] = None, - cross_subscription_restorable_dropped_database_id: Optional[str] = None, - storage_container_identity: Optional[str] = None, - storage_container_sas_token: Optional[str] = None, - recoverable_database_id: Optional[str] = None, - long_term_retention_backup_resource_id: Optional[str] = None, - auto_complete_restore: Optional[bool] = None, - last_backup_name: Optional[str] = None, - cross_subscription_target_managed_instance_id: Optional[str] = None, - is_ledger_on: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword collation: Collation of the managed database. - :paramtype collation: str - :keyword restore_point_in_time: Conditional. If createMode is PointInTimeRestore, this value is - required. Specifies the point in time (ISO8601 format) of the source database that will be - restored to create the new database. - :paramtype restore_point_in_time: ~datetime.datetime - :keyword catalog_collation: Collation of the metadata catalog. Known values are: - "DATABASE_DEFAULT" and "SQL_Latin1_General_CP1_CI_AS". - :paramtype catalog_collation: str or ~azure.mgmt.sql.models.CatalogCollationType - :keyword create_mode: Managed database create mode. PointInTimeRestore: Create a database by - restoring a point in time backup of an existing database. SourceDatabaseName, - SourceManagedInstanceName and PointInTime must be specified. RestoreExternalBackup: Create a - database by restoring from external backup files. Collation, StorageContainerUri and - StorageContainerSasToken must be specified. Recovery: Creates a database by restoring a - geo-replicated backup. RecoverableDatabaseId must be specified as the recoverable database - resource ID to restore. RestoreLongTermRetentionBackup: Create a database by restoring from a - long term retention backup (longTermRetentionBackupResourceId required). Known values are: - "Default", "RestoreExternalBackup", "PointInTimeRestore", "Recovery", and - "RestoreLongTermRetentionBackup". - :paramtype create_mode: str or ~azure.mgmt.sql.models.ManagedDatabaseCreateMode - :keyword storage_container_uri: Conditional. If createMode is RestoreExternalBackup, this value - is required. Specifies the uri of the storage container where backups for this restore are - stored. - :paramtype storage_container_uri: str - :keyword source_database_id: The resource identifier of the source database associated with - create operation of this database. - :paramtype source_database_id: str - :keyword cross_subscription_source_database_id: The resource identifier of the - cross-subscription source database associated with create operation of this database. - :paramtype cross_subscription_source_database_id: str - :keyword restorable_dropped_database_id: The restorable dropped database resource id to restore - when creating this database. - :paramtype restorable_dropped_database_id: str - :keyword cross_subscription_restorable_dropped_database_id: The restorable cross-subscription - dropped database resource id to restore when creating this database. - :paramtype cross_subscription_restorable_dropped_database_id: str - :keyword storage_container_identity: Conditional. If createMode is RestoreExternalBackup, this - value is used. Specifies the identity used for storage container authentication. Can be - 'SharedAccessSignature' or 'ManagedIdentity'; if not specified 'SharedAccessSignature' is - assumed. - :paramtype storage_container_identity: str - :keyword storage_container_sas_token: Conditional. If createMode is RestoreExternalBackup and - storageContainerIdentity is not ManagedIdentity, this value is required. Specifies the storage - container sas token. - :paramtype storage_container_sas_token: str - :keyword recoverable_database_id: The resource identifier of the recoverable database - associated with create operation of this database. - :paramtype recoverable_database_id: str - :keyword long_term_retention_backup_resource_id: The name of the Long Term Retention backup to - be used for restore of this managed database. - :paramtype long_term_retention_backup_resource_id: str - :keyword auto_complete_restore: Whether to auto complete restore of this managed database. - :paramtype auto_complete_restore: bool - :keyword last_backup_name: Last backup file name for restore of this managed database. - :paramtype last_backup_name: str - :keyword cross_subscription_target_managed_instance_id: Target managed instance id used in - cross-subscription restore. - :paramtype cross_subscription_target_managed_instance_id: str - :keyword is_ledger_on: Whether or not this database is a ledger database, which means all - tables in the database are ledger tables. Note: the value of this property cannot be changed - after the database has been created. - :paramtype is_ledger_on: bool - """ - super().__init__(**kwargs) - self.tags = tags - self.collation = collation - self.status: Optional[Union[str, "_models.ManagedDatabaseStatus"]] = None - self.creation_date: Optional[datetime.datetime] = None - self.earliest_restore_point: Optional[datetime.datetime] = None - self.restore_point_in_time = restore_point_in_time - self.default_secondary_location: Optional[str] = None - self.catalog_collation = catalog_collation - self.create_mode = create_mode - self.storage_container_uri = storage_container_uri - self.source_database_id = source_database_id - self.cross_subscription_source_database_id = cross_subscription_source_database_id - self.restorable_dropped_database_id = restorable_dropped_database_id - self.cross_subscription_restorable_dropped_database_id = cross_subscription_restorable_dropped_database_id - self.storage_container_identity = storage_container_identity - self.storage_container_sas_token = storage_container_sas_token - self.failover_group_id: Optional[str] = None - self.recoverable_database_id = recoverable_database_id - self.long_term_retention_backup_resource_id = long_term_retention_backup_resource_id - self.auto_complete_restore = auto_complete_restore - self.last_backup_name = last_backup_name - self.cross_subscription_target_managed_instance_id = cross_subscription_target_managed_instance_id - self.is_ledger_on = is_ledger_on - - -class ManagedInstance(TrackedResource): - """An Azure SQL managed instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar identity: The Azure Active Directory identity of the managed instance. - :vartype identity: ~azure.mgmt.sql.models.ResourceIdentity - :ivar sku: Managed instance SKU. Allowed values for sku.name: GP_Gen5, GP_G8IM, GP_G8IH, - BC_Gen5, BC_G8IM, BC_G8IH. - :vartype sku: ~azure.mgmt.sql.models.Sku - :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. - - Restore: Creates an instance by restoring a set of backups to specific point in time. - RestorePointInTime and SourceManagedInstanceId must be specified. Known values are: "Default" - and "PointInTimeRestore". - :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 - :ivar administrator_login_password: The administrator login password (required for managed - instance creation). - :vartype administrator_login_password: str - :ivar subnet_id: Subnet resource ID for the managed instance. - :vartype subnet_id: str - :ivar state: The state of the managed instance. - :vartype state: str - :ivar license_type: The license type. Possible values are 'LicenseIncluded' (regular price - inclusive of a new SQL license) and 'BasePrice' (discounted AHB price for bringing your own SQL - licenses). 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_iops: Storage IOps. Minimum value: 300. Maximum value: 80000. Increments of 1 - IOps allowed only. Maximum value depends on the selected hardware family and number of vCores. - :vartype storage_iops: int - :ivar storage_throughput_mbps: Storage throughput MBps parameter is not supported in the - instance create/update operation. - :vartype storage_throughput_mbps: int - :ivar collation: Collation of the managed instance. - :vartype collation: str - :ivar dns_zone: The Dns Zone that the managed instance is in. - :vartype dns_zone: str - :ivar dns_zone_partner: The resource id of another managed instance whose DNS zone this managed - instance will share after creation. - :vartype dns_zone_partner: str - :ivar public_data_endpoint_enabled: Whether or not the public data endpoint is enabled. - :vartype public_data_endpoint_enabled: bool - :ivar source_managed_instance_id: The resource identifier of the source managed instance - associated with create operation of this instance. - :vartype source_managed_instance_id: str - :ivar restore_point_in_time: Specifies the point in time (ISO8601 format) of the source - database that will be restored to create the new database. - :vartype restore_point_in_time: ~datetime.datetime - :ivar proxy_override: Connection type used for connecting to the instance. Known values are: - "Proxy", "Redirect", and "Default". - :vartype proxy_override: str or ~azure.mgmt.sql.models.ManagedInstanceProxyOverride - :ivar timezone_id: Id of the timezone. Allowed values are timezones supported by Windows. - Windows keeps details on supported timezones, including the id, in registry under - KEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones. - You can get those registry values via SQL Server by querying SELECT name AS timezone_id FROM - sys.time_zone_info. - List of Ids can also be obtained by executing [System.TimeZoneInfo]::GetSystemTimeZones() in - PowerShell. - An example of valid timezone id is "Pacific Standard Time" or "W. Europe Standard Time". - :vartype timezone_id: str - :ivar instance_pool_id: The Id of the instance pool this managed server belongs to. - :vartype instance_pool_id: str - :ivar maintenance_configuration_id: Specifies maintenance configuration id to apply to this - managed instance. - :vartype maintenance_configuration_id: str - :ivar private_endpoint_connections: List of private endpoint connections on a managed instance. - :vartype private_endpoint_connections: list[~azure.mgmt.sql.models.ManagedInstancePecProperty] - :ivar minimal_tls_version: Minimal TLS version. Allowed values: 'None', '1.0', '1.1', '1.2'. - :vartype minimal_tls_version: str - :ivar current_backup_storage_redundancy: The storage account type used to store backups for - this instance. The options are Local (LocallyRedundantStorage), Zone (ZoneRedundantStorage), - Geo (GeoRedundantStorage) and GeoZone(GeoZoneRedundantStorage). Known values are: "Geo", - "Local", "Zone", and "GeoZone". - :vartype current_backup_storage_redundancy: str or - ~azure.mgmt.sql.models.BackupStorageRedundancy - :ivar requested_backup_storage_redundancy: The storage account type to be used to store backups - for this instance. The options are Local (LocallyRedundantStorage), Zone - (ZoneRedundantStorage), Geo (GeoRedundantStorage) and GeoZone(GeoZoneRedundantStorage). Known - values are: "Geo", "Local", "Zone", and "GeoZone". - :vartype requested_backup_storage_redundancy: str or - ~azure.mgmt.sql.models.BackupStorageRedundancy - :ivar zone_redundant: Whether or not the multi-az is enabled. - :vartype zone_redundant: bool - :ivar primary_user_assigned_identity_id: The resource id of a user assigned identity to be used - by default. - :vartype primary_user_assigned_identity_id: str - :ivar key_id: A CMK URI of the key to use for encryption. - :vartype key_id: str - :ivar administrators: The Azure Active Directory administrator of the instance. This can only - be used at instance create time. If used for instance update, it will be ignored or it will - result in an error. For updates individual APIs will need to be used. - :vartype administrators: ~azure.mgmt.sql.models.ManagedInstanceExternalAdministrator - :ivar service_principal: The managed instance's service principal. - :vartype service_principal: ~azure.mgmt.sql.models.ServicePrincipal - :ivar virtual_cluster_id: Virtual cluster resource id for the Managed Instance. - :vartype virtual_cluster_id: str - :ivar external_governance_status: Status of external governance. Known values are: "Enabled" - and "Disabled". - :vartype external_governance_status: str or ~azure.mgmt.sql.models.ExternalGovernanceStatus - :ivar pricing_model: Weather or not Managed Instance is freemium. Known values are: "Regular" - and "Freemium". - :vartype pricing_model: str or ~azure.mgmt.sql.models.FreemiumType - :ivar create_time: Specifies the point in time (ISO8601 format) of the Managed Instance - creation. - :vartype create_time: ~datetime.datetime - :ivar authentication_metadata: The managed instance's authentication metadata lookup mode. - Known values are: "AzureAD", "Paired", and "Windows". - :vartype authentication_metadata: str or ~azure.mgmt.sql.models.AuthMetadataLookupModes - :ivar database_format: Specifies the internal format of instance databases specific to the SQL - engine version. Known values are: "AlwaysUpToDate" and "SQLServer2022". - :vartype database_format: str or ~azure.mgmt.sql.models.ManagedInstanceDatabaseFormat - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, - "fully_qualified_domain_name": {"readonly": True}, - "state": {"readonly": True}, - "hybrid_secondary_usage_detected": {"readonly": True}, - "dns_zone": {"readonly": True}, - "private_endpoint_connections": {"readonly": True}, - "current_backup_storage_redundancy": {"readonly": True}, - "virtual_cluster_id": {"readonly": True}, - "external_governance_status": {"readonly": True}, - "create_time": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "identity": {"key": "identity", "type": "ResourceIdentity"}, - "sku": {"key": "sku", "type": "Sku"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "managed_instance_create_mode": {"key": "properties.managedInstanceCreateMode", "type": "str"}, - "fully_qualified_domain_name": {"key": "properties.fullyQualifiedDomainName", "type": "str"}, - "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_iops": {"key": "properties.storageIOps", "type": "int"}, - "storage_throughput_mbps": {"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"}, - "public_data_endpoint_enabled": {"key": "properties.publicDataEndpointEnabled", "type": "bool"}, - "source_managed_instance_id": {"key": "properties.sourceManagedInstanceId", "type": "str"}, - "restore_point_in_time": {"key": "properties.restorePointInTime", "type": "iso-8601"}, - "proxy_override": {"key": "properties.proxyOverride", "type": "str"}, - "timezone_id": {"key": "properties.timezoneId", "type": "str"}, - "instance_pool_id": {"key": "properties.instancePoolId", "type": "str"}, - "maintenance_configuration_id": {"key": "properties.maintenanceConfigurationId", "type": "str"}, - "private_endpoint_connections": { - "key": "properties.privateEndpointConnections", - "type": "[ManagedInstancePecProperty]", - }, - "minimal_tls_version": {"key": "properties.minimalTlsVersion", "type": "str"}, - "current_backup_storage_redundancy": {"key": "properties.currentBackupStorageRedundancy", "type": "str"}, - "requested_backup_storage_redundancy": {"key": "properties.requestedBackupStorageRedundancy", "type": "str"}, - "zone_redundant": {"key": "properties.zoneRedundant", "type": "bool"}, - "primary_user_assigned_identity_id": {"key": "properties.primaryUserAssignedIdentityId", "type": "str"}, - "key_id": {"key": "properties.keyId", "type": "str"}, - "administrators": {"key": "properties.administrators", "type": "ManagedInstanceExternalAdministrator"}, - "service_principal": {"key": "properties.servicePrincipal", "type": "ServicePrincipal"}, - "virtual_cluster_id": {"key": "properties.virtualClusterId", "type": "str"}, - "external_governance_status": {"key": "properties.externalGovernanceStatus", "type": "str"}, - "pricing_model": {"key": "properties.pricingModel", "type": "str"}, - "create_time": {"key": "properties.createTime", "type": "iso-8601"}, - "authentication_metadata": {"key": "properties.authenticationMetadata", "type": "str"}, - "database_format": {"key": "properties.databaseFormat", "type": "str"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - location: str, - tags: Optional[dict[str, str]] = None, - 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_iops: Optional[int] = None, - storage_throughput_mbps: Optional[int] = None, - collation: Optional[str] = None, - dns_zone_partner: Optional[str] = None, - public_data_endpoint_enabled: Optional[bool] = None, - source_managed_instance_id: Optional[str] = None, - restore_point_in_time: Optional[datetime.datetime] = None, - proxy_override: Optional[Union[str, "_models.ManagedInstanceProxyOverride"]] = None, - timezone_id: Optional[str] = None, - instance_pool_id: Optional[str] = None, - maintenance_configuration_id: Optional[str] = None, - minimal_tls_version: Optional[str] = None, - requested_backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = None, - zone_redundant: Optional[bool] = None, - primary_user_assigned_identity_id: Optional[str] = None, - key_id: Optional[str] = None, - administrators: Optional["_models.ManagedInstanceExternalAdministrator"] = None, - service_principal: Optional["_models.ServicePrincipal"] = None, - pricing_model: Optional[Union[str, "_models.FreemiumType"]] = None, - authentication_metadata: Optional[Union[str, "_models.AuthMetadataLookupModes"]] = None, - database_format: Optional[Union[str, "_models.ManagedInstanceDatabaseFormat"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword identity: The Azure Active Directory identity of the managed instance. - :paramtype identity: ~azure.mgmt.sql.models.ResourceIdentity - :keyword sku: Managed instance SKU. Allowed values for sku.name: GP_Gen5, GP_G8IM, GP_G8IH, - BC_Gen5, BC_G8IM, BC_G8IH. - :paramtype sku: ~azure.mgmt.sql.models.Sku - :keyword managed_instance_create_mode: Specifies the mode of database creation. - - Default: Regular instance creation. - - Restore: Creates an instance by restoring a set of backups to specific point in time. - RestorePointInTime and SourceManagedInstanceId must be specified. 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 - :keyword administrator_login_password: The administrator login password (required for managed - instance creation). - :paramtype administrator_login_password: str - :keyword subnet_id: Subnet resource ID for the managed instance. - :paramtype subnet_id: str - :keyword license_type: The license type. Possible values are 'LicenseIncluded' (regular price - inclusive of a new SQL license) and 'BasePrice' (discounted AHB price for bringing your own SQL - licenses). 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_iops: Storage IOps. Minimum value: 300. Maximum value: 80000. Increments of 1 - IOps allowed only. Maximum value depends on the selected hardware family and number of vCores. - :paramtype storage_iops: int - :keyword storage_throughput_mbps: Storage throughput MBps parameter is not supported in the - instance create/update operation. - :paramtype storage_throughput_mbps: int - :keyword collation: Collation of the managed instance. - :paramtype collation: str - :keyword dns_zone_partner: The resource id of another managed instance whose DNS zone this - managed instance will share after creation. - :paramtype dns_zone_partner: str - :keyword public_data_endpoint_enabled: Whether or not the public data endpoint is enabled. - :paramtype public_data_endpoint_enabled: bool - :keyword source_managed_instance_id: The resource identifier of the source managed instance - associated with create operation of this instance. - :paramtype source_managed_instance_id: str - :keyword restore_point_in_time: Specifies the point in time (ISO8601 format) of the source - database that will be restored to create the new database. - :paramtype restore_point_in_time: ~datetime.datetime - :keyword proxy_override: Connection type used for connecting to the instance. Known values are: - "Proxy", "Redirect", and "Default". - :paramtype proxy_override: str or ~azure.mgmt.sql.models.ManagedInstanceProxyOverride - :keyword timezone_id: Id of the timezone. Allowed values are timezones supported by Windows. - Windows keeps details on supported timezones, including the id, in registry under - KEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones. - You can get those registry values via SQL Server by querying SELECT name AS timezone_id FROM - sys.time_zone_info. - List of Ids can also be obtained by executing [System.TimeZoneInfo]::GetSystemTimeZones() in - PowerShell. - An example of valid timezone id is "Pacific Standard Time" or "W. Europe Standard Time". - :paramtype timezone_id: str - :keyword instance_pool_id: The Id of the instance pool this managed server belongs to. - :paramtype instance_pool_id: str - :keyword maintenance_configuration_id: Specifies maintenance configuration id to apply to this - managed instance. - :paramtype maintenance_configuration_id: str - :keyword minimal_tls_version: Minimal TLS version. Allowed values: 'None', '1.0', '1.1', '1.2'. - :paramtype minimal_tls_version: str - :keyword requested_backup_storage_redundancy: The storage account type to be used to store - backups for this instance. The options are Local (LocallyRedundantStorage), Zone - (ZoneRedundantStorage), Geo (GeoRedundantStorage) and GeoZone(GeoZoneRedundantStorage). Known - values are: "Geo", "Local", "Zone", and "GeoZone". - :paramtype requested_backup_storage_redundancy: str or - ~azure.mgmt.sql.models.BackupStorageRedundancy - :keyword zone_redundant: Whether or not the multi-az is enabled. - :paramtype zone_redundant: bool - :keyword primary_user_assigned_identity_id: The resource id of a user assigned identity to be - used by default. - :paramtype primary_user_assigned_identity_id: str - :keyword key_id: A CMK URI of the key to use for encryption. - :paramtype key_id: str - :keyword administrators: The Azure Active Directory administrator of the instance. This can - only be used at instance create time. If used for instance update, it will be ignored or it - will result in an error. For updates individual APIs will need to be used. - :paramtype administrators: ~azure.mgmt.sql.models.ManagedInstanceExternalAdministrator - :keyword service_principal: The managed instance's service principal. - :paramtype service_principal: ~azure.mgmt.sql.models.ServicePrincipal - :keyword pricing_model: Weather or not Managed Instance is freemium. Known values are: - "Regular" and "Freemium". - :paramtype pricing_model: str or ~azure.mgmt.sql.models.FreemiumType - :keyword authentication_metadata: The managed instance's authentication metadata lookup mode. - Known values are: "AzureAD", "Paired", and "Windows". - :paramtype authentication_metadata: str or ~azure.mgmt.sql.models.AuthMetadataLookupModes - :keyword database_format: Specifies the internal format of instance databases specific to the - SQL engine version. Known values are: "AlwaysUpToDate" and "SQLServer2022". - :paramtype database_format: str or ~azure.mgmt.sql.models.ManagedInstanceDatabaseFormat - """ - super().__init__(location=location, tags=tags, **kwargs) - self.identity = identity - self.sku = sku - self.provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None - self.managed_instance_create_mode = managed_instance_create_mode - self.fully_qualified_domain_name: Optional[str] = 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: Optional[str] = None - self.license_type = license_type - self.hybrid_secondary_usage = hybrid_secondary_usage - self.hybrid_secondary_usage_detected: Optional[Union[str, "_models.HybridSecondaryUsageDetected"]] = None - self.v_cores = v_cores - self.storage_size_in_gb = storage_size_in_gb - self.storage_iops = storage_iops - self.storage_throughput_mbps = storage_throughput_mbps - self.collation = collation - self.dns_zone: Optional[str] = None - self.dns_zone_partner = dns_zone_partner - self.public_data_endpoint_enabled = public_data_endpoint_enabled - self.source_managed_instance_id = source_managed_instance_id - self.restore_point_in_time = restore_point_in_time - self.proxy_override = proxy_override - self.timezone_id = timezone_id - self.instance_pool_id = instance_pool_id - self.maintenance_configuration_id = maintenance_configuration_id - self.private_endpoint_connections: Optional[list["_models.ManagedInstancePecProperty"]] = None - self.minimal_tls_version = minimal_tls_version - self.current_backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = None - self.requested_backup_storage_redundancy = requested_backup_storage_redundancy - self.zone_redundant = zone_redundant - self.primary_user_assigned_identity_id = primary_user_assigned_identity_id - self.key_id = key_id - self.administrators = administrators - self.service_principal = service_principal - self.virtual_cluster_id: Optional[str] = None - self.external_governance_status: Optional[Union[str, "_models.ExternalGovernanceStatus"]] = None - self.pricing_model = pricing_model - self.create_time: Optional[datetime.datetime] = None - self.authentication_metadata = authentication_metadata - self.database_format = database_format - - -class ManagedInstanceAdministrator(ProxyResource): - """An Azure SQL managed instance administrator. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar administrator_type: Type of the managed instance administrator. "ActiveDirectory" - :vartype administrator_type: str or ~azure.mgmt.sql.models.ManagedInstanceAdministratorType - :ivar login: Login name of the managed instance administrator. - :vartype login: str - :ivar sid: SID (object ID) of the managed instance administrator. - :vartype sid: str - :ivar tenant_id: Tenant ID of the managed instance administrator. - :vartype tenant_id: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "administrator_type": {"key": "properties.administratorType", "type": "str"}, - "login": {"key": "properties.login", "type": "str"}, - "sid": {"key": "properties.sid", "type": "str"}, - "tenant_id": {"key": "properties.tenantId", "type": "str"}, - } - - def __init__( - self, - *, - administrator_type: Optional[Union[str, "_models.ManagedInstanceAdministratorType"]] = None, - login: Optional[str] = None, - sid: Optional[str] = None, - tenant_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword administrator_type: Type of the managed instance administrator. "ActiveDirectory" - :paramtype administrator_type: str or ~azure.mgmt.sql.models.ManagedInstanceAdministratorType - :keyword login: Login name of the managed instance administrator. - :paramtype login: str - :keyword sid: SID (object ID) of the managed instance administrator. - :paramtype sid: str - :keyword tenant_id: Tenant ID of the managed instance administrator. - :paramtype tenant_id: str - """ - super().__init__(**kwargs) - self.administrator_type = administrator_type - self.login = login - self.sid = sid - self.tenant_id = tenant_id - - -class ManagedInstanceAdministratorListResult(_serialization.Model): - """A list of managed instance administrators. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ManagedInstanceAdministrator] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ManagedInstanceAdministrator]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ManagedInstanceAdministrator"]] = None - self.next_link: Optional[str] = None - - -class ManagedInstanceAdvancedThreatProtection(ProxyResource): - """A managed instance Advanced Threat Protection. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: SystemData of AdvancedThreatProtectionResource. - :vartype system_data: ~azure.mgmt.sql.models.SystemData - :ivar state: Specifies the state of the Advanced Threat Protection, whether it is enabled or - disabled or a state has not been applied yet on the specific database or server. Known values - are: "New", "Enabled", and "Disabled". - :vartype state: str or ~azure.mgmt.sql.models.AdvancedThreatProtectionState - :ivar creation_time: Specifies the UTC creation time of the policy. - :vartype creation_time: ~datetime.datetime - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "creation_time": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "state": {"key": "properties.state", "type": "str"}, - "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, - } - - def __init__( - self, *, state: Optional[Union[str, "_models.AdvancedThreatProtectionState"]] = None, **kwargs: Any - ) -> None: - """ - :keyword state: Specifies the state of the Advanced Threat Protection, whether it is enabled or - disabled or a state has not been applied yet on the specific database or server. Known values - are: "New", "Enabled", and "Disabled". - :paramtype state: str or ~azure.mgmt.sql.models.AdvancedThreatProtectionState - """ - super().__init__(**kwargs) - self.system_data: Optional["_models.SystemData"] = None - self.state = state - self.creation_time: Optional[datetime.datetime] = None - - -class ManagedInstanceAdvancedThreatProtectionListResult(_serialization.Model): # pylint: disable=name-too-long - """A list of the managed instance's Advanced Threat Protection settings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ManagedInstanceAdvancedThreatProtection]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ManagedInstanceAdvancedThreatProtection"]] = None - self.next_link: Optional[str] = None - - -class ManagedInstanceAzureADOnlyAuthentication(ProxyResource): - """Azure Active Directory only authentication. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar azure_ad_only_authentication: Azure Active Directory only Authentication enabled. - :vartype azure_ad_only_authentication: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "azure_ad_only_authentication": {"key": "properties.azureADOnlyAuthentication", "type": "bool"}, - } - - def __init__(self, *, azure_ad_only_authentication: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword azure_ad_only_authentication: Azure Active Directory only Authentication enabled. - :paramtype azure_ad_only_authentication: bool - """ - super().__init__(**kwargs) - self.azure_ad_only_authentication = azure_ad_only_authentication - - -class ManagedInstanceAzureADOnlyAuthListResult(_serialization.Model): - """A list of active directory only authentications. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ManagedInstanceAzureADOnlyAuthentication]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ManagedInstanceAzureADOnlyAuthentication"]] = None - self.next_link: Optional[str] = None - - -class ManagedInstanceDtc(ProxyResource): - """SQL Managed Instance DTC. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar dtc_enabled: Active status of managed instance DTC. - :vartype dtc_enabled: bool - :ivar security_settings: Security settings of managed instance DTC. - :vartype security_settings: ~azure.mgmt.sql.models.ManagedInstanceDtcSecuritySettings - :ivar external_dns_suffix_search_list: External dns suffix search list of managed instance DTC. - :vartype external_dns_suffix_search_list: list[str] - :ivar dtc_host_name_dns_suffix: Host name dns suffix of managed instance DTC. - :vartype dtc_host_name_dns_suffix: str - :ivar provisioning_state: Provisioning state of managed instance DTC. Known values are: - "Created", "InProgress", "Succeeded", "Failed", and "Canceled". - :vartype provisioning_state: str or ~azure.mgmt.sql.models.ProvisioningState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "dtc_host_name_dns_suffix": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "dtc_enabled": {"key": "properties.dtcEnabled", "type": "bool"}, - "security_settings": {"key": "properties.securitySettings", "type": "ManagedInstanceDtcSecuritySettings"}, - "external_dns_suffix_search_list": {"key": "properties.externalDnsSuffixSearchList", "type": "[str]"}, - "dtc_host_name_dns_suffix": {"key": "properties.dtcHostNameDnsSuffix", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - dtc_enabled: Optional[bool] = None, - security_settings: Optional["_models.ManagedInstanceDtcSecuritySettings"] = None, - external_dns_suffix_search_list: Optional[list[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword dtc_enabled: Active status of managed instance DTC. - :paramtype dtc_enabled: bool - :keyword security_settings: Security settings of managed instance DTC. - :paramtype security_settings: ~azure.mgmt.sql.models.ManagedInstanceDtcSecuritySettings - :keyword external_dns_suffix_search_list: External dns suffix search list of managed instance - DTC. - :paramtype external_dns_suffix_search_list: list[str] - """ - super().__init__(**kwargs) - self.dtc_enabled = dtc_enabled - self.security_settings = security_settings - self.external_dns_suffix_search_list = external_dns_suffix_search_list - self.dtc_host_name_dns_suffix: Optional[str] = None - self.provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None - - -class ManagedInstanceDtcListResult(_serialization.Model): - """A list of managed instance's DTCs. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ManagedInstanceDtc] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ManagedInstanceDtc]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ManagedInstanceDtc"]] = None - self.next_link: Optional[str] = None - - -class ManagedInstanceDtcSecuritySettings(_serialization.Model): - """The Security Settings of managed instance DTC. - - :ivar transaction_manager_communication_settings: Transaction Manager communication settings of - managed instance DTC. - :vartype transaction_manager_communication_settings: - ~azure.mgmt.sql.models.ManagedInstanceDtcTransactionManagerCommunicationSettings - :ivar xa_transactions_enabled: Allow XA Transactions to managed instance DTC. - :vartype xa_transactions_enabled: bool - :ivar sna_lu6_point2_transactions_enabled: Allow SNA LU 6.2 Transactions to managed instance - DTC. - :vartype sna_lu6_point2_transactions_enabled: bool - :ivar xa_transactions_default_timeout: Default timeout for XA Transactions (in seconds). - :vartype xa_transactions_default_timeout: int - :ivar xa_transactions_maximum_timeout: Maximum timeout for XA Transactions (in seconds). - :vartype xa_transactions_maximum_timeout: int - """ - - _attribute_map = { - "transaction_manager_communication_settings": { - "key": "transactionManagerCommunicationSettings", - "type": "ManagedInstanceDtcTransactionManagerCommunicationSettings", - }, - "xa_transactions_enabled": {"key": "xaTransactionsEnabled", "type": "bool"}, - "sna_lu6_point2_transactions_enabled": {"key": "snaLu6point2TransactionsEnabled", "type": "bool"}, - "xa_transactions_default_timeout": {"key": "xaTransactionsDefaultTimeout", "type": "int"}, - "xa_transactions_maximum_timeout": {"key": "xaTransactionsMaximumTimeout", "type": "int"}, - } - - def __init__( - self, - *, - transaction_manager_communication_settings: Optional[ - "_models.ManagedInstanceDtcTransactionManagerCommunicationSettings" - ] = None, - xa_transactions_enabled: Optional[bool] = None, - sna_lu6_point2_transactions_enabled: Optional[bool] = None, - xa_transactions_default_timeout: Optional[int] = None, - xa_transactions_maximum_timeout: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword transaction_manager_communication_settings: Transaction Manager communication settings - of managed instance DTC. - :paramtype transaction_manager_communication_settings: - ~azure.mgmt.sql.models.ManagedInstanceDtcTransactionManagerCommunicationSettings - :keyword xa_transactions_enabled: Allow XA Transactions to managed instance DTC. - :paramtype xa_transactions_enabled: bool - :keyword sna_lu6_point2_transactions_enabled: Allow SNA LU 6.2 Transactions to managed instance - DTC. - :paramtype sna_lu6_point2_transactions_enabled: bool - :keyword xa_transactions_default_timeout: Default timeout for XA Transactions (in seconds). - :paramtype xa_transactions_default_timeout: int - :keyword xa_transactions_maximum_timeout: Maximum timeout for XA Transactions (in seconds). - :paramtype xa_transactions_maximum_timeout: int - """ - super().__init__(**kwargs) - self.transaction_manager_communication_settings = transaction_manager_communication_settings - self.xa_transactions_enabled = xa_transactions_enabled - self.sna_lu6_point2_transactions_enabled = sna_lu6_point2_transactions_enabled - self.xa_transactions_default_timeout = xa_transactions_default_timeout - self.xa_transactions_maximum_timeout = xa_transactions_maximum_timeout - - -class ManagedInstanceDtcTransactionManagerCommunicationSettings(_serialization.Model): # pylint: disable=name-too-long - """The Transaction Manager Communication Settings of managed instance DTC. - - :ivar allow_inbound_enabled: Allow Inbound traffic to managed instance DTC. - :vartype allow_inbound_enabled: bool - :ivar allow_outbound_enabled: Allow Outbound traffic of managed instance DTC. - :vartype allow_outbound_enabled: bool - :ivar authentication: Authentication type of managed instance DTC. - :vartype authentication: str - """ - - _attribute_map = { - "allow_inbound_enabled": {"key": "allowInboundEnabled", "type": "bool"}, - "allow_outbound_enabled": {"key": "allowOutboundEnabled", "type": "bool"}, - "authentication": {"key": "authentication", "type": "str"}, - } - - def __init__( - self, - *, - allow_inbound_enabled: Optional[bool] = None, - allow_outbound_enabled: Optional[bool] = None, - authentication: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword allow_inbound_enabled: Allow Inbound traffic to managed instance DTC. - :paramtype allow_inbound_enabled: bool - :keyword allow_outbound_enabled: Allow Outbound traffic of managed instance DTC. - :paramtype allow_outbound_enabled: bool - :keyword authentication: Authentication type of managed instance DTC. - :paramtype authentication: str - """ - super().__init__(**kwargs) - self.allow_inbound_enabled = allow_inbound_enabled - self.allow_outbound_enabled = allow_outbound_enabled - self.authentication = authentication - - -class ManagedInstanceEditionCapability(_serialization.Model): - """The managed server capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The managed server version name. - :vartype name: str - :ivar supported_families: The supported families. - :vartype supported_families: list[~azure.mgmt.sql.models.ManagedInstanceFamilyCapability] - :ivar supported_storage_capabilities: The list of supported storage capabilities for this - edition. - :vartype supported_storage_capabilities: list[~azure.mgmt.sql.models.StorageCapability] - :ivar zone_redundant: Whether or not zone redundancy is supported for the edition. - :vartype zone_redundant: bool - :ivar status: The status of the capability. 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_families": {"readonly": True}, - "supported_storage_capabilities": {"readonly": True}, - "zone_redundant": {"readonly": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "supported_families": {"key": "supportedFamilies", "type": "[ManagedInstanceFamilyCapability]"}, - "supported_storage_capabilities": {"key": "supportedStorageCapabilities", "type": "[StorageCapability]"}, - "zone_redundant": {"key": "zoneRedundant", "type": "bool"}, - "status": {"key": "status", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - } - - def __init__(self, *, 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: Optional[str] = None - self.supported_families: Optional[list["_models.ManagedInstanceFamilyCapability"]] = None - self.supported_storage_capabilities: Optional[list["_models.StorageCapability"]] = None - self.zone_redundant: Optional[bool] = None - self.status: Optional[Union[str, "_models.CapabilityStatus"]] = None - self.reason = reason - - -class ManagedInstanceEncryptionProtector(ProxyResource): - """The managed instance encryption protector. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar kind: Kind of encryption protector. This is metadata used for the Azure portal - experience. - :vartype kind: str - :ivar server_key_name: The name of the managed instance key. - :vartype server_key_name: str - :ivar server_key_type: The encryption protector type like 'ServiceManaged', 'AzureKeyVault'. - Known values are: "ServiceManaged" and "AzureKeyVault". - :vartype server_key_type: str or ~azure.mgmt.sql.models.ServerKeyType - :ivar uri: The URI of the server key. - :vartype uri: str - :ivar thumbprint: Thumbprint of the server key. - :vartype thumbprint: str - :ivar auto_rotation_enabled: Key auto rotation opt-in flag. Either true or false. - :vartype auto_rotation_enabled: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "kind": {"readonly": True}, - "uri": {"readonly": True}, - "thumbprint": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "server_key_name": {"key": "properties.serverKeyName", "type": "str"}, - "server_key_type": {"key": "properties.serverKeyType", "type": "str"}, - "uri": {"key": "properties.uri", "type": "str"}, - "thumbprint": {"key": "properties.thumbprint", "type": "str"}, - "auto_rotation_enabled": {"key": "properties.autoRotationEnabled", "type": "bool"}, - } - - def __init__( - self, - *, - server_key_name: Optional[str] = None, - server_key_type: Optional[Union[str, "_models.ServerKeyType"]] = None, - auto_rotation_enabled: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword server_key_name: The name of the managed instance key. - :paramtype server_key_name: str - :keyword server_key_type: The encryption protector type like 'ServiceManaged', 'AzureKeyVault'. - Known values are: "ServiceManaged" and "AzureKeyVault". - :paramtype server_key_type: str or ~azure.mgmt.sql.models.ServerKeyType - :keyword auto_rotation_enabled: Key auto rotation opt-in flag. Either true or false. - :paramtype auto_rotation_enabled: bool - """ - super().__init__(**kwargs) - self.kind: Optional[str] = None - self.server_key_name = server_key_name - self.server_key_type = server_key_type - self.uri: Optional[str] = None - self.thumbprint: Optional[str] = None - self.auto_rotation_enabled = auto_rotation_enabled - - -class ManagedInstanceEncryptionProtectorListResult(_serialization.Model): # pylint: disable=name-too-long - """A list of managed instance encryption protectors. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ManagedInstanceEncryptionProtector]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ManagedInstanceEncryptionProtector"]] = None - self.next_link: Optional[str] = None - - -class ManagedInstanceExternalAdministrator(_serialization.Model): - """Properties of a active directory administrator. - - :ivar administrator_type: Type of the sever administrator. "ActiveDirectory" - :vartype administrator_type: str or ~azure.mgmt.sql.models.AdministratorType - :ivar principal_type: Principal Type of the sever administrator. Known values are: "User", - "Group", and "Application". - :vartype principal_type: str or ~azure.mgmt.sql.models.PrincipalType - :ivar login: Login name of the server administrator. - :vartype login: str - :ivar sid: SID (object ID) of the server administrator. - :vartype sid: str - :ivar tenant_id: Tenant ID of the administrator. - :vartype tenant_id: str - :ivar azure_ad_only_authentication: Azure Active Directory only Authentication enabled. - :vartype azure_ad_only_authentication: bool - """ - - _attribute_map = { - "administrator_type": {"key": "administratorType", "type": "str"}, - "principal_type": {"key": "principalType", "type": "str"}, - "login": {"key": "login", "type": "str"}, - "sid": {"key": "sid", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "azure_ad_only_authentication": {"key": "azureADOnlyAuthentication", "type": "bool"}, - } - - def __init__( - self, - *, - administrator_type: Optional[Union[str, "_models.AdministratorType"]] = None, - principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, - login: Optional[str] = None, - sid: Optional[str] = None, - tenant_id: Optional[str] = None, - azure_ad_only_authentication: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword administrator_type: Type of the sever administrator. "ActiveDirectory" - :paramtype administrator_type: str or ~azure.mgmt.sql.models.AdministratorType - :keyword principal_type: Principal Type of the sever administrator. Known values are: "User", - "Group", and "Application". - :paramtype principal_type: str or ~azure.mgmt.sql.models.PrincipalType - :keyword login: Login name of the server administrator. - :paramtype login: str - :keyword sid: SID (object ID) of the server administrator. - :paramtype sid: str - :keyword tenant_id: Tenant ID of the administrator. - :paramtype tenant_id: str - :keyword azure_ad_only_authentication: Azure Active Directory only Authentication enabled. - :paramtype azure_ad_only_authentication: bool - """ - super().__init__(**kwargs) - self.administrator_type = administrator_type - self.principal_type = principal_type - self.login = login - self.sid = sid - self.tenant_id = tenant_id - self.azure_ad_only_authentication = azure_ad_only_authentication - - -class ManagedInstanceFamilyCapability(_serialization.Model): - """The managed server family capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Family name. - :vartype name: str - :ivar sku: SKU name. - :vartype sku: str - :ivar supported_license_types: List of supported license types. - :vartype supported_license_types: list[~azure.mgmt.sql.models.LicenseTypeCapability] - :ivar supported_vcores_values: List of supported virtual cores values. - :vartype supported_vcores_values: list[~azure.mgmt.sql.models.ManagedInstanceVcoresCapability] - :ivar status: The status of the capability. Known values are: "Visible", "Available", - "Default", and "Disabled". - :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :ivar reason: The reason for the capability not being available. - :vartype reason: str - """ - - _validation = { - "name": {"readonly": True}, - "sku": {"readonly": True}, - "supported_license_types": {"readonly": True}, - "supported_vcores_values": {"readonly": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "sku": {"key": "sku", "type": "str"}, - "supported_license_types": {"key": "supportedLicenseTypes", "type": "[LicenseTypeCapability]"}, - "supported_vcores_values": {"key": "supportedVcoresValues", "type": "[ManagedInstanceVcoresCapability]"}, - "status": {"key": "status", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - } - - def __init__(self, *, 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: Optional[str] = None - self.sku: Optional[str] = None - self.supported_license_types: Optional[list["_models.LicenseTypeCapability"]] = None - self.supported_vcores_values: Optional[list["_models.ManagedInstanceVcoresCapability"]] = None - self.status: Optional[Union[str, "_models.CapabilityStatus"]] = None - self.reason = reason - - -class ManagedInstanceKey(ProxyResource): - """A managed instance key. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar kind: Kind of encryption protector. This is metadata used for the Azure portal - experience. - :vartype kind: str - :ivar server_key_type: The key type like 'ServiceManaged', 'AzureKeyVault'. Known values are: - "ServiceManaged" and "AzureKeyVault". - :vartype server_key_type: str or ~azure.mgmt.sql.models.ServerKeyType - :ivar uri: The URI of the key. If the ServerKeyType is AzureKeyVault, then the URI is required. - :vartype uri: str - :ivar thumbprint: Thumbprint of the key. - :vartype thumbprint: str - :ivar creation_date: The key creation date. - :vartype creation_date: ~datetime.datetime - :ivar auto_rotation_enabled: Key auto rotation opt-in flag. Either true or false. - :vartype auto_rotation_enabled: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "kind": {"readonly": True}, - "thumbprint": {"readonly": True}, - "creation_date": {"readonly": True}, - "auto_rotation_enabled": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "server_key_type": {"key": "properties.serverKeyType", "type": "str"}, - "uri": {"key": "properties.uri", "type": "str"}, - "thumbprint": {"key": "properties.thumbprint", "type": "str"}, - "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, - "auto_rotation_enabled": {"key": "properties.autoRotationEnabled", "type": "bool"}, - } - - def __init__( - self, - *, - server_key_type: Optional[Union[str, "_models.ServerKeyType"]] = None, - uri: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword server_key_type: The key type like 'ServiceManaged', 'AzureKeyVault'. Known values - are: "ServiceManaged" and "AzureKeyVault". - :paramtype server_key_type: str or ~azure.mgmt.sql.models.ServerKeyType - :keyword uri: The URI of the key. If the ServerKeyType is AzureKeyVault, then the URI is - required. - :paramtype uri: str - """ - super().__init__(**kwargs) - self.kind: Optional[str] = None - self.server_key_type = server_key_type - self.uri = uri - self.thumbprint: Optional[str] = None - self.creation_date: Optional[datetime.datetime] = None - self.auto_rotation_enabled: Optional[bool] = None - - -class ManagedInstanceKeyListResult(_serialization.Model): - """A list of managed instance keys. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ManagedInstanceKey] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ManagedInstanceKey]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ManagedInstanceKey"]] = None - self.next_link: Optional[str] = None - - -class ManagedInstanceListResult(_serialization.Model): - """A list of managed instances. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ManagedInstance] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ManagedInstance]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ManagedInstance"]] = None - self.next_link: Optional[str] = None - - -class ManagedInstanceLongTermRetentionBackup(ProxyResource): - """A long term retention backup for a managed database. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar managed_instance_name: The managed instance that the backup database belongs to. - :vartype managed_instance_name: str - :ivar managed_instance_create_time: The create time of the instance. - :vartype managed_instance_create_time: ~datetime.datetime - :ivar database_name: The name of the database the backup belong to. - :vartype database_name: str - :ivar database_deletion_time: The delete time of the database. - :vartype database_deletion_time: ~datetime.datetime - :ivar backup_time: The time the backup was taken. - :vartype backup_time: ~datetime.datetime - :ivar backup_expiration_time: The time the long term retention backup will expire. - :vartype backup_expiration_time: ~datetime.datetime - :ivar backup_storage_redundancy: The storage redundancy type of the backup. Known values are: - "Geo", "Local", "Zone", and "GeoZone". - :vartype backup_storage_redundancy: str or ~azure.mgmt.sql.models.BackupStorageRedundancy - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "managed_instance_name": {"readonly": True}, - "managed_instance_create_time": {"readonly": True}, - "database_name": {"readonly": True}, - "database_deletion_time": {"readonly": True}, - "backup_time": {"readonly": True}, - "backup_expiration_time": {"readonly": True}, - "backup_storage_redundancy": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "managed_instance_name": {"key": "properties.managedInstanceName", "type": "str"}, - "managed_instance_create_time": {"key": "properties.managedInstanceCreateTime", "type": "iso-8601"}, - "database_name": {"key": "properties.databaseName", "type": "str"}, - "database_deletion_time": {"key": "properties.databaseDeletionTime", "type": "iso-8601"}, - "backup_time": {"key": "properties.backupTime", "type": "iso-8601"}, - "backup_expiration_time": {"key": "properties.backupExpirationTime", "type": "iso-8601"}, - "backup_storage_redundancy": {"key": "properties.backupStorageRedundancy", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.managed_instance_name: Optional[str] = None - self.managed_instance_create_time: Optional[datetime.datetime] = None - self.database_name: Optional[str] = None - self.database_deletion_time: Optional[datetime.datetime] = None - self.backup_time: Optional[datetime.datetime] = None - self.backup_expiration_time: Optional[datetime.datetime] = None - self.backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = None - - -class ManagedInstanceLongTermRetentionBackupListResult(_serialization.Model): # pylint: disable=name-too-long - """A list of long term retention backups for managed database(s). - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ManagedInstanceLongTermRetentionBackup]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ManagedInstanceLongTermRetentionBackup"]] = None - self.next_link: Optional[str] = None - - -class ManagedInstanceLongTermRetentionPolicy(ProxyResource): - """A long term retention policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar weekly_retention: The weekly retention policy for an LTR backup in an ISO 8601 format. - :vartype weekly_retention: str - :ivar monthly_retention: The monthly retention policy for an LTR backup in an ISO 8601 format. - :vartype monthly_retention: str - :ivar yearly_retention: The yearly retention policy for an LTR backup in an ISO 8601 format. - :vartype yearly_retention: str - :ivar week_of_year: The week of year to take the yearly backup in an ISO 8601 format. - :vartype week_of_year: int - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "weekly_retention": {"key": "properties.weeklyRetention", "type": "str"}, - "monthly_retention": {"key": "properties.monthlyRetention", "type": "str"}, - "yearly_retention": {"key": "properties.yearlyRetention", "type": "str"}, - "week_of_year": {"key": "properties.weekOfYear", "type": "int"}, - } - - def __init__( - self, - *, - weekly_retention: Optional[str] = None, - monthly_retention: Optional[str] = None, - yearly_retention: Optional[str] = None, - week_of_year: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword weekly_retention: The weekly retention policy for an LTR backup in an ISO 8601 format. - :paramtype weekly_retention: str - :keyword monthly_retention: The monthly retention policy for an LTR backup in an ISO 8601 - format. - :paramtype monthly_retention: str - :keyword yearly_retention: The yearly retention policy for an LTR backup in an ISO 8601 format. - :paramtype yearly_retention: str - :keyword week_of_year: The week of year to take the yearly backup in an ISO 8601 format. - :paramtype week_of_year: int - """ - super().__init__(**kwargs) - self.weekly_retention = weekly_retention - self.monthly_retention = monthly_retention - self.yearly_retention = yearly_retention - self.week_of_year = week_of_year - - -class ManagedInstanceLongTermRetentionPolicyListResult(_serialization.Model): # pylint: disable=name-too-long - """A list of long term retention policies. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ManagedInstanceLongTermRetentionPolicy]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ManagedInstanceLongTermRetentionPolicy"]] = None - self.next_link: Optional[str] = None - - -class ManagedInstanceMaintenanceConfigurationCapability(_serialization.Model): # pylint: disable=name-too-long - """The maintenance configuration capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Maintenance configuration name. - :vartype name: str - :ivar status: The status of the capability. 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}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "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: Optional[str] = None - self.status: Optional[Union[str, "_models.CapabilityStatus"]] = None - self.reason = reason - - -class ManagedInstanceOperation(ProxyResource): - """A managed instance operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar managed_instance_name: The name of the managed instance the operation is being performed - on. - :vartype managed_instance_name: str - :ivar operation: The name of operation. - :vartype operation: str - :ivar operation_friendly_name: The friendly name of operation. - :vartype operation_friendly_name: str - :ivar percent_complete: The percentage of the operation completed. - :vartype percent_complete: int - :ivar start_time: The operation start time. - :vartype start_time: ~datetime.datetime - :ivar state: The operation state. Known values are: "Pending", "InProgress", "Succeeded", - "Failed", "CancelInProgress", and "Cancelled". - :vartype state: str or ~azure.mgmt.sql.models.ManagementOperationState - :ivar error_code: The operation error code. - :vartype error_code: int - :ivar error_description: The operation error description. - :vartype error_description: str - :ivar error_severity: The operation error severity. - :vartype error_severity: int - :ivar is_user_error: Whether or not the error is a user error. - :vartype is_user_error: bool - :ivar estimated_completion_time: The estimated completion time of the operation. - :vartype estimated_completion_time: ~datetime.datetime - :ivar description: The operation description. - :vartype description: str - :ivar is_cancellable: Whether the operation can be cancelled. - :vartype is_cancellable: bool - :ivar operation_parameters: The operation parameters. - :vartype operation_parameters: ~azure.mgmt.sql.models.ManagedInstanceOperationParametersPair - :ivar operation_steps: The operation steps. - :vartype operation_steps: ~azure.mgmt.sql.models.ManagedInstanceOperationSteps - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "managed_instance_name": {"readonly": True}, - "operation": {"readonly": True}, - "operation_friendly_name": {"readonly": True}, - "percent_complete": {"readonly": True}, - "start_time": {"readonly": True}, - "state": {"readonly": True}, - "error_code": {"readonly": True}, - "error_description": {"readonly": True}, - "error_severity": {"readonly": True}, - "is_user_error": {"readonly": True}, - "estimated_completion_time": {"readonly": True}, - "description": {"readonly": True}, - "is_cancellable": {"readonly": True}, - "operation_parameters": {"readonly": True}, - "operation_steps": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "managed_instance_name": {"key": "properties.managedInstanceName", "type": "str"}, - "operation": {"key": "properties.operation", "type": "str"}, - "operation_friendly_name": {"key": "properties.operationFriendlyName", "type": "str"}, - "percent_complete": {"key": "properties.percentComplete", "type": "int"}, - "start_time": {"key": "properties.startTime", "type": "iso-8601"}, - "state": {"key": "properties.state", "type": "str"}, - "error_code": {"key": "properties.errorCode", "type": "int"}, - "error_description": {"key": "properties.errorDescription", "type": "str"}, - "error_severity": {"key": "properties.errorSeverity", "type": "int"}, - "is_user_error": {"key": "properties.isUserError", "type": "bool"}, - "estimated_completion_time": {"key": "properties.estimatedCompletionTime", "type": "iso-8601"}, - "description": {"key": "properties.description", "type": "str"}, - "is_cancellable": {"key": "properties.isCancellable", "type": "bool"}, - "operation_parameters": { - "key": "properties.operationParameters", - "type": "ManagedInstanceOperationParametersPair", - }, - "operation_steps": {"key": "properties.operationSteps", "type": "ManagedInstanceOperationSteps"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.managed_instance_name: Optional[str] = None - self.operation: Optional[str] = None - self.operation_friendly_name: Optional[str] = None - self.percent_complete: Optional[int] = None - self.start_time: Optional[datetime.datetime] = None - self.state: Optional[Union[str, "_models.ManagementOperationState"]] = None - self.error_code: Optional[int] = None - self.error_description: Optional[str] = None - self.error_severity: Optional[int] = None - self.is_user_error: Optional[bool] = None - self.estimated_completion_time: Optional[datetime.datetime] = None - self.description: Optional[str] = None - self.is_cancellable: Optional[bool] = None - self.operation_parameters: Optional["_models.ManagedInstanceOperationParametersPair"] = None - self.operation_steps: Optional["_models.ManagedInstanceOperationSteps"] = None - - -class ManagedInstanceOperationListResult(_serialization.Model): - """The response to a list managed instance operations request. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ManagedInstanceOperation] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ManagedInstanceOperation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ManagedInstanceOperation"]] = None - self.next_link: Optional[str] = None - - -class ManagedInstanceOperationParametersPair(_serialization.Model): - """The parameters of a managed instance operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar current_parameters: The current parameters. - :vartype current_parameters: ~azure.mgmt.sql.models.UpsertManagedServerOperationParameters - :ivar requested_parameters: The requested parameters. - :vartype requested_parameters: ~azure.mgmt.sql.models.UpsertManagedServerOperationParameters - """ - - _validation = { - "current_parameters": {"readonly": True}, - "requested_parameters": {"readonly": True}, - } - - _attribute_map = { - "current_parameters": {"key": "currentParameters", "type": "UpsertManagedServerOperationParameters"}, - "requested_parameters": {"key": "requestedParameters", "type": "UpsertManagedServerOperationParameters"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.current_parameters: Optional["_models.UpsertManagedServerOperationParameters"] = None - self.requested_parameters: Optional["_models.UpsertManagedServerOperationParameters"] = None - - -class ManagedInstanceOperationSteps(_serialization.Model): - """The steps of a managed instance operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar total_steps: The total number of operation steps. - :vartype total_steps: str - :ivar current_step: The number of current operation steps. - :vartype current_step: int - :ivar steps_list: The operation steps list. - :vartype steps_list: list[~azure.mgmt.sql.models.UpsertManagedServerOperationStep] - """ - - _validation = { - "total_steps": {"readonly": True}, - "current_step": {"readonly": True}, - "steps_list": {"readonly": True}, - } - - _attribute_map = { - "total_steps": {"key": "totalSteps", "type": "str"}, - "current_step": {"key": "currentStep", "type": "int"}, - "steps_list": {"key": "stepsList", "type": "[UpsertManagedServerOperationStep]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.total_steps: Optional[str] = None - self.current_step: Optional[int] = None - self.steps_list: Optional[list["_models.UpsertManagedServerOperationStep"]] = None - - -class ManagedInstancePairInfo(_serialization.Model): - """Pairs of Managed Instances in the failover group. - - :ivar primary_managed_instance_id: Id of Primary Managed Instance in pair. - :vartype primary_managed_instance_id: str - :ivar partner_managed_instance_id: Id of Partner Managed Instance in pair. - :vartype partner_managed_instance_id: str - """ - - _attribute_map = { - "primary_managed_instance_id": {"key": "primaryManagedInstanceId", "type": "str"}, - "partner_managed_instance_id": {"key": "partnerManagedInstanceId", "type": "str"}, - } - - def __init__( - self, - *, - primary_managed_instance_id: Optional[str] = None, - partner_managed_instance_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword primary_managed_instance_id: Id of Primary Managed Instance in pair. - :paramtype primary_managed_instance_id: str - :keyword partner_managed_instance_id: Id of Partner Managed Instance in pair. - :paramtype partner_managed_instance_id: str - """ - super().__init__(**kwargs) - self.primary_managed_instance_id = primary_managed_instance_id - self.partner_managed_instance_id = partner_managed_instance_id - - -class ManagedInstancePecProperty(_serialization.Model): - """A private endpoint connection under a managed instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar properties: Private endpoint connection properties. - :vartype properties: ~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnectionProperties - """ - - _validation = { - "id": {"readonly": True}, - "properties": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "properties": {"key": "properties", "type": "ManagedInstancePrivateEndpointConnectionProperties"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.properties: Optional["_models.ManagedInstancePrivateEndpointConnectionProperties"] = None - - -class ManagedInstancePrivateEndpointConnection(ProxyResource): - """A private endpoint connection. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar private_endpoint: Private endpoint which the connection belongs to. - :vartype private_endpoint: ~azure.mgmt.sql.models.ManagedInstancePrivateEndpointProperty - :ivar private_link_service_connection_state: Connection State of the Private Endpoint - Connection. - :vartype private_link_service_connection_state: - ~azure.mgmt.sql.models.ManagedInstancePrivateLinkServiceConnectionStateProperty - :ivar provisioning_state: State of the Private Endpoint Connection. - :vartype provisioning_state: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "private_endpoint": {"key": "properties.privateEndpoint", "type": "ManagedInstancePrivateEndpointProperty"}, - "private_link_service_connection_state": { - "key": "properties.privateLinkServiceConnectionState", - "type": "ManagedInstancePrivateLinkServiceConnectionStateProperty", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - private_endpoint: Optional["_models.ManagedInstancePrivateEndpointProperty"] = None, - private_link_service_connection_state: Optional[ - "_models.ManagedInstancePrivateLinkServiceConnectionStateProperty" - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword private_endpoint: Private endpoint which the connection belongs to. - :paramtype private_endpoint: ~azure.mgmt.sql.models.ManagedInstancePrivateEndpointProperty - :keyword private_link_service_connection_state: Connection State of the Private Endpoint - Connection. - :paramtype private_link_service_connection_state: - ~azure.mgmt.sql.models.ManagedInstancePrivateLinkServiceConnectionStateProperty - """ - super().__init__(**kwargs) - self.private_endpoint = private_endpoint - self.private_link_service_connection_state = private_link_service_connection_state - self.provisioning_state: Optional[str] = None - - -class ManagedInstancePrivateEndpointConnectionListResult(_serialization.Model): # pylint: disable=name-too-long - """A list of private endpoint connections. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ManagedInstancePrivateEndpointConnection]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ManagedInstancePrivateEndpointConnection"]] = None - self.next_link: Optional[str] = None - - -class ManagedInstancePrivateEndpointConnectionProperties(_serialization.Model): # pylint: disable=name-too-long - """Properties of a private endpoint connection. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar private_endpoint: Private endpoint which the connection belongs to. - :vartype private_endpoint: ~azure.mgmt.sql.models.ManagedInstancePrivateEndpointProperty - :ivar private_link_service_connection_state: Connection State of the Private Endpoint - Connection. - :vartype private_link_service_connection_state: - ~azure.mgmt.sql.models.ManagedInstancePrivateLinkServiceConnectionStateProperty - :ivar provisioning_state: State of the Private Endpoint Connection. - :vartype provisioning_state: str - """ - - _validation = { - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "private_endpoint": {"key": "privateEndpoint", "type": "ManagedInstancePrivateEndpointProperty"}, - "private_link_service_connection_state": { - "key": "privateLinkServiceConnectionState", - "type": "ManagedInstancePrivateLinkServiceConnectionStateProperty", - }, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - private_endpoint: Optional["_models.ManagedInstancePrivateEndpointProperty"] = None, - private_link_service_connection_state: Optional[ - "_models.ManagedInstancePrivateLinkServiceConnectionStateProperty" - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword private_endpoint: Private endpoint which the connection belongs to. - :paramtype private_endpoint: ~azure.mgmt.sql.models.ManagedInstancePrivateEndpointProperty - :keyword private_link_service_connection_state: Connection State of the Private Endpoint - Connection. - :paramtype private_link_service_connection_state: - ~azure.mgmt.sql.models.ManagedInstancePrivateLinkServiceConnectionStateProperty - """ - super().__init__(**kwargs) - self.private_endpoint = private_endpoint - self.private_link_service_connection_state = private_link_service_connection_state - self.provisioning_state: Optional[str] = None - - -class ManagedInstancePrivateEndpointProperty(_serialization.Model): - """ManagedInstancePrivateEndpointProperty. - - :ivar id: Resource id of the private endpoint. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource id of the private endpoint. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class ManagedInstancePrivateLink(ProxyResource): - """A private link resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar properties: The private link resource group id. - :vartype properties: ~azure.mgmt.sql.models.ManagedInstancePrivateLinkProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "properties": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "properties": {"key": "properties", "type": "ManagedInstancePrivateLinkProperties"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.properties: Optional["_models.ManagedInstancePrivateLinkProperties"] = None - - -class ManagedInstancePrivateLinkListResult(_serialization.Model): - """A list of private link resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ManagedInstancePrivateLink] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ManagedInstancePrivateLink]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ManagedInstancePrivateLink"]] = None - self.next_link: Optional[str] = None - - -class ManagedInstancePrivateLinkProperties(_serialization.Model): - """Properties of a private link resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar group_id: The private link resource group id. - :vartype group_id: str - :ivar required_members: The private link resource required member names. - :vartype required_members: list[str] - """ - - _validation = { - "group_id": {"readonly": True}, - "required_members": {"readonly": True}, - } - - _attribute_map = { - "group_id": {"key": "groupId", "type": "str"}, - "required_members": {"key": "requiredMembers", "type": "[str]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.group_id: Optional[str] = None - self.required_members: Optional[list[str]] = None - - -class ManagedInstancePrivateLinkServiceConnectionStateProperty(_serialization.Model): # pylint: disable=name-too-long - """ManagedInstancePrivateLinkServiceConnectionStateProperty. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar status: The private link service connection status. Required. - :vartype status: str - :ivar description: The private link service connection description. Required. - :vartype description: str - :ivar actions_required: The private link service connection description. - :vartype actions_required: str - """ - - _validation = { - "status": {"required": True}, - "description": {"required": True}, - "actions_required": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "actions_required": {"key": "actionsRequired", "type": "str"}, - } - - def __init__(self, *, status: str, description: str, **kwargs: Any) -> None: - """ - :keyword status: The private link service connection status. Required. - :paramtype status: str - :keyword description: The private link service connection description. Required. - :paramtype description: str - """ - super().__init__(**kwargs) - self.status = status - self.description = description - self.actions_required: Optional[str] = None - - -class ManagedInstanceQuery(ProxyResource): - """Database query. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar query_text: Query text. - :vartype query_text: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "query_text": {"key": "properties.queryText", "type": "str"}, - } - - def __init__(self, *, query_text: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword query_text: Query text. - :paramtype query_text: str - """ - super().__init__(**kwargs) - self.query_text = query_text - - -class ManagedInstanceQueryStatistics(_serialization.Model): - """Execution statistics for one particular query. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.QueryStatistics] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[QueryStatistics]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.QueryStatistics"]] = None - self.next_link: Optional[str] = None - - -class ManagedInstanceUpdate(_serialization.Model): - """An update request for an Azure SQL Database managed instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar sku: Managed instance sku. - :vartype sku: ~azure.mgmt.sql.models.Sku - :ivar identity: Managed instance identity. - :vartype identity: ~azure.mgmt.sql.models.ResourceIdentity - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :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. - - Restore: Creates an instance by restoring a set of backups to specific point in time. - RestorePointInTime and SourceManagedInstanceId must be specified. Known values are: "Default" - and "PointInTimeRestore". - :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 - :ivar administrator_login_password: The administrator login password (required for managed - instance creation). - :vartype administrator_login_password: str - :ivar subnet_id: Subnet resource ID for the managed instance. - :vartype subnet_id: str - :ivar state: The state of the managed instance. - :vartype state: str - :ivar license_type: The license type. Possible values are 'LicenseIncluded' (regular price - inclusive of a new SQL license) and 'BasePrice' (discounted AHB price for bringing your own SQL - licenses). 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_iops: Storage IOps. Minimum value: 300. Maximum value: 80000. Increments of 1 - IOps allowed only. Maximum value depends on the selected hardware family and number of vCores. - :vartype storage_iops: int - :ivar storage_throughput_mbps: Storage throughput MBps parameter is not supported in the - instance create/update operation. - :vartype storage_throughput_mbps: int - :ivar collation: Collation of the managed instance. - :vartype collation: str - :ivar dns_zone: The Dns Zone that the managed instance is in. - :vartype dns_zone: str - :ivar dns_zone_partner: The resource id of another managed instance whose DNS zone this managed - instance will share after creation. - :vartype dns_zone_partner: str - :ivar public_data_endpoint_enabled: Whether or not the public data endpoint is enabled. - :vartype public_data_endpoint_enabled: bool - :ivar source_managed_instance_id: The resource identifier of the source managed instance - associated with create operation of this instance. - :vartype source_managed_instance_id: str - :ivar restore_point_in_time: Specifies the point in time (ISO8601 format) of the source - database that will be restored to create the new database. - :vartype restore_point_in_time: ~datetime.datetime - :ivar proxy_override: Connection type used for connecting to the instance. Known values are: - "Proxy", "Redirect", and "Default". - :vartype proxy_override: str or ~azure.mgmt.sql.models.ManagedInstanceProxyOverride - :ivar timezone_id: Id of the timezone. Allowed values are timezones supported by Windows. - Windows keeps details on supported timezones, including the id, in registry under - KEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones. - You can get those registry values via SQL Server by querying SELECT name AS timezone_id FROM - sys.time_zone_info. - List of Ids can also be obtained by executing [System.TimeZoneInfo]::GetSystemTimeZones() in - PowerShell. - An example of valid timezone id is "Pacific Standard Time" or "W. Europe Standard Time". - :vartype timezone_id: str - :ivar instance_pool_id: The Id of the instance pool this managed server belongs to. - :vartype instance_pool_id: str - :ivar maintenance_configuration_id: Specifies maintenance configuration id to apply to this - managed instance. - :vartype maintenance_configuration_id: str - :ivar private_endpoint_connections: List of private endpoint connections on a managed instance. - :vartype private_endpoint_connections: list[~azure.mgmt.sql.models.ManagedInstancePecProperty] - :ivar minimal_tls_version: Minimal TLS version. Allowed values: 'None', '1.0', '1.1', '1.2'. - :vartype minimal_tls_version: str - :ivar current_backup_storage_redundancy: The storage account type used to store backups for - this instance. The options are Local (LocallyRedundantStorage), Zone (ZoneRedundantStorage), - Geo (GeoRedundantStorage) and GeoZone(GeoZoneRedundantStorage). Known values are: "Geo", - "Local", "Zone", and "GeoZone". - :vartype current_backup_storage_redundancy: str or - ~azure.mgmt.sql.models.BackupStorageRedundancy - :ivar requested_backup_storage_redundancy: The storage account type to be used to store backups - for this instance. The options are Local (LocallyRedundantStorage), Zone - (ZoneRedundantStorage), Geo (GeoRedundantStorage) and GeoZone(GeoZoneRedundantStorage). Known - values are: "Geo", "Local", "Zone", and "GeoZone". - :vartype requested_backup_storage_redundancy: str or - ~azure.mgmt.sql.models.BackupStorageRedundancy - :ivar zone_redundant: Whether or not the multi-az is enabled. - :vartype zone_redundant: bool - :ivar primary_user_assigned_identity_id: The resource id of a user assigned identity to be used - by default. - :vartype primary_user_assigned_identity_id: str - :ivar key_id: A CMK URI of the key to use for encryption. - :vartype key_id: str - :ivar administrators: The Azure Active Directory administrator of the instance. This can only - be used at instance create time. If used for instance update, it will be ignored or it will - result in an error. For updates individual APIs will need to be used. - :vartype administrators: ~azure.mgmt.sql.models.ManagedInstanceExternalAdministrator - :ivar service_principal: The managed instance's service principal. - :vartype service_principal: ~azure.mgmt.sql.models.ServicePrincipal - :ivar virtual_cluster_id: Virtual cluster resource id for the Managed Instance. - :vartype virtual_cluster_id: str - :ivar external_governance_status: Status of external governance. Known values are: "Enabled" - and "Disabled". - :vartype external_governance_status: str or ~azure.mgmt.sql.models.ExternalGovernanceStatus - :ivar pricing_model: Weather or not Managed Instance is freemium. Known values are: "Regular" - and "Freemium". - :vartype pricing_model: str or ~azure.mgmt.sql.models.FreemiumType - :ivar create_time: Specifies the point in time (ISO8601 format) of the Managed Instance - creation. - :vartype create_time: ~datetime.datetime - :ivar authentication_metadata: The managed instance's authentication metadata lookup mode. - Known values are: "AzureAD", "Paired", and "Windows". - :vartype authentication_metadata: str or ~azure.mgmt.sql.models.AuthMetadataLookupModes - :ivar database_format: Specifies the internal format of instance databases specific to the SQL - engine version. Known values are: "AlwaysUpToDate" and "SQLServer2022". - :vartype database_format: str or ~azure.mgmt.sql.models.ManagedInstanceDatabaseFormat - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "fully_qualified_domain_name": {"readonly": True}, - "state": {"readonly": True}, - "hybrid_secondary_usage_detected": {"readonly": True}, - "dns_zone": {"readonly": True}, - "private_endpoint_connections": {"readonly": True}, - "current_backup_storage_redundancy": {"readonly": True}, - "virtual_cluster_id": {"readonly": True}, - "external_governance_status": {"readonly": True}, - "create_time": {"readonly": True}, - } - - _attribute_map = { - "sku": {"key": "sku", "type": "Sku"}, - "identity": {"key": "identity", "type": "ResourceIdentity"}, - "tags": {"key": "tags", "type": "{str}"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "managed_instance_create_mode": {"key": "properties.managedInstanceCreateMode", "type": "str"}, - "fully_qualified_domain_name": {"key": "properties.fullyQualifiedDomainName", "type": "str"}, - "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_iops": {"key": "properties.storageIOps", "type": "int"}, - "storage_throughput_mbps": {"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"}, - "public_data_endpoint_enabled": {"key": "properties.publicDataEndpointEnabled", "type": "bool"}, - "source_managed_instance_id": {"key": "properties.sourceManagedInstanceId", "type": "str"}, - "restore_point_in_time": {"key": "properties.restorePointInTime", "type": "iso-8601"}, - "proxy_override": {"key": "properties.proxyOverride", "type": "str"}, - "timezone_id": {"key": "properties.timezoneId", "type": "str"}, - "instance_pool_id": {"key": "properties.instancePoolId", "type": "str"}, - "maintenance_configuration_id": {"key": "properties.maintenanceConfigurationId", "type": "str"}, - "private_endpoint_connections": { - "key": "properties.privateEndpointConnections", - "type": "[ManagedInstancePecProperty]", - }, - "minimal_tls_version": {"key": "properties.minimalTlsVersion", "type": "str"}, - "current_backup_storage_redundancy": {"key": "properties.currentBackupStorageRedundancy", "type": "str"}, - "requested_backup_storage_redundancy": {"key": "properties.requestedBackupStorageRedundancy", "type": "str"}, - "zone_redundant": {"key": "properties.zoneRedundant", "type": "bool"}, - "primary_user_assigned_identity_id": {"key": "properties.primaryUserAssignedIdentityId", "type": "str"}, - "key_id": {"key": "properties.keyId", "type": "str"}, - "administrators": {"key": "properties.administrators", "type": "ManagedInstanceExternalAdministrator"}, - "service_principal": {"key": "properties.servicePrincipal", "type": "ServicePrincipal"}, - "virtual_cluster_id": {"key": "properties.virtualClusterId", "type": "str"}, - "external_governance_status": {"key": "properties.externalGovernanceStatus", "type": "str"}, - "pricing_model": {"key": "properties.pricingModel", "type": "str"}, - "create_time": {"key": "properties.createTime", "type": "iso-8601"}, - "authentication_metadata": {"key": "properties.authenticationMetadata", "type": "str"}, - "database_format": {"key": "properties.databaseFormat", "type": "str"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - sku: Optional["_models.Sku"] = None, - 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_iops: Optional[int] = None, - storage_throughput_mbps: Optional[int] = None, - collation: Optional[str] = None, - dns_zone_partner: Optional[str] = None, - public_data_endpoint_enabled: Optional[bool] = None, - source_managed_instance_id: Optional[str] = None, - restore_point_in_time: Optional[datetime.datetime] = None, - proxy_override: Optional[Union[str, "_models.ManagedInstanceProxyOverride"]] = None, - timezone_id: Optional[str] = None, - instance_pool_id: Optional[str] = None, - maintenance_configuration_id: Optional[str] = None, - minimal_tls_version: Optional[str] = None, - requested_backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = None, - zone_redundant: Optional[bool] = None, - primary_user_assigned_identity_id: Optional[str] = None, - key_id: Optional[str] = None, - administrators: Optional["_models.ManagedInstanceExternalAdministrator"] = None, - service_principal: Optional["_models.ServicePrincipal"] = None, - pricing_model: Optional[Union[str, "_models.FreemiumType"]] = None, - authentication_metadata: Optional[Union[str, "_models.AuthMetadataLookupModes"]] = None, - database_format: Optional[Union[str, "_models.ManagedInstanceDatabaseFormat"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword sku: Managed instance sku. - :paramtype sku: ~azure.mgmt.sql.models.Sku - :keyword identity: Managed instance identity. - :paramtype identity: ~azure.mgmt.sql.models.ResourceIdentity - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword managed_instance_create_mode: Specifies the mode of database creation. - - Default: Regular instance creation. - - Restore: Creates an instance by restoring a set of backups to specific point in time. - RestorePointInTime and SourceManagedInstanceId must be specified. 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 - :keyword administrator_login_password: The administrator login password (required for managed - instance creation). - :paramtype administrator_login_password: str - :keyword subnet_id: Subnet resource ID for the managed instance. - :paramtype subnet_id: str - :keyword license_type: The license type. Possible values are 'LicenseIncluded' (regular price - inclusive of a new SQL license) and 'BasePrice' (discounted AHB price for bringing your own SQL - licenses). 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_iops: Storage IOps. Minimum value: 300. Maximum value: 80000. Increments of 1 - IOps allowed only. Maximum value depends on the selected hardware family and number of vCores. - :paramtype storage_iops: int - :keyword storage_throughput_mbps: Storage throughput MBps parameter is not supported in the - instance create/update operation. - :paramtype storage_throughput_mbps: int - :keyword collation: Collation of the managed instance. - :paramtype collation: str - :keyword dns_zone_partner: The resource id of another managed instance whose DNS zone this - managed instance will share after creation. - :paramtype dns_zone_partner: str - :keyword public_data_endpoint_enabled: Whether or not the public data endpoint is enabled. - :paramtype public_data_endpoint_enabled: bool - :keyword source_managed_instance_id: The resource identifier of the source managed instance - associated with create operation of this instance. - :paramtype source_managed_instance_id: str - :keyword restore_point_in_time: Specifies the point in time (ISO8601 format) of the source - database that will be restored to create the new database. - :paramtype restore_point_in_time: ~datetime.datetime - :keyword proxy_override: Connection type used for connecting to the instance. Known values are: - "Proxy", "Redirect", and "Default". - :paramtype proxy_override: str or ~azure.mgmt.sql.models.ManagedInstanceProxyOverride - :keyword timezone_id: Id of the timezone. Allowed values are timezones supported by Windows. - Windows keeps details on supported timezones, including the id, in registry under - KEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones. - You can get those registry values via SQL Server by querying SELECT name AS timezone_id FROM - sys.time_zone_info. - List of Ids can also be obtained by executing [System.TimeZoneInfo]::GetSystemTimeZones() in - PowerShell. - An example of valid timezone id is "Pacific Standard Time" or "W. Europe Standard Time". - :paramtype timezone_id: str - :keyword instance_pool_id: The Id of the instance pool this managed server belongs to. - :paramtype instance_pool_id: str - :keyword maintenance_configuration_id: Specifies maintenance configuration id to apply to this - managed instance. - :paramtype maintenance_configuration_id: str - :keyword minimal_tls_version: Minimal TLS version. Allowed values: 'None', '1.0', '1.1', '1.2'. - :paramtype minimal_tls_version: str - :keyword requested_backup_storage_redundancy: The storage account type to be used to store - backups for this instance. The options are Local (LocallyRedundantStorage), Zone - (ZoneRedundantStorage), Geo (GeoRedundantStorage) and GeoZone(GeoZoneRedundantStorage). Known - values are: "Geo", "Local", "Zone", and "GeoZone". - :paramtype requested_backup_storage_redundancy: str or - ~azure.mgmt.sql.models.BackupStorageRedundancy - :keyword zone_redundant: Whether or not the multi-az is enabled. - :paramtype zone_redundant: bool - :keyword primary_user_assigned_identity_id: The resource id of a user assigned identity to be - used by default. - :paramtype primary_user_assigned_identity_id: str - :keyword key_id: A CMK URI of the key to use for encryption. - :paramtype key_id: str - :keyword administrators: The Azure Active Directory administrator of the instance. This can - only be used at instance create time. If used for instance update, it will be ignored or it - will result in an error. For updates individual APIs will need to be used. - :paramtype administrators: ~azure.mgmt.sql.models.ManagedInstanceExternalAdministrator - :keyword service_principal: The managed instance's service principal. - :paramtype service_principal: ~azure.mgmt.sql.models.ServicePrincipal - :keyword pricing_model: Weather or not Managed Instance is freemium. Known values are: - "Regular" and "Freemium". - :paramtype pricing_model: str or ~azure.mgmt.sql.models.FreemiumType - :keyword authentication_metadata: The managed instance's authentication metadata lookup mode. - Known values are: "AzureAD", "Paired", and "Windows". - :paramtype authentication_metadata: str or ~azure.mgmt.sql.models.AuthMetadataLookupModes - :keyword database_format: Specifies the internal format of instance databases specific to the - SQL engine version. Known values are: "AlwaysUpToDate" and "SQLServer2022". - :paramtype database_format: str or ~azure.mgmt.sql.models.ManagedInstanceDatabaseFormat - """ - super().__init__(**kwargs) - self.sku = sku - self.identity = identity - self.tags = tags - self.provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None - self.managed_instance_create_mode = managed_instance_create_mode - self.fully_qualified_domain_name: Optional[str] = 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: Optional[str] = None - self.license_type = license_type - self.hybrid_secondary_usage = hybrid_secondary_usage - self.hybrid_secondary_usage_detected: Optional[Union[str, "_models.HybridSecondaryUsageDetected"]] = None - self.v_cores = v_cores - self.storage_size_in_gb = storage_size_in_gb - self.storage_iops = storage_iops - self.storage_throughput_mbps = storage_throughput_mbps - self.collation = collation - self.dns_zone: Optional[str] = None - self.dns_zone_partner = dns_zone_partner - self.public_data_endpoint_enabled = public_data_endpoint_enabled - self.source_managed_instance_id = source_managed_instance_id - self.restore_point_in_time = restore_point_in_time - self.proxy_override = proxy_override - self.timezone_id = timezone_id - self.instance_pool_id = instance_pool_id - self.maintenance_configuration_id = maintenance_configuration_id - self.private_endpoint_connections: Optional[list["_models.ManagedInstancePecProperty"]] = None - self.minimal_tls_version = minimal_tls_version - self.current_backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = None - self.requested_backup_storage_redundancy = requested_backup_storage_redundancy - self.zone_redundant = zone_redundant - self.primary_user_assigned_identity_id = primary_user_assigned_identity_id - self.key_id = key_id - self.administrators = administrators - self.service_principal = service_principal - self.virtual_cluster_id: Optional[str] = None - self.external_governance_status: Optional[Union[str, "_models.ExternalGovernanceStatus"]] = None - self.pricing_model = pricing_model - self.create_time: Optional[datetime.datetime] = None - self.authentication_metadata = authentication_metadata - self.database_format = database_format - - -class ManagedInstanceVcoresCapability(_serialization.Model): - """The managed instance virtual cores capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The virtual cores identifier. - :vartype name: str - :ivar value: The virtual cores value. - :vartype value: int - :ivar included_max_size: Included size. - :vartype included_max_size: ~azure.mgmt.sql.models.MaxSizeCapability - :ivar supported_storage_sizes: Storage size ranges. - :vartype supported_storage_sizes: list[~azure.mgmt.sql.models.MaxSizeRangeCapability] - :ivar instance_pool_supported: True if this service objective is supported for managed - instances in an instance pool. - :vartype instance_pool_supported: bool - :ivar standalone_supported: True if this service objective is supported for standalone managed - instances. - :vartype standalone_supported: bool - :ivar supported_maintenance_configurations: List of supported maintenance configurations. - :vartype supported_maintenance_configurations: - list[~azure.mgmt.sql.models.ManagedInstanceMaintenanceConfigurationCapability] - :ivar status: The status of the capability. 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}, - "value": {"readonly": True}, - "included_max_size": {"readonly": True}, - "supported_storage_sizes": {"readonly": True}, - "instance_pool_supported": {"readonly": True}, - "standalone_supported": {"readonly": True}, - "supported_maintenance_configurations": {"readonly": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "value": {"key": "value", "type": "int"}, - "included_max_size": {"key": "includedMaxSize", "type": "MaxSizeCapability"}, - "supported_storage_sizes": {"key": "supportedStorageSizes", "type": "[MaxSizeRangeCapability]"}, - "instance_pool_supported": {"key": "instancePoolSupported", "type": "bool"}, - "standalone_supported": {"key": "standaloneSupported", "type": "bool"}, - "supported_maintenance_configurations": { - "key": "supportedMaintenanceConfigurations", - "type": "[ManagedInstanceMaintenanceConfigurationCapability]", - }, - "status": {"key": "status", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - } - - def __init__(self, *, 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: Optional[str] = None - self.value: Optional[int] = None - self.included_max_size: Optional["_models.MaxSizeCapability"] = None - self.supported_storage_sizes: Optional[list["_models.MaxSizeRangeCapability"]] = None - self.instance_pool_supported: Optional[bool] = None - self.standalone_supported: Optional[bool] = None - self.supported_maintenance_configurations: Optional[ - list["_models.ManagedInstanceMaintenanceConfigurationCapability"] - ] = None - self.status: Optional[Union[str, "_models.CapabilityStatus"]] = None - self.reason = reason - - -class ManagedInstanceVersionCapability(_serialization.Model): - """The managed instance capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The server version name. - :vartype name: str - :ivar supported_editions: The list of supported managed instance editions. - :vartype supported_editions: list[~azure.mgmt.sql.models.ManagedInstanceEditionCapability] - :ivar supported_instance_pool_editions: The list of supported instance pool editions. - :vartype supported_instance_pool_editions: - list[~azure.mgmt.sql.models.InstancePoolEditionCapability] - :ivar status: The status of the capability. Known values are: "Visible", "Available", - "Default", and "Disabled". - :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :ivar reason: The reason for the capability not being available. - :vartype reason: str - """ - - _validation = { - "name": {"readonly": True}, - "supported_editions": {"readonly": True}, - "supported_instance_pool_editions": {"readonly": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "supported_editions": {"key": "supportedEditions", "type": "[ManagedInstanceEditionCapability]"}, - "supported_instance_pool_editions": { - "key": "supportedInstancePoolEditions", - "type": "[InstancePoolEditionCapability]", - }, - "status": {"key": "status", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - } - - def __init__(self, *, 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: Optional[str] = None - self.supported_editions: Optional[list["_models.ManagedInstanceEditionCapability"]] = None - self.supported_instance_pool_editions: Optional[list["_models.InstancePoolEditionCapability"]] = None - self.status: Optional[Union[str, "_models.CapabilityStatus"]] = None - self.reason = reason - - -class ManagedInstanceVulnerabilityAssessment(ProxyResource): - """A managed instance vulnerability assessment. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar storage_container_path: A blob storage container path to hold the scan results (e.g. - https://myStorage.blob.core.windows.net/VaScans/). - :vartype storage_container_path: str - :ivar storage_container_sas_key: A shared access signature (SAS Key) that has write access to - the blob container specified in 'storageContainerPath' parameter. If 'storageAccountAccessKey' - isn't specified, StorageContainerSasKey is required. Applies only if the storage account is not - behind a Vnet or a firewall. - :vartype storage_container_sas_key: str - :ivar storage_account_access_key: Specifies the identifier key of the storage account for - vulnerability assessment scan results. If 'StorageContainerSasKey' isn't specified, - storageAccountAccessKey is required. Applies only if the storage account is not behind a Vnet - or a firewall. - :vartype storage_account_access_key: str - :ivar recurring_scans: The recurring scans settings. - :vartype recurring_scans: - ~azure.mgmt.sql.models.VulnerabilityAssessmentRecurringScansProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "storage_container_path": {"key": "properties.storageContainerPath", "type": "str"}, - "storage_container_sas_key": {"key": "properties.storageContainerSasKey", "type": "str"}, - "storage_account_access_key": {"key": "properties.storageAccountAccessKey", "type": "str"}, - "recurring_scans": { - "key": "properties.recurringScans", - "type": "VulnerabilityAssessmentRecurringScansProperties", - }, - } - - def __init__( - self, - *, - storage_container_path: Optional[str] = None, - storage_container_sas_key: Optional[str] = None, - storage_account_access_key: Optional[str] = None, - recurring_scans: Optional["_models.VulnerabilityAssessmentRecurringScansProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword storage_container_path: A blob storage container path to hold the scan results (e.g. - https://myStorage.blob.core.windows.net/VaScans/). - :paramtype storage_container_path: str - :keyword storage_container_sas_key: A shared access signature (SAS Key) that has write access - to the blob container specified in 'storageContainerPath' parameter. If - 'storageAccountAccessKey' isn't specified, StorageContainerSasKey is required. Applies only if - the storage account is not behind a Vnet or a firewall. - :paramtype storage_container_sas_key: str - :keyword storage_account_access_key: Specifies the identifier key of the storage account for - vulnerability assessment scan results. If 'StorageContainerSasKey' isn't specified, - storageAccountAccessKey is required. Applies only if the storage account is not behind a Vnet - or a firewall. - :paramtype storage_account_access_key: str - :keyword recurring_scans: The recurring scans settings. - :paramtype recurring_scans: - ~azure.mgmt.sql.models.VulnerabilityAssessmentRecurringScansProperties - """ - super().__init__(**kwargs) - self.storage_container_path = storage_container_path - self.storage_container_sas_key = storage_container_sas_key - self.storage_account_access_key = storage_account_access_key - self.recurring_scans = recurring_scans - - -class ManagedInstanceVulnerabilityAssessmentListResult(_serialization.Model): # pylint: disable=name-too-long - """A list of the ManagedInstance's vulnerability assessments. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ManagedInstanceVulnerabilityAssessment]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ManagedInstanceVulnerabilityAssessment"]] = None - self.next_link: Optional[str] = None - - -class ManagedLedgerDigestUploads(ProxyResource): - """Azure SQL Database ledger digest upload settings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar digest_storage_endpoint: The digest storage endpoint, which must be either an Azure blob - storage endpoint or an URI for Azure Confidential Ledger. - :vartype digest_storage_endpoint: str - :ivar state: Specifies the state of ledger digest upload. Known values are: "Enabled" and - "Disabled". - :vartype state: str or ~azure.mgmt.sql.models.ManagedLedgerDigestUploadsState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "digest_storage_endpoint": {"key": "properties.digestStorageEndpoint", "type": "str"}, - "state": {"key": "properties.state", "type": "str"}, - } - - def __init__(self, *, digest_storage_endpoint: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword digest_storage_endpoint: The digest storage endpoint, which must be either an Azure - blob storage endpoint or an URI for Azure Confidential Ledger. - :paramtype digest_storage_endpoint: str - """ - super().__init__(**kwargs) - self.digest_storage_endpoint = digest_storage_endpoint - self.state: Optional[Union[str, "_models.ManagedLedgerDigestUploadsState"]] = None - - -class ManagedLedgerDigestUploadsListResult(_serialization.Model): - """A list of ledger digest upload settings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ManagedLedgerDigestUploads] - :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": "[ManagedLedgerDigestUploads]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ManagedLedgerDigestUploads"]] = None - self.next_link: Optional[str] = None - - -class ManagedServerDnsAlias(ProxyResource): - """A managed server DNS alias. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar azure_dns_record: The fully qualified DNS record for managed server alias. - :vartype azure_dns_record: str - :ivar public_azure_dns_record: The fully qualified public DNS record for managed server alias. - :vartype public_azure_dns_record: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "azure_dns_record": {"readonly": True}, - "public_azure_dns_record": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "azure_dns_record": {"key": "properties.azureDnsRecord", "type": "str"}, - "public_azure_dns_record": {"key": "properties.publicAzureDnsRecord", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.azure_dns_record: Optional[str] = None - self.public_azure_dns_record: Optional[str] = None - - -class ManagedServerDnsAliasAcquisition(_serialization.Model): - """A managed server DNS alias acquisition request. - - All required parameters must be populated in order to send to server. - - :ivar old_managed_server_dns_alias_resource_id: The resource ID of the managed server DNS alias - that will be acquired to point to this managed server instead. Required. - :vartype old_managed_server_dns_alias_resource_id: str - """ - - _validation = { - "old_managed_server_dns_alias_resource_id": {"required": True}, - } - - _attribute_map = { - "old_managed_server_dns_alias_resource_id": {"key": "oldManagedServerDnsAliasResourceId", "type": "str"}, - } - - def __init__(self, *, old_managed_server_dns_alias_resource_id: str, **kwargs: Any) -> None: - """ - :keyword old_managed_server_dns_alias_resource_id: The resource ID of the managed server DNS - alias that will be acquired to point to this managed server instead. Required. - :paramtype old_managed_server_dns_alias_resource_id: str - """ - super().__init__(**kwargs) - self.old_managed_server_dns_alias_resource_id = old_managed_server_dns_alias_resource_id - - -class ManagedServerDnsAliasCreation(_serialization.Model): - """A managed server dns alias creation request. - - :ivar create_dns_record: Whether or not DNS record should be created for this alias. - :vartype create_dns_record: bool - """ - - _attribute_map = { - "create_dns_record": {"key": "createDnsRecord", "type": "bool"}, - } - - def __init__(self, *, create_dns_record: bool = True, **kwargs: Any) -> None: - """ - :keyword create_dns_record: Whether or not DNS record should be created for this alias. - :paramtype create_dns_record: bool - """ - super().__init__(**kwargs) - self.create_dns_record = create_dns_record - - -class ManagedServerDnsAliasListResult(_serialization.Model): - """A list of managed server DNS aliases. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ManagedServerDnsAlias] - :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": "[ManagedServerDnsAlias]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ManagedServerDnsAlias"]] = None - self.next_link: Optional[str] = None - - -class ManagedServerSecurityAlertPolicy(ProxyResource): - """A managed server security alert policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: SystemData of SecurityAlertPolicyResource. - :vartype system_data: ~azure.mgmt.sql.models.SystemData - :ivar state: Specifies the state of the policy, whether it is enabled or disabled or a policy - has not been applied yet on the specific database. Known values are: "Enabled" and "Disabled". - :vartype state: str or ~azure.mgmt.sql.models.SecurityAlertsPolicyState - :ivar disabled_alerts: Specifies an array of alerts that are disabled. Allowed values are: - Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, Unsafe_Action, - Brute_Force. - :vartype disabled_alerts: list[str] - :ivar email_addresses: Specifies an array of e-mail addresses to which the alert is sent. - :vartype email_addresses: list[str] - :ivar email_account_admins: Specifies that the alert is sent to the account administrators. - :vartype email_account_admins: bool - :ivar storage_endpoint: Specifies the blob storage endpoint (e.g. - https://MyAccount.blob.core.windows.net). This blob storage will hold all Threat Detection - audit logs. - :vartype storage_endpoint: str - :ivar storage_account_access_key: Specifies the identifier key of the Threat Detection audit - storage account. - :vartype storage_account_access_key: str - :ivar retention_days: Specifies the number of days to keep in the Threat Detection audit logs. - :vartype retention_days: int - :ivar creation_time: Specifies the UTC creation time of the policy. - :vartype creation_time: ~datetime.datetime - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "creation_time": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "state": {"key": "properties.state", "type": "str"}, - "disabled_alerts": {"key": "properties.disabledAlerts", "type": "[str]"}, - "email_addresses": {"key": "properties.emailAddresses", "type": "[str]"}, - "email_account_admins": {"key": "properties.emailAccountAdmins", "type": "bool"}, - "storage_endpoint": {"key": "properties.storageEndpoint", "type": "str"}, - "storage_account_access_key": {"key": "properties.storageAccountAccessKey", "type": "str"}, - "retention_days": {"key": "properties.retentionDays", "type": "int"}, - "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, - } - - def __init__( - self, - *, - state: Optional[Union[str, "_models.SecurityAlertsPolicyState"]] = None, - disabled_alerts: Optional[list[str]] = None, - email_addresses: Optional[list[str]] = None, - email_account_admins: Optional[bool] = None, - storage_endpoint: Optional[str] = None, - storage_account_access_key: Optional[str] = None, - retention_days: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword state: Specifies the state of the policy, whether it is enabled or disabled or a - policy has not been applied yet on the specific database. Known values are: "Enabled" and - "Disabled". - :paramtype state: str or ~azure.mgmt.sql.models.SecurityAlertsPolicyState - :keyword disabled_alerts: Specifies an array of alerts that are disabled. Allowed values are: - Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, Unsafe_Action, - Brute_Force. - :paramtype disabled_alerts: list[str] - :keyword email_addresses: Specifies an array of e-mail addresses to which the alert is sent. - :paramtype email_addresses: list[str] - :keyword email_account_admins: Specifies that the alert is sent to the account administrators. - :paramtype email_account_admins: bool - :keyword storage_endpoint: Specifies the blob storage endpoint (e.g. - https://MyAccount.blob.core.windows.net). This blob storage will hold all Threat Detection - audit logs. - :paramtype storage_endpoint: str - :keyword storage_account_access_key: Specifies the identifier key of the Threat Detection audit - storage account. - :paramtype storage_account_access_key: str - :keyword retention_days: Specifies the number of days to keep in the Threat Detection audit - logs. - :paramtype retention_days: int - """ - super().__init__(**kwargs) - self.system_data: Optional["_models.SystemData"] = None - self.state = state - self.disabled_alerts = disabled_alerts - self.email_addresses = email_addresses - self.email_account_admins = email_account_admins - self.storage_endpoint = storage_endpoint - self.storage_account_access_key = storage_account_access_key - self.retention_days = retention_days - self.creation_time: Optional[datetime.datetime] = None - - -class ManagedServerSecurityAlertPolicyListResult(_serialization.Model): # pylint: disable=name-too-long - """A list of the managed Server's security alert policies. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ManagedServerSecurityAlertPolicy]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ManagedServerSecurityAlertPolicy"]] = None - self.next_link: Optional[str] = None - - -class ManagedTransparentDataEncryption(ProxyResource): - """A managed database transparent data encryption state. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar state: Specifies the state of the transparent data encryption. Known values are: - "Enabled" and "Disabled". - :vartype state: str or ~azure.mgmt.sql.models.TransparentDataEncryptionState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "state": {"key": "properties.state", "type": "str"}, - } - - def __init__( - self, *, state: Optional[Union[str, "_models.TransparentDataEncryptionState"]] = None, **kwargs: Any - ) -> None: - """ - :keyword state: Specifies the state of the transparent data encryption. Known values are: - "Enabled" and "Disabled". - :paramtype state: str or ~azure.mgmt.sql.models.TransparentDataEncryptionState - """ - super().__init__(**kwargs) - self.state = state - - -class ManagedTransparentDataEncryptionListResult(_serialization.Model): # pylint: disable=name-too-long - """A list of managed transparent data encryptions. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ManagedTransparentDataEncryption] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ManagedTransparentDataEncryption]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ManagedTransparentDataEncryption"]] = None - self.next_link: Optional[str] = None - - -class MaxSizeCapability(_serialization.Model): - """The maximum size capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar limit: The maximum size limit (see 'unit' for the units). - :vartype limit: int - :ivar unit: The units that the limit is expressed in. Known values are: "Megabytes", - "Gigabytes", "Terabytes", and "Petabytes". - :vartype unit: str or ~azure.mgmt.sql.models.MaxSizeUnit - """ - - _validation = { - "limit": {"readonly": True}, - "unit": {"readonly": True}, - } - - _attribute_map = { - "limit": {"key": "limit", "type": "int"}, - "unit": {"key": "unit", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.limit: Optional[int] = None - self.unit: Optional[Union[str, "_models.MaxSizeUnit"]] = None - - -class MaxSizeRangeCapability(_serialization.Model): - """The maximum size range capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar min_value: Minimum value. - :vartype min_value: ~azure.mgmt.sql.models.MaxSizeCapability - :ivar max_value: Maximum value. - :vartype max_value: ~azure.mgmt.sql.models.MaxSizeCapability - :ivar scale_size: Scale/step size for discrete values between the minimum value and the maximum - value. - :vartype scale_size: ~azure.mgmt.sql.models.MaxSizeCapability - :ivar log_size: Size of transaction log. - :vartype log_size: ~azure.mgmt.sql.models.LogSizeCapability - :ivar status: The status of the capability. 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}, - "log_size": {"readonly": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "min_value": {"key": "minValue", "type": "MaxSizeCapability"}, - "max_value": {"key": "maxValue", "type": "MaxSizeCapability"}, - "scale_size": {"key": "scaleSize", "type": "MaxSizeCapability"}, - "log_size": {"key": "logSize", "type": "LogSizeCapability"}, - "status": {"key": "status", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - } - - def __init__(self, *, 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: Optional["_models.MaxSizeCapability"] = None - self.max_value: Optional["_models.MaxSizeCapability"] = None - self.scale_size: Optional["_models.MaxSizeCapability"] = None - self.log_size: Optional["_models.LogSizeCapability"] = None - self.status: Optional[Union[str, "_models.CapabilityStatus"]] = None - self.reason = reason - - -class Metric(_serialization.Model): - """Database metrics. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar start_time: The start time for the metric (ISO-8601 format). - :vartype start_time: ~datetime.datetime - :ivar end_time: The end time for the metric (ISO-8601 format). - :vartype end_time: ~datetime.datetime - :ivar time_grain: The time step to be used to summarize the metric values. - :vartype time_grain: str - :ivar unit: The unit of the metric. Known values are: "count", "bytes", "seconds", "percent", - "countPerSecond", and "bytesPerSecond". - :vartype unit: str or ~azure.mgmt.sql.models.UnitType - :ivar name: The name information for the metric. - :vartype name: ~azure.mgmt.sql.models.MetricName - :ivar metric_values: The metric values for the specified time window and timestep. - :vartype metric_values: list[~azure.mgmt.sql.models.MetricValue] - """ - - _validation = { - "start_time": {"readonly": True}, - "end_time": {"readonly": True}, - "time_grain": {"readonly": True}, - "unit": {"readonly": True}, - "name": {"readonly": True}, - "metric_values": {"readonly": True}, - } - - _attribute_map = { - "start_time": {"key": "startTime", "type": "iso-8601"}, - "end_time": {"key": "endTime", "type": "iso-8601"}, - "time_grain": {"key": "timeGrain", "type": "str"}, - "unit": {"key": "unit", "type": "str"}, - "name": {"key": "name", "type": "MetricName"}, - "metric_values": {"key": "metricValues", "type": "[MetricValue]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.start_time: Optional[datetime.datetime] = None - self.end_time: Optional[datetime.datetime] = None - self.time_grain: Optional[str] = None - self.unit: Optional[Union[str, "_models.UnitType"]] = None - self.name: Optional["_models.MetricName"] = None - self.metric_values: Optional[list["_models.MetricValue"]] = None - - -class MetricAvailability(_serialization.Model): - """A metric availability value. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar retention: The length of retention for the database metric. - :vartype retention: str - :ivar time_grain: The granularity of the database metric. - :vartype time_grain: str - """ - - _validation = { - "retention": {"readonly": True}, - "time_grain": {"readonly": True}, - } - - _attribute_map = { - "retention": {"key": "retention", "type": "str"}, - "time_grain": {"key": "timeGrain", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.retention: Optional[str] = None - self.time_grain: Optional[str] = None - - -class MetricDefinition(_serialization.Model): - """A database metric definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name information for the metric. - :vartype name: ~azure.mgmt.sql.models.MetricName - :ivar primary_aggregation_type: The primary aggregation type defining how metric values are - displayed. Known values are: "None", "Average", "Count", "Minimum", "Maximum", and "Total". - :vartype primary_aggregation_type: str or ~azure.mgmt.sql.models.PrimaryAggregationType - :ivar resource_uri: The resource uri of the database. - :vartype resource_uri: str - :ivar unit: The unit of the metric. Known values are: "Count", "Bytes", "Seconds", "Percent", - "CountPerSecond", and "BytesPerSecond". - :vartype unit: str or ~azure.mgmt.sql.models.UnitDefinitionType - :ivar metric_availabilities: The list of database metric availabilities for the metric. - :vartype metric_availabilities: list[~azure.mgmt.sql.models.MetricAvailability] - """ - - _validation = { - "name": {"readonly": True}, - "primary_aggregation_type": {"readonly": True}, - "resource_uri": {"readonly": True}, - "unit": {"readonly": True}, - "metric_availabilities": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "MetricName"}, - "primary_aggregation_type": {"key": "primaryAggregationType", "type": "str"}, - "resource_uri": {"key": "resourceUri", "type": "str"}, - "unit": {"key": "unit", "type": "str"}, - "metric_availabilities": {"key": "metricAvailabilities", "type": "[MetricAvailability]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional["_models.MetricName"] = None - self.primary_aggregation_type: Optional[Union[str, "_models.PrimaryAggregationType"]] = None - self.resource_uri: Optional[str] = None - self.unit: Optional[Union[str, "_models.UnitDefinitionType"]] = None - self.metric_availabilities: Optional[list["_models.MetricAvailability"]] = None - - -class MetricDefinitionListResult(_serialization.Model): - """The response to a list database metric definitions request. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of metric definitions for the database. Required. - :vartype value: list[~azure.mgmt.sql.models.MetricDefinition] - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[MetricDefinition]"}, - } - - def __init__(self, *, value: list["_models.MetricDefinition"], **kwargs: Any) -> None: - """ - :keyword value: The list of metric definitions for the database. Required. - :paramtype value: list[~azure.mgmt.sql.models.MetricDefinition] - """ - super().__init__(**kwargs) - self.value = value - - -class MetricListResult(_serialization.Model): - """The response to a list database metrics request. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of metrics for the database. Required. - :vartype value: list[~azure.mgmt.sql.models.Metric] - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Metric]"}, - } - - def __init__(self, *, value: list["_models.Metric"], **kwargs: Any) -> None: - """ - :keyword value: The list of metrics for the database. Required. - :paramtype value: list[~azure.mgmt.sql.models.Metric] - """ - super().__init__(**kwargs) - self.value = value - - -class MetricName(_serialization.Model): - """A database metric name. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The name of the database metric. - :vartype value: str - :ivar localized_value: The friendly name of the database metric. - :vartype localized_value: str - """ - - _validation = { - "value": {"readonly": True}, - "localized_value": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "str"}, - "localized_value": {"key": "localizedValue", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[str] = None - self.localized_value: Optional[str] = None - - -class MetricValue(_serialization.Model): - """Represents database metrics. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar count: The number of values for the metric. - :vartype count: int - :ivar average: The average value of the metric. - :vartype average: float - :ivar maximum: The max value of the metric. - :vartype maximum: float - :ivar minimum: The min value of the metric. - :vartype minimum: float - :ivar timestamp: The metric timestamp (ISO-8601 format). - :vartype timestamp: ~datetime.datetime - :ivar total: The total value of the metric. - :vartype total: float - """ - - _validation = { - "count": {"readonly": True}, - "average": {"readonly": True}, - "maximum": {"readonly": True}, - "minimum": {"readonly": True}, - "timestamp": {"readonly": True}, - "total": {"readonly": True}, - } - - _attribute_map = { - "count": {"key": "count", "type": "int"}, - "average": {"key": "average", "type": "float"}, - "maximum": {"key": "maximum", "type": "float"}, - "minimum": {"key": "minimum", "type": "float"}, - "timestamp": {"key": "timestamp", "type": "iso-8601"}, - "total": {"key": "total", "type": "float"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.count: Optional[int] = None - self.average: Optional[float] = None - self.maximum: Optional[float] = None - self.minimum: Optional[float] = None - self.timestamp: Optional[datetime.datetime] = None - self.total: Optional[float] = None - - -class MinCapacityCapability(_serialization.Model): - """The min capacity capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Min capacity value. - :vartype value: float - :ivar status: The status of the capability. Known values are: "Visible", "Available", - "Default", and "Disabled". - :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :ivar reason: The reason for the capability not being available. - :vartype reason: str - """ - - _validation = { - "value": {"readonly": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "float"}, - "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.value: Optional[float] = None - self.status: Optional[Union[str, "_models.CapabilityStatus"]] = None - self.reason = reason - - -class Name(_serialization.Model): - """ARM Usage Name. - - :ivar value: Usage name value. - :vartype value: str - :ivar localized_value: Usage name localized value. - :vartype localized_value: str - """ - - _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 = { - "storage_account_resource_id": {"key": "storageAccountResourceId", "type": "str"}, - "sql_server_resource_id": {"key": "sqlServerResourceId", "type": "str"}, - } - - 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.storage_account_resource_id = storage_account_resource_id - self.sql_server_resource_id = sql_server_resource_id - - -class Operation(_serialization.Model): - """SQL REST API operation definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name of the operation being performed on this particular object. - :vartype name: str - :ivar display: The localized display information for this particular operation / action. - :vartype display: ~azure.mgmt.sql.models.OperationDisplay - :ivar origin: The intended executor of the operation. Known values are: "user" and "system". - :vartype origin: str or ~azure.mgmt.sql.models.OperationOrigin - :ivar properties: Additional descriptions for the operation. - :vartype properties: dict[str, JSON] - """ - - _validation = { - "name": {"readonly": True}, - "display": {"readonly": True}, - "origin": {"readonly": True}, - "properties": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display": {"key": "display", "type": "OperationDisplay"}, - "origin": {"key": "origin", "type": "str"}, - "properties": {"key": "properties", "type": "{object}"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.display: Optional["_models.OperationDisplay"] = None - self.origin: Optional[Union[str, "_models.OperationOrigin"]] = None - self.properties: Optional[dict[str, JSON]] = None - - -class OperationDisplay(_serialization.Model): - """Display metadata associated with the operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: The localized friendly form of the resource provider name. - :vartype provider: str - :ivar resource: The localized friendly form of the resource type related to this - action/operation. - :vartype resource: str - :ivar operation: The localized friendly name for the operation. - :vartype operation: str - :ivar description: The localized friendly description for the operation. - :vartype description: str - """ - - _validation = { - "provider": {"readonly": True}, - "resource": {"readonly": True}, - "operation": {"readonly": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "provider": {"key": "provider", "type": "str"}, - "resource": {"key": "resource", "type": "str"}, - "operation": {"key": "operation", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.provider: Optional[str] = None - self.resource: Optional[str] = None - self.operation: Optional[str] = None - self.description: Optional[str] = None - - -class OperationImpact(_serialization.Model): - """The impact of an operation, both in absolute and relative terms. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name of the impact dimension. - :vartype name: str - :ivar unit: The unit in which estimated impact to dimension is measured. - :vartype unit: str - :ivar change_value_absolute: The absolute impact to dimension. - :vartype change_value_absolute: float - :ivar change_value_relative: The relative impact to dimension (null if not applicable). - :vartype change_value_relative: float - """ - - _validation = { - "name": {"readonly": True}, - "unit": {"readonly": True}, - "change_value_absolute": {"readonly": True}, - "change_value_relative": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "unit": {"key": "unit", "type": "str"}, - "change_value_absolute": {"key": "changeValueAbsolute", "type": "float"}, - "change_value_relative": {"key": "changeValueRelative", "type": "float"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.unit: Optional[str] = None - self.change_value_absolute: Optional[float] = None - self.change_value_relative: Optional[float] = None - - -class OperationListResult(_serialization.Model): - """Result of the request to list SQL operations. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.Operation] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Operation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.Operation"]] = None - self.next_link: Optional[str] = None - - -class OutboundEnvironmentEndpoint(_serialization.Model): - """An endpoint that the managed instance service requires outbound network access to. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar category: The type of service accessed by the managed instance service, e.g., Azure - Storage, Azure Active Directory, etc. - :vartype category: str - :ivar endpoints: The endpoints that the managed instance service communicates with in order to - function correctly. - :vartype endpoints: list[~azure.mgmt.sql.models.EndpointDependency] - """ - - _validation = { - "category": {"readonly": True}, - "endpoints": {"readonly": True}, - } - - _attribute_map = { - "category": {"key": "category", "type": "str"}, - "endpoints": {"key": "endpoints", "type": "[EndpointDependency]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.category: Optional[str] = None - self.endpoints: Optional[list["_models.EndpointDependency"]] = None - - -class OutboundEnvironmentEndpointCollection(_serialization.Model): - """A collection of endpoints that the managed instance service requires outbound network access - to. - - 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.OutboundEnvironmentEndpoint] - :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": "[OutboundEnvironmentEndpoint]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.OutboundEnvironmentEndpoint"]] = None - self.next_link: Optional[str] = None - - -class OutboundFirewallRule(ProxyResource): - """An Azure SQL DB Server Outbound Firewall Rule. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar provisioning_state: The state of the outbound rule. - :vartype provisioning_state: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.provisioning_state: Optional[str] = None - - -class OutboundFirewallRuleListResult(_serialization.Model): - """A list of outbound rules. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.OutboundFirewallRule] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[OutboundFirewallRule]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.OutboundFirewallRule"]] = None - self.next_link: Optional[str] = None - - -class PartnerInfo(_serialization.Model): - """Partner server information for the failover group. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource identifier of the partner server. Required. - :vartype id: str - :ivar location: Geo location of the partner server. - :vartype location: str - :ivar replication_role: Replication role of the partner server. Known values are: "Primary" and - "Secondary". - :vartype replication_role: str or ~azure.mgmt.sql.models.FailoverGroupReplicationRole - """ - - _validation = { - "id": {"required": True}, - "location": {"readonly": True}, - "replication_role": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "replication_role": {"key": "replicationRole", "type": "str"}, - } - - def __init__(self, *, id: str, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource identifier of the partner server. Required. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - self.location: Optional[str] = None - self.replication_role: Optional[Union[str, "_models.FailoverGroupReplicationRole"]] = None - - -class PartnerRegionInfo(_serialization.Model): - """Partner region information for the failover group. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar location: Geo location of the partner managed instances. - :vartype location: str - :ivar replication_role: Replication role of the partner managed instances. Known values are: - "Primary" and "Secondary". - :vartype replication_role: str or ~azure.mgmt.sql.models.InstanceFailoverGroupReplicationRole - """ - - _validation = { - "replication_role": {"readonly": True}, - } - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - "replication_role": {"key": "replicationRole", "type": "str"}, - } - - def __init__(self, *, location: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword location: Geo location of the partner managed instances. - :paramtype location: str - """ - super().__init__(**kwargs) - self.location = location - self.replication_role: Optional[Union[str, "_models.InstanceFailoverGroupReplicationRole"]] = None - - -class PerformanceLevelCapability(_serialization.Model): - """The performance level capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Performance level value. - :vartype value: float - :ivar unit: Unit type used to measure performance level. Known values are: "DTU" and "VCores". - :vartype unit: str or ~azure.mgmt.sql.models.PerformanceLevelUnit - """ - - _validation = { - "value": {"readonly": True}, - "unit": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "float"}, - "unit": {"key": "unit", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[float] = None - self.unit: Optional[Union[str, "_models.PerformanceLevelUnit"]] = 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: "LogTransitionInProgress", "Copying", - "BuildingHyperscaleComponents", "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: Optional[Union[str, "_models.Phase"]] = None - self.phase_information: Optional[dict[str, str]] = None - - -class PrivateEndpointConnection(ProxyResource): - """A private endpoint connection. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :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: - ~azure.mgmt.sql.models.PrivateLinkServiceConnectionStateProperty - :ivar provisioning_state: State of the private endpoint connection. Known values are: - "Approving", "Ready", "Dropping", "Failed", and "Rejecting". - :vartype provisioning_state: str or ~azure.mgmt.sql.models.PrivateEndpointProvisioningState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "group_ids": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpointProperty"}, - "group_ids": {"key": "properties.groupIds", "type": "[str]"}, - "private_link_service_connection_state": { - "key": "properties.privateLinkServiceConnectionState", - "type": "PrivateLinkServiceConnectionStateProperty", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - private_endpoint: Optional["_models.PrivateEndpointProperty"] = None, - private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionStateProperty"] = None, - **kwargs: Any - ) -> None: - """ - :keyword private_endpoint: Private endpoint which the connection belongs to. - :paramtype private_endpoint: ~azure.mgmt.sql.models.PrivateEndpointProperty - :keyword private_link_service_connection_state: Connection state of the private endpoint - connection. - :paramtype private_link_service_connection_state: - ~azure.mgmt.sql.models.PrivateLinkServiceConnectionStateProperty - """ - super().__init__(**kwargs) - self.private_endpoint = private_endpoint - self.group_ids: Optional[list[str]] = None - self.private_link_service_connection_state = private_link_service_connection_state - self.provisioning_state: Optional[Union[str, "_models.PrivateEndpointProvisioningState"]] = None - - -class PrivateEndpointConnectionListResult(_serialization.Model): - """A list of private endpoint connections. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.PrivateEndpointConnection] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.PrivateEndpointConnection"]] = None - self.next_link: Optional[str] = None - - -class PrivateEndpointConnectionProperties(_serialization.Model): - """Properties of a private endpoint connection. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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: - ~azure.mgmt.sql.models.PrivateLinkServiceConnectionStateProperty - :ivar provisioning_state: State of the private endpoint connection. Known values are: - "Approving", "Ready", "Dropping", "Failed", and "Rejecting". - :vartype provisioning_state: str or ~azure.mgmt.sql.models.PrivateEndpointProvisioningState - """ - - _validation = { - "group_ids": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "private_endpoint": {"key": "privateEndpoint", "type": "PrivateEndpointProperty"}, - "group_ids": {"key": "groupIds", "type": "[str]"}, - "private_link_service_connection_state": { - "key": "privateLinkServiceConnectionState", - "type": "PrivateLinkServiceConnectionStateProperty", - }, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - private_endpoint: Optional["_models.PrivateEndpointProperty"] = None, - private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionStateProperty"] = None, - **kwargs: Any - ) -> None: - """ - :keyword private_endpoint: Private endpoint which the connection belongs to. - :paramtype private_endpoint: ~azure.mgmt.sql.models.PrivateEndpointProperty - :keyword private_link_service_connection_state: Connection state of the private endpoint - connection. - :paramtype private_link_service_connection_state: - ~azure.mgmt.sql.models.PrivateLinkServiceConnectionStateProperty - """ - super().__init__(**kwargs) - self.private_endpoint = private_endpoint - self.group_ids: Optional[list[str]] = None - self.private_link_service_connection_state = private_link_service_connection_state - self.provisioning_state: Optional[Union[str, "_models.PrivateEndpointProvisioningState"]] = None - - -class PrivateEndpointConnectionRequestStatus(_serialization.Model): - """Contains the private endpoint connection requests status. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar private_link_service_id: Resource id for which the private endpoint is created. - :vartype private_link_service_id: str - :ivar private_endpoint_connection_name: The connection name for the private endpoint. - :vartype private_endpoint_connection_name: str - :ivar status: Status of this private endpoint connection. - :vartype status: str - """ - - _validation = { - "private_link_service_id": {"readonly": True}, - "private_endpoint_connection_name": {"readonly": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "private_link_service_id": {"key": "privateLinkServiceId", "type": "str"}, - "private_endpoint_connection_name": {"key": "privateEndpointConnectionName", "type": "str"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.private_link_service_id: Optional[str] = None - self.private_endpoint_connection_name: Optional[str] = None - self.status: Optional[str] = None - - -class PrivateEndpointProperty(_serialization.Model): - """PrivateEndpointProperty. - - :ivar id: Resource id of the private endpoint. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource id of the private endpoint. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class PrivateLinkResource(ProxyResource): - """A private link resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar properties: The private link resource group id. - :vartype properties: ~azure.mgmt.sql.models.PrivateLinkResourceProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "properties": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "properties": {"key": "properties", "type": "PrivateLinkResourceProperties"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.properties: Optional["_models.PrivateLinkResourceProperties"] = None - - -class PrivateLinkResourceListResult(_serialization.Model): - """A list of private link resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.PrivateLinkResource] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[PrivateLinkResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.PrivateLinkResource"]] = None - self.next_link: Optional[str] = None - - -class PrivateLinkResourceProperties(_serialization.Model): - """Properties of a private link resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar group_id: The private link resource group id. - :vartype group_id: str - :ivar required_members: The private link resource required member names. - :vartype required_members: list[str] - :ivar required_zone_names: The private link resource required zone names. - :vartype required_zone_names: list[str] - """ - - _validation = { - "group_id": {"readonly": True}, - "required_members": {"readonly": True}, - "required_zone_names": {"readonly": True}, - } - - _attribute_map = { - "group_id": {"key": "groupId", "type": "str"}, - "required_members": {"key": "requiredMembers", "type": "[str]"}, - "required_zone_names": {"key": "requiredZoneNames", "type": "[str]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.group_id: Optional[str] = None - self.required_members: Optional[list[str]] = None - self.required_zone_names: Optional[list[str]] = None - - -class PrivateLinkServiceConnectionStateProperty(_serialization.Model): # pylint: disable=name-too-long - """PrivateLinkServiceConnectionStateProperty. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar status: The private link service connection status. Required. Known values are: - "Approved", "Pending", "Rejected", and "Disconnected". - :vartype status: str or ~azure.mgmt.sql.models.PrivateLinkServiceConnectionStateStatus - :ivar description: The private link service connection description. Required. - :vartype description: str - :ivar actions_required: The actions required for private link service connection. "None" - :vartype actions_required: str or - ~azure.mgmt.sql.models.PrivateLinkServiceConnectionStateActionsRequire - """ - - _validation = { - "status": {"required": True}, - "description": {"required": True}, - "actions_required": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "actions_required": {"key": "actionsRequired", "type": "str"}, - } - - def __init__( - self, *, status: Union[str, "_models.PrivateLinkServiceConnectionStateStatus"], description: str, **kwargs: Any - ) -> None: - """ - :keyword status: The private link service connection status. Required. Known values are: - "Approved", "Pending", "Rejected", and "Disconnected". - :paramtype status: str or ~azure.mgmt.sql.models.PrivateLinkServiceConnectionStateStatus - :keyword description: The private link service connection description. Required. - :paramtype description: str - """ - super().__init__(**kwargs) - self.status = status - self.description = description - self.actions_required: Optional[Union[str, "_models.PrivateLinkServiceConnectionStateActionsRequire"]] = None - - -class QueryCheck(_serialization.Model): - """SQL Vulnerability Assessment query check object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar query: SQL Vulnerability Assessment rule query. - :vartype query: str - :ivar expected_result: SQL Vulnerability Assessment query expected result. - :vartype expected_result: list[list[str]] - :ivar column_names: SQL Vulnerability Assessment column names of query expected result. - :vartype column_names: list[str] - """ - - _validation = { - "query": {"readonly": True}, - "expected_result": {"readonly": True}, - "column_names": {"readonly": True}, - } - - _attribute_map = { - "query": {"key": "query", "type": "str"}, - "expected_result": {"key": "expectedResult", "type": "[[str]]"}, - "column_names": {"key": "columnNames", "type": "[str]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.query: Optional[str] = None - self.expected_result: Optional[list[list[str]]] = None - self.column_names: Optional[list[str]] = None - - -class QueryMetricInterval(_serialization.Model): - """Properties of a query metrics interval. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar interval_start_time: The start time for the metric interval (ISO-8601 format). - :vartype interval_start_time: str - :ivar interval_type: Interval type (length). Known values are: "PT1H" and "P1D". - :vartype interval_type: str or ~azure.mgmt.sql.models.QueryTimeGrainType - :ivar execution_count: Execution count of a query in this interval. - :vartype execution_count: int - :ivar metrics: List of metric objects for this interval. - :vartype metrics: list[~azure.mgmt.sql.models.QueryMetricProperties] - """ - - _validation = { - "interval_start_time": {"readonly": True}, - "interval_type": {"readonly": True}, - "execution_count": {"readonly": True}, - } - - _attribute_map = { - "interval_start_time": {"key": "intervalStartTime", "type": "str"}, - "interval_type": {"key": "intervalType", "type": "str"}, - "execution_count": {"key": "executionCount", "type": "int"}, - "metrics": {"key": "metrics", "type": "[QueryMetricProperties]"}, - } - - def __init__(self, *, metrics: Optional[list["_models.QueryMetricProperties"]] = None, **kwargs: Any) -> None: - """ - :keyword metrics: List of metric objects for this interval. - :paramtype metrics: list[~azure.mgmt.sql.models.QueryMetricProperties] - """ - super().__init__(**kwargs) - self.interval_start_time: Optional[str] = None - self.interval_type: Optional[Union[str, "_models.QueryTimeGrainType"]] = None - self.execution_count: Optional[int] = None - self.metrics = metrics - - -class QueryMetricIntervalAutoGenerated(_serialization.Model): - """Properties of a query metrics interval. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar interval_start_time: The start time for the metric interval (ISO-8601 format). - :vartype interval_start_time: str - :ivar interval_type: Interval type (length). Known values are: "PT1H" and "P1D". - :vartype interval_type: str or ~azure.mgmt.sql.models.QueryTimeGrainType - :ivar execution_count: Execution count of a query in this interval. - :vartype execution_count: int - :ivar metrics: List of metric objects for this interval. - :vartype metrics: list[~azure.mgmt.sql.models.QueryMetricProperties] - """ - - _validation = { - "interval_start_time": {"readonly": True}, - "interval_type": {"readonly": True}, - "execution_count": {"readonly": True}, - } - - _attribute_map = { - "interval_start_time": {"key": "intervalStartTime", "type": "str"}, - "interval_type": {"key": "intervalType", "type": "str"}, - "execution_count": {"key": "executionCount", "type": "int"}, - "metrics": {"key": "metrics", "type": "[QueryMetricProperties]"}, - } - - def __init__(self, *, metrics: Optional[list["_models.QueryMetricProperties"]] = None, **kwargs: Any) -> None: - """ - :keyword metrics: List of metric objects for this interval. - :paramtype metrics: list[~azure.mgmt.sql.models.QueryMetricProperties] - """ - super().__init__(**kwargs) - self.interval_start_time: Optional[str] = None - self.interval_type: Optional[Union[str, "_models.QueryTimeGrainType"]] = None - self.execution_count: Optional[int] = None - self.metrics = metrics - - -class QueryMetricProperties(_serialization.Model): - """Properties of a topquery metric in one interval. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name information for the metric. - :vartype name: str - :ivar display_name: The UI appropriate name for the metric. - :vartype display_name: str - :ivar unit: The unit of the metric. Known values are: "percentage", "KB", "microseconds", and - "count". - :vartype unit: str or ~azure.mgmt.sql.models.QueryMetricUnitType - :ivar value: The value of the metric. - :vartype value: float - :ivar min: Metric value when min() aggregate function is used over the interval. - :vartype min: float - :ivar max: Metric value when max() aggregate function is used over the interval. - :vartype max: float - :ivar avg: Metric value when avg() aggregate function is used over the interval. - :vartype avg: float - :ivar sum: Metric value when sum() aggregate function is used over the interval. - :vartype sum: float - :ivar stdev: Metric value when stdev aggregate function is used over the interval. - :vartype stdev: float - """ - - _validation = { - "name": {"readonly": True}, - "display_name": {"readonly": True}, - "unit": {"readonly": True}, - "value": {"readonly": True}, - "min": {"readonly": True}, - "max": {"readonly": True}, - "avg": {"readonly": True}, - "sum": {"readonly": True}, - "stdev": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "unit": {"key": "unit", "type": "str"}, - "value": {"key": "value", "type": "float"}, - "min": {"key": "min", "type": "float"}, - "max": {"key": "max", "type": "float"}, - "avg": {"key": "avg", "type": "float"}, - "sum": {"key": "sum", "type": "float"}, - "stdev": {"key": "stdev", "type": "float"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.display_name: Optional[str] = None - self.unit: Optional[Union[str, "_models.QueryMetricUnitType"]] = None - self.value: Optional[float] = None - self.min: Optional[float] = None - self.max: Optional[float] = None - self.avg: Optional[float] = None - self.sum: Optional[float] = None - self.stdev: Optional[float] = None - - -class QueryStatistics(ProxyResource): - """QueryStatistics. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar database_name: Database name of the database in which this query was executed. - :vartype database_name: str - :ivar query_id: Unique query id (unique within one database). - :vartype query_id: str - :ivar start_time: The start time for the metric (ISO-8601 format). - :vartype start_time: str - :ivar end_time: The end time for the metric (ISO-8601 format). - :vartype end_time: str - :ivar intervals: List of intervals with appropriate metric data. - :vartype intervals: list[~azure.mgmt.sql.models.QueryMetricInterval] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "database_name": {"readonly": True}, - "query_id": {"readonly": True}, - "start_time": {"readonly": True}, - "end_time": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "database_name": {"key": "properties.databaseName", "type": "str"}, - "query_id": {"key": "properties.queryId", "type": "str"}, - "start_time": {"key": "properties.startTime", "type": "str"}, - "end_time": {"key": "properties.endTime", "type": "str"}, - "intervals": {"key": "properties.intervals", "type": "[QueryMetricInterval]"}, - } - - def __init__(self, *, intervals: Optional[list["_models.QueryMetricInterval"]] = None, **kwargs: Any) -> None: - """ - :keyword intervals: List of intervals with appropriate metric data. - :paramtype intervals: list[~azure.mgmt.sql.models.QueryMetricInterval] - """ - super().__init__(**kwargs) - self.database_name: Optional[str] = None - self.query_id: Optional[str] = None - self.start_time: Optional[str] = None - self.end_time: Optional[str] = None - self.intervals = intervals - - -class QueryStatisticsProperties(_serialization.Model): - """Properties of a query execution statistics. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar database_name: Database name of the database in which this query was executed. - :vartype database_name: str - :ivar query_id: Unique query id (unique within one database). - :vartype query_id: str - :ivar start_time: The start time for the metric (ISO-8601 format). - :vartype start_time: str - :ivar end_time: The end time for the metric (ISO-8601 format). - :vartype end_time: str - :ivar intervals: List of intervals with appropriate metric data. - :vartype intervals: list[~azure.mgmt.sql.models.QueryMetricIntervalAutoGenerated] - """ - - _validation = { - "database_name": {"readonly": True}, - "query_id": {"readonly": True}, - "start_time": {"readonly": True}, - "end_time": {"readonly": True}, - } - - _attribute_map = { - "database_name": {"key": "databaseName", "type": "str"}, - "query_id": {"key": "queryId", "type": "str"}, - "start_time": {"key": "startTime", "type": "str"}, - "end_time": {"key": "endTime", "type": "str"}, - "intervals": {"key": "intervals", "type": "[QueryMetricIntervalAutoGenerated]"}, - } - - def __init__( - self, *, intervals: Optional[list["_models.QueryMetricIntervalAutoGenerated"]] = None, **kwargs: Any - ) -> None: - """ - :keyword intervals: List of intervals with appropriate metric data. - :paramtype intervals: list[~azure.mgmt.sql.models.QueryMetricIntervalAutoGenerated] - """ - super().__init__(**kwargs) - self.database_name: Optional[str] = None - self.query_id: Optional[str] = None - self.start_time: Optional[str] = None - self.end_time: Optional[str] = None - self.intervals = intervals - - -class ReadScaleCapability(_serialization.Model): - """The read scale capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar max_number_of_replicas: The maximum number of read scale replicas. - :vartype max_number_of_replicas: int - :ivar status: The status of the capability. 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 = { - "max_number_of_replicas": {"readonly": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "max_number_of_replicas": {"key": "maxNumberOfReplicas", "type": "int"}, - "status": {"key": "status", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - } - - def __init__(self, *, reason: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword reason: The reason for the capability not being available. - :paramtype reason: str - """ - super().__init__(**kwargs) - self.max_number_of_replicas: Optional[int] = None - self.status: Optional[Union[str, "_models.CapabilityStatus"]] = None - self.reason = reason - - -class RecommendedAction(ProxyResource): - """Database, Server or Elastic Pool Recommended Action. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar kind: Resource kind. - :vartype kind: str - :ivar location: Resource location. - :vartype location: str - :ivar recommendation_reason: Gets the reason for recommending this action. e.g., - DuplicateIndex. - :vartype recommendation_reason: str - :ivar valid_since: Gets the time since when this recommended action is valid. - :vartype valid_since: ~datetime.datetime - :ivar last_refresh: Gets time when this recommended action was last refreshed. - :vartype last_refresh: ~datetime.datetime - :ivar state: Gets the info of the current state the recommended action is in. - :vartype state: ~azure.mgmt.sql.models.RecommendedActionStateInfo - :ivar is_executable_action: Gets if this recommended action is actionable by user. - :vartype is_executable_action: bool - :ivar is_revertable_action: Gets if changes applied by this recommended action can be reverted - by user. - :vartype is_revertable_action: bool - :ivar is_archived_action: Gets if this recommended action was suggested some time ago but user - chose to ignore this and system added a new recommended action again. - :vartype is_archived_action: bool - :ivar execute_action_start_time: Gets the time when system started applying this recommended - action on the user resource. e.g., index creation start time. - :vartype execute_action_start_time: ~datetime.datetime - :ivar execute_action_duration: Gets the time taken for applying this recommended action on user - resource. e.g., time taken for index creation. - :vartype execute_action_duration: str - :ivar revert_action_start_time: Gets the time when system started reverting changes of this - recommended action on user resource. e.g., time when index drop is executed. - :vartype revert_action_start_time: ~datetime.datetime - :ivar revert_action_duration: Gets the time taken for reverting changes of this recommended - action on user resource. e.g., time taken for dropping the created index. - :vartype revert_action_duration: str - :ivar execute_action_initiated_by: Gets if approval for applying this recommended action was - given by user/system. Known values are: "User" and "System". - :vartype execute_action_initiated_by: str or - ~azure.mgmt.sql.models.RecommendedActionInitiatedBy - :ivar execute_action_initiated_time: Gets the time when this recommended action was approved - for execution. - :vartype execute_action_initiated_time: ~datetime.datetime - :ivar revert_action_initiated_by: Gets if approval for reverting this recommended action was - given by user/system. Known values are: "User" and "System". - :vartype revert_action_initiated_by: str or ~azure.mgmt.sql.models.RecommendedActionInitiatedBy - :ivar revert_action_initiated_time: Gets the time when this recommended action was approved for - revert. - :vartype revert_action_initiated_time: ~datetime.datetime - :ivar score: Gets the impact of this recommended action. Possible values are 1 - Low impact, 2 - - Medium Impact and 3 - High Impact. - :vartype score: int - :ivar implementation_details: Gets the implementation details of this recommended action for - user to apply it manually. - :vartype implementation_details: ~azure.mgmt.sql.models.RecommendedActionImplementationInfo - :ivar error_details: Gets the error details if and why this recommended action is put to error - state. - :vartype error_details: ~azure.mgmt.sql.models.RecommendedActionErrorInfo - :ivar estimated_impact: Gets the estimated impact info for this recommended action e.g., - Estimated CPU gain, Estimated Disk Space change. - :vartype estimated_impact: list[~azure.mgmt.sql.models.RecommendedActionImpactRecord] - :ivar observed_impact: Gets the observed/actual impact info for this recommended action e.g., - Actual CPU gain, Actual Disk Space change. - :vartype observed_impact: list[~azure.mgmt.sql.models.RecommendedActionImpactRecord] - :ivar time_series: Gets the time series info of metrics for this recommended action e.g., CPU - consumption time series. - :vartype time_series: list[~azure.mgmt.sql.models.RecommendedActionMetricInfo] - :ivar linked_objects: Gets the linked objects, if any. - :vartype linked_objects: list[str] - :ivar details: Gets additional details specific to this recommended action. - :vartype details: dict[str, JSON] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "kind": {"readonly": True}, - "location": {"readonly": True}, - "recommendation_reason": {"readonly": True}, - "valid_since": {"readonly": True}, - "last_refresh": {"readonly": True}, - "is_executable_action": {"readonly": True}, - "is_revertable_action": {"readonly": True}, - "is_archived_action": {"readonly": True}, - "execute_action_start_time": {"readonly": True}, - "execute_action_duration": {"readonly": True}, - "revert_action_start_time": {"readonly": True}, - "revert_action_duration": {"readonly": True}, - "execute_action_initiated_by": {"readonly": True}, - "execute_action_initiated_time": {"readonly": True}, - "revert_action_initiated_by": {"readonly": True}, - "revert_action_initiated_time": {"readonly": True}, - "score": {"readonly": True}, - "implementation_details": {"readonly": True}, - "error_details": {"readonly": True}, - "estimated_impact": {"readonly": True}, - "observed_impact": {"readonly": True}, - "time_series": {"readonly": True}, - "linked_objects": {"readonly": True}, - "details": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "recommendation_reason": {"key": "properties.recommendationReason", "type": "str"}, - "valid_since": {"key": "properties.validSince", "type": "iso-8601"}, - "last_refresh": {"key": "properties.lastRefresh", "type": "iso-8601"}, - "state": {"key": "properties.state", "type": "RecommendedActionStateInfo"}, - "is_executable_action": {"key": "properties.isExecutableAction", "type": "bool"}, - "is_revertable_action": {"key": "properties.isRevertableAction", "type": "bool"}, - "is_archived_action": {"key": "properties.isArchivedAction", "type": "bool"}, - "execute_action_start_time": {"key": "properties.executeActionStartTime", "type": "iso-8601"}, - "execute_action_duration": {"key": "properties.executeActionDuration", "type": "str"}, - "revert_action_start_time": {"key": "properties.revertActionStartTime", "type": "iso-8601"}, - "revert_action_duration": {"key": "properties.revertActionDuration", "type": "str"}, - "execute_action_initiated_by": {"key": "properties.executeActionInitiatedBy", "type": "str"}, - "execute_action_initiated_time": {"key": "properties.executeActionInitiatedTime", "type": "iso-8601"}, - "revert_action_initiated_by": {"key": "properties.revertActionInitiatedBy", "type": "str"}, - "revert_action_initiated_time": {"key": "properties.revertActionInitiatedTime", "type": "iso-8601"}, - "score": {"key": "properties.score", "type": "int"}, - "implementation_details": { - "key": "properties.implementationDetails", - "type": "RecommendedActionImplementationInfo", - }, - "error_details": {"key": "properties.errorDetails", "type": "RecommendedActionErrorInfo"}, - "estimated_impact": {"key": "properties.estimatedImpact", "type": "[RecommendedActionImpactRecord]"}, - "observed_impact": {"key": "properties.observedImpact", "type": "[RecommendedActionImpactRecord]"}, - "time_series": {"key": "properties.timeSeries", "type": "[RecommendedActionMetricInfo]"}, - "linked_objects": {"key": "properties.linkedObjects", "type": "[str]"}, - "details": {"key": "properties.details", "type": "{object}"}, - } - - def __init__( # pylint: disable=too-many-locals - self, *, state: Optional["_models.RecommendedActionStateInfo"] = None, **kwargs: Any - ) -> None: - """ - :keyword state: Gets the info of the current state the recommended action is in. - :paramtype state: ~azure.mgmt.sql.models.RecommendedActionStateInfo - """ - super().__init__(**kwargs) - self.kind: Optional[str] = None - self.location: Optional[str] = None - self.recommendation_reason: Optional[str] = None - self.valid_since: Optional[datetime.datetime] = None - self.last_refresh: Optional[datetime.datetime] = None - self.state = state - self.is_executable_action: Optional[bool] = None - self.is_revertable_action: Optional[bool] = None - self.is_archived_action: Optional[bool] = None - self.execute_action_start_time: Optional[datetime.datetime] = None - self.execute_action_duration: Optional[str] = None - self.revert_action_start_time: Optional[datetime.datetime] = None - self.revert_action_duration: Optional[str] = None - self.execute_action_initiated_by: Optional[Union[str, "_models.RecommendedActionInitiatedBy"]] = None - self.execute_action_initiated_time: Optional[datetime.datetime] = None - self.revert_action_initiated_by: Optional[Union[str, "_models.RecommendedActionInitiatedBy"]] = None - self.revert_action_initiated_time: Optional[datetime.datetime] = None - self.score: Optional[int] = None - self.implementation_details: Optional["_models.RecommendedActionImplementationInfo"] = None - self.error_details: Optional["_models.RecommendedActionErrorInfo"] = None - self.estimated_impact: Optional[list["_models.RecommendedActionImpactRecord"]] = None - self.observed_impact: Optional[list["_models.RecommendedActionImpactRecord"]] = None - self.time_series: Optional[list["_models.RecommendedActionMetricInfo"]] = None - self.linked_objects: Optional[list[str]] = None - self.details: Optional[dict[str, JSON]] = None - - -class RecommendedActionErrorInfo(_serialization.Model): - """Contains error information for an Azure SQL Database, Server or Elastic Pool Recommended - Action. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar error_code: Gets the reason why the recommended action was put to error state. e.g., - DatabaseHasQdsOff, IndexAlreadyExists. - :vartype error_code: str - :ivar is_retryable: Gets whether the error could be ignored and recommended action could be - retried. Possible values are: Yes/No. Known values are: "Yes" and "No". - :vartype is_retryable: str or ~azure.mgmt.sql.models.IsRetryable - """ - - _validation = { - "error_code": {"readonly": True}, - "is_retryable": {"readonly": True}, - } - - _attribute_map = { - "error_code": {"key": "errorCode", "type": "str"}, - "is_retryable": {"key": "isRetryable", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.error_code: Optional[str] = None - self.is_retryable: Optional[Union[str, "_models.IsRetryable"]] = None - - -class RecommendedActionImpactRecord(_serialization.Model): - """Contains information of estimated or observed impact on various metrics for an Azure SQL - Database, Server or Elastic Pool Recommended Action. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar dimension_name: Gets the name of the impact dimension. e.g., CPUChange, DiskSpaceChange, - NumberOfQueriesAffected. - :vartype dimension_name: str - :ivar unit: Gets the name of the impact dimension. e.g., CPUChange, DiskSpaceChange, - NumberOfQueriesAffected. - :vartype unit: str - :ivar absolute_value: Gets the absolute value of this dimension if applicable. e.g., Number of - Queries affected. - :vartype absolute_value: float - :ivar change_value_absolute: Gets the absolute change in the value of this dimension. e.g., - Absolute Disk space change in Megabytes. - :vartype change_value_absolute: float - :ivar change_value_relative: Gets the relative change in the value of this dimension. e.g., - Relative Disk space change in Percentage. - :vartype change_value_relative: float - """ - - _validation = { - "dimension_name": {"readonly": True}, - "unit": {"readonly": True}, - "absolute_value": {"readonly": True}, - "change_value_absolute": {"readonly": True}, - "change_value_relative": {"readonly": True}, - } - - _attribute_map = { - "dimension_name": {"key": "dimensionName", "type": "str"}, - "unit": {"key": "unit", "type": "str"}, - "absolute_value": {"key": "absoluteValue", "type": "float"}, - "change_value_absolute": {"key": "changeValueAbsolute", "type": "float"}, - "change_value_relative": {"key": "changeValueRelative", "type": "float"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.dimension_name: Optional[str] = None - self.unit: Optional[str] = None - self.absolute_value: Optional[float] = None - self.change_value_absolute: Optional[float] = None - self.change_value_relative: Optional[float] = None - - -class RecommendedActionImplementationInfo(_serialization.Model): - """Contains information for manual implementation for an Azure SQL Database, Server or Elastic - Pool Recommended Action. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar method: Gets the method in which this recommended action can be manually implemented. - e.g., TSql, AzurePowerShell. Known values are: "TSql" and "AzurePowerShell". - :vartype method: str or ~azure.mgmt.sql.models.ImplementationMethod - :ivar script: Gets the manual implementation script. e.g., T-SQL script that could be executed - on the database. - :vartype script: str - """ - - _validation = { - "method": {"readonly": True}, - "script": {"readonly": True}, - } - - _attribute_map = { - "method": {"key": "method", "type": "str"}, - "script": {"key": "script", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.method: Optional[Union[str, "_models.ImplementationMethod"]] = None - self.script: Optional[str] = None - - -class RecommendedActionMetricInfo(_serialization.Model): - """Contains time series of various impacted metrics for an Azure SQL Database, Server or Elastic - Pool Recommended Action. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar metric_name: Gets the name of the metric. e.g., CPU, Number of Queries. - :vartype metric_name: str - :ivar unit: Gets the unit in which metric is measured. e.g., DTU, Frequency. - :vartype unit: str - :ivar time_grain: Gets the duration of time interval for the value given by this MetricInfo. - e.g., PT1H (1 hour). - :vartype time_grain: str - :ivar start_time: Gets the start time of time interval given by this MetricInfo. - :vartype start_time: ~datetime.datetime - :ivar value: Gets the value of the metric in the time interval given by this MetricInfo. - :vartype value: float - """ - - _validation = { - "metric_name": {"readonly": True}, - "unit": {"readonly": True}, - "time_grain": {"readonly": True}, - "start_time": {"readonly": True}, - "value": {"readonly": True}, - } - - _attribute_map = { - "metric_name": {"key": "metricName", "type": "str"}, - "unit": {"key": "unit", "type": "str"}, - "time_grain": {"key": "timeGrain", "type": "str"}, - "start_time": {"key": "startTime", "type": "iso-8601"}, - "value": {"key": "value", "type": "float"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.metric_name: Optional[str] = None - self.unit: Optional[str] = None - self.time_grain: Optional[str] = None - self.start_time: Optional[datetime.datetime] = None - self.value: Optional[float] = None - - -class RecommendedActionStateInfo(_serialization.Model): - """Contains information of current state for an Azure SQL Database, Server or Elastic Pool - Recommended Action. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar current_value: Current state the recommended action is in. Some commonly used states are: - Active -> recommended action is active and no action has been taken yet. Pending -> - recommended action is approved for and is awaiting execution. Executing -> recommended action - is being applied on the user database. Verifying -> recommended action was applied and is - being verified of its usefulness by the system. Success -> recommended action was applied - and improvement found during verification. Pending Revert -> verification found little or no - improvement so recommended action is queued for revert or user has manually reverted. Reverting - -> changes made while applying recommended action are being reverted on the user database. - Reverted -> successfully reverted the changes made by recommended action on user database. - Ignored -> user explicitly ignored/discarded the recommended action. Required. Known values - are: "Active", "Pending", "Executing", "Verifying", "PendingRevert", "RevertCancelled", - "Reverting", "Reverted", "Ignored", "Expired", "Monitoring", "Resolved", "Success", and - "Error". - :vartype current_value: str or ~azure.mgmt.sql.models.RecommendedActionCurrentState - :ivar action_initiated_by: Gets who initiated the execution of this recommended action. - Possible Value are: User -> When user explicity notified system to apply the recommended - action. System -> When auto-execute status of this advisor was set to 'Enabled', in which case - the system applied it. Known values are: "User" and "System". - :vartype action_initiated_by: str or ~azure.mgmt.sql.models.RecommendedActionInitiatedBy - :ivar last_modified: Gets the time when the state was last modified. - :vartype last_modified: ~datetime.datetime - """ - - _validation = { - "current_value": {"required": True}, - "action_initiated_by": {"readonly": True}, - "last_modified": {"readonly": True}, - } - - _attribute_map = { - "current_value": {"key": "currentValue", "type": "str"}, - "action_initiated_by": {"key": "actionInitiatedBy", "type": "str"}, - "last_modified": {"key": "lastModified", "type": "iso-8601"}, - } - - def __init__(self, *, current_value: Union[str, "_models.RecommendedActionCurrentState"], **kwargs: Any) -> None: - """ - :keyword current_value: Current state the recommended action is in. Some commonly used states - are: Active -> recommended action is active and no action has been taken yet. Pending - -> recommended action is approved for and is awaiting execution. Executing -> recommended - action is being applied on the user database. Verifying -> recommended action was applied and - is being verified of its usefulness by the system. Success -> recommended action was - applied and improvement found during verification. Pending Revert -> verification found little - or no improvement so recommended action is queued for revert or user has manually reverted. - Reverting -> changes made while applying recommended action are being reverted on the user - database. Reverted -> successfully reverted the changes made by recommended action on user - database. Ignored -> user explicitly ignored/discarded the recommended action. Required. - Known values are: "Active", "Pending", "Executing", "Verifying", "PendingRevert", - "RevertCancelled", "Reverting", "Reverted", "Ignored", "Expired", "Monitoring", "Resolved", - "Success", and "Error". - :paramtype current_value: str or ~azure.mgmt.sql.models.RecommendedActionCurrentState - """ - super().__init__(**kwargs) - self.current_value = current_value - self.action_initiated_by: Optional[Union[str, "_models.RecommendedActionInitiatedBy"]] = None - self.last_modified: Optional[datetime.datetime] = None - - -class RecommendedSensitivityLabelUpdate(ProxyResource): - """A recommended sensitivity label update operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar op: Known values are: "enable" and "disable". - :vartype op: str or ~azure.mgmt.sql.models.RecommendedSensitivityLabelUpdateKind - :ivar schema: Schema name of the column to update. - :vartype schema: str - :ivar table: Table name of the column to update. - :vartype table: str - :ivar column: Column name to update. - :vartype column: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "op": {"key": "properties.op", "type": "str"}, - "schema": {"key": "properties.schema", "type": "str"}, - "table": {"key": "properties.table", "type": "str"}, - "column": {"key": "properties.column", "type": "str"}, - } - - def __init__( - self, - *, - op: Optional[Union[str, "_models.RecommendedSensitivityLabelUpdateKind"]] = None, - schema: Optional[str] = None, - table: Optional[str] = None, - column: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword op: Known values are: "enable" and "disable". - :paramtype op: str or ~azure.mgmt.sql.models.RecommendedSensitivityLabelUpdateKind - :keyword schema: Schema name of the column to update. - :paramtype schema: str - :keyword table: Table name of the column to update. - :paramtype table: str - :keyword column: Column name to update. - :paramtype column: str - """ - super().__init__(**kwargs) - self.op = op - self.schema = schema - self.table = table - self.column = column - - -class RecommendedSensitivityLabelUpdateList(_serialization.Model): - """A list of recommended sensitivity label update operations. - - :ivar operations: - :vartype operations: list[~azure.mgmt.sql.models.RecommendedSensitivityLabelUpdate] - """ - - _attribute_map = { - "operations": {"key": "operations", "type": "[RecommendedSensitivityLabelUpdate]"}, - } - - def __init__( - self, *, operations: Optional[list["_models.RecommendedSensitivityLabelUpdate"]] = None, **kwargs: Any - ) -> None: - """ - :keyword operations: - :paramtype operations: list[~azure.mgmt.sql.models.RecommendedSensitivityLabelUpdate] - """ - super().__init__(**kwargs) - self.operations = operations - - -class RecoverableDatabase(ProxyResource): - """A recoverable database resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar edition: The edition of the database. - :vartype edition: str - :ivar service_level_objective: The service level objective name of the database. - :vartype service_level_objective: str - :ivar elastic_pool_name: The elastic pool name of the database. - :vartype elastic_pool_name: str - :ivar last_available_backup_date: The last available backup date. - :vartype last_available_backup_date: ~datetime.datetime - :ivar keys: The resource ids of the user assigned identities to use. - :vartype keys: dict[str, ~azure.mgmt.sql.models.DatabaseKey] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "edition": {"readonly": True}, - "service_level_objective": {"readonly": True}, - "elastic_pool_name": {"readonly": True}, - "last_available_backup_date": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "edition": {"key": "properties.edition", "type": "str"}, - "service_level_objective": {"key": "properties.serviceLevelObjective", "type": "str"}, - "elastic_pool_name": {"key": "properties.elasticPoolName", "type": "str"}, - "last_available_backup_date": {"key": "properties.lastAvailableBackupDate", "type": "iso-8601"}, - "keys": {"key": "properties.keys", "type": "{DatabaseKey}"}, - } - - def __init__(self, *, keys: Optional[dict[str, "_models.DatabaseKey"]] = None, **kwargs: Any) -> None: - """ - :keyword keys: The resource ids of the user assigned identities to use. - :paramtype keys: dict[str, ~azure.mgmt.sql.models.DatabaseKey] - """ - super().__init__(**kwargs) - self.edition: Optional[str] = None - self.service_level_objective: Optional[str] = None - self.elastic_pool_name: Optional[str] = None - self.last_available_backup_date: Optional[datetime.datetime] = None - self.keys = keys - - -class RecoverableDatabaseListResult(_serialization.Model): - """A list of recoverable databases. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.RecoverableDatabase] - :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": "[RecoverableDatabase]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.RecoverableDatabase"]] = None - self.next_link: Optional[str] = None - - -class RecoverableManagedDatabase(ProxyResource): - """A recoverable managed database resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar last_available_backup_date: The last available backup date. - :vartype last_available_backup_date: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "last_available_backup_date": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "last_available_backup_date": {"key": "properties.lastAvailableBackupDate", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.last_available_backup_date: Optional[str] = None - - -class RecoverableManagedDatabaseListResult(_serialization.Model): - """A list of recoverable managed databases. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.RecoverableManagedDatabase] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[RecoverableManagedDatabase]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.RecoverableManagedDatabase"]] = None - self.next_link: Optional[str] = None - - -class RefreshExternalGovernanceStatusOperationResult(ProxyResource): # pylint: disable=name-too-long - """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 server_name: Server name. - :vartype server_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}, - "server_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"}, - "server_name": {"key": "properties.serverName", "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: Optional[str] = None - self.request_type: Optional[str] = None - self.queued_time: Optional[str] = None - self.server_name: Optional[str] = None - self.status: Optional[str] = None - self.error_message: Optional[str] = None - - -class RefreshExternalGovernanceStatusOperationResultMI(ProxyResource): # pylint: disable=name-too-long - """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: Optional[str] = None - self.request_type: Optional[str] = None - self.queued_time: Optional[str] = None - self.managed_instance_name: Optional[str] = None - self.status: Optional[str] = None - self.error_message: Optional[str] = None - - -class Remediation(_serialization.Model): - """SQL Vulnerability Assessment remediation Details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar description: SQL Vulnerability Assessment remediation description. - :vartype description: str - :ivar scripts: SQL Vulnerability Assessment remediation script. - :vartype scripts: list[str] - :ivar automated: SQL Vulnerability Assessment is remediation automated. - :vartype automated: bool - :ivar portal_link: SQL Vulnerability Assessment optional link to remediate in Azure Portal. - :vartype portal_link: str - """ - - _validation = { - "description": {"readonly": True}, - "scripts": {"readonly": True}, - "automated": {"readonly": True}, - "portal_link": {"readonly": True}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "scripts": {"key": "scripts", "type": "[str]"}, - "automated": {"key": "automated", "type": "bool"}, - "portal_link": {"key": "portalLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.description: Optional[str] = None - self.scripts: Optional[list[str]] = None - self.automated: Optional[bool] = None - self.portal_link: Optional[str] = None - - -class ReplicationLink(ProxyResource): - """A replication link. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar partner_server: Resource partner server. - :vartype partner_server: str - :ivar partner_database: Resource partner database. - :vartype partner_database: str - :ivar partner_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", - "NonReadableSecondary", "Source", and "Copy". - :vartype role: str or ~azure.mgmt.sql.models.ReplicationRole - :ivar partner_role: Partner replication role. Known values are: "Primary", "Secondary", - "NonReadableSecondary", "Source", and "Copy". - :vartype partner_role: str or ~azure.mgmt.sql.models.ReplicationRole - :ivar replication_mode: Replication mode. - :vartype replication_mode: str - :ivar start_time: Time at which the link was created. - :vartype start_time: ~datetime.datetime - :ivar percent_complete: Seeding completion percentage for the link. - :vartype percent_complete: int - :ivar replication_state: Replication state (PENDING, SEEDING, CATCHUP, SUSPENDED). Known values - are: "PENDING", "SEEDING", "CATCH_UP", and "SUSPENDED". - :vartype replication_state: str or ~azure.mgmt.sql.models.ReplicationState - :ivar is_termination_allowed: Whether the user is currently allowed to terminate the link. - :vartype is_termination_allowed: bool - :ivar link_type: Link type (GEO, NAMED, STANDBY). Update operation does not support NAMED. - Known values are: "GEO", "NAMED", and "STANDBY". - :vartype link_type: str or ~azure.mgmt.sql.models.ReplicationLinkType - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "partner_server": {"readonly": True}, - "partner_database": {"readonly": True}, - "partner_database_id": {"readonly": True}, - "partner_location": {"readonly": True}, - "role": {"readonly": True}, - "partner_role": {"readonly": True}, - "replication_mode": {"readonly": True}, - "start_time": {"readonly": True}, - "percent_complete": {"readonly": True}, - "replication_state": {"readonly": True}, - "is_termination_allowed": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "partner_server": {"key": "properties.partnerServer", "type": "str"}, - "partner_database": {"key": "properties.partnerDatabase", "type": "str"}, - "partner_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"}, - "replication_mode": {"key": "properties.replicationMode", "type": "str"}, - "start_time": {"key": "properties.startTime", "type": "iso-8601"}, - "percent_complete": {"key": "properties.percentComplete", "type": "int"}, - "replication_state": {"key": "properties.replicationState", "type": "str"}, - "is_termination_allowed": {"key": "properties.isTerminationAllowed", "type": "bool"}, - "link_type": {"key": "properties.linkType", "type": "str"}, - } - - def __init__(self, *, link_type: Optional[Union[str, "_models.ReplicationLinkType"]] = None, **kwargs: Any) -> None: - """ - :keyword link_type: Link type (GEO, NAMED, STANDBY). Update operation does not support NAMED. - Known values are: "GEO", "NAMED", and "STANDBY". - :paramtype link_type: str or ~azure.mgmt.sql.models.ReplicationLinkType - """ - super().__init__(**kwargs) - self.partner_server: Optional[str] = None - self.partner_database: Optional[str] = None - self.partner_database_id: Optional[str] = None - self.partner_location: Optional[str] = None - self.role: Optional[Union[str, "_models.ReplicationRole"]] = None - self.partner_role: Optional[Union[str, "_models.ReplicationRole"]] = None - self.replication_mode: Optional[str] = None - self.start_time: Optional[datetime.datetime] = None - self.percent_complete: Optional[int] = None - self.replication_state: Optional[Union[str, "_models.ReplicationState"]] = None - self.is_termination_allowed: Optional[bool] = None - self.link_type = link_type - - -class ReplicationLinkListResult(_serialization.Model): - """A list of replication links. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ReplicationLink] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ReplicationLink]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ReplicationLink"]] = None - self.next_link: Optional[str] = None - - -class ReplicationLinkUpdate(ProxyResource): - """A replication link update request. - - 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 link_type: Link type (GEO, NAMED, STANDBY). Update operation does not support NAMED. - Known values are: "GEO", "NAMED", and "STANDBY". - :vartype link_type: str or ~azure.mgmt.sql.models.ReplicationLinkType - """ - - _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"}, - "link_type": {"key": "properties.linkType", "type": "str"}, - } - - def __init__(self, *, link_type: Optional[Union[str, "_models.ReplicationLinkType"]] = None, **kwargs: Any) -> None: - """ - :keyword link_type: Link type (GEO, NAMED, STANDBY). Update operation does not support NAMED. - Known values are: "GEO", "NAMED", and "STANDBY". - :paramtype link_type: str or ~azure.mgmt.sql.models.ReplicationLinkType - """ - super().__init__(**kwargs) - self.link_type = link_type - - -class ResourceIdentity(_serialization.Model): - """Azure Active Directory identity configuration for a resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar user_assigned_identities: The resource ids of the user assigned identities to use. - :vartype user_assigned_identities: dict[str, ~azure.mgmt.sql.models.UserIdentity] - :ivar principal_id: The Azure Active Directory principal id. - :vartype principal_id: str - :ivar type: The identity type. Set this to 'SystemAssigned' in order to automatically create - and assign an Azure Active Directory principal for the resource. Known values are: "None", - "SystemAssigned", "UserAssigned", and "SystemAssigned,UserAssigned". - :vartype type: str or ~azure.mgmt.sql.models.IdentityType - :ivar tenant_id: The Azure Active Directory tenant id. - :vartype tenant_id: str - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserIdentity}"}, - "principal_id": {"key": "principalId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - } - - def __init__( - self, - *, - user_assigned_identities: Optional[dict[str, "_models.UserIdentity"]] = None, - type: Optional[Union[str, "_models.IdentityType"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword user_assigned_identities: The resource ids of the user assigned identities to use. - :paramtype user_assigned_identities: dict[str, ~azure.mgmt.sql.models.UserIdentity] - :keyword type: The identity type. Set this to 'SystemAssigned' in order to automatically create - and assign an Azure Active Directory principal for the resource. Known values are: "None", - "SystemAssigned", "UserAssigned", and "SystemAssigned,UserAssigned". - :paramtype type: str or ~azure.mgmt.sql.models.IdentityType - """ - super().__init__(**kwargs) - self.user_assigned_identities = user_assigned_identities - self.principal_id: Optional[str] = None - self.type = type - self.tenant_id: Optional[str] = None - - -class ResourceMoveDefinition(_serialization.Model): - """Contains the information necessary to perform a resource move (rename). - - All required parameters must be populated in order to send to server. - - :ivar id: The target ID for the resource. Required. - :vartype id: str - """ - - _validation = { - "id": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: str, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: The target ID for the resource. Required. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class RestorableDroppedDatabase(ProxyResource): - """A restorable dropped database resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar sku: The name and tier of the SKU. - :vartype sku: ~azure.mgmt.sql.models.Sku - :ivar location: Resource location. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar database_name: The name of the database. - :vartype database_name: str - :ivar max_size_bytes: The max size of the database expressed in bytes. - :vartype max_size_bytes: int - :ivar creation_date: The creation date of the database (ISO8601 format). - :vartype creation_date: ~datetime.datetime - :ivar deletion_date: The deletion date of the database (ISO8601 format). - :vartype deletion_date: ~datetime.datetime - :ivar earliest_restore_date: The earliest restore date of the database (ISO8601 format). - :vartype earliest_restore_date: ~datetime.datetime - :ivar backup_storage_redundancy: The storage account type used to store backups for this - database. Known values are: "Geo", "Local", "Zone", and "GeoZone". - :vartype backup_storage_redundancy: str or ~azure.mgmt.sql.models.BackupStorageRedundancy - :ivar keys: The resource ids of the user assigned identities to use. - :vartype keys: dict[str, ~azure.mgmt.sql.models.DatabaseKey] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "database_name": {"readonly": True}, - "max_size_bytes": {"readonly": True}, - "creation_date": {"readonly": True}, - "deletion_date": {"readonly": True}, - "earliest_restore_date": {"readonly": True}, - "backup_storage_redundancy": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "sku": {"key": "sku", "type": "Sku"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "database_name": {"key": "properties.databaseName", "type": "str"}, - "max_size_bytes": {"key": "properties.maxSizeBytes", "type": "int"}, - "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, - "deletion_date": {"key": "properties.deletionDate", "type": "iso-8601"}, - "earliest_restore_date": {"key": "properties.earliestRestoreDate", "type": "iso-8601"}, - "backup_storage_redundancy": {"key": "properties.backupStorageRedundancy", "type": "str"}, - "keys": {"key": "properties.keys", "type": "{DatabaseKey}"}, - } - - def __init__( - self, - *, - sku: Optional["_models.Sku"] = None, - location: Optional[str] = None, - tags: Optional[dict[str, str]] = None, - keys: Optional[dict[str, "_models.DatabaseKey"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword sku: The name and tier of the SKU. - :paramtype sku: ~azure.mgmt.sql.models.Sku - :keyword location: Resource location. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword keys: The resource ids of the user assigned identities to use. - :paramtype keys: dict[str, ~azure.mgmt.sql.models.DatabaseKey] - """ - super().__init__(**kwargs) - self.sku = sku - self.location = location - self.tags = tags - self.database_name: Optional[str] = None - self.max_size_bytes: Optional[int] = None - self.creation_date: Optional[datetime.datetime] = None - self.deletion_date: Optional[datetime.datetime] = None - self.earliest_restore_date: Optional[datetime.datetime] = None - self.backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = None - self.keys = keys - - -class RestorableDroppedDatabaseListResult(_serialization.Model): - """A list of restorable dropped databases. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.RestorableDroppedDatabase] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[RestorableDroppedDatabase]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.RestorableDroppedDatabase"]] = None - self.next_link: Optional[str] = None - - -class RestorableDroppedManagedDatabase(TrackedResource): - """A restorable dropped managed database resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar database_name: The name of the database. - :vartype database_name: str - :ivar creation_date: The creation date of the database (ISO8601 format). - :vartype creation_date: ~datetime.datetime - :ivar deletion_date: The deletion date of the database (ISO8601 format). - :vartype deletion_date: ~datetime.datetime - :ivar earliest_restore_date: The earliest restore date of the database (ISO8601 format). - :vartype earliest_restore_date: ~datetime.datetime - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "database_name": {"readonly": True}, - "creation_date": {"readonly": True}, - "deletion_date": {"readonly": True}, - "earliest_restore_date": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "database_name": {"key": "properties.databaseName", "type": "str"}, - "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, - "deletion_date": {"key": "properties.deletionDate", "type": "iso-8601"}, - "earliest_restore_date": {"key": "properties.earliestRestoreDate", "type": "iso-8601"}, - } - - def __init__(self, *, location: str, tags: Optional[dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(location=location, tags=tags, **kwargs) - self.database_name: Optional[str] = None - self.creation_date: Optional[datetime.datetime] = None - self.deletion_date: Optional[datetime.datetime] = None - self.earliest_restore_date: Optional[datetime.datetime] = None - - -class RestorableDroppedManagedDatabaseListResult(_serialization.Model): # pylint: disable=name-too-long - """A list of restorable dropped managed databases. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.RestorableDroppedManagedDatabase] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[RestorableDroppedManagedDatabase]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.RestorableDroppedManagedDatabase"]] = None - self.next_link: Optional[str] = None - - -class RestorePoint(ProxyResource): - """Database restore points. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar location: Resource location. - :vartype location: str - :ivar restore_point_type: The type of restore point. Known values are: "CONTINUOUS" and - "DISCRETE". - :vartype restore_point_type: str or ~azure.mgmt.sql.models.RestorePointType - :ivar earliest_restore_date: The earliest time to which this database can be restored. - :vartype earliest_restore_date: ~datetime.datetime - :ivar restore_point_creation_date: The time the backup was taken. - :vartype restore_point_creation_date: ~datetime.datetime - :ivar restore_point_label: The label of restore point for backup request by user. - :vartype restore_point_label: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"readonly": True}, - "restore_point_type": {"readonly": True}, - "earliest_restore_date": {"readonly": True}, - "restore_point_creation_date": {"readonly": True}, - "restore_point_label": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "restore_point_type": {"key": "properties.restorePointType", "type": "str"}, - "earliest_restore_date": {"key": "properties.earliestRestoreDate", "type": "iso-8601"}, - "restore_point_creation_date": {"key": "properties.restorePointCreationDate", "type": "iso-8601"}, - "restore_point_label": {"key": "properties.restorePointLabel", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.location: Optional[str] = None - self.restore_point_type: Optional[Union[str, "_models.RestorePointType"]] = None - self.earliest_restore_date: Optional[datetime.datetime] = None - self.restore_point_creation_date: Optional[datetime.datetime] = None - self.restore_point_label: Optional[str] = None - - -class RestorePointListResult(_serialization.Model): - """A list of long term retention backups. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.RestorePoint] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[RestorePoint]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.RestorePoint"]] = None - self.next_link: Optional[str] = None - - -class ScheduleItem(_serialization.Model): - """Schedule info describing when the server should be started or stopped. - - All required parameters must be populated in order to send to server. - - :ivar start_day: Start day. Required. Known values are: "Sunday", "Monday", "Tuesday", - "Wednesday", "Thursday", "Friday", and "Saturday". - :vartype start_day: str or ~azure.mgmt.sql.models.DayOfWeek - :ivar start_time: Start time. Required. - :vartype start_time: str - :ivar stop_day: Stop day. Required. Known values are: "Sunday", "Monday", "Tuesday", - "Wednesday", "Thursday", "Friday", and "Saturday". - :vartype stop_day: str or ~azure.mgmt.sql.models.DayOfWeek - :ivar stop_time: Stop time. Required. - :vartype stop_time: str - """ - - _validation = { - "start_day": {"required": True}, - "start_time": {"required": True}, - "stop_day": {"required": True}, - "stop_time": {"required": True}, - } - - _attribute_map = { - "start_day": {"key": "startDay", "type": "str"}, - "start_time": {"key": "startTime", "type": "str"}, - "stop_day": {"key": "stopDay", "type": "str"}, - "stop_time": {"key": "stopTime", "type": "str"}, - } - - def __init__( - self, - *, - start_day: Union[str, "_models.DayOfWeek"], - start_time: str, - stop_day: Union[str, "_models.DayOfWeek"], - stop_time: str, - **kwargs: Any - ) -> None: - """ - :keyword start_day: Start day. Required. Known values are: "Sunday", "Monday", "Tuesday", - "Wednesday", "Thursday", "Friday", and "Saturday". - :paramtype start_day: str or ~azure.mgmt.sql.models.DayOfWeek - :keyword start_time: Start time. Required. - :paramtype start_time: str - :keyword stop_day: Stop day. Required. Known values are: "Sunday", "Monday", "Tuesday", - "Wednesday", "Thursday", "Friday", and "Saturday". - :paramtype stop_day: str or ~azure.mgmt.sql.models.DayOfWeek - :keyword stop_time: Stop time. Required. - :paramtype stop_time: str - """ - super().__init__(**kwargs) - self.start_day = start_day - self.start_time = start_time - self.stop_day = stop_day - self.stop_time = stop_time - - -class SecurityEvent(ProxyResource): - """A security event. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar event_time: The time when the security event occurred. - :vartype event_time: ~datetime.datetime - :ivar security_event_type: The type of the security event. Known values are: "Undefined", - "SqlInjectionVulnerability", and "SqlInjectionExploit". - :vartype security_event_type: str or ~azure.mgmt.sql.models.SecurityEventType - :ivar subscription: The subscription name. - :vartype subscription: str - :ivar server: The server name. - :vartype server: str - :ivar database: The database name. - :vartype database: str - :ivar client_ip: The IP address of the client who executed the statement. - :vartype client_ip: str - :ivar application_name: The application used to execute the statement. - :vartype application_name: str - :ivar principal_name: The principal user who executed the statement. - :vartype principal_name: str - :ivar security_event_sql_injection_additional_properties: The sql injection additional - properties, populated only if the type of the security event is sql injection. - :vartype security_event_sql_injection_additional_properties: - ~azure.mgmt.sql.models.SecurityEventSqlInjectionAdditionalProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "event_time": {"readonly": True}, - "security_event_type": {"readonly": True}, - "subscription": {"readonly": True}, - "server": {"readonly": True}, - "database": {"readonly": True}, - "client_ip": {"readonly": True}, - "application_name": {"readonly": True}, - "principal_name": {"readonly": True}, - "security_event_sql_injection_additional_properties": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "event_time": {"key": "properties.eventTime", "type": "iso-8601"}, - "security_event_type": {"key": "properties.securityEventType", "type": "str"}, - "subscription": {"key": "properties.subscription", "type": "str"}, - "server": {"key": "properties.server", "type": "str"}, - "database": {"key": "properties.database", "type": "str"}, - "client_ip": {"key": "properties.clientIp", "type": "str"}, - "application_name": {"key": "properties.applicationName", "type": "str"}, - "principal_name": {"key": "properties.principalName", "type": "str"}, - "security_event_sql_injection_additional_properties": { - "key": "properties.securityEventSqlInjectionAdditionalProperties", - "type": "SecurityEventSqlInjectionAdditionalProperties", - }, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.event_time: Optional[datetime.datetime] = None - self.security_event_type: Optional[Union[str, "_models.SecurityEventType"]] = None - self.subscription: Optional[str] = None - self.server: Optional[str] = None - self.database: Optional[str] = None - self.client_ip: Optional[str] = None - self.application_name: Optional[str] = None - self.principal_name: Optional[str] = None - self.security_event_sql_injection_additional_properties: Optional[ - "_models.SecurityEventSqlInjectionAdditionalProperties" - ] = None - - -class SecurityEventCollection(_serialization.Model): - """A list of security events. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.SecurityEvent] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SecurityEvent]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.SecurityEvent"]] = None - self.next_link: Optional[str] = None - - -class SecurityEventsFilterParameters(_serialization.Model): - """The properties that are supported in the $filter operation. - - :ivar event_time: Filter on the event time. - :vartype event_time: ~datetime.datetime - :ivar show_server_records: Whether to show server records or not. - :vartype show_server_records: bool - """ - - _attribute_map = { - "event_time": {"key": "eventTime", "type": "iso-8601"}, - "show_server_records": {"key": "showServerRecords", "type": "bool"}, - } - - def __init__( - self, - *, - event_time: Optional[datetime.datetime] = None, - show_server_records: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword event_time: Filter on the event time. - :paramtype event_time: ~datetime.datetime - :keyword show_server_records: Whether to show server records or not. - :paramtype show_server_records: bool - """ - super().__init__(**kwargs) - self.event_time = event_time - self.show_server_records = show_server_records - - -class SecurityEventSqlInjectionAdditionalProperties(_serialization.Model): # pylint: disable=name-too-long - """The properties of a security event sql injection additional properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar threat_id: The threat ID. - :vartype threat_id: str - :ivar statement: The statement. - :vartype statement: str - :ivar statement_highlight_offset: The statement highlight offset. - :vartype statement_highlight_offset: int - :ivar statement_highlight_length: The statement highlight length. - :vartype statement_highlight_length: int - :ivar error_code: The sql error code. - :vartype error_code: int - :ivar error_severity: The sql error severity. - :vartype error_severity: int - :ivar error_message: The sql error message. - :vartype error_message: str - """ - - _validation = { - "threat_id": {"readonly": True}, - "statement": {"readonly": True}, - "statement_highlight_offset": {"readonly": True}, - "statement_highlight_length": {"readonly": True}, - "error_code": {"readonly": True}, - "error_severity": {"readonly": True}, - "error_message": {"readonly": True}, - } - - _attribute_map = { - "threat_id": {"key": "threatId", "type": "str"}, - "statement": {"key": "statement", "type": "str"}, - "statement_highlight_offset": {"key": "statementHighlightOffset", "type": "int"}, - "statement_highlight_length": {"key": "statementHighlightLength", "type": "int"}, - "error_code": {"key": "errorCode", "type": "int"}, - "error_severity": {"key": "errorSeverity", "type": "int"}, - "error_message": {"key": "errorMessage", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.threat_id: Optional[str] = None - self.statement: Optional[str] = None - self.statement_highlight_offset: Optional[int] = None - self.statement_highlight_length: Optional[int] = None - self.error_code: Optional[int] = None - self.error_severity: Optional[int] = None - self.error_message: Optional[str] = None - - -class SensitivityLabel(ProxyResource): - """A sensitivity label. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar managed_by: Resource that manages the sensitivity label. - :vartype managed_by: str - :ivar schema_name: The schema name. - :vartype schema_name: str - :ivar table_name: The table name. - :vartype table_name: str - :ivar column_name: The column name. - :vartype column_name: str - :ivar label_name: The label name. - :vartype label_name: str - :ivar label_id: The label ID. - :vartype label_id: str - :ivar information_type: The information type. - :vartype information_type: str - :ivar information_type_id: The information type ID. - :vartype information_type_id: str - :ivar is_disabled: Is sensitivity recommendation disabled. Applicable for recommended - sensitivity label only. Specifies whether the sensitivity recommendation on this column is - disabled (dismissed) or not. - :vartype is_disabled: bool - :ivar rank: Known values are: "None", "Low", "Medium", "High", and "Critical". - :vartype rank: str or ~azure.mgmt.sql.models.SensitivityLabelRank - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "managed_by": {"readonly": True}, - "schema_name": {"readonly": True}, - "table_name": {"readonly": True}, - "column_name": {"readonly": True}, - "is_disabled": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "managed_by": {"key": "managedBy", "type": "str"}, - "schema_name": {"key": "properties.schemaName", "type": "str"}, - "table_name": {"key": "properties.tableName", "type": "str"}, - "column_name": {"key": "properties.columnName", "type": "str"}, - "label_name": {"key": "properties.labelName", "type": "str"}, - "label_id": {"key": "properties.labelId", "type": "str"}, - "information_type": {"key": "properties.informationType", "type": "str"}, - "information_type_id": {"key": "properties.informationTypeId", "type": "str"}, - "is_disabled": {"key": "properties.isDisabled", "type": "bool"}, - "rank": {"key": "properties.rank", "type": "str"}, - } - - def __init__( - self, - *, - label_name: Optional[str] = None, - label_id: Optional[str] = None, - information_type: Optional[str] = None, - information_type_id: Optional[str] = None, - rank: Optional[Union[str, "_models.SensitivityLabelRank"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword label_name: The label name. - :paramtype label_name: str - :keyword label_id: The label ID. - :paramtype label_id: str - :keyword information_type: The information type. - :paramtype information_type: str - :keyword information_type_id: The information type ID. - :paramtype information_type_id: str - :keyword rank: Known values are: "None", "Low", "Medium", "High", and "Critical". - :paramtype rank: str or ~azure.mgmt.sql.models.SensitivityLabelRank - """ - super().__init__(**kwargs) - self.managed_by: Optional[str] = None - self.schema_name: Optional[str] = None - self.table_name: Optional[str] = None - self.column_name: Optional[str] = None - self.label_name = label_name - self.label_id = label_id - self.information_type = information_type - self.information_type_id = information_type_id - self.is_disabled: Optional[bool] = None - self.rank = rank - - -class SensitivityLabelListResult(_serialization.Model): - """A list of sensitivity labels. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.SensitivityLabel] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SensitivityLabel]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.SensitivityLabel"]] = None - self.next_link: Optional[str] = None - - -class SensitivityLabelUpdate(ProxyResource): - """A sensitivity label update operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar op: Known values are: "set" and "remove". - :vartype op: str or ~azure.mgmt.sql.models.SensitivityLabelUpdateKind - :ivar schema: Schema name of the column to update. - :vartype schema: str - :ivar table: Table name of the column to update. - :vartype table: str - :ivar column: Column name to update. - :vartype column: str - :ivar sensitivity_label: The sensitivity label information to apply on a column. - :vartype sensitivity_label: ~azure.mgmt.sql.models.SensitivityLabel - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "op": {"key": "properties.op", "type": "str"}, - "schema": {"key": "properties.schema", "type": "str"}, - "table": {"key": "properties.table", "type": "str"}, - "column": {"key": "properties.column", "type": "str"}, - "sensitivity_label": {"key": "properties.sensitivityLabel", "type": "SensitivityLabel"}, - } - - def __init__( - self, - *, - op: Optional[Union[str, "_models.SensitivityLabelUpdateKind"]] = None, - schema: Optional[str] = None, - table: Optional[str] = None, - column: Optional[str] = None, - sensitivity_label: Optional["_models.SensitivityLabel"] = None, - **kwargs: Any - ) -> None: - """ - :keyword op: Known values are: "set" and "remove". - :paramtype op: str or ~azure.mgmt.sql.models.SensitivityLabelUpdateKind - :keyword schema: Schema name of the column to update. - :paramtype schema: str - :keyword table: Table name of the column to update. - :paramtype table: str - :keyword column: Column name to update. - :paramtype column: str - :keyword sensitivity_label: The sensitivity label information to apply on a column. - :paramtype sensitivity_label: ~azure.mgmt.sql.models.SensitivityLabel - """ - super().__init__(**kwargs) - self.op = op - self.schema = schema - self.table = table - self.column = column - self.sensitivity_label = sensitivity_label - - -class SensitivityLabelUpdateList(_serialization.Model): - """A list of sensitivity label update operations. - - :ivar operations: - :vartype operations: list[~azure.mgmt.sql.models.SensitivityLabelUpdate] - """ - - _attribute_map = { - "operations": {"key": "operations", "type": "[SensitivityLabelUpdate]"}, - } - - def __init__(self, *, operations: Optional[list["_models.SensitivityLabelUpdate"]] = None, **kwargs: Any) -> None: - """ - :keyword operations: - :paramtype operations: list[~azure.mgmt.sql.models.SensitivityLabelUpdate] - """ - super().__init__(**kwargs) - self.operations = operations - - -class Server(TrackedResource): - """An Azure SQL Database server. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar identity: The Azure Active Directory identity of the server. - :vartype identity: ~azure.mgmt.sql.models.ResourceIdentity - :ivar kind: Kind of sql server. This is metadata used for the Azure portal experience. - :vartype kind: str - :ivar administrator_login: Administrator username for the server. Once created it cannot be - changed. - :vartype administrator_login: str - :ivar administrator_login_password: The administrator login password (required for server - creation). - :vartype administrator_login_password: str - :ivar version: The version of the server. - :vartype version: str - :ivar state: The state of the server. - :vartype state: str - :ivar fully_qualified_domain_name: The fully qualified domain name of the server. - :vartype fully_qualified_domain_name: str - :ivar private_endpoint_connections: List of private endpoint connections on a server. - :vartype private_endpoint_connections: - list[~azure.mgmt.sql.models.ServerPrivateEndpointConnection] - :ivar minimal_tls_version: Minimal TLS version. Allowed values: 'None', 1.0', '1.1', '1.2', - '1.3'. Known values are: "None", "1.0", "1.1", "1.2", and "1.3". - :vartype minimal_tls_version: str or ~azure.mgmt.sql.models.MinimalTlsVersion - :ivar public_network_access: Whether or not public endpoint access is allowed for this server. - Value is optional but if passed in, must be 'Enabled' or 'Disabled' or 'SecuredByPerimeter'. - Known values are: "Enabled", "Disabled", and "SecuredByPerimeter". - :vartype public_network_access: str or ~azure.mgmt.sql.models.ServerPublicNetworkAccessFlag - :ivar workspace_feature: Whether or not existing server has a workspace created and if it - allows connection from workspace. Known values are: "Connected" and "Disconnected". - :vartype workspace_feature: str or ~azure.mgmt.sql.models.ServerWorkspaceFeature - :ivar primary_user_assigned_identity_id: The resource id of a user assigned identity to be used - by default. - :vartype primary_user_assigned_identity_id: str - :ivar federated_client_id: The Client id used for cross tenant CMK scenario. - :vartype federated_client_id: str - :ivar key_id: A CMK URI of the key to use for encryption. - :vartype key_id: str - :ivar administrators: The Azure Active Directory administrator can be utilized during server - creation and for server updates, except for the azureADOnlyAuthentication property. To update - the azureADOnlyAuthentication property, individual API must be used. - :vartype administrators: ~azure.mgmt.sql.models.ServerExternalAdministrator - :ivar restrict_outbound_network_access: Whether or not to restrict outbound network access for - this server. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values - are: "Enabled" and "Disabled". - :vartype restrict_outbound_network_access: str or - ~azure.mgmt.sql.models.ServerNetworkAccessFlag - :ivar is_i_pv6_enabled: Whether or not to enable IPv6 support for this server. Value is - optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled" and - "Disabled". - :vartype is_i_pv6_enabled: str or ~azure.mgmt.sql.models.ServerNetworkAccessFlag - :ivar external_governance_status: Status of external governance. Known values are: "Enabled" - and "Disabled". - :vartype external_governance_status: str or ~azure.mgmt.sql.models.ExternalGovernanceStatus - :ivar retention_days: Number of days this server will stay soft-deleted. - :vartype retention_days: int - :ivar create_mode: Create mode for server, only valid values for this are Normal and Restore. - Known values are: "Normal" and "Restore". - :vartype create_mode: str or ~azure.mgmt.sql.models.ServerCreateMode - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "kind": {"readonly": True}, - "state": {"readonly": True}, - "fully_qualified_domain_name": {"readonly": True}, - "private_endpoint_connections": {"readonly": True}, - "workspace_feature": {"readonly": True}, - "external_governance_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"}, - "tags": {"key": "tags", "type": "{str}"}, - "identity": {"key": "identity", "type": "ResourceIdentity"}, - "kind": {"key": "kind", "type": "str"}, - "administrator_login": {"key": "properties.administratorLogin", "type": "str"}, - "administrator_login_password": {"key": "properties.administratorLoginPassword", "type": "str"}, - "version": {"key": "properties.version", "type": "str"}, - "state": {"key": "properties.state", "type": "str"}, - "fully_qualified_domain_name": {"key": "properties.fullyQualifiedDomainName", "type": "str"}, - "private_endpoint_connections": { - "key": "properties.privateEndpointConnections", - "type": "[ServerPrivateEndpointConnection]", - }, - "minimal_tls_version": {"key": "properties.minimalTlsVersion", "type": "str"}, - "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, - "workspace_feature": {"key": "properties.workspaceFeature", "type": "str"}, - "primary_user_assigned_identity_id": {"key": "properties.primaryUserAssignedIdentityId", "type": "str"}, - "federated_client_id": {"key": "properties.federatedClientId", "type": "str"}, - "key_id": {"key": "properties.keyId", "type": "str"}, - "administrators": {"key": "properties.administrators", "type": "ServerExternalAdministrator"}, - "restrict_outbound_network_access": {"key": "properties.restrictOutboundNetworkAccess", "type": "str"}, - "is_i_pv6_enabled": {"key": "properties.isIPv6Enabled", "type": "str"}, - "external_governance_status": {"key": "properties.externalGovernanceStatus", "type": "str"}, - "retention_days": {"key": "properties.retentionDays", "type": "int"}, - "create_mode": {"key": "properties.createMode", "type": "str"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - location: str, - tags: Optional[dict[str, str]] = None, - identity: Optional["_models.ResourceIdentity"] = None, - administrator_login: Optional[str] = None, - administrator_login_password: Optional[str] = None, - version: Optional[str] = None, - minimal_tls_version: Optional[Union[str, "_models.MinimalTlsVersion"]] = None, - public_network_access: Optional[Union[str, "_models.ServerPublicNetworkAccessFlag"]] = None, - primary_user_assigned_identity_id: Optional[str] = None, - federated_client_id: Optional[str] = None, - key_id: Optional[str] = None, - administrators: Optional["_models.ServerExternalAdministrator"] = None, - restrict_outbound_network_access: Optional[Union[str, "_models.ServerNetworkAccessFlag"]] = None, - is_i_pv6_enabled: Optional[Union[str, "_models.ServerNetworkAccessFlag"]] = None, - retention_days: Optional[int] = None, - create_mode: Optional[Union[str, "_models.ServerCreateMode"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword identity: The Azure Active Directory identity of the server. - :paramtype identity: ~azure.mgmt.sql.models.ResourceIdentity - :keyword administrator_login: Administrator username for the server. Once created it cannot be - changed. - :paramtype administrator_login: str - :keyword administrator_login_password: The administrator login password (required for server - creation). - :paramtype administrator_login_password: str - :keyword version: The version of the server. - :paramtype version: str - :keyword minimal_tls_version: Minimal TLS version. Allowed values: 'None', 1.0', '1.1', '1.2', - '1.3'. Known values are: "None", "1.0", "1.1", "1.2", and "1.3". - :paramtype minimal_tls_version: str or ~azure.mgmt.sql.models.MinimalTlsVersion - :keyword public_network_access: Whether or not public endpoint access is allowed for this - server. Value is optional but if passed in, must be 'Enabled' or 'Disabled' or - 'SecuredByPerimeter'. Known values are: "Enabled", "Disabled", and "SecuredByPerimeter". - :paramtype public_network_access: str or ~azure.mgmt.sql.models.ServerPublicNetworkAccessFlag - :keyword primary_user_assigned_identity_id: The resource id of a user assigned identity to be - used by default. - :paramtype primary_user_assigned_identity_id: str - :keyword federated_client_id: The Client id used for cross tenant CMK scenario. - :paramtype federated_client_id: str - :keyword key_id: A CMK URI of the key to use for encryption. - :paramtype key_id: str - :keyword administrators: The Azure Active Directory administrator can be utilized during server - creation and for server updates, except for the azureADOnlyAuthentication property. To update - the azureADOnlyAuthentication property, individual API must be used. - :paramtype administrators: ~azure.mgmt.sql.models.ServerExternalAdministrator - :keyword restrict_outbound_network_access: Whether or not to restrict outbound network access - for this server. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known - values are: "Enabled" and "Disabled". - :paramtype restrict_outbound_network_access: str or - ~azure.mgmt.sql.models.ServerNetworkAccessFlag - :keyword is_i_pv6_enabled: Whether or not to enable IPv6 support for this server. Value is - optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled" and - "Disabled". - :paramtype is_i_pv6_enabled: str or ~azure.mgmt.sql.models.ServerNetworkAccessFlag - :keyword retention_days: Number of days this server will stay soft-deleted. - :paramtype retention_days: int - :keyword create_mode: Create mode for server, only valid values for this are Normal and - Restore. Known values are: "Normal" and "Restore". - :paramtype create_mode: str or ~azure.mgmt.sql.models.ServerCreateMode - """ - super().__init__(location=location, tags=tags, **kwargs) - self.identity = identity - self.kind: Optional[str] = None - self.administrator_login = administrator_login - self.administrator_login_password = administrator_login_password - self.version = version - self.state: Optional[str] = None - self.fully_qualified_domain_name: Optional[str] = None - self.private_endpoint_connections: Optional[list["_models.ServerPrivateEndpointConnection"]] = None - self.minimal_tls_version = minimal_tls_version - self.public_network_access = public_network_access - self.workspace_feature: Optional[Union[str, "_models.ServerWorkspaceFeature"]] = None - self.primary_user_assigned_identity_id = primary_user_assigned_identity_id - self.federated_client_id = federated_client_id - self.key_id = key_id - self.administrators = administrators - self.restrict_outbound_network_access = restrict_outbound_network_access - self.is_i_pv6_enabled = is_i_pv6_enabled - self.external_governance_status: Optional[Union[str, "_models.ExternalGovernanceStatus"]] = None - self.retention_days = retention_days - self.create_mode = create_mode - - -class ServerAdvancedThreatProtection(ProxyResource): - """A server Advanced Threat Protection. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: SystemData of AdvancedThreatProtectionResource. - :vartype system_data: ~azure.mgmt.sql.models.SystemData - :ivar state: Specifies the state of the Advanced Threat Protection, whether it is enabled or - disabled or a state has not been applied yet on the specific database or server. Known values - are: "New", "Enabled", and "Disabled". - :vartype state: str or ~azure.mgmt.sql.models.AdvancedThreatProtectionState - :ivar creation_time: Specifies the UTC creation time of the policy. - :vartype creation_time: ~datetime.datetime - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "creation_time": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "state": {"key": "properties.state", "type": "str"}, - "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, - } - - def __init__( - self, *, state: Optional[Union[str, "_models.AdvancedThreatProtectionState"]] = None, **kwargs: Any - ) -> None: - """ - :keyword state: Specifies the state of the Advanced Threat Protection, whether it is enabled or - disabled or a state has not been applied yet on the specific database or server. Known values - are: "New", "Enabled", and "Disabled". - :paramtype state: str or ~azure.mgmt.sql.models.AdvancedThreatProtectionState - """ - super().__init__(**kwargs) - self.system_data: Optional["_models.SystemData"] = None - self.state = state - self.creation_time: Optional[datetime.datetime] = None - - -class ServerAutomaticTuning(ProxyResource): - """Server-level Automatic Tuning. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar desired_state: Automatic tuning desired state. Known values are: "Custom", "Auto", and - "Unspecified". - :vartype desired_state: str or ~azure.mgmt.sql.models.AutomaticTuningServerMode - :ivar actual_state: Automatic tuning actual state. Known values are: "Custom", "Auto", and - "Unspecified". - :vartype actual_state: str or ~azure.mgmt.sql.models.AutomaticTuningServerMode - :ivar options: Automatic tuning options definition. - :vartype options: dict[str, ~azure.mgmt.sql.models.AutomaticTuningServerOptions] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "actual_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "desired_state": {"key": "properties.desiredState", "type": "str"}, - "actual_state": {"key": "properties.actualState", "type": "str"}, - "options": {"key": "properties.options", "type": "{AutomaticTuningServerOptions}"}, - } - - def __init__( - self, - *, - desired_state: Optional[Union[str, "_models.AutomaticTuningServerMode"]] = None, - options: Optional[dict[str, "_models.AutomaticTuningServerOptions"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword desired_state: Automatic tuning desired state. Known values are: "Custom", "Auto", and - "Unspecified". - :paramtype desired_state: str or ~azure.mgmt.sql.models.AutomaticTuningServerMode - :keyword options: Automatic tuning options definition. - :paramtype options: dict[str, ~azure.mgmt.sql.models.AutomaticTuningServerOptions] - """ - super().__init__(**kwargs) - self.desired_state = desired_state - self.actual_state: Optional[Union[str, "_models.AutomaticTuningServerMode"]] = None - self.options = options - - -class ServerAzureADAdministrator(ProxyResource): - """Azure Active Directory administrator. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar administrator_type: Type of the sever administrator. "ActiveDirectory" - :vartype administrator_type: str or ~azure.mgmt.sql.models.AdministratorType - :ivar login: Login name of the server administrator. - :vartype login: str - :ivar sid: SID (object ID) of the server administrator. - :vartype sid: str - :ivar tenant_id: Tenant ID of the administrator. - :vartype tenant_id: str - :ivar azure_ad_only_authentication: Azure Active Directory only Authentication enabled. - :vartype azure_ad_only_authentication: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "azure_ad_only_authentication": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "administrator_type": {"key": "properties.administratorType", "type": "str"}, - "login": {"key": "properties.login", "type": "str"}, - "sid": {"key": "properties.sid", "type": "str"}, - "tenant_id": {"key": "properties.tenantId", "type": "str"}, - "azure_ad_only_authentication": {"key": "properties.azureADOnlyAuthentication", "type": "bool"}, - } - - def __init__( - self, - *, - administrator_type: Optional[Union[str, "_models.AdministratorType"]] = None, - login: Optional[str] = None, - sid: Optional[str] = None, - tenant_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword administrator_type: Type of the sever administrator. "ActiveDirectory" - :paramtype administrator_type: str or ~azure.mgmt.sql.models.AdministratorType - :keyword login: Login name of the server administrator. - :paramtype login: str - :keyword sid: SID (object ID) of the server administrator. - :paramtype sid: str - :keyword tenant_id: Tenant ID of the administrator. - :paramtype tenant_id: str - """ - super().__init__(**kwargs) - self.administrator_type = administrator_type - self.login = login - self.sid = sid - self.tenant_id = tenant_id - self.azure_ad_only_authentication: Optional[bool] = None - - -class ServerAzureADOnlyAuthentication(ProxyResource): - """Azure Active Directory only authentication. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar azure_ad_only_authentication: Azure Active Directory only Authentication enabled. - :vartype azure_ad_only_authentication: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "azure_ad_only_authentication": {"key": "properties.azureADOnlyAuthentication", "type": "bool"}, - } - - def __init__(self, *, azure_ad_only_authentication: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword azure_ad_only_authentication: Azure Active Directory only Authentication enabled. - :paramtype azure_ad_only_authentication: bool - """ - super().__init__(**kwargs) - self.azure_ad_only_authentication = azure_ad_only_authentication - - -class ServerBlobAuditingPolicy(ProxyResource): - """A server blob auditing policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar is_devops_audit_enabled: Specifies the state of devops audit. If state is Enabled, devops - logs will be sent to Azure Monitor. - In order to send the events to Azure Monitor, specify 'State' as 'Enabled', - 'IsAzureMonitorTargetEnabled' as true and 'IsDevopsAuditEnabled' as true - - When using REST API to configure auditing, Diagnostic Settings with 'DevOpsOperationsAudit' - diagnostic logs category on the master database should also be created. - - Diagnostic Settings URI format: - PUT - https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/master/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview - - For more information, see `Diagnostic Settings REST API - `_ - or `Diagnostic Settings PowerShell `_. - :vartype is_devops_audit_enabled: bool - :ivar retention_days: Specifies the number of days to keep in the audit logs in the storage - account. - :vartype retention_days: int - :ivar audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. - - The recommended set of action groups to use is the following combination - this will audit all - the queries and stored procedures executed against the database, as well as successful and - failed logins: - - BATCH_COMPLETED_GROUP, - SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, - FAILED_DATABASE_AUTHENTICATION_GROUP. - - This above combination is also the set that is configured by default when enabling auditing - from the Azure portal. - - The supported action groups to audit are (note: choose only specific groups that cover your - auditing needs. Using unnecessary groups could lead to very large quantities of audit records): - - APPLICATION_ROLE_CHANGE_PASSWORD_GROUP - BACKUP_RESTORE_GROUP - DATABASE_LOGOUT_GROUP - DATABASE_OBJECT_CHANGE_GROUP - DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP - DATABASE_OBJECT_PERMISSION_CHANGE_GROUP - DATABASE_OPERATION_GROUP - DATABASE_PERMISSION_CHANGE_GROUP - DATABASE_PRINCIPAL_CHANGE_GROUP - DATABASE_PRINCIPAL_IMPERSONATION_GROUP - DATABASE_ROLE_MEMBER_CHANGE_GROUP - FAILED_DATABASE_AUTHENTICATION_GROUP - SCHEMA_OBJECT_ACCESS_GROUP - SCHEMA_OBJECT_CHANGE_GROUP - SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP - SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP - SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP - USER_CHANGE_PASSWORD_GROUP - BATCH_STARTED_GROUP - BATCH_COMPLETED_GROUP - DBCC_GROUP - DATABASE_OWNERSHIP_CHANGE_GROUP - DATABASE_CHANGE_GROUP - LEDGER_OPERATION_GROUP - - These are groups that cover all sql statements and stored procedures executed against the - database, and should not be used in combination with other groups as this will result in - duplicate audit logs. - - For more information, see `Database-Level Audit Action Groups - `_. - - For Database auditing policy, specific Actions can also be specified (note that Actions cannot - be specified for Server auditing policy). The supported actions to audit are: - SELECT - UPDATE - INSERT - DELETE - EXECUTE - RECEIVE - REFERENCES - - The general form for defining an action to be audited is: - {action} ON {object} BY {principal} - - Note that :code:`` in the above format can refer to an object like a table, view, or - stored procedure, or an entire database or schema. For the latter cases, the forms - DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. - - For example: - SELECT on dbo.myTable by public - SELECT on DATABASE::myDatabase by public - SELECT on SCHEMA::mySchema by public - - For more information, see `Database-Level Audit Actions - `_. - :vartype audit_actions_and_groups: list[str] - :ivar is_storage_secondary_key_in_use: Specifies whether storageAccountAccessKey value is the - storage's secondary key. - :vartype is_storage_secondary_key_in_use: bool - :ivar is_azure_monitor_target_enabled: Specifies whether audit events are sent to Azure - Monitor. - In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and - 'IsAzureMonitorTargetEnabled' as true. - - When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' - diagnostic logs category on the database should be also created. - Note that for server level audit you should use the 'master' database as {databaseName}. - - Diagnostic Settings URI format: - PUT - https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview - - For more information, see `Diagnostic Settings REST API - `_ - or `Diagnostic Settings PowerShell `_. - :vartype is_azure_monitor_target_enabled: bool - :ivar queue_delay_ms: Specifies the amount of time in milliseconds that can elapse before audit - actions are forced to be processed. - The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. - :vartype queue_delay_ms: int - :ivar is_managed_identity_in_use: Specifies whether Managed Identity is used to access blob - storage. - :vartype is_managed_identity_in_use: bool - :ivar state: Specifies the state of the audit. If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled are required. Known values are: "Enabled" and "Disabled". - :vartype state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState - :ivar storage_endpoint: Specifies the blob storage endpoint (e.g. - https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled is required. - :vartype storage_endpoint: str - :ivar storage_account_access_key: Specifies the identifier key of the auditing storage account. - If state is Enabled and storageEndpoint is specified, not specifying the - storageAccountAccessKey will use SQL server system-assigned managed identity to access the - storage. - Prerequisites for using managed identity authentication: - - - #. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). - #. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data - Contributor' RBAC role to the server identity. - For more information, see `Auditing to storage using Managed Identity authentication - `_. - :vartype storage_account_access_key: str - :ivar storage_account_subscription_id: Specifies the blob storage subscription Id. - :vartype storage_account_subscription_id: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "is_devops_audit_enabled": {"key": "properties.isDevopsAuditEnabled", "type": "bool"}, - "retention_days": {"key": "properties.retentionDays", "type": "int"}, - "audit_actions_and_groups": {"key": "properties.auditActionsAndGroups", "type": "[str]"}, - "is_storage_secondary_key_in_use": {"key": "properties.isStorageSecondaryKeyInUse", "type": "bool"}, - "is_azure_monitor_target_enabled": {"key": "properties.isAzureMonitorTargetEnabled", "type": "bool"}, - "queue_delay_ms": {"key": "properties.queueDelayMs", "type": "int"}, - "is_managed_identity_in_use": {"key": "properties.isManagedIdentityInUse", "type": "bool"}, - "state": {"key": "properties.state", "type": "str"}, - "storage_endpoint": {"key": "properties.storageEndpoint", "type": "str"}, - "storage_account_access_key": {"key": "properties.storageAccountAccessKey", "type": "str"}, - "storage_account_subscription_id": {"key": "properties.storageAccountSubscriptionId", "type": "str"}, - } - - def __init__( - self, - *, - is_devops_audit_enabled: Optional[bool] = None, - retention_days: Optional[int] = None, - audit_actions_and_groups: Optional[list[str]] = None, - is_storage_secondary_key_in_use: Optional[bool] = None, - is_azure_monitor_target_enabled: Optional[bool] = None, - queue_delay_ms: Optional[int] = None, - is_managed_identity_in_use: Optional[bool] = None, - state: Optional[Union[str, "_models.BlobAuditingPolicyState"]] = None, - storage_endpoint: Optional[str] = None, - storage_account_access_key: Optional[str] = None, - storage_account_subscription_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword is_devops_audit_enabled: Specifies the state of devops audit. If state is Enabled, - devops logs will be sent to Azure Monitor. - In order to send the events to Azure Monitor, specify 'State' as 'Enabled', - 'IsAzureMonitorTargetEnabled' as true and 'IsDevopsAuditEnabled' as true - - When using REST API to configure auditing, Diagnostic Settings with 'DevOpsOperationsAudit' - diagnostic logs category on the master database should also be created. - - Diagnostic Settings URI format: - PUT - https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/master/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview - - For more information, see `Diagnostic Settings REST API - `_ - or `Diagnostic Settings PowerShell `_. - :paramtype is_devops_audit_enabled: bool - :keyword retention_days: Specifies the number of days to keep in the audit logs in the storage - account. - :paramtype retention_days: int - :keyword audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. - - The recommended set of action groups to use is the following combination - this will audit all - the queries and stored procedures executed against the database, as well as successful and - failed logins: - - BATCH_COMPLETED_GROUP, - SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, - FAILED_DATABASE_AUTHENTICATION_GROUP. - - This above combination is also the set that is configured by default when enabling auditing - from the Azure portal. - - The supported action groups to audit are (note: choose only specific groups that cover your - auditing needs. Using unnecessary groups could lead to very large quantities of audit records): - - APPLICATION_ROLE_CHANGE_PASSWORD_GROUP - BACKUP_RESTORE_GROUP - DATABASE_LOGOUT_GROUP - DATABASE_OBJECT_CHANGE_GROUP - DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP - DATABASE_OBJECT_PERMISSION_CHANGE_GROUP - DATABASE_OPERATION_GROUP - DATABASE_PERMISSION_CHANGE_GROUP - DATABASE_PRINCIPAL_CHANGE_GROUP - DATABASE_PRINCIPAL_IMPERSONATION_GROUP - DATABASE_ROLE_MEMBER_CHANGE_GROUP - FAILED_DATABASE_AUTHENTICATION_GROUP - SCHEMA_OBJECT_ACCESS_GROUP - SCHEMA_OBJECT_CHANGE_GROUP - SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP - SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP - SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP - USER_CHANGE_PASSWORD_GROUP - BATCH_STARTED_GROUP - BATCH_COMPLETED_GROUP - DBCC_GROUP - DATABASE_OWNERSHIP_CHANGE_GROUP - DATABASE_CHANGE_GROUP - LEDGER_OPERATION_GROUP - - These are groups that cover all sql statements and stored procedures executed against the - database, and should not be used in combination with other groups as this will result in - duplicate audit logs. - - For more information, see `Database-Level Audit Action Groups - `_. - - For Database auditing policy, specific Actions can also be specified (note that Actions cannot - be specified for Server auditing policy). The supported actions to audit are: - SELECT - UPDATE - INSERT - DELETE - EXECUTE - RECEIVE - REFERENCES - - The general form for defining an action to be audited is: - {action} ON {object} BY {principal} - - Note that :code:`` in the above format can refer to an object like a table, view, or - stored procedure, or an entire database or schema. For the latter cases, the forms - DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. - - For example: - SELECT on dbo.myTable by public - SELECT on DATABASE::myDatabase by public - SELECT on SCHEMA::mySchema by public - - For more information, see `Database-Level Audit Actions - `_. - :paramtype audit_actions_and_groups: list[str] - :keyword is_storage_secondary_key_in_use: Specifies whether storageAccountAccessKey value is - the storage's secondary key. - :paramtype is_storage_secondary_key_in_use: bool - :keyword is_azure_monitor_target_enabled: Specifies whether audit events are sent to Azure - Monitor. - In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and - 'IsAzureMonitorTargetEnabled' as true. - - When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' - diagnostic logs category on the database should be also created. - Note that for server level audit you should use the 'master' database as {databaseName}. - - Diagnostic Settings URI format: - PUT - https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview - - For more information, see `Diagnostic Settings REST API - `_ - or `Diagnostic Settings PowerShell `_. - :paramtype is_azure_monitor_target_enabled: bool - :keyword queue_delay_ms: Specifies the amount of time in milliseconds that can elapse before - audit actions are forced to be processed. - The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. - :paramtype queue_delay_ms: int - :keyword is_managed_identity_in_use: Specifies whether Managed Identity is used to access blob - storage. - :paramtype is_managed_identity_in_use: bool - :keyword state: Specifies the state of the audit. If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled are required. Known values are: "Enabled" and "Disabled". - :paramtype state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState - :keyword storage_endpoint: Specifies the blob storage endpoint (e.g. - https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled is required. - :paramtype storage_endpoint: str - :keyword storage_account_access_key: Specifies the identifier key of the auditing storage - account. - If state is Enabled and storageEndpoint is specified, not specifying the - storageAccountAccessKey will use SQL server system-assigned managed identity to access the - storage. - Prerequisites for using managed identity authentication: - - - #. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). - #. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data - Contributor' RBAC role to the server identity. - For more information, see `Auditing to storage using Managed Identity authentication - `_. - :paramtype storage_account_access_key: str - :keyword storage_account_subscription_id: Specifies the blob storage subscription Id. - :paramtype storage_account_subscription_id: str - """ - super().__init__(**kwargs) - self.is_devops_audit_enabled = is_devops_audit_enabled - self.retention_days = retention_days - self.audit_actions_and_groups = audit_actions_and_groups - self.is_storage_secondary_key_in_use = is_storage_secondary_key_in_use - self.is_azure_monitor_target_enabled = is_azure_monitor_target_enabled - self.queue_delay_ms = queue_delay_ms - self.is_managed_identity_in_use = is_managed_identity_in_use - self.state = state - self.storage_endpoint = storage_endpoint - self.storage_account_access_key = storage_account_access_key - self.storage_account_subscription_id = storage_account_subscription_id - - -class ServerBlobAuditingPolicyListResult(_serialization.Model): - """A list of server auditing settings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ServerBlobAuditingPolicy] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ServerBlobAuditingPolicy]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ServerBlobAuditingPolicy"]] = None - self.next_link: Optional[str] = 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: Optional[str] = None - self.kind: Optional[str] = None - self.state: Optional[str] = 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. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar server_configuration_option_value: Value of the server configuration option. - :vartype server_configuration_option_value: int - :ivar provisioning_state: Provisioning state of server configuration option. Known values are: - "Created", "InProgress", "Succeeded", "Failed", and "Canceled". - :vartype provisioning_state: str or ~azure.mgmt.sql.models.ProvisioningState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "server_configuration_option_value": {"key": "properties.serverConfigurationOptionValue", "type": "int"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__(self, *, server_configuration_option_value: Optional[int] = None, **kwargs: Any) -> None: - """ - :keyword server_configuration_option_value: Value of the server configuration option. - :paramtype server_configuration_option_value: int - """ - super().__init__(**kwargs) - self.server_configuration_option_value = server_configuration_option_value - self.provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None - - -class ServerConfigurationOptionListResult(_serialization.Model): - """A list of server configuration options. - - 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.ServerConfigurationOption] - :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": "[ServerConfigurationOption]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ServerConfigurationOption"]] = None - self.next_link: Optional[str] = None - - -class ServerConnectionPolicy(ProxyResource): - """A server connection policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar location: Resource location. - :vartype location: str - :ivar kind: Metadata used for the Azure portal experience. - :vartype kind: str - :ivar connection_type: The server connection type. Known values are: "Default", "Redirect", and - "Proxy". - :vartype connection_type: str or ~azure.mgmt.sql.models.ServerConnectionType - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"readonly": True}, - "kind": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "connection_type": {"key": "properties.connectionType", "type": "str"}, - } - - def __init__( - self, *, connection_type: Optional[Union[str, "_models.ServerConnectionType"]] = None, **kwargs: Any - ) -> None: - """ - :keyword connection_type: The server connection type. Known values are: "Default", "Redirect", - and "Proxy". - :paramtype connection_type: str or ~azure.mgmt.sql.models.ServerConnectionType - """ - super().__init__(**kwargs) - self.location: Optional[str] = None - self.kind: Optional[str] = None - self.connection_type = connection_type - - -class ServerConnectionPolicyListResult(_serialization.Model): - """A list of server connection policy objects. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ServerConnectionPolicy] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ServerConnectionPolicy]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ServerConnectionPolicy"]] = None - self.next_link: Optional[str] = None - - -class ServerDevOpsAuditingSettings(ProxyResource): - """A server DevOps auditing settings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: SystemData of ServerDevOpsAuditSettingsResource. - :vartype system_data: ~azure.mgmt.sql.models.SystemData - :ivar is_azure_monitor_target_enabled: Specifies whether DevOps audit events are sent to Azure - Monitor. - In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and - 'IsAzureMonitorTargetEnabled' as true. - - When using REST API to configure DevOps audit, Diagnostic Settings with 'DevOpsOperationsAudit' - diagnostic logs category on the master database should be also created. - - Diagnostic Settings URI format: - PUT - https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/master/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview - - For more information, see `Diagnostic Settings REST API - `_ - or `Diagnostic Settings PowerShell `_. - :vartype is_azure_monitor_target_enabled: bool - :ivar is_managed_identity_in_use: Specifies whether Managed Identity is used to access blob - storage. - :vartype is_managed_identity_in_use: bool - :ivar state: Specifies the state of the audit. If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled are required. Known values are: "Enabled" and "Disabled". - :vartype state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState - :ivar storage_endpoint: Specifies the blob storage endpoint (e.g. - https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled is required. - :vartype storage_endpoint: str - :ivar storage_account_access_key: Specifies the identifier key of the auditing storage account. - If state is Enabled and storageEndpoint is specified, not specifying the - storageAccountAccessKey will use SQL server system-assigned managed identity to access the - storage. - Prerequisites for using managed identity authentication: - - - #. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). - #. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data - Contributor' RBAC role to the server identity. - For more information, see `Auditing to storage using Managed Identity authentication - `_. - :vartype storage_account_access_key: str - :ivar storage_account_subscription_id: Specifies the blob storage subscription Id. - :vartype storage_account_subscription_id: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "is_azure_monitor_target_enabled": {"key": "properties.isAzureMonitorTargetEnabled", "type": "bool"}, - "is_managed_identity_in_use": {"key": "properties.isManagedIdentityInUse", "type": "bool"}, - "state": {"key": "properties.state", "type": "str"}, - "storage_endpoint": {"key": "properties.storageEndpoint", "type": "str"}, - "storage_account_access_key": {"key": "properties.storageAccountAccessKey", "type": "str"}, - "storage_account_subscription_id": {"key": "properties.storageAccountSubscriptionId", "type": "str"}, - } - - def __init__( - self, - *, - is_azure_monitor_target_enabled: Optional[bool] = None, - is_managed_identity_in_use: Optional[bool] = None, - state: Optional[Union[str, "_models.BlobAuditingPolicyState"]] = None, - storage_endpoint: Optional[str] = None, - storage_account_access_key: Optional[str] = None, - storage_account_subscription_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword is_azure_monitor_target_enabled: Specifies whether DevOps audit events are sent to - Azure Monitor. - In order to send the events to Azure Monitor, specify 'State' as 'Enabled' and - 'IsAzureMonitorTargetEnabled' as true. - - When using REST API to configure DevOps audit, Diagnostic Settings with 'DevOpsOperationsAudit' - diagnostic logs category on the master database should be also created. - - Diagnostic Settings URI format: - PUT - https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/master/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview - - For more information, see `Diagnostic Settings REST API - `_ - or `Diagnostic Settings PowerShell `_. - :paramtype is_azure_monitor_target_enabled: bool - :keyword is_managed_identity_in_use: Specifies whether Managed Identity is used to access blob - storage. - :paramtype is_managed_identity_in_use: bool - :keyword state: Specifies the state of the audit. If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled are required. Known values are: "Enabled" and "Disabled". - :paramtype state: str or ~azure.mgmt.sql.models.BlobAuditingPolicyState - :keyword storage_endpoint: Specifies the blob storage endpoint (e.g. - https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled is required. - :paramtype storage_endpoint: str - :keyword storage_account_access_key: Specifies the identifier key of the auditing storage - account. - If state is Enabled and storageEndpoint is specified, not specifying the - storageAccountAccessKey will use SQL server system-assigned managed identity to access the - storage. - Prerequisites for using managed identity authentication: - - - #. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). - #. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data - Contributor' RBAC role to the server identity. - For more information, see `Auditing to storage using Managed Identity authentication - `_. - :paramtype storage_account_access_key: str - :keyword storage_account_subscription_id: Specifies the blob storage subscription Id. - :paramtype storage_account_subscription_id: str - """ - super().__init__(**kwargs) - self.system_data: Optional["_models.SystemData"] = None - self.is_azure_monitor_target_enabled = is_azure_monitor_target_enabled - self.is_managed_identity_in_use = is_managed_identity_in_use - self.state = state - self.storage_endpoint = storage_endpoint - self.storage_account_access_key = storage_account_access_key - self.storage_account_subscription_id = storage_account_subscription_id - - -class ServerDevOpsAuditSettingsListResult(_serialization.Model): - """A list of server DevOps audit settings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ServerDevOpsAuditingSettings] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ServerDevOpsAuditingSettings]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ServerDevOpsAuditingSettings"]] = None - self.next_link: Optional[str] = None - - -class ServerDnsAlias(ProxyResource): - """A server DNS alias. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar azure_dns_record: The fully qualified DNS record for alias. - :vartype azure_dns_record: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "azure_dns_record": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "azure_dns_record": {"key": "properties.azureDnsRecord", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.azure_dns_record: Optional[str] = None - - -class ServerDnsAliasAcquisition(_serialization.Model): - """A server dns alias acquisition request. - - All required parameters must be populated in order to send to server. - - :ivar old_server_dns_alias_id: The id of the server alias that will be acquired to point to - this server instead. Required. - :vartype old_server_dns_alias_id: str - """ - - _validation = { - "old_server_dns_alias_id": {"required": True}, - } - - _attribute_map = { - "old_server_dns_alias_id": {"key": "oldServerDnsAliasId", "type": "str"}, - } - - def __init__(self, *, old_server_dns_alias_id: str, **kwargs: Any) -> None: - """ - :keyword old_server_dns_alias_id: The id of the server alias that will be acquired to point to - this server instead. Required. - :paramtype old_server_dns_alias_id: str - """ - super().__init__(**kwargs) - self.old_server_dns_alias_id = old_server_dns_alias_id - - -class ServerDnsAliasListResult(_serialization.Model): - """A list of server DNS aliases. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ServerDnsAlias] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ServerDnsAlias]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ServerDnsAlias"]] = None - self.next_link: Optional[str] = None - - -class ServerExternalAdministrator(_serialization.Model): - """Properties of a active directory administrator. - - :ivar administrator_type: Type of the sever administrator. "ActiveDirectory" - :vartype administrator_type: str or ~azure.mgmt.sql.models.AdministratorType - :ivar principal_type: Principal Type of the sever administrator. Known values are: "User", - "Group", and "Application". - :vartype principal_type: str or ~azure.mgmt.sql.models.PrincipalType - :ivar login: Login name of the server administrator. - :vartype login: str - :ivar sid: SID (object ID) of the server administrator. - :vartype sid: str - :ivar tenant_id: Tenant ID of the administrator. - :vartype tenant_id: str - :ivar azure_ad_only_authentication: Azure Active Directory only Authentication enabled. - :vartype azure_ad_only_authentication: bool - """ - - _attribute_map = { - "administrator_type": {"key": "administratorType", "type": "str"}, - "principal_type": {"key": "principalType", "type": "str"}, - "login": {"key": "login", "type": "str"}, - "sid": {"key": "sid", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "azure_ad_only_authentication": {"key": "azureADOnlyAuthentication", "type": "bool"}, - } - - def __init__( - self, - *, - administrator_type: Optional[Union[str, "_models.AdministratorType"]] = None, - principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, - login: Optional[str] = None, - sid: Optional[str] = None, - tenant_id: Optional[str] = None, - azure_ad_only_authentication: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword administrator_type: Type of the sever administrator. "ActiveDirectory" - :paramtype administrator_type: str or ~azure.mgmt.sql.models.AdministratorType - :keyword principal_type: Principal Type of the sever administrator. Known values are: "User", - "Group", and "Application". - :paramtype principal_type: str or ~azure.mgmt.sql.models.PrincipalType - :keyword login: Login name of the server administrator. - :paramtype login: str - :keyword sid: SID (object ID) of the server administrator. - :paramtype sid: str - :keyword tenant_id: Tenant ID of the administrator. - :paramtype tenant_id: str - :keyword azure_ad_only_authentication: Azure Active Directory only Authentication enabled. - :paramtype azure_ad_only_authentication: bool - """ - super().__init__(**kwargs) - self.administrator_type = administrator_type - self.principal_type = principal_type - self.login = login - self.sid = sid - self.tenant_id = tenant_id - self.azure_ad_only_authentication = azure_ad_only_authentication - - -class ServerInfo(_serialization.Model): - """Server info for the server trust group. - - All required parameters must be populated in order to send to server. - - :ivar server_id: Server Id. Required. - :vartype server_id: str - """ - - _validation = { - "server_id": {"required": True}, - } - - _attribute_map = { - "server_id": {"key": "serverId", "type": "str"}, - } - - def __init__(self, *, server_id: str, **kwargs: Any) -> None: - """ - :keyword server_id: Server Id. Required. - :paramtype server_id: str - """ - super().__init__(**kwargs) - self.server_id = server_id - - -class ServerKey(ProxyResource): - """A server key. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar kind: Kind of encryption protector. This is metadata used for the Azure portal - experience. - :vartype kind: str - :ivar location: Resource location. - :vartype location: str - :ivar subregion: Subregion of the server key. - :vartype subregion: str - :ivar server_key_type: The server key type like 'ServiceManaged', 'AzureKeyVault'. Known values - 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. - :vartype uri: str - :ivar thumbprint: Thumbprint of the server key. - :vartype thumbprint: str - :ivar creation_date: The server key creation date. - :vartype creation_date: ~datetime.datetime - :ivar auto_rotation_enabled: Key auto rotation opt-in flag. Either true or false. - :vartype auto_rotation_enabled: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "kind": {"readonly": True}, - "location": {"readonly": True}, - "subregion": {"readonly": True}, - "thumbprint": {"readonly": True}, - "creation_date": {"readonly": True}, - "auto_rotation_enabled": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "subregion": {"key": "properties.subregion", "type": "str"}, - "server_key_type": {"key": "properties.serverKeyType", "type": "str"}, - "uri": {"key": "properties.uri", "type": "str"}, - "thumbprint": {"key": "properties.thumbprint", "type": "str"}, - "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, - "auto_rotation_enabled": {"key": "properties.autoRotationEnabled", "type": "bool"}, - } - - def __init__( - self, - *, - server_key_type: Optional[Union[str, "_models.ServerKeyType"]] = None, - uri: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword server_key_type: The server key type like 'ServiceManaged', 'AzureKeyVault'. Known - 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. - :paramtype uri: str - """ - super().__init__(**kwargs) - self.kind: Optional[str] = None - self.location: Optional[str] = None - self.subregion: Optional[str] = None - self.server_key_type = server_key_type - self.uri = uri - self.thumbprint: Optional[str] = None - self.creation_date: Optional[datetime.datetime] = None - self.auto_rotation_enabled: Optional[bool] = None - - -class ServerKeyListResult(_serialization.Model): - """A list of server keys. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ServerKey] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ServerKey]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ServerKey"]] = None - self.next_link: Optional[str] = None - - -class ServerListResult(_serialization.Model): - """A list of servers. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.Server] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Server]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.Server"]] = None - self.next_link: Optional[str] = None - - -class ServerOperation(ProxyResource): - """A server operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar operation: The name of operation. - :vartype operation: str - :ivar operation_friendly_name: The friendly name of operation. - :vartype operation_friendly_name: str - :ivar percent_complete: The percentage of the operation completed. - :vartype percent_complete: int - :ivar server_name: The name of the server. - :vartype server_name: str - :ivar start_time: The operation start time. - :vartype start_time: ~datetime.datetime - :ivar state: The operation state. Known values are: "Pending", "InProgress", "Succeeded", - "Failed", "CancelInProgress", and "Cancelled". - :vartype state: str or ~azure.mgmt.sql.models.ManagementOperationState - :ivar error_code: The operation error code. - :vartype error_code: int - :ivar error_description: The operation error description. - :vartype error_description: str - :ivar error_severity: The operation error severity. - :vartype error_severity: int - :ivar is_user_error: Whether or not the error is a user error. - :vartype is_user_error: bool - :ivar estimated_completion_time: The estimated completion time of the operation. - :vartype estimated_completion_time: ~datetime.datetime - :ivar description: The operation description. - :vartype description: str - :ivar is_cancellable: Whether the operation can be cancelled. - :vartype is_cancellable: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "operation": {"readonly": True}, - "operation_friendly_name": {"readonly": True}, - "percent_complete": {"readonly": True}, - "server_name": {"readonly": True}, - "start_time": {"readonly": True}, - "state": {"readonly": True}, - "error_code": {"readonly": True}, - "error_description": {"readonly": True}, - "error_severity": {"readonly": True}, - "is_user_error": {"readonly": True}, - "estimated_completion_time": {"readonly": True}, - "description": {"readonly": True}, - "is_cancellable": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "operation": {"key": "properties.operation", "type": "str"}, - "operation_friendly_name": {"key": "properties.operationFriendlyName", "type": "str"}, - "percent_complete": {"key": "properties.percentComplete", "type": "int"}, - "server_name": {"key": "properties.serverName", "type": "str"}, - "start_time": {"key": "properties.startTime", "type": "iso-8601"}, - "state": {"key": "properties.state", "type": "str"}, - "error_code": {"key": "properties.errorCode", "type": "int"}, - "error_description": {"key": "properties.errorDescription", "type": "str"}, - "error_severity": {"key": "properties.errorSeverity", "type": "int"}, - "is_user_error": {"key": "properties.isUserError", "type": "bool"}, - "estimated_completion_time": {"key": "properties.estimatedCompletionTime", "type": "iso-8601"}, - "description": {"key": "properties.description", "type": "str"}, - "is_cancellable": {"key": "properties.isCancellable", "type": "bool"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.operation: Optional[str] = None - self.operation_friendly_name: Optional[str] = None - self.percent_complete: Optional[int] = None - self.server_name: Optional[str] = None - self.start_time: Optional[datetime.datetime] = None - self.state: Optional[Union[str, "_models.ManagementOperationState"]] = None - self.error_code: Optional[int] = None - self.error_description: Optional[str] = None - self.error_severity: Optional[int] = None - self.is_user_error: Optional[bool] = None - self.estimated_completion_time: Optional[datetime.datetime] = None - self.description: Optional[str] = None - self.is_cancellable: Optional[bool] = None - - -class ServerOperationListResult(_serialization.Model): - """The response to a list server operations request. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ServerOperation] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ServerOperation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ServerOperation"]] = None - self.next_link: Optional[str] = None - - -class ServerPrivateEndpointConnection(_serialization.Model): - """A private endpoint connection under a server. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar properties: Private endpoint connection properties. - :vartype properties: ~azure.mgmt.sql.models.PrivateEndpointConnectionProperties - """ - - _validation = { - "id": {"readonly": True}, - "properties": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "properties": {"key": "properties", "type": "PrivateEndpointConnectionProperties"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.properties: Optional["_models.PrivateEndpointConnectionProperties"] = None - - -class ServerSecurityAlertPolicy(ProxyResource): - """A server security alert policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: SystemData of SecurityAlertPolicyResource. - :vartype system_data: ~azure.mgmt.sql.models.SystemData - :ivar state: Specifies the state of the policy, whether it is enabled or disabled or a policy - has not been applied yet on the specific database. Known values are: "Enabled" and "Disabled". - :vartype state: str or ~azure.mgmt.sql.models.SecurityAlertsPolicyState - :ivar disabled_alerts: Specifies an array of alerts that are disabled. Allowed values are: - Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, Unsafe_Action, - Brute_Force. - :vartype disabled_alerts: list[str] - :ivar email_addresses: Specifies an array of e-mail addresses to which the alert is sent. - :vartype email_addresses: list[str] - :ivar email_account_admins: Specifies that the alert is sent to the account administrators. - :vartype email_account_admins: bool - :ivar storage_endpoint: Specifies the blob storage endpoint (e.g. - https://MyAccount.blob.core.windows.net). This blob storage will hold all Threat Detection - audit logs. - :vartype storage_endpoint: str - :ivar storage_account_access_key: Specifies the identifier key of the Threat Detection audit - storage account. - :vartype storage_account_access_key: str - :ivar retention_days: Specifies the number of days to keep in the Threat Detection audit logs. - :vartype retention_days: int - :ivar creation_time: Specifies the UTC creation time of the policy. - :vartype creation_time: ~datetime.datetime - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "creation_time": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "state": {"key": "properties.state", "type": "str"}, - "disabled_alerts": {"key": "properties.disabledAlerts", "type": "[str]"}, - "email_addresses": {"key": "properties.emailAddresses", "type": "[str]"}, - "email_account_admins": {"key": "properties.emailAccountAdmins", "type": "bool"}, - "storage_endpoint": {"key": "properties.storageEndpoint", "type": "str"}, - "storage_account_access_key": {"key": "properties.storageAccountAccessKey", "type": "str"}, - "retention_days": {"key": "properties.retentionDays", "type": "int"}, - "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, - } - - def __init__( - self, - *, - state: Optional[Union[str, "_models.SecurityAlertsPolicyState"]] = None, - disabled_alerts: Optional[list[str]] = None, - email_addresses: Optional[list[str]] = None, - email_account_admins: Optional[bool] = None, - storage_endpoint: Optional[str] = None, - storage_account_access_key: Optional[str] = None, - retention_days: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword state: Specifies the state of the policy, whether it is enabled or disabled or a - policy has not been applied yet on the specific database. Known values are: "Enabled" and - "Disabled". - :paramtype state: str or ~azure.mgmt.sql.models.SecurityAlertsPolicyState - :keyword disabled_alerts: Specifies an array of alerts that are disabled. Allowed values are: - Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, Unsafe_Action, - Brute_Force. - :paramtype disabled_alerts: list[str] - :keyword email_addresses: Specifies an array of e-mail addresses to which the alert is sent. - :paramtype email_addresses: list[str] - :keyword email_account_admins: Specifies that the alert is sent to the account administrators. - :paramtype email_account_admins: bool - :keyword storage_endpoint: Specifies the blob storage endpoint (e.g. - https://MyAccount.blob.core.windows.net). This blob storage will hold all Threat Detection - audit logs. - :paramtype storage_endpoint: str - :keyword storage_account_access_key: Specifies the identifier key of the Threat Detection audit - storage account. - :paramtype storage_account_access_key: str - :keyword retention_days: Specifies the number of days to keep in the Threat Detection audit - logs. - :paramtype retention_days: int - """ - super().__init__(**kwargs) - self.system_data: Optional["_models.SystemData"] = None - self.state = state - self.disabled_alerts = disabled_alerts - self.email_addresses = email_addresses - self.email_account_admins = email_account_admins - self.storage_endpoint = storage_endpoint - self.storage_account_access_key = storage_account_access_key - self.retention_days = retention_days - self.creation_time: Optional[datetime.datetime] = None - - -class ServerTrustCertificate(ProxyResource): - """Server trust certificate imported from box to enable connection between box and Sql Managed - Instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar public_blob: The certificate public blob. - :vartype public_blob: str - :ivar thumbprint: The certificate thumbprint. - :vartype thumbprint: str - :ivar certificate_name: The certificate name. - :vartype certificate_name: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "thumbprint": {"readonly": True}, - "certificate_name": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "public_blob": {"key": "properties.publicBlob", "type": "str"}, - "thumbprint": {"key": "properties.thumbprint", "type": "str"}, - "certificate_name": {"key": "properties.certificateName", "type": "str"}, - } - - def __init__(self, *, public_blob: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword public_blob: The certificate public blob. - :paramtype public_blob: str - """ - super().__init__(**kwargs) - self.public_blob = public_blob - self.thumbprint: Optional[str] = None - self.certificate_name: Optional[str] = None - - -class ServerTrustCertificatesListResult(_serialization.Model): - """A list of server trust certificates in instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ServerTrustCertificate] - :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": "[ServerTrustCertificate]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ServerTrustCertificate"]] = None - self.next_link: Optional[str] = None - - -class ServerTrustGroup(ProxyResource): - """A server trust group. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar group_members: Group members information for the server trust group. - :vartype group_members: list[~azure.mgmt.sql.models.ServerInfo] - :ivar trust_scopes: Trust scope of the server trust group. - :vartype trust_scopes: list[str or - ~azure.mgmt.sql.models.ServerTrustGroupPropertiesTrustScopesItem] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "group_members": {"key": "properties.groupMembers", "type": "[ServerInfo]"}, - "trust_scopes": {"key": "properties.trustScopes", "type": "[str]"}, - } - - def __init__( - self, - *, - group_members: Optional[list["_models.ServerInfo"]] = None, - trust_scopes: Optional[list[Union[str, "_models.ServerTrustGroupPropertiesTrustScopesItem"]]] = None, - **kwargs: Any - ) -> None: - """ - :keyword group_members: Group members information for the server trust group. - :paramtype group_members: list[~azure.mgmt.sql.models.ServerInfo] - :keyword trust_scopes: Trust scope of the server trust group. - :paramtype trust_scopes: list[str or - ~azure.mgmt.sql.models.ServerTrustGroupPropertiesTrustScopesItem] - """ - super().__init__(**kwargs) - self.group_members = group_members - self.trust_scopes = trust_scopes - - -class ServerTrustGroupListResult(_serialization.Model): - """A list of server trust groups. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ServerTrustGroup] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ServerTrustGroup]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ServerTrustGroup"]] = None - self.next_link: Optional[str] = None - - -class ServerUpdate(_serialization.Model): - """An update request for an Azure SQL Database server. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar identity: Server identity. - :vartype identity: ~azure.mgmt.sql.models.ResourceIdentity - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar administrator_login: Administrator username for the server. Once created it cannot be - changed. - :vartype administrator_login: str - :ivar administrator_login_password: The administrator login password (required for server - creation). - :vartype administrator_login_password: str - :ivar version: The version of the server. - :vartype version: str - :ivar state: The state of the server. - :vartype state: str - :ivar fully_qualified_domain_name: The fully qualified domain name of the server. - :vartype fully_qualified_domain_name: str - :ivar private_endpoint_connections: List of private endpoint connections on a server. - :vartype private_endpoint_connections: - list[~azure.mgmt.sql.models.ServerPrivateEndpointConnection] - :ivar minimal_tls_version: Minimal TLS version. Allowed values: 'None', 1.0', '1.1', '1.2', - '1.3'. Known values are: "None", "1.0", "1.1", "1.2", and "1.3". - :vartype minimal_tls_version: str or ~azure.mgmt.sql.models.MinimalTlsVersion - :ivar public_network_access: Whether or not public endpoint access is allowed for this server. - Value is optional but if passed in, must be 'Enabled' or 'Disabled' or 'SecuredByPerimeter'. - Known values are: "Enabled", "Disabled", and "SecuredByPerimeter". - :vartype public_network_access: str or ~azure.mgmt.sql.models.ServerPublicNetworkAccessFlag - :ivar workspace_feature: Whether or not existing server has a workspace created and if it - allows connection from workspace. Known values are: "Connected" and "Disconnected". - :vartype workspace_feature: str or ~azure.mgmt.sql.models.ServerWorkspaceFeature - :ivar primary_user_assigned_identity_id: The resource id of a user assigned identity to be used - by default. - :vartype primary_user_assigned_identity_id: str - :ivar federated_client_id: The Client id used for cross tenant CMK scenario. - :vartype federated_client_id: str - :ivar key_id: A CMK URI of the key to use for encryption. - :vartype key_id: str - :ivar administrators: The Azure Active Directory administrator can be utilized during server - creation and for server updates, except for the azureADOnlyAuthentication property. To update - the azureADOnlyAuthentication property, individual API must be used. - :vartype administrators: ~azure.mgmt.sql.models.ServerExternalAdministrator - :ivar restrict_outbound_network_access: Whether or not to restrict outbound network access for - this server. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values - are: "Enabled" and "Disabled". - :vartype restrict_outbound_network_access: str or - ~azure.mgmt.sql.models.ServerNetworkAccessFlag - :ivar is_i_pv6_enabled: Whether or not to enable IPv6 support for this server. Value is - optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled" and - "Disabled". - :vartype is_i_pv6_enabled: str or ~azure.mgmt.sql.models.ServerNetworkAccessFlag - :ivar external_governance_status: Status of external governance. Known values are: "Enabled" - and "Disabled". - :vartype external_governance_status: str or ~azure.mgmt.sql.models.ExternalGovernanceStatus - :ivar retention_days: Number of days this server will stay soft-deleted. - :vartype retention_days: int - :ivar create_mode: Create mode for server, only valid values for this are Normal and Restore. - Known values are: "Normal" and "Restore". - :vartype create_mode: str or ~azure.mgmt.sql.models.ServerCreateMode - """ - - _validation = { - "state": {"readonly": True}, - "fully_qualified_domain_name": {"readonly": True}, - "private_endpoint_connections": {"readonly": True}, - "workspace_feature": {"readonly": True}, - "external_governance_status": {"readonly": True}, - } - - _attribute_map = { - "identity": {"key": "identity", "type": "ResourceIdentity"}, - "tags": {"key": "tags", "type": "{str}"}, - "administrator_login": {"key": "properties.administratorLogin", "type": "str"}, - "administrator_login_password": {"key": "properties.administratorLoginPassword", "type": "str"}, - "version": {"key": "properties.version", "type": "str"}, - "state": {"key": "properties.state", "type": "str"}, - "fully_qualified_domain_name": {"key": "properties.fullyQualifiedDomainName", "type": "str"}, - "private_endpoint_connections": { - "key": "properties.privateEndpointConnections", - "type": "[ServerPrivateEndpointConnection]", - }, - "minimal_tls_version": {"key": "properties.minimalTlsVersion", "type": "str"}, - "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, - "workspace_feature": {"key": "properties.workspaceFeature", "type": "str"}, - "primary_user_assigned_identity_id": {"key": "properties.primaryUserAssignedIdentityId", "type": "str"}, - "federated_client_id": {"key": "properties.federatedClientId", "type": "str"}, - "key_id": {"key": "properties.keyId", "type": "str"}, - "administrators": {"key": "properties.administrators", "type": "ServerExternalAdministrator"}, - "restrict_outbound_network_access": {"key": "properties.restrictOutboundNetworkAccess", "type": "str"}, - "is_i_pv6_enabled": {"key": "properties.isIPv6Enabled", "type": "str"}, - "external_governance_status": {"key": "properties.externalGovernanceStatus", "type": "str"}, - "retention_days": {"key": "properties.retentionDays", "type": "int"}, - "create_mode": {"key": "properties.createMode", "type": "str"}, - } - - def __init__( - self, - *, - identity: Optional["_models.ResourceIdentity"] = None, - tags: Optional[dict[str, str]] = None, - administrator_login: Optional[str] = None, - administrator_login_password: Optional[str] = None, - version: Optional[str] = None, - minimal_tls_version: Optional[Union[str, "_models.MinimalTlsVersion"]] = None, - public_network_access: Optional[Union[str, "_models.ServerPublicNetworkAccessFlag"]] = None, - primary_user_assigned_identity_id: Optional[str] = None, - federated_client_id: Optional[str] = None, - key_id: Optional[str] = None, - administrators: Optional["_models.ServerExternalAdministrator"] = None, - restrict_outbound_network_access: Optional[Union[str, "_models.ServerNetworkAccessFlag"]] = None, - is_i_pv6_enabled: Optional[Union[str, "_models.ServerNetworkAccessFlag"]] = None, - retention_days: Optional[int] = None, - create_mode: Optional[Union[str, "_models.ServerCreateMode"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword identity: Server identity. - :paramtype identity: ~azure.mgmt.sql.models.ResourceIdentity - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword administrator_login: Administrator username for the server. Once created it cannot be - changed. - :paramtype administrator_login: str - :keyword administrator_login_password: The administrator login password (required for server - creation). - :paramtype administrator_login_password: str - :keyword version: The version of the server. - :paramtype version: str - :keyword minimal_tls_version: Minimal TLS version. Allowed values: 'None', 1.0', '1.1', '1.2', - '1.3'. Known values are: "None", "1.0", "1.1", "1.2", and "1.3". - :paramtype minimal_tls_version: str or ~azure.mgmt.sql.models.MinimalTlsVersion - :keyword public_network_access: Whether or not public endpoint access is allowed for this - server. Value is optional but if passed in, must be 'Enabled' or 'Disabled' or - 'SecuredByPerimeter'. Known values are: "Enabled", "Disabled", and "SecuredByPerimeter". - :paramtype public_network_access: str or ~azure.mgmt.sql.models.ServerPublicNetworkAccessFlag - :keyword primary_user_assigned_identity_id: The resource id of a user assigned identity to be - used by default. - :paramtype primary_user_assigned_identity_id: str - :keyword federated_client_id: The Client id used for cross tenant CMK scenario. - :paramtype federated_client_id: str - :keyword key_id: A CMK URI of the key to use for encryption. - :paramtype key_id: str - :keyword administrators: The Azure Active Directory administrator can be utilized during server - creation and for server updates, except for the azureADOnlyAuthentication property. To update - the azureADOnlyAuthentication property, individual API must be used. - :paramtype administrators: ~azure.mgmt.sql.models.ServerExternalAdministrator - :keyword restrict_outbound_network_access: Whether or not to restrict outbound network access - for this server. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known - values are: "Enabled" and "Disabled". - :paramtype restrict_outbound_network_access: str or - ~azure.mgmt.sql.models.ServerNetworkAccessFlag - :keyword is_i_pv6_enabled: Whether or not to enable IPv6 support for this server. Value is - optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled" and - "Disabled". - :paramtype is_i_pv6_enabled: str or ~azure.mgmt.sql.models.ServerNetworkAccessFlag - :keyword retention_days: Number of days this server will stay soft-deleted. - :paramtype retention_days: int - :keyword create_mode: Create mode for server, only valid values for this are Normal and - Restore. Known values are: "Normal" and "Restore". - :paramtype create_mode: str or ~azure.mgmt.sql.models.ServerCreateMode - """ - super().__init__(**kwargs) - self.identity = identity - self.tags = tags - self.administrator_login = administrator_login - self.administrator_login_password = administrator_login_password - self.version = version - self.state: Optional[str] = None - self.fully_qualified_domain_name: Optional[str] = None - self.private_endpoint_connections: Optional[list["_models.ServerPrivateEndpointConnection"]] = None - self.minimal_tls_version = minimal_tls_version - self.public_network_access = public_network_access - self.workspace_feature: Optional[Union[str, "_models.ServerWorkspaceFeature"]] = None - self.primary_user_assigned_identity_id = primary_user_assigned_identity_id - self.federated_client_id = federated_client_id - self.key_id = key_id - self.administrators = administrators - self.restrict_outbound_network_access = restrict_outbound_network_access - self.is_i_pv6_enabled = is_i_pv6_enabled - self.external_governance_status: Optional[Union[str, "_models.ExternalGovernanceStatus"]] = None - self.retention_days = retention_days - self.create_mode = create_mode - - -class ServerUsage(_serialization.Model): - """Represents server metrics. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Name of the server usage metric. - :vartype name: str - :ivar resource_name: The name of the resource. - :vartype resource_name: str - :ivar display_name: The metric display name. - :vartype display_name: str - :ivar current_value: The current value of the metric. - :vartype current_value: float - :ivar limit: The current limit of the metric. - :vartype limit: float - :ivar unit: The units of the metric. - :vartype unit: str - :ivar next_reset_time: The next reset time for the metric (ISO8601 format). - :vartype next_reset_time: ~datetime.datetime - """ - - _validation = { - "name": {"readonly": True}, - "resource_name": {"readonly": True}, - "display_name": {"readonly": True}, - "current_value": {"readonly": True}, - "limit": {"readonly": True}, - "unit": {"readonly": True}, - "next_reset_time": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "resource_name": {"key": "resourceName", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "current_value": {"key": "currentValue", "type": "float"}, - "limit": {"key": "limit", "type": "float"}, - "unit": {"key": "unit", "type": "str"}, - "next_reset_time": {"key": "nextResetTime", "type": "iso-8601"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - self.resource_name: Optional[str] = None - self.display_name: Optional[str] = None - self.current_value: Optional[float] = None - self.limit: Optional[float] = None - self.unit: Optional[str] = None - self.next_reset_time: Optional[datetime.datetime] = None - - -class ServerUsageListResult(_serialization.Model): - """Represents the response to a list server metrics request. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of server metrics for the server. Required. - :vartype value: list[~azure.mgmt.sql.models.ServerUsage] - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ServerUsage]"}, - } - - 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] - """ - super().__init__(**kwargs) - self.value = value - - -class ServerVersionCapability(_serialization.Model): - """The server capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The server version name. - :vartype name: str - :ivar supported_editions: The list of supported database editions. - :vartype supported_editions: list[~azure.mgmt.sql.models.EditionCapability] - :ivar supported_elastic_pool_editions: The list of supported elastic pool editions. - :vartype supported_elastic_pool_editions: - list[~azure.mgmt.sql.models.ElasticPoolEditionCapability] - :ivar status: The status of the capability. Known values are: "Visible", "Available", - "Default", and "Disabled". - :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :ivar reason: The reason for the capability not being available. - :vartype reason: str - """ - - _validation = { - "name": {"readonly": True}, - "supported_editions": {"readonly": True}, - "supported_elastic_pool_editions": {"readonly": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "supported_editions": {"key": "supportedEditions", "type": "[EditionCapability]"}, - "supported_elastic_pool_editions": { - "key": "supportedElasticPoolEditions", - "type": "[ElasticPoolEditionCapability]", - }, - "status": {"key": "status", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - } - - def __init__(self, *, 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: Optional[str] = None - self.supported_editions: Optional[list["_models.EditionCapability"]] = None - self.supported_elastic_pool_editions: Optional[list["_models.ElasticPoolEditionCapability"]] = None - self.status: Optional[Union[str, "_models.CapabilityStatus"]] = None - self.reason = reason - - -class ServerVulnerabilityAssessment(ProxyResource): - """A server vulnerability assessment. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar storage_container_path: A blob storage container path to hold the scan results (e.g. - https://myStorage.blob.core.windows.net/VaScans/). - :vartype storage_container_path: str - :ivar storage_container_sas_key: A shared access signature (SAS Key) that has write access to - the blob container specified in 'storageContainerPath' parameter. If 'storageAccountAccessKey' - isn't specified, StorageContainerSasKey is required. Applies only if the storage account is not - behind a Vnet or a firewall. - :vartype storage_container_sas_key: str - :ivar storage_account_access_key: Specifies the identifier key of the storage account for - vulnerability assessment scan results. If 'StorageContainerSasKey' isn't specified, - storageAccountAccessKey is required. Applies only if the storage account is not behind a Vnet - or a firewall. - :vartype storage_account_access_key: str - :ivar recurring_scans: The recurring scans settings. - :vartype recurring_scans: - ~azure.mgmt.sql.models.VulnerabilityAssessmentRecurringScansProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "storage_container_path": {"key": "properties.storageContainerPath", "type": "str"}, - "storage_container_sas_key": {"key": "properties.storageContainerSasKey", "type": "str"}, - "storage_account_access_key": {"key": "properties.storageAccountAccessKey", "type": "str"}, - "recurring_scans": { - "key": "properties.recurringScans", - "type": "VulnerabilityAssessmentRecurringScansProperties", - }, - } - - def __init__( - self, - *, - storage_container_path: Optional[str] = None, - storage_container_sas_key: Optional[str] = None, - storage_account_access_key: Optional[str] = None, - recurring_scans: Optional["_models.VulnerabilityAssessmentRecurringScansProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword storage_container_path: A blob storage container path to hold the scan results (e.g. - https://myStorage.blob.core.windows.net/VaScans/). - :paramtype storage_container_path: str - :keyword storage_container_sas_key: A shared access signature (SAS Key) that has write access - to the blob container specified in 'storageContainerPath' parameter. If - 'storageAccountAccessKey' isn't specified, StorageContainerSasKey is required. Applies only if - the storage account is not behind a Vnet or a firewall. - :paramtype storage_container_sas_key: str - :keyword storage_account_access_key: Specifies the identifier key of the storage account for - vulnerability assessment scan results. If 'StorageContainerSasKey' isn't specified, - storageAccountAccessKey is required. Applies only if the storage account is not behind a Vnet - or a firewall. - :paramtype storage_account_access_key: str - :keyword recurring_scans: The recurring scans settings. - :paramtype recurring_scans: - ~azure.mgmt.sql.models.VulnerabilityAssessmentRecurringScansProperties - """ - super().__init__(**kwargs) - self.storage_container_path = storage_container_path - self.storage_container_sas_key = storage_container_sas_key - self.storage_account_access_key = storage_account_access_key - self.recurring_scans = recurring_scans - - -class ServerVulnerabilityAssessmentListResult(_serialization.Model): - """A list of the server's vulnerability assessments. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ServerVulnerabilityAssessment] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ServerVulnerabilityAssessment]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.ServerVulnerabilityAssessment"]] = None - self.next_link: Optional[str] = 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: Optional[str] = None - self.is_default: Optional[bool] = None - self.is_system: Optional[bool] = None - self.description: Optional[str] = None - self.enabled: Optional[bool] = None - - -class ServiceObjectiveCapability(_serialization.Model): - """The service objectives capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The unique ID of the service objective. - :vartype id: str - :ivar name: The service objective name. - :vartype name: str - :ivar supported_max_sizes: The list of supported maximum database sizes. - :vartype supported_max_sizes: list[~azure.mgmt.sql.models.MaxSizeRangeCapability] - :ivar performance_level: The performance level. - :vartype performance_level: ~azure.mgmt.sql.models.PerformanceLevelCapability - :ivar sku: The sku. - :vartype sku: ~azure.mgmt.sql.models.Sku - :ivar supported_license_types: List of supported license types. - :vartype supported_license_types: list[~azure.mgmt.sql.models.LicenseTypeCapability] - :ivar included_max_size: The included (free) max size. - :vartype included_max_size: ~azure.mgmt.sql.models.MaxSizeCapability - :ivar zone_redundant: Whether or not zone redundancy is supported for the service objective. - :vartype zone_redundant: bool - :ivar supported_auto_pause_delay: Supported time range for auto pause delay. - :vartype supported_auto_pause_delay: ~azure.mgmt.sql.models.AutoPauseDelayTimeRange - :ivar supported_min_capacities: List of supported min capacities. - :vartype supported_min_capacities: list[~azure.mgmt.sql.models.MinCapacityCapability] - :ivar compute_model: The compute model. - :vartype compute_model: str - :ivar supported_maintenance_configurations: List of supported maintenance configurations. - :vartype supported_maintenance_configurations: - list[~azure.mgmt.sql.models.MaintenanceConfigurationCapability] - :ivar status: The status of the capability. 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}, - "supported_max_sizes": {"readonly": True}, - "performance_level": {"readonly": True}, - "sku": {"readonly": True}, - "supported_license_types": {"readonly": True}, - "included_max_size": {"readonly": True}, - "zone_redundant": {"readonly": True}, - "supported_auto_pause_delay": {"readonly": True}, - "supported_min_capacities": {"readonly": True}, - "compute_model": {"readonly": True}, - "supported_maintenance_configurations": {"readonly": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "supported_max_sizes": {"key": "supportedMaxSizes", "type": "[MaxSizeRangeCapability]"}, - "performance_level": {"key": "performanceLevel", "type": "PerformanceLevelCapability"}, - "sku": {"key": "sku", "type": "Sku"}, - "supported_license_types": {"key": "supportedLicenseTypes", "type": "[LicenseTypeCapability]"}, - "included_max_size": {"key": "includedMaxSize", "type": "MaxSizeCapability"}, - "zone_redundant": {"key": "zoneRedundant", "type": "bool"}, - "supported_auto_pause_delay": {"key": "supportedAutoPauseDelay", "type": "AutoPauseDelayTimeRange"}, - "supported_min_capacities": {"key": "supportedMinCapacities", "type": "[MinCapacityCapability]"}, - "compute_model": {"key": "computeModel", "type": "str"}, - "supported_maintenance_configurations": { - "key": "supportedMaintenanceConfigurations", - "type": "[MaintenanceConfigurationCapability]", - }, - "status": {"key": "status", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - } - - def __init__(self, *, reason: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword reason: The reason for the capability not being available. - :paramtype reason: str - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional[str] = None - self.supported_max_sizes: Optional[list["_models.MaxSizeRangeCapability"]] = None - self.performance_level: Optional["_models.PerformanceLevelCapability"] = None - self.sku: Optional["_models.Sku"] = None - self.supported_license_types: Optional[list["_models.LicenseTypeCapability"]] = None - self.included_max_size: Optional["_models.MaxSizeCapability"] = None - self.zone_redundant: Optional[bool] = None - self.supported_auto_pause_delay: Optional["_models.AutoPauseDelayTimeRange"] = None - self.supported_min_capacities: Optional[list["_models.MinCapacityCapability"]] = None - self.compute_model: Optional[str] = None - self.supported_maintenance_configurations: Optional[list["_models.MaintenanceConfigurationCapability"]] = None - self.status: Optional[Union[str, "_models.CapabilityStatus"]] = 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 server. - - :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. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The Azure Active Directory application object id. - :vartype principal_id: str - :ivar client_id: The Azure Active Directory application client id. - :vartype client_id: str - :ivar tenant_id: The Azure Active Directory tenant id. - :vartype tenant_id: str - :ivar type: Service principal type. Known values are: "None" and "SystemAssigned". - :vartype type: str or ~azure.mgmt.sql.models.ServicePrincipalType - """ - - _validation = { - "principal_id": {"readonly": True}, - "client_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "client_id": {"key": "clientId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, *, type: Optional[Union[str, "_models.ServicePrincipalType"]] = None, **kwargs: Any) -> None: - """ - :keyword type: Service principal type. Known values are: "None" and "SystemAssigned". - :paramtype type: str or ~azure.mgmt.sql.models.ServicePrincipalType - """ - super().__init__(**kwargs) - self.principal_id: Optional[str] = None - self.client_id: Optional[str] = None - self.tenant_id: Optional[str] = None - self.type = type - - -class Sku(_serialization.Model): - """An ARM Resource SKU. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the SKU, typically, a letter + Number code, e.g. P3. Required. - :vartype name: str - :ivar tier: The tier or edition of the particular SKU, e.g. Basic, Premium. - :vartype tier: str - :ivar size: Size of the particular SKU. - :vartype size: str - :ivar family: If the service has different generations of hardware, for the same SKU, then that - can be captured here. - :vartype family: str - :ivar capacity: Capacity of the particular SKU. - :vartype capacity: int - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - "size": {"key": "size", "type": "str"}, - "family": {"key": "family", "type": "str"}, - "capacity": {"key": "capacity", "type": "int"}, - } - - def __init__( - self, - *, - name: str, - tier: Optional[str] = None, - size: Optional[str] = None, - family: Optional[str] = None, - capacity: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the SKU, typically, a letter + Number code, e.g. P3. Required. - :paramtype name: str - :keyword tier: The tier or edition of the particular SKU, e.g. Basic, Premium. - :paramtype tier: str - :keyword size: Size of the particular SKU. - :paramtype size: str - :keyword family: If the service has different generations of hardware, for the same SKU, then - that can be captured here. - :paramtype family: str - :keyword capacity: Capacity of the particular SKU. - :paramtype capacity: int - """ - super().__init__(**kwargs) - self.name = name - self.tier = tier - self.size = size - self.family = family - 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: Optional[Union[str, "_models.ServiceObjectiveName"]] = None - self.service_level_objective_id: Optional[str] = None - self.in_range_time_ratio: Optional[float] = None - - -class SqlAgentConfiguration(ProxyResource): - """A recoverable managed database resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar state: The state of Sql Agent. Known values are: "Enabled" and "Disabled". - :vartype state: str or ~azure.mgmt.sql.models.SqlAgentConfigurationPropertiesState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "state": {"key": "properties.state", "type": "str"}, - } - - def __init__( - self, *, state: Optional[Union[str, "_models.SqlAgentConfigurationPropertiesState"]] = None, **kwargs: Any - ) -> None: - """ - :keyword state: The state of Sql Agent. Known values are: "Enabled" and "Disabled". - :paramtype state: str or ~azure.mgmt.sql.models.SqlAgentConfigurationPropertiesState - """ - super().__init__(**kwargs) - self.state = state - - -class SqlVulnerabilityAssessment(ProxyResource): - """A SQL Vulnerability Assessment. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: SystemData of SqlVulnerabilityAssessmentResource. - :vartype system_data: ~azure.mgmt.sql.models.SystemData - :ivar state: Specifies the state of the SQL Vulnerability Assessment, whether it is enabled or - disabled or a state has not been applied yet on the specific database or server. Known values - are: "Enabled" and "Disabled". - :vartype state: str or ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "state": {"key": "properties.state", "type": "str"}, - } - - def __init__( - self, *, state: Optional[Union[str, "_models.SqlVulnerabilityAssessmentState"]] = None, **kwargs: Any - ) -> None: - """ - :keyword state: Specifies the state of the SQL Vulnerability Assessment, whether it is enabled - or disabled or a state has not been applied yet on the specific database or server. Known - values are: "Enabled" and "Disabled". - :paramtype state: str or ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentState - """ - super().__init__(**kwargs) - self.system_data: Optional["_models.SystemData"] = None - self.state = state - - -class SqlVulnerabilityAssessmentListResult(_serialization.Model): - """A list of SQL Vulnerability Assessments. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.SqlVulnerabilityAssessment] - :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": "[SqlVulnerabilityAssessment]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.SqlVulnerabilityAssessment"]] = None - self.next_link: Optional[str] = None - - -class SqlVulnerabilityAssessmentScanError(_serialization.Model): - """Properties of a vulnerability assessment scan error. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code: Optional[str] = None - self.message: Optional[str] = None - - -class SQLVulnerabilityAssessmentScanListResult(_serialization.Model): - """A list of vulnerability assessment scan results. - - 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.SqlVulnerabilityAssessmentScanResults] - :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": "[SqlVulnerabilityAssessmentScanResults]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.SqlVulnerabilityAssessmentScanResults"]] = None - self.next_link: Optional[str] = None - - -class SqlVulnerabilityAssessmentScanRecord(ProxyResource): - """A vulnerability assessment scan record. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: SystemData of SqlVulnerabilityAssessmentScanRecordResource. - :vartype system_data: ~azure.mgmt.sql.models.SystemData - :ivar scan_id: The scan ID. - :vartype scan_id: str - :ivar trigger_type: The scan trigger type. Known values are: "OnDemand" and "Recurring". - :vartype trigger_type: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentScanTriggerType - :ivar state: The scan status. Known values are: "Passed", "Failed", "FailedToRun", and - "InProgress". - :vartype state: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentScanState - :ivar start_time: The scan start time (UTC). - :vartype start_time: ~datetime.datetime - :ivar end_time: The scan end time (UTC). - :vartype end_time: ~datetime.datetime - :ivar errors: The scan errors. - :vartype errors: list[~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanError] - :ivar server: The server name. - :vartype server: str - :ivar database: The database name. - :vartype database: str - :ivar sql_version: The SQL version. - :vartype sql_version: str - :ivar high_severity_failed_rules_count: The number of failed rules with high severity. - :vartype high_severity_failed_rules_count: int - :ivar medium_severity_failed_rules_count: The number of failed rules with medium severity. - :vartype medium_severity_failed_rules_count: int - :ivar low_severity_failed_rules_count: The number of failed rules with low severity. - :vartype low_severity_failed_rules_count: int - :ivar total_passed_rules_count: The number of total passed rules. - :vartype total_passed_rules_count: int - :ivar total_failed_rules_count: The number of total failed rules. - :vartype total_failed_rules_count: int - :ivar total_rules_count: The number of total rules assessed. - :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 = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "scan_id": {"readonly": True}, - "trigger_type": {"readonly": True}, - "state": {"readonly": True}, - "start_time": {"readonly": True}, - "end_time": {"readonly": True}, - "errors": {"readonly": True}, - "server": {"readonly": True}, - "database": {"readonly": True}, - "sql_version": {"readonly": True}, - "high_severity_failed_rules_count": {"readonly": True}, - "medium_severity_failed_rules_count": {"readonly": True}, - "low_severity_failed_rules_count": {"readonly": True}, - "total_passed_rules_count": {"readonly": True}, - "total_failed_rules_count": {"readonly": True}, - "total_rules_count": {"readonly": True}, - "is_baseline_applied": {"readonly": True}, - "last_scan_time": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "scan_id": {"key": "properties.scanId", "type": "str"}, - "trigger_type": {"key": "properties.triggerType", "type": "str"}, - "state": {"key": "properties.state", "type": "str"}, - "start_time": {"key": "properties.startTime", "type": "iso-8601"}, - "end_time": {"key": "properties.endTime", "type": "iso-8601"}, - "errors": {"key": "properties.errors", "type": "[SqlVulnerabilityAssessmentScanError]"}, - "server": {"key": "properties.server", "type": "str"}, - "database": {"key": "properties.database", "type": "str"}, - "sql_version": {"key": "properties.sqlVersion", "type": "str"}, - "high_severity_failed_rules_count": {"key": "properties.highSeverityFailedRulesCount", "type": "int"}, - "medium_severity_failed_rules_count": {"key": "properties.mediumSeverityFailedRulesCount", "type": "int"}, - "low_severity_failed_rules_count": {"key": "properties.lowSeverityFailedRulesCount", "type": "int"}, - "total_passed_rules_count": {"key": "properties.totalPassedRulesCount", "type": "int"}, - "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: - """ """ - super().__init__(**kwargs) - self.system_data: Optional["_models.SystemData"] = None - self.scan_id: Optional[str] = None - self.trigger_type: Optional[Union[str, "_models.VulnerabilityAssessmentScanTriggerType"]] = None - self.state: Optional[Union[str, "_models.VulnerabilityAssessmentScanState"]] = None - self.start_time: Optional[datetime.datetime] = None - self.end_time: Optional[datetime.datetime] = None - self.errors: Optional[list["_models.SqlVulnerabilityAssessmentScanError"]] = None - self.server: Optional[str] = None - self.database: Optional[str] = None - self.sql_version: Optional[str] = None - self.high_severity_failed_rules_count: Optional[int] = None - self.medium_severity_failed_rules_count: Optional[int] = None - self.low_severity_failed_rules_count: Optional[int] = None - self.total_passed_rules_count: Optional[int] = None - self.total_failed_rules_count: Optional[int] = None - self.total_rules_count: Optional[int] = None - self.is_baseline_applied: Optional[bool] = None - self.last_scan_time: Optional[datetime.datetime] = None - - -class SqlVulnerabilityAssessmentScanRecordListResult(_serialization.Model): # pylint: disable=name-too-long - """A list of vulnerability assessment scan records. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanRecord] - :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": "[SqlVulnerabilityAssessmentScanRecord]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.SqlVulnerabilityAssessmentScanRecord"]] = None - self.next_link: Optional[str] = None - - -class SqlVulnerabilityAssessmentScanResults(ProxyResource): - """SqlVulnerabilityAssessmentScanResults. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: SystemData of AdvancedThreatProtectionResource. - :vartype system_data: ~azure.mgmt.sql.models.SystemData - :ivar rule_id: SQL Vulnerability Assessment rule Id. - :vartype rule_id: str - :ivar status: SQL Vulnerability Assessment rule result status. Known values are: "NonFinding", - "Finding", and "InternalError". - :vartype status: str or ~azure.mgmt.sql.models.RuleStatus - :ivar error_message: SQL Vulnerability Assessment error message. - :vartype error_message: str - :ivar is_trimmed: SQL Vulnerability Assessment is the query results trimmed. - :vartype is_trimmed: bool - :ivar query_results: SQL Vulnerability Assessment query results that was run. - :vartype query_results: list[list[str]] - :ivar remediation: SQL Vulnerability Assessment the remediation details. - :vartype remediation: ~azure.mgmt.sql.models.Remediation - :ivar baseline_adjusted_result: SQL Vulnerability Assessment rule result adjusted with - baseline. - :vartype baseline_adjusted_result: ~azure.mgmt.sql.models.BaselineAdjustedResult - :ivar rule_metadata: SQL Vulnerability Assessment rule metadata. - :vartype rule_metadata: ~azure.mgmt.sql.models.VaRule - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "rule_id": {"readonly": True}, - "status": {"readonly": True}, - "error_message": {"readonly": True}, - "is_trimmed": {"readonly": True}, - "query_results": {"readonly": True}, - "remediation": {"readonly": True}, - "baseline_adjusted_result": {"readonly": True}, - "rule_metadata": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "rule_id": {"key": "properties.ruleId", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "error_message": {"key": "properties.errorMessage", "type": "str"}, - "is_trimmed": {"key": "properties.isTrimmed", "type": "bool"}, - "query_results": {"key": "properties.queryResults", "type": "[[str]]"}, - "remediation": {"key": "properties.remediation", "type": "Remediation"}, - "baseline_adjusted_result": {"key": "properties.baselineAdjustedResult", "type": "BaselineAdjustedResult"}, - "rule_metadata": {"key": "properties.ruleMetadata", "type": "VaRule"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.system_data: Optional["_models.SystemData"] = None - self.rule_id: Optional[str] = None - self.status: Optional[Union[str, "_models.RuleStatus"]] = None - self.error_message: Optional[str] = None - self.is_trimmed: Optional[bool] = None - self.query_results: Optional[list[list[str]]] = None - self.remediation: Optional["_models.Remediation"] = None - self.baseline_adjusted_result: Optional["_models.BaselineAdjustedResult"] = None - self.rule_metadata: Optional["_models.VaRule"] = None - - -class StartStopManagedInstanceSchedule(ProxyResource): - """Managed instance's Start/Stop schedule. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: System data of the scheduled resource. - :vartype system_data: ~azure.mgmt.sql.models.SystemData - :ivar description: The description of the schedule. - :vartype description: str - :ivar time_zone_id: The time zone of the schedule. - :vartype time_zone_id: str - :ivar schedule_list: Schedule list. - :vartype schedule_list: list[~azure.mgmt.sql.models.ScheduleItem] - :ivar next_run_action: Next action to be executed (Start or Stop). - :vartype next_run_action: str - :ivar next_execution_time: Timestamp when the next action will be executed in the corresponding - schedule time zone. - :vartype next_execution_time: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "next_run_action": {"readonly": True}, - "next_execution_time": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "description": {"key": "properties.description", "type": "str"}, - "time_zone_id": {"key": "properties.timeZoneId", "type": "str"}, - "schedule_list": {"key": "properties.scheduleList", "type": "[ScheduleItem]"}, - "next_run_action": {"key": "properties.nextRunAction", "type": "str"}, - "next_execution_time": {"key": "properties.nextExecutionTime", "type": "str"}, - } - - def __init__( - self, - *, - description: str = "", - time_zone_id: str = "UTC", - schedule_list: Optional[list["_models.ScheduleItem"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: The description of the schedule. - :paramtype description: str - :keyword time_zone_id: The time zone of the schedule. - :paramtype time_zone_id: str - :keyword schedule_list: Schedule list. - :paramtype schedule_list: list[~azure.mgmt.sql.models.ScheduleItem] - """ - super().__init__(**kwargs) - self.system_data: Optional["_models.SystemData"] = None - self.description = description - self.time_zone_id = time_zone_id - self.schedule_list = schedule_list - self.next_run_action: Optional[str] = None - self.next_execution_time: Optional[str] = None - - -class StartStopManagedInstanceScheduleListResult(_serialization.Model): # pylint: disable=name-too-long - """Managed instance's Start/Stop schedule list result. - - 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.StartStopManagedInstanceSchedule] - :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": "[StartStopManagedInstanceSchedule]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.StartStopManagedInstanceSchedule"]] = None - self.next_link: Optional[str] = None - - -class StorageCapability(_serialization.Model): - """The storage account type capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar storage_account_type: The storage account type for the database's backups. Known values - are: "GRS", "LRS", and "ZRS". - :vartype storage_account_type: str or - ~azure.mgmt.sql.models.StorageCapabilityStorageAccountType - :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 = { - "storage_account_type": {"readonly": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "storage_account_type": {"key": "storageAccountType", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - } - - def __init__(self, *, reason: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword reason: The reason for the capability not being available. - :paramtype reason: str - """ - super().__init__(**kwargs) - self.storage_account_type: Optional[Union[str, "_models.StorageCapabilityStorageAccountType"]] = None - self.status: Optional[Union[str, "_models.CapabilityStatus"]] = None - self.reason = reason - - -class SubscriptionUsage(ProxyResource): - """Usage Metric of a Subscription in a Location. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar display_name: User-readable name of the metric. - :vartype display_name: str - :ivar current_value: Current value of the metric. - :vartype current_value: float - :ivar limit: Boundary value of the metric. - :vartype limit: float - :ivar unit: Unit of the metric. - :vartype unit: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "display_name": {"readonly": True}, - "current_value": {"readonly": True}, - "limit": {"readonly": True}, - "unit": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "current_value": {"key": "properties.currentValue", "type": "float"}, - "limit": {"key": "properties.limit", "type": "float"}, - "unit": {"key": "properties.unit", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.display_name: Optional[str] = None - self.current_value: Optional[float] = None - self.limit: Optional[float] = None - self.unit: Optional[str] = None - - -class SubscriptionUsageListResult(_serialization.Model): - """A list of subscription usage metrics in a location. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.SubscriptionUsage] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SubscriptionUsage]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.SubscriptionUsage"]] = None - self.next_link: Optional[str] = None - - -class SynapseLinkWorkspace(ProxyResource): - """Synapse link workspace 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 workspaces: List of all synapselink workspaces. - :vartype workspaces: list[~azure.mgmt.sql.models.SynapseLinkWorkspaceInfoProperties] - """ - - _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"}, - "workspaces": {"key": "properties.workspaces", "type": "[SynapseLinkWorkspaceInfoProperties]"}, - } - - def __init__( - self, *, workspaces: Optional[list["_models.SynapseLinkWorkspaceInfoProperties"]] = None, **kwargs: Any - ) -> None: - """ - :keyword workspaces: List of all synapselink workspaces. - :paramtype workspaces: list[~azure.mgmt.sql.models.SynapseLinkWorkspaceInfoProperties] - """ - super().__init__(**kwargs) - self.workspaces = workspaces - - -class SynapseLinkWorkspaceInfoProperties(_serialization.Model): - """Properties of a Synapse link workspaces. - - :ivar workspace_id: Synapse link workspace id. - :vartype workspace_id: str - :ivar link_connection_name: Link connection name. - :vartype link_connection_name: str - """ - - _attribute_map = { - "workspace_id": {"key": "workspaceId", "type": "str"}, - "link_connection_name": {"key": "linkConnectionName", "type": "str"}, - } - - def __init__( - self, *, workspace_id: Optional[str] = None, link_connection_name: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword workspace_id: Synapse link workspace id. - :paramtype workspace_id: str - :keyword link_connection_name: Link connection name. - :paramtype link_connection_name: str - """ - super().__init__(**kwargs) - self.workspace_id = workspace_id - self.link_connection_name = link_connection_name - - -class SynapseLinkWorkspaceListResult(_serialization.Model): - """A list of synapselink workspaces. - - 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.SynapseLinkWorkspace] - :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": "[SynapseLinkWorkspace]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.SynapseLinkWorkspace"]] = None - self.next_link: Optional[str] = None - - -class SyncAgent(ProxyResource): - """An Azure SQL Database sync agent. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar name_properties_name: Name of the sync agent. - :vartype name_properties_name: str - :ivar sync_database_id: ARM resource id of the sync database in the sync agent. - :vartype sync_database_id: str - :ivar last_alive_time: Last alive time of the sync agent. - :vartype last_alive_time: ~datetime.datetime - :ivar state: State of the sync agent. Known values are: "Online", "Offline", and - "NeverConnected". - :vartype state: str or ~azure.mgmt.sql.models.SyncAgentState - :ivar is_up_to_date: If the sync agent version is up to date. - :vartype is_up_to_date: bool - :ivar expiry_time: Expiration time of the sync agent version. - :vartype expiry_time: ~datetime.datetime - :ivar version: Version of the sync agent. - :vartype version: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "name_properties_name": {"readonly": True}, - "last_alive_time": {"readonly": True}, - "state": {"readonly": True}, - "is_up_to_date": {"readonly": True}, - "expiry_time": {"readonly": True}, - "version": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "name_properties_name": {"key": "properties.name", "type": "str"}, - "sync_database_id": {"key": "properties.syncDatabaseId", "type": "str"}, - "last_alive_time": {"key": "properties.lastAliveTime", "type": "iso-8601"}, - "state": {"key": "properties.state", "type": "str"}, - "is_up_to_date": {"key": "properties.isUpToDate", "type": "bool"}, - "expiry_time": {"key": "properties.expiryTime", "type": "iso-8601"}, - "version": {"key": "properties.version", "type": "str"}, - } - - def __init__(self, *, sync_database_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword sync_database_id: ARM resource id of the sync database in the sync agent. - :paramtype sync_database_id: str - """ - super().__init__(**kwargs) - self.name_properties_name: Optional[str] = None - self.sync_database_id = sync_database_id - self.last_alive_time: Optional[datetime.datetime] = None - self.state: Optional[Union[str, "_models.SyncAgentState"]] = None - self.is_up_to_date: Optional[bool] = None - self.expiry_time: Optional[datetime.datetime] = None - self.version: Optional[str] = None - - -class SyncAgentKeyProperties(_serialization.Model): - """Properties of an Azure SQL Database sync agent key. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar sync_agent_key: Key of sync agent. - :vartype sync_agent_key: str - """ - - _validation = { - "sync_agent_key": {"readonly": True}, - } - - _attribute_map = { - "sync_agent_key": {"key": "syncAgentKey", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.sync_agent_key: Optional[str] = None - - -class SyncAgentLinkedDatabase(ProxyResource): - """An Azure SQL Database sync agent linked database. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar database_type: Type of the sync agent linked database. Known values are: - "AzureSqlDatabase" and "SqlServerDatabase". - :vartype database_type: str or ~azure.mgmt.sql.models.SyncMemberDbType - :ivar database_id: Id of the sync agent linked database. - :vartype database_id: str - :ivar description: Description of the sync agent linked database. - :vartype description: str - :ivar server_name: Server name of the sync agent linked database. - :vartype server_name: str - :ivar database_name: Database name of the sync agent linked database. - :vartype database_name: str - :ivar user_name: User name of the sync agent linked database. - :vartype user_name: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "database_type": {"readonly": True}, - "database_id": {"readonly": True}, - "description": {"readonly": True}, - "server_name": {"readonly": True}, - "database_name": {"readonly": True}, - "user_name": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "database_type": {"key": "properties.databaseType", "type": "str"}, - "database_id": {"key": "properties.databaseId", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "server_name": {"key": "properties.serverName", "type": "str"}, - "database_name": {"key": "properties.databaseName", "type": "str"}, - "user_name": {"key": "properties.userName", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.database_type: Optional[Union[str, "_models.SyncMemberDbType"]] = None - self.database_id: Optional[str] = None - self.description: Optional[str] = None - self.server_name: Optional[str] = None - self.database_name: Optional[str] = None - self.user_name: Optional[str] = None - - -class SyncAgentLinkedDatabaseListResult(_serialization.Model): - """A list of sync agent linked databases. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.SyncAgentLinkedDatabase] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SyncAgentLinkedDatabase]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.SyncAgentLinkedDatabase"]] = None - self.next_link: Optional[str] = None - - -class SyncAgentListResult(_serialization.Model): - """A list of sync agents. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.SyncAgent] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SyncAgent]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.SyncAgent"]] = None - self.next_link: Optional[str] = None - - -class SyncDatabaseIdListResult(_serialization.Model): - """A list of sync database ID properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.SyncDatabaseIdProperties] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SyncDatabaseIdProperties]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.SyncDatabaseIdProperties"]] = None - self.next_link: Optional[str] = None - - -class SyncDatabaseIdProperties(_serialization.Model): - """Properties of the sync database id. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: ARM resource id of sync database. - :vartype id: str - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - - -class SyncFullSchemaProperties(_serialization.Model): - """Properties of the database full schema. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tables: List of tables in the database full schema. - :vartype tables: list[~azure.mgmt.sql.models.SyncFullSchemaTable] - :ivar last_update_time: Last update time of the database schema. - :vartype last_update_time: ~datetime.datetime - """ - - _validation = { - "tables": {"readonly": True}, - "last_update_time": {"readonly": True}, - } - - _attribute_map = { - "tables": {"key": "tables", "type": "[SyncFullSchemaTable]"}, - "last_update_time": {"key": "lastUpdateTime", "type": "iso-8601"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.tables: Optional[list["_models.SyncFullSchemaTable"]] = None - self.last_update_time: Optional[datetime.datetime] = None - - -class SyncFullSchemaPropertiesListResult(_serialization.Model): - """A list of sync schema properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.SyncFullSchemaProperties] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SyncFullSchemaProperties]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.SyncFullSchemaProperties"]] = None - self.next_link: Optional[str] = None - - -class SyncFullSchemaTable(_serialization.Model): - """Properties of the table in the database full schema. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar columns: List of columns in the table of database full schema. - :vartype columns: list[~azure.mgmt.sql.models.SyncFullSchemaTableColumn] - :ivar error_id: Error id of the table. - :vartype error_id: str - :ivar has_error: If there is error in the table. - :vartype has_error: bool - :ivar name: Name of the table. - :vartype name: str - :ivar quoted_name: Quoted name of the table. - :vartype quoted_name: str - """ - - _validation = { - "columns": {"readonly": True}, - "error_id": {"readonly": True}, - "has_error": {"readonly": True}, - "name": {"readonly": True}, - "quoted_name": {"readonly": True}, - } - - _attribute_map = { - "columns": {"key": "columns", "type": "[SyncFullSchemaTableColumn]"}, - "error_id": {"key": "errorId", "type": "str"}, - "has_error": {"key": "hasError", "type": "bool"}, - "name": {"key": "name", "type": "str"}, - "quoted_name": {"key": "quotedName", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.columns: Optional[list["_models.SyncFullSchemaTableColumn"]] = None - self.error_id: Optional[str] = None - self.has_error: Optional[bool] = None - self.name: Optional[str] = None - self.quoted_name: Optional[str] = None - - -class SyncFullSchemaTableColumn(_serialization.Model): - """Properties of the column in the table of database full schema. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar data_size: Data size of the column. - :vartype data_size: str - :ivar data_type: Data type of the column. - :vartype data_type: str - :ivar error_id: Error id of the column. - :vartype error_id: str - :ivar has_error: If there is error in the table. - :vartype has_error: bool - :ivar is_primary_key: If it is the primary key of the table. - :vartype is_primary_key: bool - :ivar name: Name of the column. - :vartype name: str - :ivar quoted_name: Quoted name of the column. - :vartype quoted_name: str - """ - - _validation = { - "data_size": {"readonly": True}, - "data_type": {"readonly": True}, - "error_id": {"readonly": True}, - "has_error": {"readonly": True}, - "is_primary_key": {"readonly": True}, - "name": {"readonly": True}, - "quoted_name": {"readonly": True}, - } - - _attribute_map = { - "data_size": {"key": "dataSize", "type": "str"}, - "data_type": {"key": "dataType", "type": "str"}, - "error_id": {"key": "errorId", "type": "str"}, - "has_error": {"key": "hasError", "type": "bool"}, - "is_primary_key": {"key": "isPrimaryKey", "type": "bool"}, - "name": {"key": "name", "type": "str"}, - "quoted_name": {"key": "quotedName", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.data_size: Optional[str] = None - self.data_type: Optional[str] = None - self.error_id: Optional[str] = None - self.has_error: Optional[bool] = None - self.is_primary_key: Optional[bool] = None - self.name: Optional[str] = None - self.quoted_name: Optional[str] = None - - -class SyncGroup(ProxyResource): - """An Azure SQL Database sync group. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar sku: The name and capacity of the SKU. - :vartype sku: ~azure.mgmt.sql.models.Sku - :ivar interval: Sync interval of the sync group. - :vartype interval: int - :ivar last_sync_time: Last sync time of the sync group. - :vartype last_sync_time: ~datetime.datetime - :ivar conflict_resolution_policy: Conflict resolution policy of the sync group. Known values - are: "HubWin" and "MemberWin". - :vartype conflict_resolution_policy: str or ~azure.mgmt.sql.models.SyncConflictResolutionPolicy - :ivar sync_database_id: ARM resource id of the sync database in the sync group. - :vartype sync_database_id: str - :ivar hub_database_user_name: User name for the sync group hub database credential. - :vartype hub_database_user_name: str - :ivar hub_database_password: Password for the sync group hub database credential. - :vartype hub_database_password: str - :ivar sync_state: Sync state of the sync group. Known values are: "NotReady", "Error", - "Warning", "Progressing", and "Good". - :vartype sync_state: str or ~azure.mgmt.sql.models.SyncGroupState - :ivar schema: Sync schema of the sync group. - :vartype schema: ~azure.mgmt.sql.models.SyncGroupSchema - :ivar enable_conflict_logging: If conflict logging is enabled. - :vartype enable_conflict_logging: bool - :ivar conflict_logging_retention_in_days: Conflict logging retention period. - :vartype conflict_logging_retention_in_days: int - :ivar use_private_link_connection: If use private link connection is enabled. - :vartype use_private_link_connection: bool - :ivar private_endpoint_name: Private endpoint name of the sync group if use private link - connection is enabled. - :vartype private_endpoint_name: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "last_sync_time": {"readonly": True}, - "sync_state": {"readonly": True}, - "private_endpoint_name": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "sku": {"key": "sku", "type": "Sku"}, - "interval": {"key": "properties.interval", "type": "int"}, - "last_sync_time": {"key": "properties.lastSyncTime", "type": "iso-8601"}, - "conflict_resolution_policy": {"key": "properties.conflictResolutionPolicy", "type": "str"}, - "sync_database_id": {"key": "properties.syncDatabaseId", "type": "str"}, - "hub_database_user_name": {"key": "properties.hubDatabaseUserName", "type": "str"}, - "hub_database_password": {"key": "properties.hubDatabasePassword", "type": "str"}, - "sync_state": {"key": "properties.syncState", "type": "str"}, - "schema": {"key": "properties.schema", "type": "SyncGroupSchema"}, - "enable_conflict_logging": {"key": "properties.enableConflictLogging", "type": "bool"}, - "conflict_logging_retention_in_days": {"key": "properties.conflictLoggingRetentionInDays", "type": "int"}, - "use_private_link_connection": {"key": "properties.usePrivateLinkConnection", "type": "bool"}, - "private_endpoint_name": {"key": "properties.privateEndpointName", "type": "str"}, - } - - def __init__( - self, - *, - sku: Optional["_models.Sku"] = None, - interval: Optional[int] = None, - conflict_resolution_policy: Optional[Union[str, "_models.SyncConflictResolutionPolicy"]] = None, - sync_database_id: Optional[str] = None, - hub_database_user_name: Optional[str] = None, - hub_database_password: Optional[str] = None, - schema: Optional["_models.SyncGroupSchema"] = None, - enable_conflict_logging: Optional[bool] = None, - conflict_logging_retention_in_days: Optional[int] = None, - use_private_link_connection: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword sku: The name and capacity of the SKU. - :paramtype sku: ~azure.mgmt.sql.models.Sku - :keyword interval: Sync interval of the sync group. - :paramtype interval: int - :keyword conflict_resolution_policy: Conflict resolution policy of the sync group. Known values - are: "HubWin" and "MemberWin". - :paramtype conflict_resolution_policy: str or - ~azure.mgmt.sql.models.SyncConflictResolutionPolicy - :keyword sync_database_id: ARM resource id of the sync database in the sync group. - :paramtype sync_database_id: str - :keyword hub_database_user_name: User name for the sync group hub database credential. - :paramtype hub_database_user_name: str - :keyword hub_database_password: Password for the sync group hub database credential. - :paramtype hub_database_password: str - :keyword schema: Sync schema of the sync group. - :paramtype schema: ~azure.mgmt.sql.models.SyncGroupSchema - :keyword enable_conflict_logging: If conflict logging is enabled. - :paramtype enable_conflict_logging: bool - :keyword conflict_logging_retention_in_days: Conflict logging retention period. - :paramtype conflict_logging_retention_in_days: int - :keyword use_private_link_connection: If use private link connection is enabled. - :paramtype use_private_link_connection: bool - """ - super().__init__(**kwargs) - self.sku = sku - self.interval = interval - self.last_sync_time: Optional[datetime.datetime] = None - self.conflict_resolution_policy = conflict_resolution_policy - self.sync_database_id = sync_database_id - self.hub_database_user_name = hub_database_user_name - self.hub_database_password = hub_database_password - self.sync_state: Optional[Union[str, "_models.SyncGroupState"]] = None - self.schema = schema - self.enable_conflict_logging = enable_conflict_logging - self.conflict_logging_retention_in_days = conflict_logging_retention_in_days - self.use_private_link_connection = use_private_link_connection - self.private_endpoint_name: Optional[str] = None - - -class SyncGroupListResult(_serialization.Model): - """A list of sync groups. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.SyncGroup] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SyncGroup]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.SyncGroup"]] = None - self.next_link: Optional[str] = None - - -class SyncGroupLogListResult(_serialization.Model): - """A list of sync group log properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.SyncGroupLogProperties] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SyncGroupLogProperties]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.SyncGroupLogProperties"]] = None - self.next_link: Optional[str] = None - - -class SyncGroupLogProperties(_serialization.Model): - """Properties of an Azure SQL Database sync group log. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar timestamp: Timestamp of the sync group log. - :vartype timestamp: ~datetime.datetime - :ivar type: Type of the sync group log. Known values are: "All", "Error", "Warning", and - "Success". - :vartype type: str or ~azure.mgmt.sql.models.SyncGroupLogType - :ivar source: Source of the sync group log. - :vartype source: str - :ivar details: Details of the sync group log. - :vartype details: str - :ivar tracing_id: TracingId of the sync group log. - :vartype tracing_id: str - :ivar operation_status: OperationStatus of the sync group log. - :vartype operation_status: str - """ - - _validation = { - "timestamp": {"readonly": True}, - "type": {"readonly": True}, - "source": {"readonly": True}, - "details": {"readonly": True}, - "tracing_id": {"readonly": True}, - "operation_status": {"readonly": True}, - } - - _attribute_map = { - "timestamp": {"key": "timestamp", "type": "iso-8601"}, - "type": {"key": "type", "type": "str"}, - "source": {"key": "source", "type": "str"}, - "details": {"key": "details", "type": "str"}, - "tracing_id": {"key": "tracingId", "type": "str"}, - "operation_status": {"key": "operationStatus", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.timestamp: Optional[datetime.datetime] = None - self.type: Optional[Union[str, "_models.SyncGroupLogType"]] = None - self.source: Optional[str] = None - self.details: Optional[str] = None - self.tracing_id: Optional[str] = None - self.operation_status: Optional[str] = None - - -class SyncGroupSchema(_serialization.Model): - """Properties of sync group schema. - - :ivar tables: List of tables in sync group schema. - :vartype tables: list[~azure.mgmt.sql.models.SyncGroupSchemaTable] - :ivar master_sync_member_name: Name of master sync member where the schema is from. - :vartype master_sync_member_name: str - """ - - _attribute_map = { - "tables": {"key": "tables", "type": "[SyncGroupSchemaTable]"}, - "master_sync_member_name": {"key": "masterSyncMemberName", "type": "str"}, - } - - def __init__( - self, - *, - tables: Optional[list["_models.SyncGroupSchemaTable"]] = None, - master_sync_member_name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword tables: List of tables in sync group schema. - :paramtype tables: list[~azure.mgmt.sql.models.SyncGroupSchemaTable] - :keyword master_sync_member_name: Name of master sync member where the schema is from. - :paramtype master_sync_member_name: str - """ - super().__init__(**kwargs) - self.tables = tables - self.master_sync_member_name = master_sync_member_name - - -class SyncGroupSchemaTable(_serialization.Model): - """Properties of table in sync group schema. - - :ivar columns: List of columns in sync group schema. - :vartype columns: list[~azure.mgmt.sql.models.SyncGroupSchemaTableColumn] - :ivar quoted_name: Quoted name of sync group schema table. - :vartype quoted_name: str - """ - - _attribute_map = { - "columns": {"key": "columns", "type": "[SyncGroupSchemaTableColumn]"}, - "quoted_name": {"key": "quotedName", "type": "str"}, - } - - def __init__( - self, - *, - columns: Optional[list["_models.SyncGroupSchemaTableColumn"]] = None, - quoted_name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword columns: List of columns in sync group schema. - :paramtype columns: list[~azure.mgmt.sql.models.SyncGroupSchemaTableColumn] - :keyword quoted_name: Quoted name of sync group schema table. - :paramtype quoted_name: str - """ - super().__init__(**kwargs) - self.columns = columns - self.quoted_name = quoted_name - - -class SyncGroupSchemaTableColumn(_serialization.Model): - """Properties of column in sync group table. - - :ivar quoted_name: Quoted name of sync group table column. - :vartype quoted_name: str - :ivar data_size: Data size of the column. - :vartype data_size: str - :ivar data_type: Data type of the column. - :vartype data_type: str - """ - - _attribute_map = { - "quoted_name": {"key": "quotedName", "type": "str"}, - "data_size": {"key": "dataSize", "type": "str"}, - "data_type": {"key": "dataType", "type": "str"}, - } - - def __init__( - self, - *, - quoted_name: Optional[str] = None, - data_size: Optional[str] = None, - data_type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword quoted_name: Quoted name of sync group table column. - :paramtype quoted_name: str - :keyword data_size: Data size of the column. - :paramtype data_size: str - :keyword data_type: Data type of the column. - :paramtype data_type: str - """ - super().__init__(**kwargs) - self.quoted_name = quoted_name - self.data_size = data_size - self.data_type = data_type - - -class SyncMember(ProxyResource): - """An Azure SQL Database sync member. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar database_type: Database type of the sync member. Known values are: "AzureSqlDatabase" and - "SqlServerDatabase". - :vartype database_type: str or ~azure.mgmt.sql.models.SyncMemberDbType - :ivar sync_agent_id: ARM resource id of the sync agent in the sync member. - :vartype sync_agent_id: str - :ivar sql_server_database_id: SQL Server database id of the sync member. - :vartype sql_server_database_id: str - :ivar sync_member_azure_database_resource_id: ARM resource id of the sync member logical - database, for sync members in Azure. - :vartype sync_member_azure_database_resource_id: str - :ivar use_private_link_connection: Whether to use private link connection. - :vartype use_private_link_connection: bool - :ivar private_endpoint_name: Private endpoint name of the sync member if use private link - connection is enabled, for sync members in Azure. - :vartype private_endpoint_name: str - :ivar server_name: Server name of the member database in the sync member. - :vartype server_name: str - :ivar database_name: Database name of the member database in the sync member. - :vartype database_name: str - :ivar user_name: User name of the member database in the sync member. - :vartype user_name: str - :ivar password: Password of the member database in the sync member. - :vartype password: str - :ivar sync_direction: Sync direction of the sync member. Known values are: "Bidirectional", - "OneWayMemberToHub", and "OneWayHubToMember". - :vartype sync_direction: str or ~azure.mgmt.sql.models.SyncDirection - :ivar sync_state: Sync state of the sync member. Known values are: "SyncInProgress", - "SyncSucceeded", "SyncFailed", "DisabledTombstoneCleanup", "DisabledBackupRestore", - "SyncSucceededWithWarnings", "SyncCancelling", "SyncCancelled", "UnProvisioned", - "Provisioning", "Provisioned", "ProvisionFailed", "DeProvisioning", "DeProvisioned", - "DeProvisionFailed", "Reprovisioning", "ReprovisionFailed", and "UnReprovisioned". - :vartype sync_state: str or ~azure.mgmt.sql.models.SyncMemberState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "private_endpoint_name": {"readonly": True}, - "sync_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "database_type": {"key": "properties.databaseType", "type": "str"}, - "sync_agent_id": {"key": "properties.syncAgentId", "type": "str"}, - "sql_server_database_id": {"key": "properties.sqlServerDatabaseId", "type": "str"}, - "sync_member_azure_database_resource_id": { - "key": "properties.syncMemberAzureDatabaseResourceId", - "type": "str", - }, - "use_private_link_connection": {"key": "properties.usePrivateLinkConnection", "type": "bool"}, - "private_endpoint_name": {"key": "properties.privateEndpointName", "type": "str"}, - "server_name": {"key": "properties.serverName", "type": "str"}, - "database_name": {"key": "properties.databaseName", "type": "str"}, - "user_name": {"key": "properties.userName", "type": "str"}, - "password": {"key": "properties.password", "type": "str"}, - "sync_direction": {"key": "properties.syncDirection", "type": "str"}, - "sync_state": {"key": "properties.syncState", "type": "str"}, - } - - def __init__( - self, - *, - database_type: Optional[Union[str, "_models.SyncMemberDbType"]] = None, - sync_agent_id: Optional[str] = None, - sql_server_database_id: Optional[str] = None, - sync_member_azure_database_resource_id: Optional[str] = None, - use_private_link_connection: Optional[bool] = None, - server_name: Optional[str] = None, - database_name: Optional[str] = None, - user_name: Optional[str] = None, - password: Optional[str] = None, - sync_direction: Optional[Union[str, "_models.SyncDirection"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword database_type: Database type of the sync member. Known values are: "AzureSqlDatabase" - and "SqlServerDatabase". - :paramtype database_type: str or ~azure.mgmt.sql.models.SyncMemberDbType - :keyword sync_agent_id: ARM resource id of the sync agent in the sync member. - :paramtype sync_agent_id: str - :keyword sql_server_database_id: SQL Server database id of the sync member. - :paramtype sql_server_database_id: str - :keyword sync_member_azure_database_resource_id: ARM resource id of the sync member logical - database, for sync members in Azure. - :paramtype sync_member_azure_database_resource_id: str - :keyword use_private_link_connection: Whether to use private link connection. - :paramtype use_private_link_connection: bool - :keyword server_name: Server name of the member database in the sync member. - :paramtype server_name: str - :keyword database_name: Database name of the member database in the sync member. - :paramtype database_name: str - :keyword user_name: User name of the member database in the sync member. - :paramtype user_name: str - :keyword password: Password of the member database in the sync member. - :paramtype password: str - :keyword sync_direction: Sync direction of the sync member. Known values are: "Bidirectional", - "OneWayMemberToHub", and "OneWayHubToMember". - :paramtype sync_direction: str or ~azure.mgmt.sql.models.SyncDirection - """ - super().__init__(**kwargs) - self.database_type = database_type - self.sync_agent_id = sync_agent_id - self.sql_server_database_id = sql_server_database_id - self.sync_member_azure_database_resource_id = sync_member_azure_database_resource_id - self.use_private_link_connection = use_private_link_connection - self.private_endpoint_name: Optional[str] = None - self.server_name = server_name - self.database_name = database_name - self.user_name = user_name - self.password = password - self.sync_direction = sync_direction - self.sync_state: Optional[Union[str, "_models.SyncMemberState"]] = None - - -class SyncMemberListResult(_serialization.Model): - """A list of Azure SQL Database sync members. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.SyncMember] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SyncMember]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.SyncMember"]] = None - self.next_link: Optional[str] = None - - -class SystemData(_serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :ivar created_by: The identity that created the resource. - :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or ~azure.mgmt.sql.models.CreatedByType - :ivar created_at: The timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: The identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or ~azure.mgmt.sql.models.CreatedByType - :ivar last_modified_at: The timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: The identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or ~azure.mgmt.sql.models.CreatedByType - :keyword created_at: The timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: The identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or ~azure.mgmt.sql.models.CreatedByType - :keyword last_modified_at: The timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__(**kwargs) - self.created_by = created_by - self.created_by_type = created_by_type - self.created_at = created_at - self.last_modified_by = last_modified_by - self.last_modified_by_type = last_modified_by_type - self.last_modified_at = last_modified_at - - -class TdeCertificate(ProxyResource): - """A TDE certificate that can be uploaded into a server. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar private_blob: The base64 encoded certificate private blob. - :vartype private_blob: str - :ivar cert_password: The certificate password. - :vartype cert_password: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "private_blob": {"key": "properties.privateBlob", "type": "str"}, - "cert_password": {"key": "properties.certPassword", "type": "str"}, - } - - def __init__( - self, *, private_blob: Optional[str] = None, cert_password: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword private_blob: The base64 encoded certificate private blob. - :paramtype private_blob: str - :keyword cert_password: The certificate password. - :paramtype cert_password: str - """ - super().__init__(**kwargs) - self.private_blob = private_blob - self.cert_password = cert_password - - -class TimeZone(ProxyResource): - """Time Zone. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar time_zone_id: The time zone id. - :vartype time_zone_id: str - :ivar display_name: The time zone display name. - :vartype display_name: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "time_zone_id": {"readonly": True}, - "display_name": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "time_zone_id": {"key": "properties.timeZoneId", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.time_zone_id: Optional[str] = None - self.display_name: Optional[str] = None - - -class TimeZoneListResult(_serialization.Model): - """A list of time zones. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.TimeZone] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[TimeZone]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.TimeZone"]] = None - self.next_link: Optional[str] = None - - -class TopQueries(_serialization.Model): - """TopQueries. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar number_of_queries: Requested number of top queries. - :vartype number_of_queries: int - :ivar aggregation_function: Aggregation function used to calculate query metrics. - :vartype aggregation_function: str - :ivar observation_metric: Metric used to rank queries. - :vartype observation_metric: str - :ivar interval_type: Interval type (length). Known values are: "PT1H" and "P1D". - :vartype interval_type: str or ~azure.mgmt.sql.models.QueryTimeGrainType - :ivar start_time: The start time for the metric (ISO-8601 format). - :vartype start_time: str - :ivar end_time: The end time for the metric (ISO-8601 format). - :vartype end_time: str - :ivar queries: List of top resource consuming queries with appropriate metric data. - :vartype queries: list[~azure.mgmt.sql.models.QueryStatisticsProperties] - """ - - _validation = { - "number_of_queries": {"readonly": True}, - "aggregation_function": {"readonly": True}, - "observation_metric": {"readonly": True}, - "interval_type": {"readonly": True}, - "start_time": {"readonly": True}, - "end_time": {"readonly": True}, - } - - _attribute_map = { - "number_of_queries": {"key": "numberOfQueries", "type": "int"}, - "aggregation_function": {"key": "aggregationFunction", "type": "str"}, - "observation_metric": {"key": "observationMetric", "type": "str"}, - "interval_type": {"key": "intervalType", "type": "str"}, - "start_time": {"key": "startTime", "type": "str"}, - "end_time": {"key": "endTime", "type": "str"}, - "queries": {"key": "queries", "type": "[QueryStatisticsProperties]"}, - } - - def __init__(self, *, queries: Optional[list["_models.QueryStatisticsProperties"]] = None, **kwargs: Any) -> None: - """ - :keyword queries: List of top resource consuming queries with appropriate metric data. - :paramtype queries: list[~azure.mgmt.sql.models.QueryStatisticsProperties] - """ - super().__init__(**kwargs) - self.number_of_queries: Optional[int] = None - self.aggregation_function: Optional[str] = None - self.observation_metric: Optional[str] = None - self.interval_type: Optional[Union[str, "_models.QueryTimeGrainType"]] = None - self.start_time: Optional[str] = None - self.end_time: Optional[str] = None - self.queries = queries - - -class TopQueriesListResult(_serialization.Model): - """A list of top resource consuming queries on managed instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.TopQueries] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[TopQueries]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.TopQueries"]] = None - self.next_link: Optional[str] = None - - -class UpdateLongTermRetentionBackupParameters(_serialization.Model): - """Contains the information necessary to perform long term retention backup update operation. - - :ivar requested_backup_storage_redundancy: The storage redundancy type of the copied backup. - Known values are: "Geo", "Local", "Zone", and "GeoZone". - :vartype requested_backup_storage_redundancy: str or - ~azure.mgmt.sql.models.BackupStorageRedundancy - """ - - _attribute_map = { - "requested_backup_storage_redundancy": {"key": "properties.requestedBackupStorageRedundancy", "type": "str"}, - } - - def __init__( - self, - *, - requested_backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword requested_backup_storage_redundancy: The storage redundancy type of the copied backup. - Known values are: "Geo", "Local", "Zone", and "GeoZone". - :paramtype requested_backup_storage_redundancy: str or - ~azure.mgmt.sql.models.BackupStorageRedundancy - """ - super().__init__(**kwargs) - self.requested_backup_storage_redundancy = requested_backup_storage_redundancy - - -class UpdateVirtualClusterDnsServersOperation(ProxyResource): - """A refresh DNS servers operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar status: The status of the DNS refresh operation. Known values are: "Succeeded", "Failed", - and "InProgress". - :vartype status: str or ~azure.mgmt.sql.models.DNSRefreshOperationStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.status: Optional[Union[str, "_models.DNSRefreshOperationStatus"]] = None - - -class UpsertManagedServerOperationParameters(_serialization.Model): - """UpsertManagedServerOperationParameters. - - :ivar family: - :vartype family: str - :ivar tier: - :vartype tier: str - :ivar v_cores: - :vartype v_cores: int - :ivar storage_size_in_gb: - :vartype storage_size_in_gb: int - """ - - _attribute_map = { - "family": {"key": "family", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - "v_cores": {"key": "vCores", "type": "int"}, - "storage_size_in_gb": {"key": "storageSizeInGB", "type": "int"}, - } - - def __init__( - self, - *, - family: Optional[str] = None, - tier: Optional[str] = None, - v_cores: Optional[int] = None, - storage_size_in_gb: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword family: - :paramtype family: str - :keyword tier: - :paramtype tier: str - :keyword v_cores: - :paramtype v_cores: int - :keyword storage_size_in_gb: - :paramtype storage_size_in_gb: int - """ - super().__init__(**kwargs) - self.family = family - self.tier = tier - self.v_cores = v_cores - self.storage_size_in_gb = storage_size_in_gb - - -class UpsertManagedServerOperationStep(_serialization.Model): - """UpsertManagedServerOperationStep. - - :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 - """ - - _attribute_map = { - "order": {"key": "order", "type": "int"}, - "name": {"key": "name", "type": "str"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__( - self, - *, - order: Optional[int] = None, - name: Optional[str] = None, - status: Optional[Union[str, "_models.UpsertManagedServerOperationStepStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :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 - """ - super().__init__(**kwargs) - self.order = order - self.name = name - self.status = status - - -class Usage(_serialization.Model): - """ARM usage. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: ~azure.mgmt.sql.models.Name - :ivar type: Resource type. - :vartype type: str - :ivar unit: Usage unit. - :vartype unit: str - :ivar current_value: Usage current value. - :vartype current_value: int - :ivar limit: Usage limit. - :vartype limit: int - :ivar requested_limit: Usage requested limit. - :vartype requested_limit: int - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "unit": {"readonly": True}, - "current_value": {"readonly": True}, - "limit": {"readonly": True}, - "requested_limit": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "Name"}, - "type": {"key": "type", "type": "str"}, - "unit": {"key": "unit", "type": "str"}, - "current_value": {"key": "currentValue", "type": "int"}, - "limit": {"key": "limit", "type": "int"}, - "requested_limit": {"key": "requestedLimit", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.name: Optional["_models.Name"] = None - self.type: Optional[str] = None - self.unit: Optional[str] = None - self.current_value: Optional[int] = None - self.limit: Optional[int] = None - self.requested_limit: Optional[int] = None - - -class UsageListResult(_serialization.Model): - """A list of usages. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.Usage] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Usage]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.Usage"]] = None - self.next_link: Optional[str] = None - - -class UserIdentity(_serialization.Model): - """Azure Active Directory identity configuration for a resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The Azure Active Directory principal id. - :vartype principal_id: str - :ivar client_id: The Azure Active Directory client id. - :vartype client_id: str - """ - - _validation = { - "principal_id": {"readonly": True}, - "client_id": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "client_id": {"key": "clientId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.principal_id: Optional[str] = None - self.client_id: Optional[str] = None - - -class VaRule(_serialization.Model): - """SQL Vulnerability Assessment rule metadata details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar rule_id: SQL Vulnerability Assessment rule Id. - :vartype rule_id: str - :ivar severity: SQL Vulnerability Assessment rule severity. Known values are: "High", "Medium", - "Low", "Informational", and "Obsolete". - :vartype severity: str or ~azure.mgmt.sql.models.RuleSeverity - :ivar category: SQL Vulnerability Assessment rule category. - :vartype category: str - :ivar rule_type: SQL Vulnerability Assessment rule type. Known values are: "Binary", - "BaselineExpected", "PositiveList", and "NegativeList". - :vartype rule_type: str or ~azure.mgmt.sql.models.RuleType - :ivar title: SQL Vulnerability Assessment rule title. - :vartype title: str - :ivar description: SQL Vulnerability Assessment rule description. - :vartype description: str - :ivar rationale: SQL Vulnerability Assessment rule rationale. - :vartype rationale: str - :ivar query_check: SQL Vulnerability Assessment rule query details. - :vartype query_check: ~azure.mgmt.sql.models.QueryCheck - :ivar benchmark_references: SQL Vulnerability Assessment benchmark references. - :vartype benchmark_references: list[~azure.mgmt.sql.models.BenchmarkReference] - """ - - _validation = { - "rule_id": {"readonly": True}, - "severity": {"readonly": True}, - "category": {"readonly": True}, - "rule_type": {"readonly": True}, - "title": {"readonly": True}, - "description": {"readonly": True}, - "rationale": {"readonly": True}, - "query_check": {"readonly": True}, - "benchmark_references": {"readonly": True}, - } - - _attribute_map = { - "rule_id": {"key": "ruleId", "type": "str"}, - "severity": {"key": "severity", "type": "str"}, - "category": {"key": "category", "type": "str"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "title": {"key": "title", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "rationale": {"key": "rationale", "type": "str"}, - "query_check": {"key": "queryCheck", "type": "QueryCheck"}, - "benchmark_references": {"key": "benchmarkReferences", "type": "[BenchmarkReference]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.rule_id: Optional[str] = None - self.severity: Optional[Union[str, "_models.RuleSeverity"]] = None - self.category: Optional[str] = None - self.rule_type: Optional[Union[str, "_models.RuleType"]] = None - self.title: Optional[str] = None - self.description: Optional[str] = None - self.rationale: Optional[str] = None - self.query_check: Optional["_models.QueryCheck"] = None - self.benchmark_references: Optional[list["_models.BenchmarkReference"]] = None - - -class VirtualCluster(TrackedResource): - """An Azure SQL virtual cluster. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar subnet_id: Subnet resource ID for the virtual cluster. - :vartype subnet_id: str - :ivar version: Virtual cluster version. - :vartype version: str - :ivar child_resources: List of resources in this virtual cluster. - :vartype child_resources: list[str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - "subnet_id": {"readonly": True}, - "child_resources": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "subnet_id": {"key": "properties.subnetId", "type": "str"}, - "version": {"key": "properties.version", "type": "str"}, - "child_resources": {"key": "properties.childResources", "type": "[str]"}, - } - - def __init__( - self, *, location: str, tags: Optional[dict[str, str]] = None, version: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword version: Virtual cluster version. - :paramtype version: str - """ - super().__init__(location=location, tags=tags, **kwargs) - self.subnet_id: Optional[str] = None - self.version = version - self.child_resources: Optional[list[str]] = None - - -class VirtualClusterListResult(_serialization.Model): - """A list of virtual clusters. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.VirtualCluster] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualCluster]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.VirtualCluster"]] = None - self.next_link: Optional[str] = None - - -class VirtualClusterUpdate(_serialization.Model): - """An update request for virtual cluster. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar subnet_id: Subnet resource ID for the virtual cluster. - :vartype subnet_id: str - :ivar version: Virtual cluster version. - :vartype version: str - :ivar child_resources: List of resources in this virtual cluster. - :vartype child_resources: list[str] - """ - - _validation = { - "subnet_id": {"readonly": True}, - "child_resources": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "subnet_id": {"key": "properties.subnetId", "type": "str"}, - "version": {"key": "properties.version", "type": "str"}, - "child_resources": {"key": "properties.childResources", "type": "[str]"}, - } - - def __init__(self, *, tags: Optional[dict[str, str]] = None, version: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword version: Virtual cluster version. - :paramtype version: str - """ - super().__init__(**kwargs) - self.tags = tags - self.subnet_id: Optional[str] = None - self.version = version - self.child_resources: Optional[list[str]] = None - - -class VirtualNetworkRule(ProxyResource): - """A virtual network rule. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar virtual_network_subnet_id: The ARM resource id of the virtual network subnet. - :vartype virtual_network_subnet_id: str - :ivar ignore_missing_vnet_service_endpoint: Create firewall rule before the virtual network has - vnet service endpoint enabled. - :vartype ignore_missing_vnet_service_endpoint: bool - :ivar state: Virtual Network Rule State. Known values are: "Initializing", "InProgress", - "Ready", "Failed", "Deleting", and "Unknown". - :vartype state: str or ~azure.mgmt.sql.models.VirtualNetworkRuleState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "virtual_network_subnet_id": {"key": "properties.virtualNetworkSubnetId", "type": "str"}, - "ignore_missing_vnet_service_endpoint": {"key": "properties.ignoreMissingVnetServiceEndpoint", "type": "bool"}, - "state": {"key": "properties.state", "type": "str"}, - } - - def __init__( - self, - *, - virtual_network_subnet_id: Optional[str] = None, - ignore_missing_vnet_service_endpoint: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword virtual_network_subnet_id: The ARM resource id of the virtual network subnet. - :paramtype virtual_network_subnet_id: str - :keyword ignore_missing_vnet_service_endpoint: Create firewall rule before the virtual network - has vnet service endpoint enabled. - :paramtype ignore_missing_vnet_service_endpoint: bool - """ - super().__init__(**kwargs) - self.virtual_network_subnet_id = virtual_network_subnet_id - self.ignore_missing_vnet_service_endpoint = ignore_missing_vnet_service_endpoint - self.state: Optional[Union[str, "_models.VirtualNetworkRuleState"]] = None - - -class VirtualNetworkRuleListResult(_serialization.Model): - """A list of virtual network rules. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.VirtualNetworkRule] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VirtualNetworkRule]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.VirtualNetworkRule"]] = None - self.next_link: Optional[str] = None - - -class VulnerabilityAssessmentRecurringScansProperties(_serialization.Model): # pylint: disable=name-too-long - """Properties of a Vulnerability Assessment recurring scans. - - :ivar is_enabled: Recurring scans state. - :vartype is_enabled: bool - :ivar email_subscription_admins: Specifies that the schedule scan notification will be is sent - to the subscription administrators. - :vartype email_subscription_admins: bool - :ivar emails: Specifies an array of e-mail addresses to which the scan notification is sent. - :vartype emails: list[str] - """ - - _attribute_map = { - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "email_subscription_admins": {"key": "emailSubscriptionAdmins", "type": "bool"}, - "emails": {"key": "emails", "type": "[str]"}, - } - - def __init__( - self, - *, - is_enabled: Optional[bool] = None, - email_subscription_admins: bool = True, - emails: Optional[list[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword is_enabled: Recurring scans state. - :paramtype is_enabled: bool - :keyword email_subscription_admins: Specifies that the schedule scan notification will be is - sent to the subscription administrators. - :paramtype email_subscription_admins: bool - :keyword emails: Specifies an array of e-mail addresses to which the scan notification is sent. - :paramtype emails: list[str] - """ - super().__init__(**kwargs) - self.is_enabled = is_enabled - self.email_subscription_admins = email_subscription_admins - self.emails = emails - - -class VulnerabilityAssessmentScanError(_serialization.Model): - """Properties of a vulnerability assessment scan error. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code: Optional[str] = None - self.message: Optional[str] = None - - -class VulnerabilityAssessmentScanRecord(ProxyResource): - """A vulnerability assessment scan record. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar scan_id: The scan ID. - :vartype scan_id: str - :ivar trigger_type: The scan trigger type. Known values are: "OnDemand" and "Recurring". - :vartype trigger_type: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentScanTriggerType - :ivar state: The scan status. Known values are: "Passed", "Failed", "FailedToRun", and - "InProgress". - :vartype state: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentScanState - :ivar start_time: The scan start time (UTC). - :vartype start_time: ~datetime.datetime - :ivar end_time: The scan end time (UTC). - :vartype end_time: ~datetime.datetime - :ivar errors: The scan errors. - :vartype errors: list[~azure.mgmt.sql.models.VulnerabilityAssessmentScanError] - :ivar storage_container_path: The scan results storage container path. - :vartype storage_container_path: str - :ivar number_of_failed_security_checks: The number of failed security checks. - :vartype number_of_failed_security_checks: int - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "scan_id": {"readonly": True}, - "trigger_type": {"readonly": True}, - "state": {"readonly": True}, - "start_time": {"readonly": True}, - "end_time": {"readonly": True}, - "errors": {"readonly": True}, - "storage_container_path": {"readonly": True}, - "number_of_failed_security_checks": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "scan_id": {"key": "properties.scanId", "type": "str"}, - "trigger_type": {"key": "properties.triggerType", "type": "str"}, - "state": {"key": "properties.state", "type": "str"}, - "start_time": {"key": "properties.startTime", "type": "iso-8601"}, - "end_time": {"key": "properties.endTime", "type": "iso-8601"}, - "errors": {"key": "properties.errors", "type": "[VulnerabilityAssessmentScanError]"}, - "storage_container_path": {"key": "properties.storageContainerPath", "type": "str"}, - "number_of_failed_security_checks": {"key": "properties.numberOfFailedSecurityChecks", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.scan_id: Optional[str] = None - self.trigger_type: Optional[Union[str, "_models.VulnerabilityAssessmentScanTriggerType"]] = None - self.state: Optional[Union[str, "_models.VulnerabilityAssessmentScanState"]] = None - self.start_time: Optional[datetime.datetime] = None - self.end_time: Optional[datetime.datetime] = None - self.errors: Optional[list["_models.VulnerabilityAssessmentScanError"]] = None - self.storage_container_path: Optional[str] = None - self.number_of_failed_security_checks: Optional[int] = None - - -class VulnerabilityAssessmentScanRecordListResult(_serialization.Model): # pylint: disable=name-too-long - """A list of vulnerability assessment scan records. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecord] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[VulnerabilityAssessmentScanRecord]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.VulnerabilityAssessmentScanRecord"]] = None - self.next_link: Optional[str] = None - - -class WorkloadClassifier(ProxyResource): - """Workload classifier operations for a data warehouse. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar member_name: The workload classifier member name. - :vartype member_name: str - :ivar label: The workload classifier label. - :vartype label: str - :ivar context: The workload classifier context. - :vartype context: str - :ivar start_time: The workload classifier start time for classification. - :vartype start_time: str - :ivar end_time: The workload classifier end time for classification. - :vartype end_time: str - :ivar importance: The workload classifier importance. - :vartype importance: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "member_name": {"key": "properties.memberName", "type": "str"}, - "label": {"key": "properties.label", "type": "str"}, - "context": {"key": "properties.context", "type": "str"}, - "start_time": {"key": "properties.startTime", "type": "str"}, - "end_time": {"key": "properties.endTime", "type": "str"}, - "importance": {"key": "properties.importance", "type": "str"}, - } - - def __init__( - self, - *, - member_name: Optional[str] = None, - label: Optional[str] = None, - context: Optional[str] = None, - start_time: Optional[str] = None, - end_time: Optional[str] = None, - importance: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword member_name: The workload classifier member name. - :paramtype member_name: str - :keyword label: The workload classifier label. - :paramtype label: str - :keyword context: The workload classifier context. - :paramtype context: str - :keyword start_time: The workload classifier start time for classification. - :paramtype start_time: str - :keyword end_time: The workload classifier end time for classification. - :paramtype end_time: str - :keyword importance: The workload classifier importance. - :paramtype importance: str - """ - super().__init__(**kwargs) - self.member_name = member_name - self.label = label - self.context = context - self.start_time = start_time - self.end_time = end_time - self.importance = importance - - -class WorkloadClassifierListResult(_serialization.Model): - """A list of workload classifiers for a workload group. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.WorkloadClassifier] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[WorkloadClassifier]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.WorkloadClassifier"]] = None - self.next_link: Optional[str] = None - - -class WorkloadGroup(ProxyResource): - """Workload group operations for a data warehouse. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar min_resource_percent: The workload group minimum percentage resource. - :vartype min_resource_percent: int - :ivar max_resource_percent: The workload group cap percentage resource. - :vartype max_resource_percent: int - :ivar min_resource_percent_per_request: The workload group request minimum grant percentage. - :vartype min_resource_percent_per_request: float - :ivar max_resource_percent_per_request: The workload group request maximum grant percentage. - :vartype max_resource_percent_per_request: float - :ivar importance: The workload group importance level. - :vartype importance: str - :ivar query_execution_timeout: The workload group query execution timeout. - :vartype query_execution_timeout: int - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "min_resource_percent": {"key": "properties.minResourcePercent", "type": "int"}, - "max_resource_percent": {"key": "properties.maxResourcePercent", "type": "int"}, - "min_resource_percent_per_request": {"key": "properties.minResourcePercentPerRequest", "type": "float"}, - "max_resource_percent_per_request": {"key": "properties.maxResourcePercentPerRequest", "type": "float"}, - "importance": {"key": "properties.importance", "type": "str"}, - "query_execution_timeout": {"key": "properties.queryExecutionTimeout", "type": "int"}, - } - - def __init__( - self, - *, - min_resource_percent: Optional[int] = None, - max_resource_percent: Optional[int] = None, - min_resource_percent_per_request: Optional[float] = None, - max_resource_percent_per_request: Optional[float] = None, - importance: Optional[str] = None, - query_execution_timeout: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword min_resource_percent: The workload group minimum percentage resource. - :paramtype min_resource_percent: int - :keyword max_resource_percent: The workload group cap percentage resource. - :paramtype max_resource_percent: int - :keyword min_resource_percent_per_request: The workload group request minimum grant percentage. - :paramtype min_resource_percent_per_request: float - :keyword max_resource_percent_per_request: The workload group request maximum grant percentage. - :paramtype max_resource_percent_per_request: float - :keyword importance: The workload group importance level. - :paramtype importance: str - :keyword query_execution_timeout: The workload group query execution timeout. - :paramtype query_execution_timeout: int - """ - super().__init__(**kwargs) - self.min_resource_percent = min_resource_percent - self.max_resource_percent = max_resource_percent - self.min_resource_percent_per_request = min_resource_percent_per_request - self.max_resource_percent_per_request = max_resource_percent_per_request - self.importance = importance - self.query_execution_timeout = query_execution_timeout - - -class WorkloadGroupListResult(_serialization.Model): - """A list of workload groups. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.WorkloadGroup] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[WorkloadGroup]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.WorkloadGroup"]] = None - self.next_link: Optional[str] = None diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_patch.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_patch.py index f7dd32510333..87676c65a8f0 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_patch.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_patch.py @@ -1,14 +1,15 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): 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 88a49faa4a42..52d6388fc113 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -13,312 +12,308 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._data_masking_policies_operations import DataMaskingPoliciesOperations # type: ignore -from ._data_masking_rules_operations import DataMaskingRulesOperations # type: ignore -from ._geo_backup_policies_operations import GeoBackupPoliciesOperations # type: ignore -from ._databases_operations import DatabasesOperations # type: ignore -from ._elastic_pools_operations import ElasticPoolsOperations # type: ignore -from ._server_communication_links_operations import ServerCommunicationLinksOperations # type: ignore -from ._service_objectives_operations import ServiceObjectivesOperations # type: ignore -from ._elastic_pool_activities_operations import ElasticPoolActivitiesOperations # type: ignore -from ._elastic_pool_database_activities_operations import ElasticPoolDatabaseActivitiesOperations # type: ignore -from ._server_usages_operations import ServerUsagesOperations # type: ignore -from ._database_advisors_operations import DatabaseAdvisorsOperations # type: ignore -from ._database_automatic_tuning_operations import DatabaseAutomaticTuningOperations # type: ignore -from ._database_columns_operations import DatabaseColumnsOperations # type: ignore -from ._database_recommended_actions_operations import DatabaseRecommendedActionsOperations # type: ignore -from ._database_schemas_operations import DatabaseSchemasOperations # type: ignore -from ._database_security_alert_policies_operations import DatabaseSecurityAlertPoliciesOperations # type: ignore -from ._database_tables_operations import DatabaseTablesOperations # type: ignore -from ._database_vulnerability_assessment_rule_baselines_operations import DatabaseVulnerabilityAssessmentRuleBaselinesOperations # type: ignore -from ._database_vulnerability_assessments_operations import DatabaseVulnerabilityAssessmentsOperations # type: ignore -from ._database_vulnerability_assessment_scans_operations import DatabaseVulnerabilityAssessmentScansOperations # type: ignore -from ._data_warehouse_user_activities_operations import DataWarehouseUserActivitiesOperations # type: ignore -from ._deleted_servers_operations import DeletedServersOperations # type: ignore -from ._elastic_pool_operations_operations import ElasticPoolOperationsOperations # type: ignore -from ._encryption_protectors_operations import EncryptionProtectorsOperations # type: ignore -from ._firewall_rules_operations import FirewallRulesOperations # type: ignore -from ._job_agents_operations import JobAgentsOperations # type: ignore -from ._job_credentials_operations import JobCredentialsOperations # type: ignore -from ._job_executions_operations import JobExecutionsOperations # type: ignore -from ._job_private_endpoints_operations import JobPrivateEndpointsOperations # type: ignore -from ._jobs_operations import JobsOperations # type: ignore -from ._job_step_executions_operations import JobStepExecutionsOperations # type: ignore -from ._job_steps_operations import JobStepsOperations # type: ignore -from ._job_target_executions_operations import JobTargetExecutionsOperations # type: ignore -from ._job_target_groups_operations import JobTargetGroupsOperations # type: ignore -from ._job_versions_operations import JobVersionsOperations # type: ignore -from ._capabilities_operations import CapabilitiesOperations # type: ignore -from ._maintenance_window_options_operations import MaintenanceWindowOptionsOperations # type: ignore -from ._maintenance_windows_operations import MaintenanceWindowsOperations # type: ignore -from ._managed_backup_short_term_retention_policies_operations import ManagedBackupShortTermRetentionPoliciesOperations # type: ignore -from ._managed_database_columns_operations import ManagedDatabaseColumnsOperations # type: ignore -from ._managed_database_queries_operations import ManagedDatabaseQueriesOperations # type: ignore -from ._managed_database_schemas_operations import ManagedDatabaseSchemasOperations # type: ignore -from ._managed_database_security_alert_policies_operations import ManagedDatabaseSecurityAlertPoliciesOperations # type: ignore -from ._managed_database_security_events_operations import ManagedDatabaseSecurityEventsOperations # type: ignore -from ._managed_database_tables_operations import ManagedDatabaseTablesOperations # type: ignore -from ._managed_database_transparent_data_encryption_operations import ManagedDatabaseTransparentDataEncryptionOperations # type: ignore -from ._managed_database_vulnerability_assessment_rule_baselines_operations import ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations # type: ignore -from ._managed_database_vulnerability_assessments_operations import ManagedDatabaseVulnerabilityAssessmentsOperations # type: ignore -from ._managed_database_vulnerability_assessment_scans_operations import ManagedDatabaseVulnerabilityAssessmentScansOperations # type: ignore -from ._managed_instance_administrators_operations import ManagedInstanceAdministratorsOperations # type: ignore -from ._managed_instance_azure_ad_only_authentications_operations import ManagedInstanceAzureADOnlyAuthenticationsOperations # type: ignore -from ._managed_instance_encryption_protectors_operations import ManagedInstanceEncryptionProtectorsOperations # type: ignore -from ._managed_instance_keys_operations import ManagedInstanceKeysOperations # type: ignore -from ._managed_instance_long_term_retention_policies_operations import ManagedInstanceLongTermRetentionPoliciesOperations # type: ignore -from ._managed_instance_operations_operations import ManagedInstanceOperationsOperations # type: ignore -from ._managed_instance_private_endpoint_connections_operations import ManagedInstancePrivateEndpointConnectionsOperations # type: ignore -from ._managed_instance_private_link_resources_operations import ManagedInstancePrivateLinkResourcesOperations # type: ignore -from ._managed_instance_tde_certificates_operations import ManagedInstanceTdeCertificatesOperations # type: ignore -from ._managed_instance_vulnerability_assessments_operations import ManagedInstanceVulnerabilityAssessmentsOperations # type: ignore -from ._managed_restorable_dropped_database_backup_short_term_retention_policies_operations import ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations # type: ignore -from ._managed_server_security_alert_policies_operations import ManagedServerSecurityAlertPoliciesOperations # type: ignore from ._operations import Operations # type: ignore -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore -from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore -from ._recoverable_managed_databases_operations import RecoverableManagedDatabasesOperations # type: ignore -from ._restore_points_operations import RestorePointsOperations # type: ignore -from ._server_advisors_operations import ServerAdvisorsOperations # type: ignore -from ._server_automatic_tuning_operations import ServerAutomaticTuningOperations # type: ignore -from ._server_azure_ad_administrators_operations import ServerAzureADAdministratorsOperations # type: ignore -from ._server_azure_ad_only_authentications_operations import ServerAzureADOnlyAuthenticationsOperations # type: ignore -from ._server_dev_ops_audit_settings_operations import ServerDevOpsAuditSettingsOperations # type: ignore -from ._server_dns_aliases_operations import ServerDnsAliasesOperations # type: ignore -from ._server_keys_operations import ServerKeysOperations # type: ignore -from ._server_operations_operations import ServerOperationsOperations # type: ignore -from ._server_security_alert_policies_operations import ServerSecurityAlertPoliciesOperations # type: ignore -from ._server_trust_groups_operations import ServerTrustGroupsOperations # type: ignore -from ._server_vulnerability_assessments_operations import ServerVulnerabilityAssessmentsOperations # type: ignore -from ._sql_agent_operations import SqlAgentOperations # type: ignore -from ._subscription_usages_operations import SubscriptionUsagesOperations # type: ignore -from ._sync_agents_operations import SyncAgentsOperations # type: ignore -from ._sync_groups_operations import SyncGroupsOperations # type: ignore -from ._sync_members_operations import SyncMembersOperations # type: ignore -from ._tde_certificates_operations import TdeCertificatesOperations # type: ignore -from ._time_zones_operations import TimeZonesOperations # type: ignore -from ._virtual_network_rules_operations import VirtualNetworkRulesOperations # type: ignore -from ._workload_classifiers_operations import WorkloadClassifiersOperations # type: ignore -from ._workload_groups_operations import WorkloadGroupsOperations # type: ignore -from ._backup_short_term_retention_policies_operations import BackupShortTermRetentionPoliciesOperations # type: ignore -from ._database_extensions_operations import DatabaseExtensionsOperations # type: ignore -from ._database_usages_operations import DatabaseUsagesOperations # type: ignore -from ._ledger_digest_uploads_operations import LedgerDigestUploadsOperations # type: ignore -from ._outbound_firewall_rules_operations import OutboundFirewallRulesOperations # type: ignore -from ._usages_operations import UsagesOperations # type: ignore -from ._long_term_retention_managed_instance_backups_operations import LongTermRetentionManagedInstanceBackupsOperations # type: ignore -from ._restorable_dropped_managed_databases_operations import RestorableDroppedManagedDatabasesOperations # type: ignore -from ._server_connection_policies_operations import ServerConnectionPoliciesOperations # type: ignore -from ._server_trust_certificates_operations import ServerTrustCertificatesOperations # type: ignore -from ._endpoint_certificates_operations import EndpointCertificatesOperations # type: ignore -from ._managed_database_sensitivity_labels_operations import ManagedDatabaseSensitivityLabelsOperations # type: ignore -from ._managed_database_recommended_sensitivity_labels_operations import ManagedDatabaseRecommendedSensitivityLabelsOperations # type: ignore -from ._sensitivity_labels_operations import SensitivityLabelsOperations # type: ignore -from ._recommended_sensitivity_labels_operations import RecommendedSensitivityLabelsOperations # type: ignore -from ._server_blob_auditing_policies_operations import ServerBlobAuditingPoliciesOperations # type: ignore -from ._database_blob_auditing_policies_operations import DatabaseBlobAuditingPoliciesOperations # type: ignore -from ._extended_database_blob_auditing_policies_operations import ExtendedDatabaseBlobAuditingPoliciesOperations # type: ignore -from ._extended_server_blob_auditing_policies_operations import ExtendedServerBlobAuditingPoliciesOperations # type: ignore -from ._database_advanced_threat_protection_settings_operations import DatabaseAdvancedThreatProtectionSettingsOperations # type: ignore -from ._server_advanced_threat_protection_settings_operations import ServerAdvancedThreatProtectionSettingsOperations # type: ignore -from ._managed_server_dns_aliases_operations import ManagedServerDnsAliasesOperations # type: ignore -from ._managed_database_advanced_threat_protection_settings_operations import ManagedDatabaseAdvancedThreatProtectionSettingsOperations # type: ignore -from ._managed_instance_advanced_threat_protection_settings_operations import ManagedInstanceAdvancedThreatProtectionSettingsOperations # type: ignore -from ._managed_database_move_operations_operations import ManagedDatabaseMoveOperationsOperations # type: ignore -from ._managed_instance_dtcs_operations import ManagedInstanceDtcsOperations # type: ignore -from ._synapse_link_workspaces_operations import SynapseLinkWorkspacesOperations # type: ignore -from ._virtual_clusters_operations import VirtualClustersOperations # type: ignore -from ._instance_failover_groups_operations import InstanceFailoverGroupsOperations # type: ignore -from ._managed_database_restore_details_operations import ManagedDatabaseRestoreDetailsOperations # type: ignore -from ._database_encryption_protectors_operations import DatabaseEncryptionProtectorsOperations # type: ignore -from ._managed_databases_operations import ManagedDatabasesOperations # type: ignore -from ._managed_ledger_digest_uploads_operations import ManagedLedgerDigestUploadsOperations # type: ignore -from ._recoverable_databases_operations import RecoverableDatabasesOperations # type: ignore -from ._restorable_dropped_databases_operations import RestorableDroppedDatabasesOperations # type: ignore -from ._server_configuration_options_operations import ServerConfigurationOptionsOperations # type: ignore -from ._start_stop_managed_instance_schedules_operations import StartStopManagedInstanceSchedulesOperations # type: ignore -from ._transparent_data_encryptions_operations import TransparentDataEncryptionsOperations # type: ignore -from ._ipv6_firewall_rules_operations import IPv6FirewallRulesOperations # type: ignore -from ._sql_vulnerability_assessment_baseline_operations import SqlVulnerabilityAssessmentBaselineOperations # type: ignore -from ._sql_vulnerability_assessment_baselines_operations import SqlVulnerabilityAssessmentBaselinesOperations # type: ignore -from ._sql_vulnerability_assessment_execute_scan_operations import SqlVulnerabilityAssessmentExecuteScanOperations # type: ignore -from ._sql_vulnerability_assessment_rule_baseline_operations import SqlVulnerabilityAssessmentRuleBaselineOperations # type: ignore -from ._sql_vulnerability_assessment_rule_baselines_operations import SqlVulnerabilityAssessmentRuleBaselinesOperations # type: ignore -from ._sql_vulnerability_assessment_scan_result_operations import SqlVulnerabilityAssessmentScanResultOperations # type: ignore -from ._sql_vulnerability_assessment_scans_operations import SqlVulnerabilityAssessmentScansOperations # type: ignore -from ._sql_vulnerability_assessments_settings_operations import SqlVulnerabilityAssessmentsSettingsOperations # type: ignore -from ._sql_vulnerability_assessments_operations import SqlVulnerabilityAssessmentsOperations # type: ignore -from ._database_sql_vulnerability_assessment_baselines_operations import DatabaseSqlVulnerabilityAssessmentBaselinesOperations # type: ignore -from ._database_sql_vulnerability_assessment_execute_scan_operations import DatabaseSqlVulnerabilityAssessmentExecuteScanOperations # type: ignore -from ._database_sql_vulnerability_assessment_rule_baselines_operations import DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations # type: ignore -from ._database_sql_vulnerability_assessment_scan_result_operations import DatabaseSqlVulnerabilityAssessmentScanResultOperations # type: ignore -from ._database_sql_vulnerability_assessment_scans_operations import DatabaseSqlVulnerabilityAssessmentScansOperations # type: ignore -from ._database_sql_vulnerability_assessments_settings_operations import DatabaseSqlVulnerabilityAssessmentsSettingsOperations # type: ignore -from ._failover_groups_operations import FailoverGroupsOperations # type: ignore -from ._instance_pools_operations import InstancePoolsOperations # type: ignore -from ._managed_instances_operations import ManagedInstancesOperations # type: ignore -from ._replication_links_operations import ReplicationLinksOperations # type: ignore -from ._distributed_availability_groups_operations import DistributedAvailabilityGroupsOperations # type: ignore -from ._servers_operations import ServersOperations # type: ignore -from ._long_term_retention_backups_operations import LongTermRetentionBackupsOperations # type: ignore -from ._long_term_retention_policies_operations import LongTermRetentionPoliciesOperations # type: ignore -from ._database_operations_operations import DatabaseOperationsOperations # type: ignore +from ._operations import BackupShortTermRetentionPoliciesOperations # type: ignore +from ._operations import DatabaseColumnsOperations # type: ignore +from ._operations import RestorePointsOperations # type: ignore +from ._operations import SensitivityLabelsOperations # type: ignore +from ._operations import DatabasesOperations # type: ignore +from ._operations import FirewallRulesOperations # type: ignore +from ._operations import ReplicationLinksOperations # type: ignore +from ._operations import ServersOperations # type: ignore +from ._operations import ServerBlobAuditingPoliciesOperations # type: ignore +from ._operations import DatabaseBlobAuditingPoliciesOperations # type: ignore +from ._operations import ExtendedDatabaseBlobAuditingPoliciesOperations # type: ignore +from ._operations import ExtendedServerBlobAuditingPoliciesOperations # type: ignore +from ._operations import ServerAdvisorsOperations # type: ignore +from ._operations import ManagedDatabaseColumnsOperations # type: ignore +from ._operations import DatabaseTablesOperations # type: ignore +from ._operations import ManagedDatabaseTablesOperations # type: ignore +from ._operations import DatabaseSchemasOperations # type: ignore +from ._operations import ManagedDatabaseSchemasOperations # type: ignore +from ._operations import DatabaseSecurityAlertPoliciesOperations # type: ignore +from ._operations import SqlVulnerabilityAssessmentBaselineOperations # type: ignore +from ._operations import SqlVulnerabilityAssessmentsOperations # type: ignore +from ._operations import SqlVulnerabilityAssessmentsSettingsOperations # type: ignore +from ._operations import DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations # type: ignore +from ._operations import SqlVulnerabilityAssessmentRuleBaselineOperations # type: ignore +from ._operations import DatabaseSqlVulnerabilityAssessmentScanResultOperations # type: ignore +from ._operations import SqlVulnerabilityAssessmentScanResultOperations # type: ignore +from ._operations import SqlVulnerabilityAssessmentScansOperations # type: ignore +from ._operations import DatabaseVulnerabilityAssessmentRuleBaselinesOperations # type: ignore +from ._operations import ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations # type: ignore +from ._operations import DatabaseVulnerabilityAssessmentsOperations # type: ignore +from ._operations import ManagedDatabaseVulnerabilityAssessmentsOperations # type: ignore +from ._operations import ManagedDatabaseVulnerabilityAssessmentScansOperations # type: ignore +from ._operations import DataMaskingPoliciesOperations # type: ignore +from ._operations import DeletedServersOperations # type: ignore +from ._operations import DistributedAvailabilityGroupsOperations # type: ignore +from ._operations import ManagedDatabasesOperations # type: ignore +from ._operations import ServerTrustGroupsOperations # type: ignore +from ._operations import ManagedInstancesOperations # type: ignore +from ._operations import ElasticPoolsOperations # type: ignore +from ._operations import EncryptionProtectorsOperations # type: ignore +from ._operations import EndpointCertificatesOperations # type: ignore +from ._operations import FailoverGroupsOperations # type: ignore +from ._operations import GeoBackupPoliciesOperations # type: ignore +from ._operations import InstanceFailoverGroupsOperations # type: ignore +from ._operations import InstancePoolOperationsOperations # type: ignore +from ._operations import InstancePoolsOperations # type: ignore +from ._operations import IPv6FirewallRulesOperations # type: ignore +from ._operations import JobExecutionsOperations # type: ignore +from ._operations import JobAgentsOperations # type: ignore +from ._operations import JobCredentialsOperations # type: ignore +from ._operations import JobStepExecutionsOperations # type: ignore +from ._operations import JobTargetExecutionsOperations # type: ignore +from ._operations import JobsOperations # type: ignore +from ._operations import JobPrivateEndpointsOperations # type: ignore +from ._operations import JobStepsOperations # type: ignore +from ._operations import JobTargetGroupsOperations # type: ignore +from ._operations import JobVersionsOperations # type: ignore +from ._operations import LongTermRetentionBackupsOperations # type: ignore +from ._operations import LongTermRetentionManagedInstanceBackupsOperations # type: ignore +from ._operations import LongTermRetentionPoliciesOperations # type: ignore +from ._operations import ManagedBackupShortTermRetentionPoliciesOperations # type: ignore +from ._operations import ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations # type: ignore +from ._operations import ManagedDatabaseSecurityAlertPoliciesOperations # type: ignore +from ._operations import ManagedInstanceAdministratorsOperations # type: ignore +from ._operations import ManagedInstanceAzureADOnlyAuthenticationsOperations # type: ignore +from ._operations import ManagedInstanceDtcsOperations # type: ignore +from ._operations import ManagedInstanceEncryptionProtectorsOperations # type: ignore +from ._operations import ManagedInstanceKeysOperations # type: ignore +from ._operations import ManagedInstanceLongTermRetentionPoliciesOperations # type: ignore +from ._operations import ManagedInstanceOperationsOperations # type: ignore +from ._operations import ManagedInstancePrivateEndpointConnectionsOperations # type: ignore +from ._operations import ManagedInstanceVulnerabilityAssessmentsOperations # type: ignore +from ._operations import ManagedServerDnsAliasesOperations # type: ignore +from ._operations import ManagedServerSecurityAlertPoliciesOperations # type: ignore +from ._operations import NetworkSecurityPerimeterConfigurationsOperations # type: ignore +from ._operations import OutboundFirewallRulesOperations # type: ignore +from ._operations import PrivateEndpointConnectionsOperations # type: ignore +from ._operations import PrivateLinkResourcesOperations # type: ignore +from ._operations import RecoverableDatabasesOperations # type: ignore +from ._operations import RecoverableManagedDatabasesOperations # type: ignore +from ._operations import RestorableDroppedDatabasesOperations # type: ignore +from ._operations import RestorableDroppedManagedDatabasesOperations # type: ignore +from ._operations import ServerAzureADAdministratorsOperations # type: ignore +from ._operations import ServerAzureADOnlyAuthenticationsOperations # type: ignore +from ._operations import ServerConfigurationOptionsOperations # type: ignore +from ._operations import ServerConnectionPoliciesOperations # type: ignore +from ._operations import ServerDevOpsAuditSettingsOperations # type: ignore +from ._operations import ServerDnsAliasesOperations # type: ignore +from ._operations import ServerKeysOperations # type: ignore +from ._operations import ServerSecurityAlertPoliciesOperations # type: ignore +from ._operations import ServerTrustCertificatesOperations # type: ignore +from ._operations import ServerVulnerabilityAssessmentsOperations # type: ignore +from ._operations import StartStopManagedInstanceSchedulesOperations # type: ignore +from ._operations import SubscriptionUsagesOperations # type: ignore +from ._operations import SyncAgentsOperations # type: ignore +from ._operations import SyncGroupsOperations # type: ignore +from ._operations import SyncMembersOperations # type: ignore +from ._operations import TimeZonesOperations # type: ignore +from ._operations import VirtualClustersOperations # type: ignore +from ._operations import VirtualNetworkRulesOperations # type: ignore +from ._operations import WorkloadClassifiersOperations # type: ignore +from ._operations import WorkloadGroupsOperations # type: ignore +from ._operations import ManagedDatabaseSensitivityLabelsOperations # type: ignore +from ._operations import DatabaseEncryptionProtectorsOperations # type: ignore +from ._operations import DatabaseOperationsOperations # type: ignore +from ._operations import DatabaseUsagesOperations # type: ignore +from ._operations import RecommendedSensitivityLabelsOperations # type: ignore +from ._operations import SynapseLinkWorkspacesOperations # type: ignore +from ._operations import ServerOperationsOperations # type: ignore +from ._operations import ServerUsagesOperations # type: ignore +from ._operations import TdeCertificatesOperations # type: ignore +from ._operations import DatabaseAdvancedThreatProtectionSettingsOperations # type: ignore +from ._operations import DatabaseAdvisorsOperations # type: ignore +from ._operations import DatabaseAutomaticTuningOperations # type: ignore +from ._operations import DatabaseExtensionsOperations # type: ignore +from ._operations import DatabaseRecommendedActionsOperations # type: ignore +from ._operations import DatabaseSqlVulnerabilityAssessmentBaselinesOperations # type: ignore +from ._operations import SqlVulnerabilityAssessmentBaselinesOperations # type: ignore +from ._operations import DatabaseSqlVulnerabilityAssessmentsSettingsOperations # type: ignore +from ._operations import DatabaseSqlVulnerabilityAssessmentExecuteScanOperations # type: ignore +from ._operations import SqlVulnerabilityAssessmentExecuteScanOperations # type: ignore +from ._operations import SqlVulnerabilityAssessmentRuleBaselinesOperations # type: ignore +from ._operations import DatabaseSqlVulnerabilityAssessmentScansOperations # type: ignore +from ._operations import DatabaseVulnerabilityAssessmentScansOperations # type: ignore +from ._operations import DataMaskingRulesOperations # type: ignore +from ._operations import DataWarehouseUserActivitiesOperations # type: ignore +from ._operations import ManagedDatabaseSecurityEventsOperations # type: ignore +from ._operations import ManagedDatabaseRecommendedSensitivityLabelsOperations # type: ignore +from ._operations import ManagedInstanceTdeCertificatesOperations # type: ignore +from ._operations import ElasticPoolOperationsOperations # type: ignore +from ._operations import UsagesOperations # type: ignore +from ._operations import LedgerDigestUploadsOperations # type: ignore +from ._operations import MaintenanceWindowOptionsOperations # type: ignore +from ._operations import MaintenanceWindowsOperations # type: ignore +from ._operations import ManagedDatabaseAdvancedThreatProtectionSettingsOperations # type: ignore +from ._operations import ManagedDatabaseMoveOperationsOperations # type: ignore +from ._operations import ManagedDatabaseQueriesOperations # type: ignore +from ._operations import ManagedDatabaseRestoreDetailsOperations # type: ignore +from ._operations import ManagedDatabaseTransparentDataEncryptionOperations # type: ignore +from ._operations import ManagedInstanceAdvancedThreatProtectionSettingsOperations # type: ignore +from ._operations import ManagedInstancePrivateLinkResourcesOperations # type: ignore +from ._operations import ManagedLedgerDigestUploadsOperations # type: ignore +from ._operations import ServerAdvancedThreatProtectionSettingsOperations # type: ignore +from ._operations import ServerAutomaticTuningOperations # type: ignore +from ._operations import SqlAgentOperations # type: ignore +from ._operations import TransparentDataEncryptionsOperations # type: ignore +from ._operations import CapabilitiesOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ - "DataMaskingPoliciesOperations", - "DataMaskingRulesOperations", - "GeoBackupPoliciesOperations", - "DatabasesOperations", - "ElasticPoolsOperations", - "ServerCommunicationLinksOperations", - "ServiceObjectivesOperations", - "ElasticPoolActivitiesOperations", - "ElasticPoolDatabaseActivitiesOperations", - "ServerUsagesOperations", - "DatabaseAdvisorsOperations", - "DatabaseAutomaticTuningOperations", + "Operations", + "BackupShortTermRetentionPoliciesOperations", "DatabaseColumnsOperations", - "DatabaseRecommendedActionsOperations", + "RestorePointsOperations", + "SensitivityLabelsOperations", + "DatabasesOperations", + "FirewallRulesOperations", + "ReplicationLinksOperations", + "ServersOperations", + "ServerBlobAuditingPoliciesOperations", + "DatabaseBlobAuditingPoliciesOperations", + "ExtendedDatabaseBlobAuditingPoliciesOperations", + "ExtendedServerBlobAuditingPoliciesOperations", + "ServerAdvisorsOperations", + "ManagedDatabaseColumnsOperations", + "DatabaseTablesOperations", + "ManagedDatabaseTablesOperations", "DatabaseSchemasOperations", + "ManagedDatabaseSchemasOperations", "DatabaseSecurityAlertPoliciesOperations", - "DatabaseTablesOperations", + "SqlVulnerabilityAssessmentBaselineOperations", + "SqlVulnerabilityAssessmentsOperations", + "SqlVulnerabilityAssessmentsSettingsOperations", + "DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations", + "SqlVulnerabilityAssessmentRuleBaselineOperations", + "DatabaseSqlVulnerabilityAssessmentScanResultOperations", + "SqlVulnerabilityAssessmentScanResultOperations", + "SqlVulnerabilityAssessmentScansOperations", "DatabaseVulnerabilityAssessmentRuleBaselinesOperations", + "ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations", "DatabaseVulnerabilityAssessmentsOperations", - "DatabaseVulnerabilityAssessmentScansOperations", - "DataWarehouseUserActivitiesOperations", + "ManagedDatabaseVulnerabilityAssessmentsOperations", + "ManagedDatabaseVulnerabilityAssessmentScansOperations", + "DataMaskingPoliciesOperations", "DeletedServersOperations", - "ElasticPoolOperationsOperations", + "DistributedAvailabilityGroupsOperations", + "ManagedDatabasesOperations", + "ServerTrustGroupsOperations", + "ManagedInstancesOperations", + "ElasticPoolsOperations", "EncryptionProtectorsOperations", - "FirewallRulesOperations", + "EndpointCertificatesOperations", + "FailoverGroupsOperations", + "GeoBackupPoliciesOperations", + "InstanceFailoverGroupsOperations", + "InstancePoolOperationsOperations", + "InstancePoolsOperations", + "IPv6FirewallRulesOperations", + "JobExecutionsOperations", "JobAgentsOperations", "JobCredentialsOperations", - "JobExecutionsOperations", - "JobPrivateEndpointsOperations", - "JobsOperations", "JobStepExecutionsOperations", - "JobStepsOperations", "JobTargetExecutionsOperations", + "JobsOperations", + "JobPrivateEndpointsOperations", + "JobStepsOperations", "JobTargetGroupsOperations", "JobVersionsOperations", - "CapabilitiesOperations", - "MaintenanceWindowOptionsOperations", - "MaintenanceWindowsOperations", + "LongTermRetentionBackupsOperations", + "LongTermRetentionManagedInstanceBackupsOperations", + "LongTermRetentionPoliciesOperations", "ManagedBackupShortTermRetentionPoliciesOperations", - "ManagedDatabaseColumnsOperations", - "ManagedDatabaseQueriesOperations", - "ManagedDatabaseSchemasOperations", + "ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations", "ManagedDatabaseSecurityAlertPoliciesOperations", - "ManagedDatabaseSecurityEventsOperations", - "ManagedDatabaseTablesOperations", - "ManagedDatabaseTransparentDataEncryptionOperations", - "ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations", - "ManagedDatabaseVulnerabilityAssessmentsOperations", - "ManagedDatabaseVulnerabilityAssessmentScansOperations", "ManagedInstanceAdministratorsOperations", "ManagedInstanceAzureADOnlyAuthenticationsOperations", + "ManagedInstanceDtcsOperations", "ManagedInstanceEncryptionProtectorsOperations", "ManagedInstanceKeysOperations", "ManagedInstanceLongTermRetentionPoliciesOperations", "ManagedInstanceOperationsOperations", "ManagedInstancePrivateEndpointConnectionsOperations", - "ManagedInstancePrivateLinkResourcesOperations", - "ManagedInstanceTdeCertificatesOperations", "ManagedInstanceVulnerabilityAssessmentsOperations", - "ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations", + "ManagedServerDnsAliasesOperations", "ManagedServerSecurityAlertPoliciesOperations", - "Operations", + "NetworkSecurityPerimeterConfigurationsOperations", + "OutboundFirewallRulesOperations", "PrivateEndpointConnectionsOperations", "PrivateLinkResourcesOperations", + "RecoverableDatabasesOperations", "RecoverableManagedDatabasesOperations", - "RestorePointsOperations", - "ServerAdvisorsOperations", - "ServerAutomaticTuningOperations", + "RestorableDroppedDatabasesOperations", + "RestorableDroppedManagedDatabasesOperations", "ServerAzureADAdministratorsOperations", "ServerAzureADOnlyAuthenticationsOperations", + "ServerConfigurationOptionsOperations", + "ServerConnectionPoliciesOperations", "ServerDevOpsAuditSettingsOperations", "ServerDnsAliasesOperations", "ServerKeysOperations", - "ServerOperationsOperations", "ServerSecurityAlertPoliciesOperations", - "ServerTrustGroupsOperations", + "ServerTrustCertificatesOperations", "ServerVulnerabilityAssessmentsOperations", - "SqlAgentOperations", + "StartStopManagedInstanceSchedulesOperations", "SubscriptionUsagesOperations", "SyncAgentsOperations", "SyncGroupsOperations", "SyncMembersOperations", - "TdeCertificatesOperations", "TimeZonesOperations", + "VirtualClustersOperations", "VirtualNetworkRulesOperations", "WorkloadClassifiersOperations", "WorkloadGroupsOperations", - "BackupShortTermRetentionPoliciesOperations", - "DatabaseExtensionsOperations", - "DatabaseUsagesOperations", - "LedgerDigestUploadsOperations", - "OutboundFirewallRulesOperations", - "UsagesOperations", - "LongTermRetentionManagedInstanceBackupsOperations", - "RestorableDroppedManagedDatabasesOperations", - "ServerConnectionPoliciesOperations", - "ServerTrustCertificatesOperations", - "EndpointCertificatesOperations", "ManagedDatabaseSensitivityLabelsOperations", - "ManagedDatabaseRecommendedSensitivityLabelsOperations", - "SensitivityLabelsOperations", + "DatabaseEncryptionProtectorsOperations", + "DatabaseOperationsOperations", + "DatabaseUsagesOperations", "RecommendedSensitivityLabelsOperations", - "ServerBlobAuditingPoliciesOperations", - "DatabaseBlobAuditingPoliciesOperations", - "ExtendedDatabaseBlobAuditingPoliciesOperations", - "ExtendedServerBlobAuditingPoliciesOperations", + "SynapseLinkWorkspacesOperations", + "ServerOperationsOperations", + "ServerUsagesOperations", + "TdeCertificatesOperations", "DatabaseAdvancedThreatProtectionSettingsOperations", - "ServerAdvancedThreatProtectionSettingsOperations", - "ManagedServerDnsAliasesOperations", + "DatabaseAdvisorsOperations", + "DatabaseAutomaticTuningOperations", + "DatabaseExtensionsOperations", + "DatabaseRecommendedActionsOperations", + "DatabaseSqlVulnerabilityAssessmentBaselinesOperations", + "SqlVulnerabilityAssessmentBaselinesOperations", + "DatabaseSqlVulnerabilityAssessmentsSettingsOperations", + "DatabaseSqlVulnerabilityAssessmentExecuteScanOperations", + "SqlVulnerabilityAssessmentExecuteScanOperations", + "SqlVulnerabilityAssessmentRuleBaselinesOperations", + "DatabaseSqlVulnerabilityAssessmentScansOperations", + "DatabaseVulnerabilityAssessmentScansOperations", + "DataMaskingRulesOperations", + "DataWarehouseUserActivitiesOperations", + "ManagedDatabaseSecurityEventsOperations", + "ManagedDatabaseRecommendedSensitivityLabelsOperations", + "ManagedInstanceTdeCertificatesOperations", + "ElasticPoolOperationsOperations", + "UsagesOperations", + "LedgerDigestUploadsOperations", + "MaintenanceWindowOptionsOperations", + "MaintenanceWindowsOperations", "ManagedDatabaseAdvancedThreatProtectionSettingsOperations", - "ManagedInstanceAdvancedThreatProtectionSettingsOperations", "ManagedDatabaseMoveOperationsOperations", - "ManagedInstanceDtcsOperations", - "SynapseLinkWorkspacesOperations", - "VirtualClustersOperations", - "InstanceFailoverGroupsOperations", + "ManagedDatabaseQueriesOperations", "ManagedDatabaseRestoreDetailsOperations", - "DatabaseEncryptionProtectorsOperations", - "ManagedDatabasesOperations", + "ManagedDatabaseTransparentDataEncryptionOperations", + "ManagedInstanceAdvancedThreatProtectionSettingsOperations", + "ManagedInstancePrivateLinkResourcesOperations", "ManagedLedgerDigestUploadsOperations", - "RecoverableDatabasesOperations", - "RestorableDroppedDatabasesOperations", - "ServerConfigurationOptionsOperations", - "StartStopManagedInstanceSchedulesOperations", + "ServerAdvancedThreatProtectionSettingsOperations", + "ServerAutomaticTuningOperations", + "SqlAgentOperations", "TransparentDataEncryptionsOperations", - "IPv6FirewallRulesOperations", - "SqlVulnerabilityAssessmentBaselineOperations", - "SqlVulnerabilityAssessmentBaselinesOperations", - "SqlVulnerabilityAssessmentExecuteScanOperations", - "SqlVulnerabilityAssessmentRuleBaselineOperations", - "SqlVulnerabilityAssessmentRuleBaselinesOperations", - "SqlVulnerabilityAssessmentScanResultOperations", - "SqlVulnerabilityAssessmentScansOperations", - "SqlVulnerabilityAssessmentsSettingsOperations", - "SqlVulnerabilityAssessmentsOperations", - "DatabaseSqlVulnerabilityAssessmentBaselinesOperations", - "DatabaseSqlVulnerabilityAssessmentExecuteScanOperations", - "DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations", - "DatabaseSqlVulnerabilityAssessmentScanResultOperations", - "DatabaseSqlVulnerabilityAssessmentScansOperations", - "DatabaseSqlVulnerabilityAssessmentsSettingsOperations", - "FailoverGroupsOperations", - "InstancePoolsOperations", - "ManagedInstancesOperations", - "ReplicationLinksOperations", - "DistributedAvailabilityGroupsOperations", - "ServersOperations", - "LongTermRetentionBackupsOperations", - "LongTermRetentionPoliciesOperations", - "DatabaseOperationsOperations", + "CapabilitiesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _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 deleted file mode 100644 index d38ec0910181..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_backup_short_term_retention_policies_operations.py +++ /dev/null @@ -1,790 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - server_name: str, - database_name: str, - policy_name: Union[str, _models.ShortTermRetentionPolicyName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "policyName": _SERIALIZER.url("policy_name", policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - server_name: str, - database_name: str, - policy_name: Union[str, _models.ShortTermRetentionPolicyName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - 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/{policyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "policyName": _SERIALIZER.url("policy_name", policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, - server_name: str, - database_name: str, - policy_name: Union[str, _models.ShortTermRetentionPolicyName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - 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/{policyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "policyName": _SERIALIZER.url("policy_name", policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class BackupShortTermRetentionPoliciesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`backup_short_term_retention_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - policy_name: Union[str, _models.ShortTermRetentionPolicyName], - **kwargs: Any - ) -> _models.BackupShortTermRetentionPolicy: - """Gets a database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ShortTermRetentionPolicyName - :return: BackupShortTermRetentionPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.BackupShortTermRetentionPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[_models.BackupShortTermRetentionPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - policy_name=policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("BackupShortTermRetentionPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - policy_name: Union[str, _models.ShortTermRetentionPolicyName], - parameters: Union[_models.BackupShortTermRetentionPolicy, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2021-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "BackupShortTermRetentionPolicy") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - policy_name=policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - policy_name: Union[str, _models.ShortTermRetentionPolicyName], - parameters: _models.BackupShortTermRetentionPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.BackupShortTermRetentionPolicy]: - """Updates a database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Required. - :type parameters: ~azure.mgmt.sql.models.BackupShortTermRetentionPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either BackupShortTermRetentionPolicy or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - policy_name: Union[str, _models.ShortTermRetentionPolicyName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.BackupShortTermRetentionPolicy]: - """Updates a database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either BackupShortTermRetentionPolicy or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - policy_name: Union[str, _models.ShortTermRetentionPolicyName], - parameters: Union[_models.BackupShortTermRetentionPolicy, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.BackupShortTermRetentionPolicy]: - """Updates a database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Is either a - BackupShortTermRetentionPolicy type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.BackupShortTermRetentionPolicy or IO[bytes] - :return: An instance of LROPoller that returns either BackupShortTermRetentionPolicy or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.BackupShortTermRetentionPolicy] = 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, - policy_name=policy_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("BackupShortTermRetentionPolicy", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.BackupShortTermRetentionPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.BackupShortTermRetentionPolicy]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - policy_name: Union[str, _models.ShortTermRetentionPolicyName], - parameters: Union[_models.BackupShortTermRetentionPolicy, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2021-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "BackupShortTermRetentionPolicy") - - _request = build_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - policy_name=policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - policy_name: Union[str, _models.ShortTermRetentionPolicyName], - parameters: _models.BackupShortTermRetentionPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.BackupShortTermRetentionPolicy]: - """Updates a database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Required. - :type parameters: ~azure.mgmt.sql.models.BackupShortTermRetentionPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either BackupShortTermRetentionPolicy or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - policy_name: Union[str, _models.ShortTermRetentionPolicyName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.BackupShortTermRetentionPolicy]: - """Updates a database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either BackupShortTermRetentionPolicy or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - policy_name: Union[str, _models.ShortTermRetentionPolicyName], - parameters: Union[_models.BackupShortTermRetentionPolicy, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.BackupShortTermRetentionPolicy]: - """Updates a database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Is either a - BackupShortTermRetentionPolicy type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.BackupShortTermRetentionPolicy or IO[bytes] - :return: An instance of LROPoller that returns either BackupShortTermRetentionPolicy or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.BackupShortTermRetentionPolicy] = 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( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - policy_name=policy_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("BackupShortTermRetentionPolicy", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.BackupShortTermRetentionPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.BackupShortTermRetentionPolicy]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either BackupShortTermRetentionPolicy or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[_models.BackupShortTermRetentionPolicyListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index cfaf947055c2..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_capabilities_operations.py +++ /dev/null @@ -1,149 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar, Union - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_location_request( - location_name: str, - subscription_id: str, - *, - include: Optional[Union[str, _models.CapabilityGroup]] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/capabilities" - ) - path_format_arguments = { - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if include is not None: - _params["include"] = _SERIALIZER.query("include", include, "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 CapabilitiesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`capabilities` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_location( - self, location_name: str, include: Optional[Union[str, _models.CapabilityGroup]] = None, **kwargs: Any - ) -> _models.LocationCapabilities: - """Gets the subscription capabilities available for the specified location. - - :param location_name: The location name whose capabilities are retrieved. Required. - :type location_name: str - :param include: If specified, restricts the response to only include the selected item. Known - values are: "supportedEditions", "supportedElasticPoolEditions", - "supportedManagedInstanceVersions", "supportedInstancePoolEditions", and - "supportedManagedInstanceEditions". Default value is None. - :type include: str or ~azure.mgmt.sql.models.CapabilityGroup - :return: LocationCapabilities or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.LocationCapabilities - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.LocationCapabilities] = kwargs.pop("cls", None) - - _request = build_list_by_location_request( - location_name=location_name, - subscription_id=self._config.subscription_id, - include=include, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("LocationCapabilities", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_data_masking_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_data_masking_policies_operations.py deleted file mode 100644 index 610c19ff8886..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_data_masking_policies_operations.py +++ /dev/null @@ -1,332 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Literal, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - 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}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "dataMaskingPolicyName": _SERIALIZER.url("data_masking_policy_name", data_masking_policy_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") - 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}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "dataMaskingPolicyName": _SERIALIZER.url("data_masking_policy_name", data_masking_policy_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class DataMaskingPoliciesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`data_masking_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: _models.DataMaskingPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataMaskingPolicy: - """Creates or updates a database data masking policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 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 - :return: DataMaskingPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DataMaskingPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataMaskingPolicy: - """Creates or updates a database data masking policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: Parameters for creating or updating a data masking policy. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DataMaskingPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DataMaskingPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.DataMaskingPolicy, IO[bytes]], - **kwargs: Any - ) -> _models.DataMaskingPolicy: - """Creates or updates a database data masking policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: Parameters for creating or updating a data masking policy. Is either a - DataMaskingPolicy type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DataMaskingPolicy or IO[bytes] - :return: DataMaskingPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DataMaskingPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - 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)) - cls: ClsType[_models.DataMaskingPolicy] = 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, "DataMaskingPolicy") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - data_masking_policy_name=data_masking_policy_name, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: DataMaskingPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DataMaskingPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") - cls: ClsType[_models.DataMaskingPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - data_masking_policy_name=data_masking_policy_name, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_data_masking_rules_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_data_masking_rules_operations.py deleted file mode 100644 index eaae868c4112..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_data_masking_rules_operations.py +++ /dev/null @@ -1,366 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Literal, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_or_update_request( - resource_group_name: str, - server_name: str, - database_name: str, - data_masking_rule_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") - 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/{dataMaskingRuleName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "dataMaskingPolicyName": _SERIALIZER.url("data_masking_policy_name", data_masking_policy_name, "str"), - "dataMaskingRuleName": _SERIALIZER.url("data_masking_rule_name", data_masking_rule_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") - 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", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "dataMaskingPolicyName": _SERIALIZER.url("data_masking_policy_name", data_masking_policy_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class DataMaskingRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`data_masking_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - data_masking_rule_name: str, - parameters: _models.DataMaskingRule, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataMaskingRule: - """Creates or updates a database data masking rule. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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_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. - Required. - :type parameters: ~azure.mgmt.sql.models.DataMaskingRule - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DataMaskingRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DataMaskingRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - data_masking_rule_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DataMaskingRule: - """Creates or updates a database data masking rule. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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_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. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DataMaskingRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DataMaskingRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - data_masking_rule_name: str, - parameters: Union[_models.DataMaskingRule, IO[bytes]], - **kwargs: Any - ) -> _models.DataMaskingRule: - """Creates or updates a database data masking rule. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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_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[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DataMaskingRule or IO[bytes] - :return: DataMaskingRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DataMaskingRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - 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)) - cls: ClsType[_models.DataMaskingRule] = 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, "DataMaskingRule") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_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, - headers=_headers, - params=_params, - ) - _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) - - deserialized = self._deserialize("DataMaskingRule", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either DataMaskingRule or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DataMaskingRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") - cls: ClsType[_models.DataMaskingRuleListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 8f9302294e79..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_data_warehouse_user_activities_operations.py +++ /dev/null @@ -1,275 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar, Union - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataWarehouseUserActivities/{dataWarehouseUserActivityName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "dataWarehouseUserActivityName": _SERIALIZER.url( - "data_warehouse_user_activity_name", data_warehouse_user_activity_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_database_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _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 DataWarehouseUserActivitiesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`data_warehouse_user_activities` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - :return: DataWarehouseUserActivities or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DataWarehouseUserActivities - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DataWarehouseUserActivities] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - data_warehouse_user_activity_name=data_warehouse_user_activity_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> ItemPaged["_models.DataWarehouseUserActivities"]: - """List the user activities of a data warehouse which includes running and suspended queries. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :return: An iterator like instance of either DataWarehouseUserActivities or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DataWarehouseUserActivities] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DataWarehouseUserActivitiesListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DataWarehouseUserActivitiesListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) 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 deleted file mode 100644 index 010ddf395886..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_advanced_threat_protection_settings_operations.py +++ /dev/null @@ -1,475 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_database_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advancedThreatProtectionSettings", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _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, - database_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-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}/advancedThreatProtectionSettings/{advancedThreatProtectionName}", - ) - 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"), - "advancedThreatProtectionName": _SERIALIZER.url( - "advanced_threat_protection_name", advanced_threat_protection_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - server_name: str, - database_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-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}/advancedThreatProtectionSettings/{advancedThreatProtectionName}", - ) - 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"), - "advancedThreatProtectionName": _SERIALIZER.url( - "advanced_threat_protection_name", advanced_threat_protection_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -class DatabaseAdvancedThreatProtectionSettingsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`database_advanced_threat_protection_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.DatabaseAdvancedThreatProtection"]: - """Gets a list of database's Advanced Threat Protection states. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :return: An iterator like instance of either DatabaseAdvancedThreatProtection or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseAdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.DatabaseAdvancedThreatProtectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseAdvancedThreatProtectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - database_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - **kwargs: Any - ) -> _models.DatabaseAdvancedThreatProtection: - """Gets a database's Advanced Threat Protection state. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. - "Default" Required. - :type advanced_threat_protection_name: str or - ~azure.mgmt.sql.models.AdvancedThreatProtectionName - :return: DatabaseAdvancedThreatProtection or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseAdvancedThreatProtection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.DatabaseAdvancedThreatProtection] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - advanced_threat_protection_name=advanced_threat_protection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("DatabaseAdvancedThreatProtection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: _models.DatabaseAdvancedThreatProtection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseAdvancedThreatProtection: - """Creates or updates a database's Advanced Threat Protection state. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. - "Default" Required. - :type advanced_threat_protection_name: str or - ~azure.mgmt.sql.models.AdvancedThreatProtectionName - :param parameters: The database Advanced Threat Protection state. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseAdvancedThreatProtection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseAdvancedThreatProtection or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseAdvancedThreatProtection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseAdvancedThreatProtection: - """Creates or updates a database's Advanced Threat Protection state. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. - "Default" Required. - :type advanced_threat_protection_name: str or - ~azure.mgmt.sql.models.AdvancedThreatProtectionName - :param parameters: The database Advanced Threat Protection state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseAdvancedThreatProtection or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseAdvancedThreatProtection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: Union[_models.DatabaseAdvancedThreatProtection, IO[bytes]], - **kwargs: Any - ) -> _models.DatabaseAdvancedThreatProtection: - """Creates or updates a database's Advanced Threat Protection state. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. - "Default" Required. - :type advanced_threat_protection_name: str or - ~azure.mgmt.sql.models.AdvancedThreatProtectionName - :param parameters: The database Advanced Threat Protection state. Is either a - DatabaseAdvancedThreatProtection type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseAdvancedThreatProtection or IO[bytes] - :return: DatabaseAdvancedThreatProtection or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseAdvancedThreatProtection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2021-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DatabaseAdvancedThreatProtection") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - advanced_threat_protection_name=advanced_threat_protection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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) - - deserialized = self._deserialize("DatabaseAdvancedThreatProtection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 43e20585d205..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_advisors_operations.py +++ /dev/null @@ -1,457 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_database_request( - resource_group_name: str, - server_name: str, - database_name: str, - subscription_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advisors", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "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_get_request( - resource_group_name: str, - server_name: str, - database_name: str, - advisor_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advisors/{advisorName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "advisorName": _SERIALIZER.url("advisor_name", advisor_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, - server_name: str, - database_name: str, - advisor_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advisors/{advisorName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "advisorName": _SERIALIZER.url("advisor_name", advisor_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -class DatabaseAdvisorsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`database_advisors` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - expand: Optional[str] = None, - **kwargs: Any - ) -> List[_models.Advisor]: - """Gets a list of database advisors. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 expand: The child resources to include in the response. Default value is None. - :type expand: str - :return: list of Advisor or the result of cls(response) - :rtype: list[~azure.mgmt.sql.models.Advisor] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[List[_models.Advisor]] = 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, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("[Advisor]", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get( - self, resource_group_name: str, server_name: str, database_name: str, advisor_name: str, **kwargs: Any - ) -> _models.Advisor: - """Gets a database advisor. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 advisor_name: The name of the Database Advisor. Required. - :type advisor_name: str - :return: Advisor or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.Advisor - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.Advisor] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - advisor_name=advisor_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("Advisor", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - advisor_name: str, - parameters: _models.Advisor, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Advisor: - """Updates a database advisor. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 advisor_name: The name of the Database Advisor. Required. - :type advisor_name: str - :param parameters: The requested advisor resource state. Required. - :type parameters: ~azure.mgmt.sql.models.Advisor - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Advisor or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.Advisor - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - advisor_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Advisor: - """Updates a database advisor. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 advisor_name: The name of the Database Advisor. Required. - :type advisor_name: str - :param parameters: The requested advisor resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: Advisor or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.Advisor - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - advisor_name: str, - parameters: Union[_models.Advisor, IO[bytes]], - **kwargs: Any - ) -> _models.Advisor: - """Updates a database advisor. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 advisor_name: The name of the Database Advisor. Required. - :type advisor_name: str - :param parameters: The requested advisor resource state. Is either a Advisor type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.Advisor or IO[bytes] - :return: Advisor or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.Advisor - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "Advisor") - - _request = build_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - advisor_name=advisor_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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("Advisor", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_automatic_tuning_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_automatic_tuning_operations.py deleted file mode 100644 index f60aa2a29394..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_automatic_tuning_operations.py +++ /dev/null @@ -1,324 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/automaticTuning/current", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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}/automaticTuning/current", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -class DatabaseAutomaticTuningOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`database_automatic_tuning` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, **kwargs: Any - ) -> _models.DatabaseAutomaticTuning: - """Gets a database's automatic tuning. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :return: DatabaseAutomaticTuning or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseAutomaticTuning - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseAutomaticTuning] = 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, - headers=_headers, - params=_params, - ) - _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("DatabaseAutomaticTuning", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: _models.DatabaseAutomaticTuning, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseAutomaticTuning: - """Update automatic tuning properties for target database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The requested automatic tuning resource state. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseAutomaticTuning - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseAutomaticTuning or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseAutomaticTuning - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseAutomaticTuning: - """Update automatic tuning properties for target database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The requested automatic tuning resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseAutomaticTuning or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseAutomaticTuning - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.DatabaseAutomaticTuning, IO[bytes]], - **kwargs: Any - ) -> _models.DatabaseAutomaticTuning: - """Update automatic tuning properties for target database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The requested automatic tuning resource state. Is either a - DatabaseAutomaticTuning type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseAutomaticTuning or IO[bytes] - :return: DatabaseAutomaticTuning or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseAutomaticTuning - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DatabaseAutomaticTuning") - - _request = build_update_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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("DatabaseAutomaticTuning", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_blob_auditing_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_blob_auditing_policies_operations.py deleted file mode 100644 index 7531a57b2ebb..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_blob_auditing_policies_operations.py +++ /dev/null @@ -1,441 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Literal, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_database_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/auditingSettings", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, server_name: str, 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 {}) - - blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/auditingSettings/{blobAuditingPolicyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_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 {}) - - blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - 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}/auditingSettings/{blobAuditingPolicyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -class DatabaseBlobAuditingPoliciesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`database_blob_auditing_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.DatabaseBlobAuditingPolicy"]: - """Lists auditing settings 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 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 - :return: An iterator like instance of either DatabaseBlobAuditingPolicy or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseBlobAuditingPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.DatabaseBlobAuditingPolicyListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseBlobAuditingPolicyListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> _models.DatabaseBlobAuditingPolicy: - """Gets a database's blob auditing policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :return: DatabaseBlobAuditingPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseBlobAuditingPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 {}) - - blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.DatabaseBlobAuditingPolicy] = 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, - blob_auditing_policy_name=blob_auditing_policy_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("DatabaseBlobAuditingPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: _models.DatabaseBlobAuditingPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseBlobAuditingPolicy: - """Creates or updates a database's blob auditing policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The database blob auditing policy. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseBlobAuditingPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseBlobAuditingPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseBlobAuditingPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseBlobAuditingPolicy: - """Creates or updates a database's blob auditing policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The database blob auditing policy. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseBlobAuditingPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseBlobAuditingPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.DatabaseBlobAuditingPolicy, IO[bytes]], - **kwargs: Any - ) -> _models.DatabaseBlobAuditingPolicy: - """Creates or updates a database's blob auditing policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The database blob auditing policy. Is either a DatabaseBlobAuditingPolicy - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseBlobAuditingPolicy or IO[bytes] - :return: DatabaseBlobAuditingPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseBlobAuditingPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 {}) - - blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DatabaseBlobAuditingPolicy") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - blob_auditing_policy_name=blob_auditing_policy_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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) - - deserialized = self._deserialize("DatabaseBlobAuditingPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index d2d05168f791..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_columns_operations.py +++ /dev/null @@ -1,463 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_database_request( - resource_group_name: str, - server_name: str, - database_name: str, - subscription_id: str, - *, - schema: Optional[List[str]] = None, - table: Optional[List[str]] = None, - column: Optional[List[str]] = None, - order_by: Optional[List[str]] = None, - skiptoken: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/columns", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if schema is not None: - _params["schema"] = [_SERIALIZER.query("schema", q, "str") if q is not None else "" for q in schema] - if table is not None: - _params["table"] = [_SERIALIZER.query("table", q, "str") if q is not None else "" for q in table] - if column is not None: - _params["column"] = [_SERIALIZER.query("column", q, "str") if q is not None else "" for q in column] - if order_by is not None: - _params["orderBy"] = [_SERIALIZER.query("order_by", q, "str") if q is not None else "" for q in order_by] - if skiptoken is not None: - _params["$skiptoken"] = _SERIALIZER.query("skiptoken", skiptoken, "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_table_request( - resource_group_name: str, - server_name: str, - database_name: str, - schema_name: str, - table_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), - "tableName": _SERIALIZER.url("table_name", table_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - server_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), - "tableName": _SERIALIZER.url("table_name", table_name, "str"), - "columnName": _SERIALIZER.url("column_name", column_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class DatabaseColumnsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`database_columns` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - schema: Optional[List[str]] = None, - table: Optional[List[str]] = None, - column: Optional[List[str]] = None, - order_by: Optional[List[str]] = None, - skiptoken: Optional[str] = None, - **kwargs: Any - ) -> ItemPaged["_models.DatabaseColumn"]: - """List database 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: Default value is None. - :type schema: list[str] - :param table: Default value is None. - :type table: list[str] - :param column: Default value is None. - :type column: list[str] - :param order_by: Default value is None. - :type order_by: list[str] - :param skiptoken: An opaque token that identifies a starting point in the collection. Default - value is None. - :type skiptoken: str - :return: An iterator like instance of either DatabaseColumn or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseColumn] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseColumnListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - schema=schema, - table=table, - column=column, - order_by=order_by, - skiptoken=skiptoken, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseColumnListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_table( - self, - resource_group_name: str, - server_name: str, - database_name: str, - schema_name: str, - table_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> ItemPaged["_models.DatabaseColumn"]: - """List database 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 filter: An OData filter expression that filters elements in the collection. Default - value is None. - :type filter: str - :return: An iterator like instance of either DatabaseColumn or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseColumn] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseColumnListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_table_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - schema_name=schema_name, - table_name=table_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseColumnListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - **kwargs: Any - ) -> _models.DatabaseColumn: - """Get database column. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :return: DatabaseColumn or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseColumn - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseColumn] = 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, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("DatabaseColumn", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 33bbd341ff99..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_encryption_protectors_operations.py +++ /dev/null @@ -1,376 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Iterator, Optional, TypeVar, Union, cast - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_revalidate_request( - resource_group_name: str, - server_name: str, - database_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/encryptionProtector/{encryptionProtectorName}/revalidate", - ) - 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"), - "encryptionProtectorName": _SERIALIZER.url("encryption_protector_name", encryption_protector_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_revert_request( - resource_group_name: str, - server_name: str, - database_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/encryptionProtector/{encryptionProtectorName}/revert", - ) - 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"), - "encryptionProtectorName": _SERIALIZER.url("encryption_protector_name", encryption_protector_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -class DatabaseEncryptionProtectorsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`database_encryption_protectors` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - def _revalidate_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_revalidate_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - encryption_protector_name=encryption_protector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_revalidate( - self, - resource_group_name: str, - server_name: str, - database_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - **kwargs: Any - ) -> LROPoller[None]: - """Revalidates an existing encryption protector for a particular 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 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 - :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", "2022-08-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( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - encryption_protector_name=encryption_protector_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _revert_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_revert_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - encryption_protector_name=encryption_protector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_revert( - self, - resource_group_name: str, - server_name: str, - database_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - **kwargs: Any - ) -> LROPoller[None]: - """Reverts an existing encryption protector for a particular 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 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 - :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", "2022-08-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._revert_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - encryption_protector_name=encryption_protector_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_extensions_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_extensions_operations.py deleted file mode 100644 index 9e81528c6b12..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_extensions_operations.py +++ /dev/null @@ -1,522 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - server_name: str, - database_name: str, - extension_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extensions/{extensionName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "extensionName": _SERIALIZER.url("extension_name", extension_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="GET", url=_url, params=_params, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - server_name: str, - database_name: str, - extension_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - 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/{extensionName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "extensionName": _SERIALIZER.url("extension_name", extension_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extensions", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class DatabaseExtensionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`database_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @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 - ) -> None: - """Gets a database extension. This will return resource not found as it is not supported. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 extension_name: Required. - :type extension_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - extension_name=extension_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - extension_name: str, - parameters: Union[_models.DatabaseExtensions, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2021-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "DatabaseExtensions") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - extension_name=extension_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - extension_name: str, - parameters: _models.DatabaseExtensions, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ImportExportExtensionsOperationResult]: - """Perform a database extension operation, like polybase import. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 extension_name: Required. - :type extension_name: str - :param parameters: The database import request parameters. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseExtensions - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ImportExportExtensionsOperationResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportExtensionsOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - extension_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ImportExportExtensionsOperationResult]: - """Perform a database extension operation, like polybase import. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 extension_name: Required. - :type extension_name: str - :param parameters: The database import request parameters. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ImportExportExtensionsOperationResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportExtensionsOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - extension_name: str, - parameters: Union[_models.DatabaseExtensions, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ImportExportExtensionsOperationResult]: - """Perform a database extension operation, like polybase import. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 extension_name: Required. - :type extension_name: str - :param parameters: The database import request parameters. Is either a DatabaseExtensions type - or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseExtensions or IO[bytes] - :return: An instance of LROPoller that returns either ImportExportExtensionsOperationResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportExtensionsOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ImportExportExtensionsOperationResult] = 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, - extension_name=extension_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ImportExportExtensionsOperationResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ImportExportExtensionsOperationResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ImportExportExtensionsOperationResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either ImportExportExtensionsOperationResult or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ImportExportExtensionsOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[_models.ImportExportExtensionsOperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 20fe1184bb2f..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_operations_operations.py +++ /dev/null @@ -1,279 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_database_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-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", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", - resource_group_name, - "str", - max_length=90, - min_length=1, - pattern=r"^[\p{L}\p{N}_().-]*[\p{L}\p{N}_()-]$", - ), - "serverName": _SERIALIZER.url( - "server_name", server_name, "str", max_length=63, min_length=1, pattern=r"^[a-z0-9]+(-*[a-z0-9]+)*$" - ), - "databaseName": _SERIALIZER.url( - "database_name", - database_name, - "str", - max_length=128, - min_length=1, - pattern=r"^[^<>*%&:\\\/?\x00-\x1F]*[^.<>*%&:\\\/?\s\x00-\x1F]$", - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cancel_request( - resource_group_name: str, - server_name: str, - database_name: str, - operation_id: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-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", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class DatabaseOperationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`database_operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.DatabaseOperation"]: - """Gets a list of operations performed on the database. - - :param resource_group_name: The name of the resource group that contains the resource. - Required. - :type resource_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 - :return: An iterator like instance of either DatabaseOperation or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseOperation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - cls: ClsType[_models.DatabaseOperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseOperationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2024-11-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, - headers=_headers, - params=_params, - ) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore 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 deleted file mode 100644 index 83009a615904..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_recommended_actions_operations.py +++ /dev/null @@ -1,473 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_database_advisor_request( - resource_group_name: str, - server_name: str, - database_name: str, - advisor_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advisors/{advisorName}/recommendedActions", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "advisorName": _SERIALIZER.url("advisor_name", advisor_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - server_name: str, - database_name: str, - advisor_name: str, - recommended_action_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advisors/{advisorName}/recommendedActions/{recommendedActionName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "advisorName": _SERIALIZER.url("advisor_name", advisor_name, "str"), - "recommendedActionName": _SERIALIZER.url("recommended_action_name", recommended_action_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, - server_name: str, - database_name: str, - advisor_name: str, - recommended_action_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advisors/{advisorName}/recommendedActions/{recommendedActionName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "advisorName": _SERIALIZER.url("advisor_name", advisor_name, "str"), - "recommendedActionName": _SERIALIZER.url("recommended_action_name", recommended_action_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -class DatabaseRecommendedActionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`database_recommended_actions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_database_advisor( - self, resource_group_name: str, server_name: str, database_name: str, advisor_name: str, **kwargs: Any - ) -> List[_models.RecommendedAction]: - """Gets list of Database Recommended Actions. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 advisor_name: The name of the Database Advisor. Required. - :type advisor_name: str - :return: list of RecommendedAction or the result of cls(response) - :rtype: list[~azure.mgmt.sql.models.RecommendedAction] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[List[_models.RecommendedAction]] = kwargs.pop("cls", None) - - _request = build_list_by_database_advisor_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - advisor_name=advisor_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("[RecommendedAction]", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - database_name: str, - advisor_name: str, - recommended_action_name: str, - **kwargs: Any - ) -> _models.RecommendedAction: - """Gets a database recommended action. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 advisor_name: The name of the Database Advisor. Required. - :type advisor_name: str - :param recommended_action_name: The name of Database Recommended Action. Required. - :type recommended_action_name: str - :return: RecommendedAction or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.RecommendedAction - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.RecommendedAction] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - advisor_name=advisor_name, - recommended_action_name=recommended_action_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("RecommendedAction", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - advisor_name: str, - recommended_action_name: str, - parameters: _models.RecommendedAction, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RecommendedAction: - """Updates a database recommended action. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 advisor_name: The name of the Database Advisor. Required. - :type advisor_name: str - :param recommended_action_name: The name of Database Recommended Action. Required. - :type recommended_action_name: str - :param parameters: The requested recommended action resource state. Required. - :type parameters: ~azure.mgmt.sql.models.RecommendedAction - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: RecommendedAction or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.RecommendedAction - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - advisor_name: str, - recommended_action_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RecommendedAction: - """Updates a database recommended action. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 advisor_name: The name of the Database Advisor. Required. - :type advisor_name: str - :param recommended_action_name: The name of Database Recommended Action. Required. - :type recommended_action_name: str - :param parameters: The requested recommended action resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: RecommendedAction or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.RecommendedAction - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - advisor_name: str, - recommended_action_name: str, - parameters: Union[_models.RecommendedAction, IO[bytes]], - **kwargs: Any - ) -> _models.RecommendedAction: - """Updates a database recommended action. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 advisor_name: The name of the Database Advisor. Required. - :type advisor_name: str - :param recommended_action_name: The name of Database Recommended Action. Required. - :type recommended_action_name: str - :param parameters: The requested recommended action resource state. Is either a - RecommendedAction type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.RecommendedAction or IO[bytes] - :return: RecommendedAction or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.RecommendedAction - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RecommendedAction") - - _request = build_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - advisor_name=advisor_name, - recommended_action_name=recommended_action_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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("RecommendedAction", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_schemas_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_schemas_operations.py deleted file mode 100644 index 497d11025dcf..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_schemas_operations.py +++ /dev/null @@ -1,282 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_database_request( - resource_group_name: str, - server_name: str, - database_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - server_name: str, - database_name: str, - schema_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class DatabaseSchemasOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`database_schemas` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - filter: Optional[str] = None, - **kwargs: Any - ) -> ItemPaged["_models.DatabaseSchema"]: - """List database schemas. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :type database_name: str - :param filter: An OData filter expression that filters elements in the collection. Default - value is None. - :type filter: str - :return: An iterator like instance of either DatabaseSchema or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseSchema] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseSchemaListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseSchemaListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, server_name: str, database_name: str, schema_name: str, **kwargs: Any - ) -> _models.DatabaseSchema: - """Get database schema. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :return: DatabaseSchema or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSchema - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseSchema] = 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, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("DatabaseSchema", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_security_alert_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_security_alert_policies_operations.py deleted file mode 100644 index c9a36a9e9666..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_security_alert_policies_operations.py +++ /dev/null @@ -1,468 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - server_name: str, - database_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - server_name: str, - database_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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/{securityAlertPolicyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/securityAlertPolicies", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class DatabaseSecurityAlertPoliciesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`database_security_alert_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - **kwargs: Any - ) -> _models.DatabaseSecurityAlertPolicy: - """Gets a database's security alert policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :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 - :return: DatabaseSecurityAlertPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSecurityAlertPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseSecurityAlertPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - security_alert_policy_name=security_alert_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("DatabaseSecurityAlertPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - parameters: _models.DatabaseSecurityAlertPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseSecurityAlertPolicy: - """Creates or updates a database's security alert policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :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 - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseSecurityAlertPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSecurityAlertPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseSecurityAlertPolicy: - """Creates or updates a database's security alert policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseSecurityAlertPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSecurityAlertPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - parameters: Union[_models.DatabaseSecurityAlertPolicy, IO[bytes]], - **kwargs: Any - ) -> _models.DatabaseSecurityAlertPolicy: - """Creates or updates a database's security alert policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :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[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseSecurityAlertPolicy or IO[bytes] - :return: DatabaseSecurityAlertPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSecurityAlertPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DatabaseSecurityAlertPolicy") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - security_alert_policy_name=security_alert_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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) - - deserialized = self._deserialize("DatabaseSecurityAlertPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either DatabaseSecurityAlertPolicy or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseSecurityAlertPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseSecurityAlertListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 200cdf84b4fb..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessment_baselines_operations.py +++ /dev/null @@ -1,515 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_sql_vulnerability_assessment_request( # pylint: disable=name-too-long - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-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}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/baselines", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/baselines/{baselineName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - 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}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/baselines/{baselineName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -class DatabaseSqlVulnerabilityAssessmentBaselinesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`database_sql_vulnerability_assessment_baselines` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_sql_vulnerability_assessment( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **kwargs: Any - ) -> ItemPaged["_models.DatabaseSqlVulnerabilityAssessmentBaselineSet"]: - """Gets a list of database's sql vulnerability assessment rule baselines. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :return: An iterator like instance of either DatabaseSqlVulnerabilityAssessmentBaselineSet or - the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentBaselineSetListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_sql_vulnerability_assessment_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize( - "DatabaseSqlVulnerabilityAssessmentBaselineSetListResult", pipeline_response - ) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - **kwargs: Any - ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: - """Gets a list of database's sql vulnerability assessment rule baselines. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :return: DatabaseSqlVulnerabilityAssessmentBaselineSet or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-11-01-preview")) - cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentBaselineSet] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - baseline_name=baseline_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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( - "DatabaseSqlVulnerabilityAssessmentBaselineSet", pipeline_response.http_response - ) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - parameters: _models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: - """Add a database's vulnerability assessment rule baseline 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 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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :param parameters: The requested rule baseline resource. Required. - :type parameters: - ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseSqlVulnerabilityAssessmentBaselineSet or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: - """Add a database's vulnerability assessment rule baseline 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 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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :param parameters: The requested rule baseline resource. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseSqlVulnerabilityAssessmentBaselineSet or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - parameters: Union[_models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput, IO[bytes]], - **kwargs: Any - ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: - """Add a database's vulnerability assessment rule baseline 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 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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :param parameters: The requested rule baseline resource. Is either a - DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput type or a IO[bytes] type. Required. - :type parameters: - ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput or IO[bytes] - :return: DatabaseSqlVulnerabilityAssessmentBaselineSet or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - baseline_name=baseline_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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( - "DatabaseSqlVulnerabilityAssessmentBaselineSet", pipeline_response.http_response - ) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 5894e23e42e8..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessment_execute_scan_operations.py +++ /dev/null @@ -1,218 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Iterator, Optional, TypeVar, Union, cast - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_execute_request( - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/initiateScan", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -class DatabaseSqlVulnerabilityAssessmentExecuteScanOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`database_sql_vulnerability_assessment_execute_scan` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - def _execute_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2022-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_execute_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_execute( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **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 - :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", "2022-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._execute_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index 175d52df83ae..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessment_rule_baselines_operations.py +++ /dev/null @@ -1,649 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_baseline_request( - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/baselines/{baselineName}/rules", - ) - 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" - ), - "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - rule_id: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-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}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/baselines/{baselineName}/rules/{ruleId}", - ) - 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" - ), - "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), - "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - rule_id: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-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}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/baselines/{baselineName}/rules/{ruleId}", - ) - 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" - ), - "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), - "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - rule_id: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/baselines/{baselineName}/rules/{ruleId}", - ) - 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" - ), - "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), - "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -class DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`database_sql_vulnerability_assessment_rule_baselines` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_baseline( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - **kwargs: Any - ) -> ItemPaged["_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline"]: - """Gets a list of database's sql vulnerability assessment rule baselines. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :return: An iterator like instance of either DatabaseSqlVulnerabilityAssessmentRuleBaseline or - the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_baseline_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - baseline_name=baseline_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize( - "DatabaseSqlVulnerabilityAssessmentRuleBaselineListResult", pipeline_response - ) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - rule_id: str, - **kwargs: Any - ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: - """Gets a database's sql vulnerability assessment rule baseline. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :param rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-11-01-preview")) - cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - baseline_name=baseline_name, - rule_id=rule_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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( - "DatabaseSqlVulnerabilityAssessmentRuleBaseline", pipeline_response.http_response - ) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - rule_id: str, - parameters: _models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :param rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :param parameters: The requested rule baseline resource. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - rule_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :param rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :param parameters: The requested rule baseline resource. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - rule_id: str, - parameters: Union[_models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput, IO[bytes]], - **kwargs: Any - ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :param rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :param parameters: The requested rule baseline resource. Is either a - DatabaseSqlVulnerabilityAssessmentRuleBaselineInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput or - IO[bytes] - :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DatabaseSqlVulnerabilityAssessmentRuleBaselineInput") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - baseline_name=baseline_name, - rule_id=rule_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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( - "DatabaseSqlVulnerabilityAssessmentRuleBaseline", pipeline_response.http_response - ) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - rule_id: str, - **kwargs: Any - ) -> None: - """Removes the database's vulnerability assessment rule baseline. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :param rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-11-01-preview")) - 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, - vulnerability_assessment_name=vulnerability_assessment_name, - baseline_name=baseline_name, - rule_id=rule_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore 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 deleted file mode 100644 index 1a6110430890..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessment_scan_result_operations.py +++ /dev/null @@ -1,314 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar, Union - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_scan_request( - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], - scan_id: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-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}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/scanResults", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], - scan_id: str, - scan_result_id: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-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}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/scanResults/{scanResultId}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), - "scanResultId": _SERIALIZER.url("scan_result_id", scan_result_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class DatabaseSqlVulnerabilityAssessmentScanResultOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`database_sql_vulnerability_assessment_scan_result` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_scan( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], - scan_id: str, - **kwargs: Any - ) -> ItemPaged["_models.SqlVulnerabilityAssessmentScanResults"]: - """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. - :type resource_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 SQL Vulnerability Assessment. "default" - Required. - :type vulnerability_assessment_name: str or - ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentName - :param scan_id: The scan id of the SQL Vulnerability Assessment scan to retrieve result from. - Required. - :type scan_id: str - :return: An iterator like instance of either SqlVulnerabilityAssessmentScanResults or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanResults] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[_models.SQLVulnerabilityAssessmentScanListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SQLVulnerabilityAssessmentScanListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], - scan_id: str, - scan_result_id: str, - **kwargs: Any - ) -> _models.SqlVulnerabilityAssessmentScanResults: - """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. - :type resource_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 SQL Vulnerability Assessment. "default" - Required. - :type vulnerability_assessment_name: str or - ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentName - :param scan_id: The scan id of the SQL Vulnerability Assessment scan to retrieve result from. - Required. - :type scan_id: str - :param scan_result_id: The scan result id of the specific result to retrieve. Required. - :type scan_result_id: str - :return: SqlVulnerabilityAssessmentScanResults or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-11-01-preview")) - cls: ClsType[_models.SqlVulnerabilityAssessmentScanResults] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - scan_id=scan_id, - scan_result_id=scan_result_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("SqlVulnerabilityAssessmentScanResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 51c6803527c7..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessment_scans_operations.py +++ /dev/null @@ -1,298 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar, Union - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_sql_vulnerability_assessments_request( # pylint: disable=name-too-long - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-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}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/scans", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - scan_id: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-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}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class DatabaseSqlVulnerabilityAssessmentScansOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`database_sql_vulnerability_assessment_scans` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_sql_vulnerability_assessments( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **kwargs: Any - ) -> ItemPaged["_models.SqlVulnerabilityAssessmentScanRecord"]: - """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 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 - :return: An iterator like instance of either SqlVulnerabilityAssessmentScanRecord or the result - of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanRecord] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[_models.SqlVulnerabilityAssessmentScanRecordListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_sql_vulnerability_assessments_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SqlVulnerabilityAssessmentScanRecordListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - scan_id: str, - **kwargs: Any - ) -> _models.SqlVulnerabilityAssessmentScanRecord: - """Get a database vulnerability assessment scan result. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :return: SqlVulnerabilityAssessmentScanRecord or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanRecord - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-11-01-preview")) - cls: ClsType[_models.SqlVulnerabilityAssessmentScanRecord] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - scan_id=scan_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("SqlVulnerabilityAssessmentScanRecord", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 7af6c4134b3d..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessments_settings_operations.py +++ /dev/null @@ -1,275 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar, Union - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_database_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/sqlVulnerabilityAssessments", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _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, - database_name: str, - vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class DatabaseSqlVulnerabilityAssessmentsSettingsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`database_sql_vulnerability_assessments_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.SqlVulnerabilityAssessment"]: - """Lists SQL 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. Required. - :type database_name: str - :return: An iterator like instance of either SqlVulnerabilityAssessment or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SqlVulnerabilityAssessment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[_models.SqlVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SqlVulnerabilityAssessmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], - **kwargs: Any - ) -> _models.SqlVulnerabilityAssessment: - """Gets SQL Vulnerability Assessment policy for 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 vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" - Required. - :type vulnerability_assessment_name: str or - ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentName - :return: SqlVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-11-01-preview")) - cls: ClsType[_models.SqlVulnerabilityAssessment] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("SqlVulnerabilityAssessment", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 02acfc33892f..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_tables_operations.py +++ /dev/null @@ -1,299 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_schema_request( - resource_group_name: str, - server_name: str, - database_name: str, - schema_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - server_name: str, - database_name: str, - schema_name: str, - table_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), - "tableName": _SERIALIZER.url("table_name", table_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class DatabaseTablesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`database_tables` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_schema( - self, - resource_group_name: str, - server_name: str, - database_name: str, - schema_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> ItemPaged["_models.DatabaseTable"]: - """List database tables. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 filter: An OData filter expression that filters elements in the collection. Default - value is None. - :type filter: str - :return: An iterator like instance of either DatabaseTable or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseTable] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseTableListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_schema_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - schema_name=schema_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseTableListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - database_name: str, - schema_name: str, - table_name: str, - **kwargs: Any - ) -> _models.DatabaseTable: - """Get database table. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :return: DatabaseTable or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseTable - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseTable] = 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, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("DatabaseTable", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_usages_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_usages_operations.py deleted file mode 100644 index cd1568971bd4..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_usages_operations.py +++ /dev/null @@ -1,164 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_database_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/usages", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class DatabaseUsagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`database_usages` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.DatabaseUsage"]: - """Gets database 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. - :type resource_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 - :return: An iterator like instance of either DatabaseUsage or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseUsage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[_models.DatabaseUsageListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseUsageListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_vulnerability_assessment_rule_baselines_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_vulnerability_assessment_rule_baselines_operations.py deleted file mode 100644 index fbd8b77a8c5f..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_vulnerability_assessment_rule_baselines_operations.py +++ /dev/null @@ -1,525 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - rule_id: str, - baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), - "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - rule_id: str, - baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), - "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - rule_id: str, - baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), - "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -class DatabaseVulnerabilityAssessmentRuleBaselinesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`database_vulnerability_assessment_rule_baselines` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - rule_id: str, - baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: - """Gets a database's vulnerability assessment rule baseline. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 rule - baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a - baseline on a database level rule and master for server level rule). Known values are: "master" - and "default". Required. - :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName - :return: DatabaseVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - rule_id=rule_id, - baseline_name=baseline_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("DatabaseVulnerabilityAssessmentRuleBaseline", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - rule_id: str, - baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - parameters: _models.DatabaseVulnerabilityAssessmentRuleBaseline, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: - """Creates or updates a database's vulnerability assessment rule baseline. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 rule - baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a - baseline on a database level rule and master for server level rule). Known values are: "master" - 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 - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - rule_id: str, - baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: - """Creates or updates a database's vulnerability assessment rule baseline. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 rule - baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a - baseline on a database level rule and master for server level rule). Known values are: "master" - and "default". Required. - :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName - :param parameters: The requested rule baseline resource. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - rule_id: str, - baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - parameters: Union[_models.DatabaseVulnerabilityAssessmentRuleBaseline, IO[bytes]], - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: - """Creates or updates a database's vulnerability assessment rule baseline. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 rule - baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a - baseline on a database level rule and master for server level rule). Known values are: "master" - 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[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline or - IO[bytes] - :return: DatabaseVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DatabaseVulnerabilityAssessmentRuleBaseline") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - rule_id=rule_id, - baseline_name=baseline_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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("DatabaseVulnerabilityAssessmentRuleBaseline", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - rule_id: str, - baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - **kwargs: Any - ) -> None: - """Removes the database's vulnerability assessment rule baseline. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 rule - baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a - baseline on a database level rule and master for server level rule). Known values are: "master" - and "default". Required. - :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - rule_id=rule_id, - baseline_name=baseline_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_vulnerability_assessment_scans_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_vulnerability_assessment_scans_operations.py deleted file mode 100644 index 985727a50b2c..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_vulnerability_assessment_scans_operations.py +++ /dev/null @@ -1,582 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Iterator, Optional, TypeVar, Union, cast - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_initiate_scan_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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - 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, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - scan_id: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_export_request( - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - scan_id: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/export", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class DatabaseVulnerabilityAssessmentScansOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`database_vulnerability_assessment_scans` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - def _initiate_scan_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - scan_id: str, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._initiate_scan_initial( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_by_database( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **kwargs: Any - ) -> ItemPaged["_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 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 - :return: An iterator like instance of either VulnerabilityAssessmentScanRecord or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecord] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.VulnerabilityAssessmentScanRecordListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - scan_id: str, - **kwargs: Any - ) -> _models.VulnerabilityAssessmentScanRecord: - """Gets a vulnerability assessment scan record of a database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :return: VulnerabilityAssessmentScanRecord or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecord - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.VulnerabilityAssessmentScanRecord] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def export( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - scan_id: str, - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessmentScansExport: - """Convert an existing scan result to a human readable format. If already exists nothing happens. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the scanned 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. Required. - :type scan_id: str - :return: DatabaseVulnerabilityAssessmentScansExport or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentScansExport - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseVulnerabilityAssessmentScansExport] = kwargs.pop("cls", None) - - _request = build_export_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - scan_id=scan_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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) - - deserialized = self._deserialize("DatabaseVulnerabilityAssessmentScansExport", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_vulnerability_assessments_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_vulnerability_assessments_operations.py deleted file mode 100644 index b84fe2341e80..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_vulnerability_assessments_operations.py +++ /dev/null @@ -1,576 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_list_by_database_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _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 DatabaseVulnerabilityAssessmentsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`database_vulnerability_assessments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessment: - """Gets the database's vulnerability assessment. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 is - defined. 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 - :return: DatabaseVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseVulnerabilityAssessment] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("DatabaseVulnerabilityAssessment", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: _models.DatabaseVulnerabilityAssessment, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessment: - """Creates or updates the database's vulnerability assessment. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 is - defined. 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 parameters: The requested resource. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessment: - """Creates or updates the database's vulnerability assessment. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 is - defined. 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 parameters: The requested resource. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: Union[_models.DatabaseVulnerabilityAssessment, IO[bytes]], - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessment: - """Creates or updates the database's vulnerability assessment. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 is - defined. 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 parameters: The requested resource. Is either a DatabaseVulnerabilityAssessment type or - a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment or IO[bytes] - :return: DatabaseVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DatabaseVulnerabilityAssessment") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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) - - deserialized = self._deserialize("DatabaseVulnerabilityAssessment", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **kwargs: Any - ) -> None: - """Removes the database's vulnerability assessment. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 is - defined. 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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either DatabaseVulnerabilityAssessment or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 9a5d7b342a3d..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_databases_operations.py +++ /dev/null @@ -1,2557 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_metrics_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, *, filter: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/metrics", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_metric_definitions_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/metricDefinitions", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, *, skip_token: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if skip_token is not None: - _params["$skipToken"] = _SERIALIZER.query("skip_token", skip_token, "str") - _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, - database_name: str, - subscription_id: str, - *, - expand: Optional[str] = None, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - 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) - - -def build_create_or_update_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _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_delete_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_update_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _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) - - -def build_export_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "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}/export", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_failover_request( - resource_group_name: str, - server_name: str, - database_name: str, - subscription_id: str, - *, - replica_type: Optional[Union[str, _models.ReplicaType]] = None, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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}/failover", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if replica_type is not None: - _params["replicaType"] = _SERIALIZER.query("replica_type", replica_type, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_import_method_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "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}/import", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_rename_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "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/servers/{serverName}/databases/{databaseName}/move", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_pause_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "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}/pause", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_resume_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "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}/resume", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_upgrade_data_warehouse_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/upgradeDataWarehouse", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_list_by_elastic_pool_request( - resource_group_name: str, server_name: str, elastic_pool_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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}/elasticPools/{elasticPoolName}/databases", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "elasticPoolName": _SERIALIZER.url("elastic_pool_name", elastic_pool_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_inaccessible_by_server_request( # pylint: disable=name-too-long - 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}/inaccessibleDatabases", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class DatabasesOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`databases` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_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 - :return: An iterator like instance of either Metric or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.Metric] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.MetricListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace - def list_metric_definitions( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either MetricDefinition or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.MetricDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.MetricDefinitionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, skip_token: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_models.Database"]: - """Gets a list of databases. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param skip_token: Default value is None. - :type skip_token: str - :return: An iterator like instance of either Database or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) - cls: ClsType[_models.DatabaseListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - skip_token=skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - database_name: str, - expand: Optional[str] = None, - filter: Optional[str] = None, - **kwargs: Any - ) -> _models.Database: - """Gets 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 - :param expand: The child resources to include in the response. Default value is None. - :type expand: str - :param filter: An OData filter expression that filters elements in the collection. Default - value is None. - :type filter: str - :return: Database or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.Database - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2023-02-01-preview")) - cls: ClsType[_models.Database] = 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, - expand=expand, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("Database", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.Database, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "Database") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: _models.Database, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Database]: - """Creates a new database or updates an existing database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The requested database resource state. Required. - :type parameters: ~azure.mgmt.sql.models.Database - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Database or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Database]: - """Creates a new database or updates an existing database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The requested database resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Database or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.Database, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Database]: - """Creates a new database or updates an existing database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The requested database resource state. Is either a Database type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.Database or IO[bytes] - :return: An instance of LROPoller that returns either Database or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_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)) - 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) - 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, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Database", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.Database].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Database]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-02-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes the database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :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", "2023-02-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( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.DatabaseUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "DatabaseUpdate") - - _request = build_update_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: _models.DatabaseUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Database]: - """Updates an existing database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The requested database resource state. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Database or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Database]: - """Updates an existing database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The requested database resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Database or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.DatabaseUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Database]: - """Updates an existing database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The requested database resource state. Is either a DatabaseUpdate type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseUpdate or IO[bytes] - :return: An instance of LROPoller that returns either Database or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_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)) - 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) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Database", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Database].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Database]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _export_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.ExportDatabaseDefinition, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ExportDatabaseDefinition") - - _request = build_export_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_export( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: _models.ExportDatabaseDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ImportExportOperationResult]: - """Exports 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 - :param parameters: The database export request parameters. Required. - :type parameters: ~azure.mgmt.sql.models.ExportDatabaseDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ImportExportOperationResult or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_export( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ImportExportOperationResult]: - """Exports 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 - :param parameters: The database export request parameters. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ImportExportOperationResult or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_export( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.ExportDatabaseDefinition, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ImportExportOperationResult]: - """Exports 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 - :param parameters: The database export request parameters. Is either a ExportDatabaseDefinition - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ExportDatabaseDefinition or IO[bytes] - :return: An instance of LROPoller that returns either ImportExportOperationResult or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_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)) - cls: ClsType[_models.ImportExportOperationResult] = 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._export_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ImportExportOperationResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ImportExportOperationResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ImportExportOperationResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _failover_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - replica_type: Optional[Union[str, _models.ReplicaType]] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-02-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_failover_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - replica_type=replica_type, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_failover( - self, - resource_group_name: str, - server_name: str, - database_name: str, - replica_type: Optional[Union[str, _models.ReplicaType]] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Failovers a database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database to failover. Required. - :type database_name: str - :param replica_type: The type of replica to be failed over. Known values are: "Primary" and - "ReadableSecondary". Default value is None. - :type replica_type: str or ~azure.mgmt.sql.models.ReplicaType - :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", "2023-02-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._failover_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - replica_type=replica_type, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _import_method_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.ImportExistingDatabaseDefinition, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ImportExistingDatabaseDefinition") - - _request = build_import_method_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_import_method( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: _models.ImportExistingDatabaseDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ImportExportOperationResult]: - """Imports a bacpac into a new database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The database import request parameters. Required. - :type parameters: ~azure.mgmt.sql.models.ImportExistingDatabaseDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ImportExportOperationResult or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_import_method( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ImportExportOperationResult]: - """Imports a bacpac into a new database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The database import request parameters. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ImportExportOperationResult or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_import_method( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.ImportExistingDatabaseDefinition, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ImportExportOperationResult]: - """Imports a bacpac into a new database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The database import request parameters. Is either a - ImportExistingDatabaseDefinition type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ImportExistingDatabaseDefinition or IO[bytes] - :return: An instance of LROPoller that returns either ImportExportOperationResult or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_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)) - cls: ClsType[_models.ImportExportOperationResult] = 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._import_method_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ImportExportOperationResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ImportExportOperationResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ImportExportOperationResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @overload - def rename( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: _models.ResourceMoveDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Renames 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 to rename. Required. - :type database_name: str - :param parameters: The resource move definition for renaming this database. Required. - :type parameters: ~azure.mgmt.sql.models.ResourceMoveDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def rename( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Renames 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 to rename. Required. - :type database_name: str - :param parameters: The resource move definition for renaming this database. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def rename( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.ResourceMoveDefinition, IO[bytes]], - **kwargs: Any - ) -> None: - """Renames 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 to rename. Required. - :type database_name: str - :param parameters: The resource move definition for renaming this database. Is either a - ResourceMoveDefinition type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ResourceMoveDefinition or IO[bytes] - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2023-02-01-preview")) - 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, "ResourceMoveDefinition") - - _request = build_rename_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - def _pause_initial( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-02-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_pause_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_pause( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> LROPoller[_models.Database]: - """Pauses a database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database to be paused. Required. - :type database_name: str - :return: An instance of LROPoller that returns either Database or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) - 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) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._pause_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Database", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Database].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Database]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _resume_initial( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-02-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_resume_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_resume( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> LROPoller[_models.Database]: - """Resumes a database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database to be resumed. Required. - :type database_name: str - :return: An instance of LROPoller that returns either Database or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) - 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) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._resume_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Database", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Database].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Database]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _upgrade_data_warehouse_initial( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-02-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_upgrade_data_warehouse_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_upgrade_data_warehouse( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Upgrades a data warehouse. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database to be upgraded. Required. - :type database_name: str - :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", "2023-02-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._upgrade_data_warehouse_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_by_elastic_pool( - self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any - ) -> ItemPaged["_models.Database"]: - """Gets a list of databases in an elastic pool. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 - :return: An iterator like instance of either Database or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) - cls: ClsType[_models.DatabaseListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_inaccessible_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> ItemPaged["_models.Database"]: - """Gets a list of inaccessible databases in a logical server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either Database or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.Database] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) - cls: ClsType[_models.DatabaseListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_inaccessible_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) 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 deleted file mode 100644 index 47af268e7cbe..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_deleted_servers_operations.py +++ /dev/null @@ -1,463 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Iterator, Optional, TypeVar, Union, cast - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/deletedServers") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(location_name: str, deleted_server_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/deletedServers/{deletedServerName}", - ) - path_format_arguments = { - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "deletedServerName": _SERIALIZER.url("deleted_server_name", deleted_server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_location_request(location_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/deletedServers", - ) - path_format_arguments = { - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_recover_request( - location_name: str, deleted_server_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/deletedServers/{deletedServerName}/recover", - ) - path_format_arguments = { - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "deletedServerName": _SERIALIZER.url("deleted_server_name", deleted_server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class DeletedServersOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`deleted_servers` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_models.DeletedServer"]: - """Gets a list of all deleted servers in a subscription. - - :return: An iterator like instance of either DeletedServer or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DeletedServer] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DeletedServerListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DeletedServerListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @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 - :return: DeletedServer or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DeletedServer - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DeletedServer] = kwargs.pop("cls", None) - - _request = build_get_request( - location_name=location_name, - deleted_server_name=deleted_server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_location(self, location_name: str, **kwargs: Any) -> ItemPaged["_models.DeletedServer"]: - """Gets a list of deleted servers for a location. - - :param location_name: The name of the region where the resource is located. Required. - :type location_name: str - :return: An iterator like instance of either DeletedServer or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DeletedServer] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DeletedServerListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DeletedServerListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _recover_initial(self, location_name: str, deleted_server_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_recover_request( - location_name=location_name, - deleted_server_name=deleted_server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_recover( - self, location_name: str, deleted_server_name: str, **kwargs: Any - ) -> LROPoller[_models.DeletedServer]: - """Recovers a deleted server. - - :param location_name: The name of the region where the resource is located. Required. - :type location_name: str - :param deleted_server_name: The name of the deleted server. Required. - :type deleted_server_name: str - :return: An instance of LROPoller that returns either DeletedServer or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.DeletedServer] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DeletedServer] = kwargs.pop("cls", None) - 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._recover_initial( - location_name=location_name, - deleted_server_name=deleted_server_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DeletedServer", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.DeletedServer].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.DeletedServer]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 05819d9c081e..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_distributed_availability_groups_operations.py +++ /dev/null @@ -1,1431 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_instance_request( - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_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-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "distributedAvailabilityGroupName": _SERIALIZER.url( - "distributed_availability_group_name", distributed_availability_group_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - managed_instance_name: str, - 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-08-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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "distributedAvailabilityGroupName": _SERIALIZER.url( - "distributed_availability_group_name", distributed_availability_group_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_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-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "distributedAvailabilityGroupName": _SERIALIZER.url( - "distributed_availability_group_name", distributed_availability_group_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_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-08-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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "distributedAvailabilityGroupName": _SERIALIZER.url( - "distributed_availability_group_name", distributed_availability_group_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_failover_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-08-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}/failover", - ) - 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]+)*$", - ), - "distributedAvailabilityGroupName": _SERIALIZER.url( - "distributed_availability_group_name", - distributed_availability_group_name, - "str", - max_length=128, - min_length=1, - pattern=r"^[#a-zA-Z_][\w@#$]*$", - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_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-08-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", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "distributedAvailabilityGroupName": _SERIALIZER.url( - "distributed_availability_group_name", distributed_availability_group_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class DistributedAvailabilityGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`distributed_availability_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.DistributedAvailabilityGroup"]: - """Gets a list of a distributed availability groups in instance. - - :param resource_group_name: The name of the resource group that 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 - :return: An iterator like instance of either DistributedAvailabilityGroup or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DistributedAvailabilityGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) - cls: ClsType[_models.DistributedAvailabilityGroupsListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DistributedAvailabilityGroupsListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - managed_instance_name: str, - distributed_availability_group_name: str, - **kwargs: Any - ) -> _models.DistributedAvailabilityGroup: - """Gets a distributed availability group info. - - :param resource_group_name: The name of the resource group that 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 - :return: DistributedAvailabilityGroup or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DistributedAvailabilityGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2023-08-01-preview")) - cls: ClsType[_models.DistributedAvailabilityGroup] = kwargs.pop("cls", None) - - _request = build_get_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, - headers=_headers, - params=_params, - ) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DistributedAvailabilityGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - distributed_availability_group_name: str, - parameters: Union[_models.DistributedAvailabilityGroup, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "DistributedAvailabilityGroup") - - _request = build_create_or_update_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - distributed_availability_group_name: str, - parameters: _models.DistributedAvailabilityGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DistributedAvailabilityGroup]: - """Creates a distributed availability group between Sql On-Prem and Sql Managed Instance. - - :param resource_group_name: The name of the resource group that 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 info. Required. - :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :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_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - distributed_availability_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DistributedAvailabilityGroup]: - """Creates a distributed availability group between Sql On-Prem and Sql Managed Instance. - - :param resource_group_name: The name of the resource group that 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 info. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - distributed_availability_group_name: str, - parameters: Union[_models.DistributedAvailabilityGroup, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.DistributedAvailabilityGroup]: - """Creates a distributed availability group between Sql On-Prem and Sql Managed Instance. - - :param resource_group_name: The name of the resource group that 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 info. Is either a - DistributedAvailabilityGroup type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroup or IO[bytes] - :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", "2023-08-01-preview")) - 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._create_or_update_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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DistributedAvailabilityGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.DistributedAvailabilityGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.DistributedAvailabilityGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, - resource_group_name: str, - managed_instance_name: str, - distributed_availability_group_name: str, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-08-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, - resource_group_name: str, - managed_instance_name: str, - distributed_availability_group_name: str, - **kwargs: Any - ) -> LROPoller[None]: - """Drops a distributed availability group between Sql On-Prem and Sql Managed Instance. - - :param resource_group_name: The name of the resource group that 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 - :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", "2023-08-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( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - distributed_availability_group_name=distributed_availability_group_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - distributed_availability_group_name: str, - parameters: Union[_models.DistributedAvailabilityGroup, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "DistributedAvailabilityGroup") - - _request = build_update_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - managed_instance_name: str, - distributed_availability_group_name: str, - parameters: _models.DistributedAvailabilityGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DistributedAvailabilityGroup]: - """Updates a distributed availability group replication mode. - - :param resource_group_name: The name of the resource group that 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 info. Required. - :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :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_update( - self, - resource_group_name: str, - managed_instance_name: str, - distributed_availability_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DistributedAvailabilityGroup]: - """Updates a distributed availability group replication mode. - - :param resource_group_name: The name of the resource group that 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 info. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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_update( - self, - resource_group_name: str, - managed_instance_name: str, - distributed_availability_group_name: str, - parameters: Union[_models.DistributedAvailabilityGroup, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.DistributedAvailabilityGroup]: - """Updates a distributed availability group replication mode. - - :param resource_group_name: The name of the resource group that 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 info. Is either a - DistributedAvailabilityGroup type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroup or IO[bytes] - :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", "2023-08-01-preview")) - 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._update_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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DistributedAvailabilityGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.DistributedAvailabilityGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.DistributedAvailabilityGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _failover_initial( - self, - resource_group_name: str, - managed_instance_name: str, - distributed_availability_group_name: str, - parameters: Union[_models.DistributedAvailabilityGroupsFailoverRequest, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "DistributedAvailabilityGroupsFailoverRequest") - - _request = build_failover_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_failover( - self, - resource_group_name: str, - managed_instance_name: str, - distributed_availability_group_name: str, - parameters: _models.DistributedAvailabilityGroupsFailoverRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DistributedAvailabilityGroup]: - """Performs requested failover type in this 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 failover request parameters. Required. - :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroupsFailoverRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :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_failover( - self, - resource_group_name: str, - managed_instance_name: str, - distributed_availability_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.DistributedAvailabilityGroup]: - """Performs requested failover type in this 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 failover request parameters. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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_failover( - self, - resource_group_name: str, - managed_instance_name: str, - distributed_availability_group_name: str, - parameters: Union[_models.DistributedAvailabilityGroupsFailoverRequest, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.DistributedAvailabilityGroup]: - """Performs requested failover type in this 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 failover request parameters. Is either a - DistributedAvailabilityGroupsFailoverRequest type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroupsFailoverRequest or - IO[bytes] - :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", "2023-08-01-preview")) - 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._failover_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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DistributedAvailabilityGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.DistributedAvailabilityGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.DistributedAvailabilityGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _set_role_initial( - self, - resource_group_name: str, - managed_instance_name: str, - distributed_availability_group_name: str, - parameters: Union[_models.DistributedAvailabilityGroupSetRole, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroupSetRole or IO[bytes] - :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", "2023-08-01-preview")) - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DistributedAvailabilityGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.DistributedAvailabilityGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.DistributedAvailabilityGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_elastic_pool_activities_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_elastic_pool_activities_operations.py deleted file mode 100644 index 10482df69e01..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_elastic_pool_activities_operations.py +++ /dev/null @@ -1,165 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_elastic_pool_request( - resource_group_name: str, server_name: str, elastic_pool_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/elasticPoolActivity", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "elasticPoolName": _SERIALIZER.url("elastic_pool_name", elastic_pool_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ElasticPoolActivitiesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`elastic_pool_activities` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_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 - :return: An iterator like instance of either ElasticPoolActivity or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ElasticPoolActivity] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.ElasticPoolActivityListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 c3fd515dd7c8..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_elastic_pool_database_activities_operations.py +++ /dev/null @@ -1,165 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_elastic_pool_request( - resource_group_name: str, server_name: str, elastic_pool_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/elasticPoolDatabaseActivity", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "elasticPoolName": _SERIALIZER.url("elastic_pool_name", elastic_pool_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ElasticPoolDatabaseActivitiesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`elastic_pool_database_activities` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_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 - :return: An iterator like instance of either ElasticPoolDatabaseActivity or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ElasticPoolDatabaseActivity] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.ElasticPoolDatabaseActivityListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 831ab267b82d..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_elastic_pool_operations_operations.py +++ /dev/null @@ -1,256 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_cancel_request( - resource_group_name: str, - server_name: str, - elastic_pool_name: str, - operation_id: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/operations/{operationId}/cancel", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "elasticPoolName": _SERIALIZER.url("elastic_pool_name", elastic_pool_name, "str"), - "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_list_by_elastic_pool_request( - resource_group_name: str, server_name: str, elastic_pool_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/operations", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "elasticPoolName": _SERIALIZER.url("elastic_pool_name", elastic_pool_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ElasticPoolOperationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`elastic_pool_operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_cancel_request( - resource_group_name=resource_group_name, - server_name=server_name, - elastic_pool_name=elastic_pool_name, - operation_id=operation_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @distributed_trace - def list_by_elastic_pool( - self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any - ) -> ItemPaged["_models.ElasticPoolOperation"]: - """Gets a list of operations performed on the elastic pool. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 - :return: An iterator like instance of either ElasticPoolOperation or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ElasticPoolOperation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ElasticPoolOperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ElasticPoolOperationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_elastic_pools_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_elastic_pools_operations.py deleted file mode 100644 index 6b267763e388..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_elastic_pools_operations.py +++ /dev/null @@ -1,1241 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_metrics_request( - resource_group_name: str, - server_name: str, - elastic_pool_name: str, - subscription_id: str, - *, - filter: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/metrics", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "elasticPoolName": _SERIALIZER.url("elastic_pool_name", elastic_pool_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_metric_definitions_request( - resource_group_name: str, server_name: str, elastic_pool_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/metricDefinitions", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "elasticPoolName": _SERIALIZER.url("elastic_pool_name", elastic_pool_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, *, skip: Optional[int] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if skip is not None: - _params["$skip"] = _SERIALIZER.query("skip", skip, "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) - - -def build_get_request( - resource_group_name: str, server_name: str, elastic_pool_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "elasticPoolName": _SERIALIZER.url("elastic_pool_name", elastic_pool_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, server_name: str, elastic_pool_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-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}/elasticPools/{elasticPoolName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "elasticPoolName": _SERIALIZER.url("elastic_pool_name", elastic_pool_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, server_name: str, elastic_pool_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "elasticPoolName": _SERIALIZER.url("elastic_pool_name", elastic_pool_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_update_request( - resource_group_name: str, server_name: str, elastic_pool_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-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}/elasticPools/{elasticPoolName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "elasticPoolName": _SERIALIZER.url("elastic_pool_name", elastic_pool_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_failover_request( - resource_group_name: str, server_name: str, elastic_pool_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/failover", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "elasticPoolName": _SERIALIZER.url("elastic_pool_name", elastic_pool_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -class ElasticPoolsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`elastic_pools` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_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 - :return: An iterator like instance of either Metric or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.Metric] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.MetricListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace - def list_metric_definitions( - self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either MetricDefinition or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.MetricDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.MetricDefinitionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, skip: Optional[int] = None, **kwargs: Any - ) -> ItemPaged["_models.ElasticPool"]: - """Gets all elastic pools 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 - :param skip: The number of elements in the collection to skip. Default value is None. - :type skip: int - :return: An iterator like instance of either ElasticPool or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ElasticPool] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.ElasticPoolListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - skip=skip, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ElasticPoolListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any - ) -> _models.ElasticPool: - """Gets an elastic pool. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 - :return: ElasticPool or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ElasticPool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - cls: ClsType[_models.ElasticPool] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - elastic_pool_name=elastic_pool_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ElasticPool", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - elastic_pool_name: str, - parameters: Union[_models.ElasticPool, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ElasticPool") - - _request = build_create_or_update_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - elastic_pool_name: str, - parameters: _models.ElasticPool, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ElasticPool]: - """Creates or updates an elastic pool. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 parameters: The elastic pool parameters. Required. - :type parameters: ~azure.mgmt.sql.models.ElasticPool - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ElasticPool or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ElasticPool] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - elastic_pool_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ElasticPool]: - """Creates or updates an elastic pool. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 parameters: The elastic pool parameters. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ElasticPool or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ElasticPool] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - elastic_pool_name: str, - parameters: Union[_models.ElasticPool, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ElasticPool]: - """Creates or updates an elastic pool. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 parameters: The elastic pool parameters. Is either a ElasticPool type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.sql.models.ElasticPool or IO[bytes] - :return: An instance of LROPoller that returns either ElasticPool or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ElasticPool] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - 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) - 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, - elastic_pool_name=elastic_pool_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ElasticPool", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.ElasticPool].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ElasticPool]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes an elastic pool. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 - :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", "2022-08-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( - resource_group_name=resource_group_name, - server_name=server_name, - elastic_pool_name=elastic_pool_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - server_name: str, - elastic_pool_name: str, - parameters: Union[_models.ElasticPoolUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ElasticPoolUpdate") - - _request = build_update_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - server_name: str, - elastic_pool_name: str, - parameters: _models.ElasticPoolUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ElasticPool]: - """Updates an elastic pool. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 parameters: The elastic pool update parameters. Required. - :type parameters: ~azure.mgmt.sql.models.ElasticPoolUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ElasticPool or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ElasticPool] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - server_name: str, - elastic_pool_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ElasticPool]: - """Updates an elastic pool. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 parameters: The elastic pool update parameters. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ElasticPool or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ElasticPool] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - server_name: str, - elastic_pool_name: str, - parameters: Union[_models.ElasticPoolUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ElasticPool]: - """Updates an elastic pool. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 parameters: The elastic pool update parameters. Is either a ElasticPoolUpdate type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ElasticPoolUpdate or IO[bytes] - :return: An instance of LROPoller that returns either ElasticPool or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ElasticPool] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - 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) - 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( - resource_group_name=resource_group_name, - server_name=server_name, - elastic_pool_name=elastic_pool_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ElasticPool", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ElasticPool].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ElasticPool]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _failover_initial( - self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_failover_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_failover( - self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Failovers an elastic pool. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 to failover. Required. - :type elastic_pool_name: str - :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", "2022-08-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._failover_initial( - resource_group_name=resource_group_name, - server_name=server_name, - elastic_pool_name=elastic_pool_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_encryption_protectors_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_encryption_protectors_operations.py deleted file mode 100644 index 745b4310f4ee..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_encryption_protectors_operations.py +++ /dev/null @@ -1,660 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_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", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - server_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector/{encryptionProtectorName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "encryptionProtectorName": _SERIALIZER.url("encryption_protector_name", encryption_protector_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - server_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector/{encryptionProtectorName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "encryptionProtectorName": _SERIALIZER.url("encryption_protector_name", encryption_protector_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_revalidate_request( - resource_group_name: str, - server_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector/{encryptionProtectorName}/revalidate", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "encryptionProtectorName": _SERIALIZER.url("encryption_protector_name", encryption_protector_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -class EncryptionProtectorsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`encryption_protectors` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.EncryptionProtector"]: - """Gets a list of server encryption protectors. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either EncryptionProtector or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.EncryptionProtector] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.EncryptionProtectorListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("EncryptionProtectorListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - **kwargs: Any - ) -> _models.EncryptionProtector: - """Gets a server encryption protector. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param encryption_protector_name: The name of the encryption protector to be retrieved. - "current" Required. - :type encryption_protector_name: str or ~azure.mgmt.sql.models.EncryptionProtectorName - :return: EncryptionProtector or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.EncryptionProtector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.EncryptionProtector] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - encryption_protector_name=encryption_protector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("EncryptionProtector", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - parameters: Union[_models.EncryptionProtector, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "EncryptionProtector") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - encryption_protector_name=encryption_protector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - parameters: _models.EncryptionProtector, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.EncryptionProtector]: - """Updates an existing encryption protector. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_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 - :param parameters: The requested encryption protector resource state. Required. - :type parameters: ~azure.mgmt.sql.models.EncryptionProtector - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either EncryptionProtector or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.EncryptionProtector] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.EncryptionProtector]: - """Updates an existing encryption protector. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_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 - :param parameters: The requested encryption protector resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either EncryptionProtector or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.EncryptionProtector] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - parameters: Union[_models.EncryptionProtector, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.EncryptionProtector]: - """Updates an existing encryption protector. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_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 - :param parameters: The requested encryption protector resource state. Is either a - EncryptionProtector type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.EncryptionProtector or IO[bytes] - :return: An instance of LROPoller that returns either EncryptionProtector or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.EncryptionProtector] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.EncryptionProtector] = 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, - encryption_protector_name=encryption_protector_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("EncryptionProtector", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.EncryptionProtector].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.EncryptionProtector]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _revalidate_initial( - self, - resource_group_name: str, - server_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_revalidate_request( - resource_group_name=resource_group_name, - server_name=server_name, - encryption_protector_name=encryption_protector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_revalidate( - self, - resource_group_name: str, - server_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - **kwargs: Any - ) -> LROPoller[None]: - """Revalidates an existing encryption protector. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_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 - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._revalidate_initial( - resource_group_name=resource_group_name, - server_name=server_name, - encryption_protector_name=encryption_protector_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index 92c7d2426427..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_endpoint_certificates_operations.py +++ /dev/null @@ -1,253 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_instance_request( - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/endpointCertificates", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, managed_instance_name: str, endpoint_type: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/endpointCertificates/{endpointType}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "endpointType": _SERIALIZER.url("endpoint_type", endpoint_type, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class EndpointCertificatesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`endpoint_certificates` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.EndpointCertificate"]: - """List certificates used on endpoints on the target instance. - - :param resource_group_name: The name of the resource group that 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 - :return: An iterator like instance of either EndpointCertificate or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.EndpointCertificate] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.EndpointCertificateListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("EndpointCertificateListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, managed_instance_name: str, endpoint_type: str, **kwargs: Any - ) -> _models.EndpointCertificate: - """Gets a certificate used on the endpoint with the given id. - - :param resource_group_name: The name of the resource group that 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 endpoint_type: Type of the endpoint whose certificate the customer is looking for. - Required. - :type endpoint_type: str - :return: EndpointCertificate or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.EndpointCertificate - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.EndpointCertificate] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - endpoint_type=endpoint_type, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("EndpointCertificate", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_extended_database_blob_auditing_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_extended_database_blob_auditing_policies_operations.py deleted file mode 100644 index 56bbc5662092..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_extended_database_blob_auditing_policies_operations.py +++ /dev/null @@ -1,441 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Literal, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_database_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extendedAuditingSettings", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, server_name: str, 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 {}) - - blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extendedAuditingSettings/{blobAuditingPolicyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_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 {}) - - blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - 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}/extendedAuditingSettings/{blobAuditingPolicyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -class ExtendedDatabaseBlobAuditingPoliciesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`extended_database_blob_auditing_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.ExtendedDatabaseBlobAuditingPolicy"]: - """Lists extended auditing settings 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 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 - :return: An iterator like instance of either ExtendedDatabaseBlobAuditingPolicy or the result - of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.ExtendedDatabaseBlobAuditingPolicyListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ExtendedDatabaseBlobAuditingPolicyListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> _models.ExtendedDatabaseBlobAuditingPolicy: - """Gets an extended database's blob auditing policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :return: ExtendedDatabaseBlobAuditingPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 {}) - - blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.ExtendedDatabaseBlobAuditingPolicy] = 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, - blob_auditing_policy_name=blob_auditing_policy_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ExtendedDatabaseBlobAuditingPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: _models.ExtendedDatabaseBlobAuditingPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ExtendedDatabaseBlobAuditingPolicy: - """Creates or updates an extended database's blob auditing policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The extended database blob auditing policy. Required. - :type parameters: ~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ExtendedDatabaseBlobAuditingPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ExtendedDatabaseBlobAuditingPolicy: - """Creates or updates an extended database's blob auditing policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The extended database blob auditing policy. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ExtendedDatabaseBlobAuditingPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.ExtendedDatabaseBlobAuditingPolicy, IO[bytes]], - **kwargs: Any - ) -> _models.ExtendedDatabaseBlobAuditingPolicy: - """Creates or updates an extended database's blob auditing policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The extended database blob auditing policy. Is either a - ExtendedDatabaseBlobAuditingPolicy type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicy or IO[bytes] - :return: ExtendedDatabaseBlobAuditingPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 {}) - - blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ExtendedDatabaseBlobAuditingPolicy") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - blob_auditing_policy_name=blob_auditing_policy_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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) - - deserialized = self._deserialize("ExtendedDatabaseBlobAuditingPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 712ef69f69c9..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_extended_server_blob_auditing_policies_operations.py +++ /dev/null @@ -1,488 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Literal, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_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", "2021-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/extendedAuditingSettings", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/extendedAuditingSettings/{blobAuditingPolicyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_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 {}) - - blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - 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}/extendedAuditingSettings/{blobAuditingPolicyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -class ExtendedServerBlobAuditingPoliciesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`extended_server_blob_auditing_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.ExtendedServerBlobAuditingPolicy"]: - """Lists extended auditing settings of 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 - :return: An iterator like instance of either ExtendedServerBlobAuditingPolicy or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.ExtendedServerBlobAuditingPolicyListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ExtendedServerBlobAuditingPolicyListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> _models.ExtendedServerBlobAuditingPolicy: - """Gets an extended server's blob auditing policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: ExtendedServerBlobAuditingPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 {}) - - blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.ExtendedServerBlobAuditingPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - blob_auditing_policy_name=blob_auditing_policy_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ExtendedServerBlobAuditingPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ExtendedServerBlobAuditingPolicy, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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 {}) - - blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ExtendedServerBlobAuditingPolicy") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - blob_auditing_policy_name=blob_auditing_policy_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - parameters: _models.ExtendedServerBlobAuditingPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ExtendedServerBlobAuditingPolicy]: - """Creates or updates an extended server's blob auditing policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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: Properties of extended blob auditing policy. Required. - :type parameters: ~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ExtendedServerBlobAuditingPolicy or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ExtendedServerBlobAuditingPolicy]: - """Creates or updates an extended server's blob auditing policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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: Properties of extended blob auditing policy. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ExtendedServerBlobAuditingPolicy or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ExtendedServerBlobAuditingPolicy, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ExtendedServerBlobAuditingPolicy]: - """Creates or updates an extended server's blob auditing policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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: Properties of extended blob auditing policy. Is either a - ExtendedServerBlobAuditingPolicy type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy or IO[bytes] - :return: An instance of LROPoller that returns either ExtendedServerBlobAuditingPolicy or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - 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) - 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, - parameters=parameters, - blob_auditing_policy_name=blob_auditing_policy_name, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ExtendedServerBlobAuditingPolicy", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ExtendedServerBlobAuditingPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ExtendedServerBlobAuditingPolicy]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 4ec017bf3b72..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_failover_groups_operations.py +++ /dev/null @@ -1,1316 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, server_name: str, 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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, server_name: str, failover_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_update_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/failover", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_force_failover_allow_data_loss_request( # pylint: disable=name-too-long - 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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/forceFailoverAllowDataLoss", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_try_planned_before_forced_failover_request( # pylint: disable=name-too-long - 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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/tryPlannedBeforeForcedFailover", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class FailoverGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`failover_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_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 - :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", "2023-05-01-preview")) - cls: ClsType[_models.FailoverGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace - def get( - self, resource_group_name: str, server_name: str, failover_group_name: str, **kwargs: Any - ) -> _models.FailoverGroup: - """Gets a failover group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :return: FailoverGroup or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.FailoverGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[_models.FailoverGroup] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - failover_group_name=failover_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("FailoverGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - failover_group_name: str, - parameters: Union[_models.FailoverGroup, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "FailoverGroup") - - _request = build_create_or_update_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - failover_group_name: str, - parameters: _models.FailoverGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.FailoverGroup]: - """Creates or updates a failover group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :param parameters: The failover group parameters. Required. - :type parameters: ~azure.mgmt.sql.models.FailoverGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - failover_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.FailoverGroup]: - """Creates or updates a failover group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :param parameters: The failover group parameters. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - failover_group_name: str, - parameters: Union[_models.FailoverGroup, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.FailoverGroup]: - """Creates or updates a failover group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :param parameters: The failover group parameters. Is either a FailoverGroup type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.sql.models.FailoverGroup or IO[bytes] - :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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - 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._create_or_update_initial( - resource_group_name=resource_group_name, - server_name=server_name, - failover_group_name=failover_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("FailoverGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.FailoverGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.FailoverGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, server_name: str, failover_group_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, server_name: str, failover_group_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes a failover group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :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", "2023-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_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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - server_name: str, - failover_group_name: str, - parameters: Union[_models.FailoverGroupUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "FailoverGroupUpdate") - - _request = build_update_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - server_name: str, - failover_group_name: str, - parameters: _models.FailoverGroupUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.FailoverGroup]: - """Updates a failover group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :param parameters: The failover group parameters. Required. - :type parameters: ~azure.mgmt.sql.models.FailoverGroupUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - server_name: str, - failover_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.FailoverGroup]: - """Updates a failover group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :param parameters: The failover group parameters. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - server_name: str, - failover_group_name: str, - parameters: Union[_models.FailoverGroupUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.FailoverGroup]: - """Updates a failover group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :param parameters: The failover group parameters. Is either a FailoverGroupUpdate type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.FailoverGroupUpdate or IO[bytes] - :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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - 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._update_initial( - resource_group_name=resource_group_name, - server_name=server_name, - failover_group_name=failover_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("FailoverGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.FailoverGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.FailoverGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _failover_initial( - self, resource_group_name: str, server_name: str, failover_group_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_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. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :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", "2023-05-01-preview")) - 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._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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("FailoverGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.FailoverGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.FailoverGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _force_failover_allow_data_loss_initial( - self, resource_group_name: str, server_name: str, failover_group_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_force_failover_allow_data_loss_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_force_failover_allow_data_loss( - 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 might 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 containing the failover group. Required. - :type server_name: str - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :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", "2023-05-01-preview")) - 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._force_failover_allow_data_loss_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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("FailoverGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.FailoverGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.FailoverGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _try_planned_before_forced_failover_initial( # pylint: disable=name-too-long - self, resource_group_name: str, server_name: str, failover_group_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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", "2023-05-01-preview")) - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("FailoverGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.FailoverGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.FailoverGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_firewall_rules_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_firewall_rules_operations.py deleted file mode 100644 index 2930458cf9ab..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_firewall_rules_operations.py +++ /dev/null @@ -1,675 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, server_name: str, firewall_rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "firewallRuleName": _SERIALIZER.url("firewall_rule_name", firewall_rule_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, server_name: str, firewall_rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "firewallRuleName": _SERIALIZER.url("firewall_rule_name", firewall_rule_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, server_name: str, firewall_rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "firewallRuleName": _SERIALIZER.url("firewall_rule_name", firewall_rule_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_replace_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_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) - - -class FirewallRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`firewall_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 - :return: FirewallRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.FirewallRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.FirewallRule] = kwargs.pop("cls", None) - - _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, - headers=_headers, - params=_params, - ) - _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("FirewallRule", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - firewall_rule_name: str, - parameters: _models.FirewallRule, - *, - content_type: str = "application/json", - **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 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 - :return: FirewallRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.FirewallRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - firewall_rule_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **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 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: FirewallRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.FirewallRule - :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[bytes]], - **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 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[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.FirewallRule or IO[bytes] - :return: FirewallRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.FirewallRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.FirewallRule] = 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, "FirewallRule") - - _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, - headers=_headers, - params=_params, - ) - _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) - - deserialized = self._deserialize("FirewallRule", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_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, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either FirewallRule or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.FirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.FirewallRuleListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @overload - def replace( - self, - resource_group_name: str, - server_name: str, - parameters: _models.FirewallRuleList, - *, - content_type: str = "application/json", - **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 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 - :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 replace( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **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 parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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 replace( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.FirewallRuleList, IO[bytes]], - **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 parameters: Is either a FirewallRuleList type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.FirewallRuleList or IO[bytes] - :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: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.FirewallRule]] = 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, "FirewallRuleList") - - _request = build_replace_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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("FirewallRule", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_geo_backup_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_geo_backup_policies_operations.py deleted file mode 100644 index 1266e9de2202..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_geo_backup_policies_operations.py +++ /dev/null @@ -1,464 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - 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}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "geoBackupPolicyName": _SERIALIZER.url("geo_backup_policy_name", geo_backup_policy_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - server_name: str, - database_name: str, - geo_backup_policy_name: Union[str, _models.GeoBackupPolicyName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - 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}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "geoBackupPolicyName": _SERIALIZER.url("geo_backup_policy_name", geo_backup_policy_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_database_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "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}/geoBackupPolicies", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class GeoBackupPoliciesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`geo_backup_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - geo_backup_policy_name: Union[str, _models.GeoBackupPolicyName], - parameters: _models.GeoBackupPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GeoBackupPolicy: - """Updates a database geo backup policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :param parameters: The required parameters for creating or updating the geo backup policy. - Required. - :type parameters: ~azure.mgmt.sql.models.GeoBackupPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: GeoBackupPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.GeoBackupPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - geo_backup_policy_name: Union[str, _models.GeoBackupPolicyName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GeoBackupPolicy: - """Updates a database geo backup policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :param parameters: The required parameters for creating or updating the geo backup policy. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: GeoBackupPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.GeoBackupPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - geo_backup_policy_name: Union[str, _models.GeoBackupPolicyName], - parameters: Union[_models.GeoBackupPolicy, IO[bytes]], - **kwargs: Any - ) -> _models.GeoBackupPolicy: - """Updates a database geo backup policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :param parameters: The required parameters for creating or updating the geo backup policy. Is - either a GeoBackupPolicy type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.GeoBackupPolicy or IO[bytes] - :return: GeoBackupPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.GeoBackupPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GeoBackupPolicy] = 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, "GeoBackupPolicy") - - _request = build_create_or_update_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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) - - deserialized = self._deserialize("GeoBackupPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: GeoBackupPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.GeoBackupPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.GeoBackupPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - geo_backup_policy_name=geo_backup_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either GeoBackupPolicy or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.GeoBackupPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.GeoBackupPolicyListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 03286fc1992a..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_instance_failover_groups_operations.py +++ /dev/null @@ -1,925 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_location_request( - resource_group_name: str, location_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-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}/instanceFailoverGroups", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, location_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: str = kwargs.pop("api_version", _params.pop("api-version", "2022-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}/instanceFailoverGroups/{failoverGroupName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, location_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: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, location_name: str, failover_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_failover_request( - resource_group_name: str, location_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: str = kwargs.pop("api_version", _params.pop("api-version", "2022-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}/instanceFailoverGroups/{failoverGroupName}/failover", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_force_failover_allow_data_loss_request( # pylint: disable=name-too-long - resource_group_name: str, location_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: str = kwargs.pop("api_version", _params.pop("api-version", "2022-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}/instanceFailoverGroups/{failoverGroupName}/forceFailoverAllowDataLoss", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class InstanceFailoverGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`instance_failover_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.InstanceFailoverGroup"]: - """Lists the failover groups in a 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 name of the region where the resource is located. Required. - :type location_name: str - :return: An iterator like instance of either InstanceFailoverGroup or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.InstanceFailoverGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - cls: ClsType[_models.InstanceFailoverGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("InstanceFailoverGroupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, location_name: str, failover_group_name: str, **kwargs: Any - ) -> _models.InstanceFailoverGroup: - """Gets a failover group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :return: InstanceFailoverGroup or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.InstanceFailoverGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-05-01-preview")) - cls: ClsType[_models.InstanceFailoverGroup] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - location_name=location_name, - failover_group_name=failover_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("InstanceFailoverGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - location_name: str, - failover_group_name: str, - parameters: Union[_models.InstanceFailoverGroup, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2022-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "InstanceFailoverGroup") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - location_name=location_name, - failover_group_name=failover_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - location_name: str, - failover_group_name: str, - parameters: _models.InstanceFailoverGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.InstanceFailoverGroup]: - """Creates or updates a failover group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :param parameters: The failover group parameters. Required. - :type parameters: ~azure.mgmt.sql.models.InstanceFailoverGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either InstanceFailoverGroup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.InstanceFailoverGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - location_name: str, - failover_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.InstanceFailoverGroup]: - """Creates or updates a failover group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :param parameters: The failover group parameters. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either InstanceFailoverGroup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.InstanceFailoverGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - location_name: str, - failover_group_name: str, - parameters: Union[_models.InstanceFailoverGroup, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.InstanceFailoverGroup]: - """Creates or updates a failover group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :param parameters: The failover group parameters. Is either a InstanceFailoverGroup type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.InstanceFailoverGroup or IO[bytes] - :return: An instance of LROPoller that returns either InstanceFailoverGroup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.InstanceFailoverGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - 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) - 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, - location_name=location_name, - failover_group_name=failover_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("InstanceFailoverGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.InstanceFailoverGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.InstanceFailoverGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, location_name: str, failover_group_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2022-05-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - location_name=location_name, - failover_group_name=failover_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, location_name: str, failover_group_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes a failover group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :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", "2022-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_initial( - resource_group_name=resource_group_name, - location_name=location_name, - failover_group_name=failover_group_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _failover_initial( - self, resource_group_name: str, location_name: str, failover_group_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2022-05-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_failover_request( - resource_group_name=resource_group_name, - location_name=location_name, - failover_group_name=failover_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_failover( - self, resource_group_name: str, location_name: str, failover_group_name: str, **kwargs: Any - ) -> LROPoller[_models.InstanceFailoverGroup]: - """Fails over from the current primary managed instance to this managed instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :return: An instance of LROPoller that returns either InstanceFailoverGroup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.InstanceFailoverGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - 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) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._failover_initial( - resource_group_name=resource_group_name, - location_name=location_name, - failover_group_name=failover_group_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("InstanceFailoverGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.InstanceFailoverGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.InstanceFailoverGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _force_failover_allow_data_loss_initial( - self, resource_group_name: str, location_name: str, failover_group_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2022-05-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_force_failover_allow_data_loss_request( - resource_group_name=resource_group_name, - location_name=location_name, - failover_group_name=failover_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_force_failover_allow_data_loss( - self, resource_group_name: str, location_name: str, failover_group_name: str, **kwargs: Any - ) -> LROPoller[_models.InstanceFailoverGroup]: - """Fails over from the current primary managed instance to this managed instance. This operation - might result in data loss. - - :param resource_group_name: The name of the resource group that 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 - :param failover_group_name: The name of the failover group. Required. - :type failover_group_name: str - :return: An instance of LROPoller that returns either InstanceFailoverGroup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.InstanceFailoverGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - 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) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._force_failover_allow_data_loss_initial( - resource_group_name=resource_group_name, - location_name=location_name, - failover_group_name=failover_group_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("InstanceFailoverGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.InstanceFailoverGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.InstanceFailoverGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_instance_pools_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_instance_pools_operations.py deleted file mode 100644 index 6b54928c3872..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_instance_pools_operations.py +++ /dev/null @@ -1,908 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/instancePools") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _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, instance_pool_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "instancePoolName": _SERIALIZER.url("instance_pool_name", instance_pool_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, instance_pool_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "instancePoolName": _SERIALIZER.url("instance_pool_name", instance_pool_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, instance_pool_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "instancePoolName": _SERIALIZER.url("instance_pool_name", instance_pool_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_update_request( - resource_group_name: str, instance_pool_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "instancePoolName": _SERIALIZER.url("instance_pool_name", instance_pool_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -class InstancePoolsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`instance_pools` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_models.InstancePool"]: - """Gets a list of all instance pools in the subscription. - - :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", "2023-05-01-preview")) - cls: ClsType[_models.InstancePoolListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_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 - :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", "2023-05-01-preview")) - cls: ClsType[_models.InstancePoolListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace - def get(self, resource_group_name: str, instance_pool_name: str, **kwargs: Any) -> _models.InstancePool: - """Gets an instance pool. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param instance_pool_name: The name of the instance pool to be retrieved. Required. - :type instance_pool_name: str - :return: InstancePool or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.InstancePool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[_models.InstancePool] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - instance_pool_name=instance_pool_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("InstancePool", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - instance_pool_name: str, - parameters: Union[_models.InstancePool, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "InstancePool") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - instance_pool_name=instance_pool_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - instance_pool_name: str, - parameters: _models.InstancePool, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.InstancePool]: - """Creates or updates an instance pool. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param instance_pool_name: The name of the instance pool to be created or updated. Required. - :type instance_pool_name: str - :param parameters: The requested instance pool resource state. Required. - :type parameters: ~azure.mgmt.sql.models.InstancePool - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either InstancePool or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.InstancePool] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - instance_pool_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.InstancePool]: - """Creates or updates an instance pool. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param instance_pool_name: The name of the instance pool to be created or updated. Required. - :type instance_pool_name: str - :param parameters: The requested instance pool resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either InstancePool or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.InstancePool] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - instance_pool_name: str, - parameters: Union[_models.InstancePool, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.InstancePool]: - """Creates or updates an instance pool. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param instance_pool_name: The name of the instance pool to be created or updated. Required. - :type instance_pool_name: str - :param parameters: The requested instance pool resource state. Is either a InstancePool type or - a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.InstancePool or IO[bytes] - :return: An instance of LROPoller that returns either InstancePool or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.InstancePool] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.InstancePool] = 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, - instance_pool_name=instance_pool_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("InstancePool", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.InstancePool].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.InstancePool]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial(self, resource_group_name: str, instance_pool_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - instance_pool_name=instance_pool_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete(self, resource_group_name: str, instance_pool_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes an instance pool. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param instance_pool_name: The name of the instance pool to be deleted. Required. - :type instance_pool_name: str - :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", "2023-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_initial( - resource_group_name=resource_group_name, - instance_pool_name=instance_pool_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - instance_pool_name: str, - parameters: Union[_models.InstancePoolUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "InstancePoolUpdate") - - _request = build_update_request( - resource_group_name=resource_group_name, - instance_pool_name=instance_pool_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - instance_pool_name: str, - parameters: _models.InstancePoolUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.InstancePool]: - """Updates an instance pool. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param instance_pool_name: The name of the instance pool to be updated. Required. - :type instance_pool_name: str - :param parameters: The requested instance pool resource state. Required. - :type parameters: ~azure.mgmt.sql.models.InstancePoolUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either InstancePool or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.InstancePool] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - instance_pool_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.InstancePool]: - """Updates an instance pool. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param instance_pool_name: The name of the instance pool to be updated. Required. - :type instance_pool_name: str - :param parameters: The requested instance pool resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either InstancePool or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.InstancePool] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - instance_pool_name: str, - parameters: Union[_models.InstancePoolUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.InstancePool]: - """Updates an instance pool. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param instance_pool_name: The name of the instance pool to be updated. Required. - :type instance_pool_name: str - :param parameters: The requested instance pool resource state. Is either a InstancePoolUpdate - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.InstancePoolUpdate or IO[bytes] - :return: An instance of LROPoller that returns either InstancePool or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.InstancePool] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.InstancePool] = 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( - resource_group_name=resource_group_name, - instance_pool_name=instance_pool_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("InstancePool", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.InstancePool].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.InstancePool]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 7113d38aaf03..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_ipv6_firewall_rules_operations.py +++ /dev/null @@ -1,512 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_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", "2022-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/ipv6FirewallRules", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, server_name: str, firewall_rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/ipv6FirewallRules/{firewallRuleName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "firewallRuleName": _SERIALIZER.url("firewall_rule_name", firewall_rule_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, server_name: str, firewall_rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-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}/ipv6FirewallRules/{firewallRuleName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "firewallRuleName": _SERIALIZER.url("firewall_rule_name", firewall_rule_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, server_name: str, firewall_rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/ipv6FirewallRules/{firewallRuleName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "firewallRuleName": _SERIALIZER.url("firewall_rule_name", firewall_rule_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -class IPv6FirewallRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`ipv6_firewall_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.IPv6FirewallRule"]: - """Gets a list of IPv6 firewall rules. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either IPv6FirewallRule or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.IPv6FirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[_models.IPv6FirewallRuleListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("IPv6FirewallRuleListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, server_name: str, firewall_rule_name: str, **kwargs: Any - ) -> _models.IPv6FirewallRule: - """Gets an IPv6 firewall rule. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. 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 - :return: IPv6FirewallRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.IPv6FirewallRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-11-01-preview")) - cls: ClsType[_models.IPv6FirewallRule] = kwargs.pop("cls", None) - - _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, - headers=_headers, - params=_params, - ) - _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("IPv6FirewallRule", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - firewall_rule_name: str, - parameters: _models.IPv6FirewallRule, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IPv6FirewallRule: - """Creates or updates an IPv6 firewall rule. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. 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 an IPv6 firewall rule. - Required. - :type parameters: ~azure.mgmt.sql.models.IPv6FirewallRule - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: IPv6FirewallRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.IPv6FirewallRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - firewall_rule_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IPv6FirewallRule: - """Creates or updates an IPv6 firewall rule. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. 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 an IPv6 firewall rule. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: IPv6FirewallRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.IPv6FirewallRule - :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.IPv6FirewallRule, IO[bytes]], - **kwargs: Any - ) -> _models.IPv6FirewallRule: - """Creates or updates an IPv6 firewall rule. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. 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 an IPv6 firewall rule. Is - either a IPv6FirewallRule type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.IPv6FirewallRule or IO[bytes] - :return: IPv6FirewallRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.IPv6FirewallRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "IPv6FirewallRule") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - firewall_rule_name=firewall_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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) - - deserialized = self._deserialize("IPv6FirewallRule", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 an IPv6 firewall rule. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. 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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-11-01-preview")) - 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, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_agents_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_agents_operations.py deleted file mode 100644 index 3246560a9642..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_agents_operations.py +++ /dev/null @@ -1,862 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_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", "2020-11-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", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, server_name: str, job_agent_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, server_name: str, job_agent_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, server_name: str, job_agent_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_update_request( - resource_group_name: str, server_name: str, job_agent_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -class JobAgentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`job_agents` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.JobAgent"]: - """Gets a list of job agents in a server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either JobAgent or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobAgent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobAgentListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("JobAgentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, resource_group_name: str, server_name: str, job_agent_name: str, **kwargs: Any) -> _models.JobAgent: - """Gets a job agent. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 to be retrieved. Required. - :type job_agent_name: str - :return: JobAgent or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobAgent - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobAgent] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("JobAgent", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - parameters: Union[_models.JobAgent, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "JobAgent") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - parameters: _models.JobAgent, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.JobAgent]: - """Creates or updates a job agent. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 to be created or updated. Required. - :type job_agent_name: str - :param parameters: The requested job agent resource state. Required. - :type parameters: ~azure.mgmt.sql.models.JobAgent - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either JobAgent or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.JobAgent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.JobAgent]: - """Creates or updates a job agent. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 to be created or updated. Required. - :type job_agent_name: str - :param parameters: The requested job agent resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either JobAgent or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.JobAgent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - parameters: Union[_models.JobAgent, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.JobAgent]: - """Creates or updates a job agent. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 to be created or updated. Required. - :type job_agent_name: str - :param parameters: The requested job agent resource state. Is either a JobAgent type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.JobAgent or IO[bytes] - :return: An instance of LROPoller that returns either JobAgent or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.JobAgent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.JobAgent] = 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, - job_agent_name=job_agent_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("JobAgent", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.JobAgent].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.JobAgent]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, server_name: str, job_agent_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, server_name: str, job_agent_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes a job agent. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 to be deleted. Required. - :type job_agent_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - parameters: Union[_models.JobAgentUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "JobAgentUpdate") - - _request = build_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - parameters: _models.JobAgentUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.JobAgent]: - """Updates a job agent. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 to be updated. Required. - :type job_agent_name: str - :param parameters: The update to the job agent. Required. - :type parameters: ~azure.mgmt.sql.models.JobAgentUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either JobAgent or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.JobAgent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.JobAgent]: - """Updates a job agent. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 to be updated. Required. - :type job_agent_name: str - :param parameters: The update to the job agent. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either JobAgent or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.JobAgent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - parameters: Union[_models.JobAgentUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.JobAgent]: - """Updates a job agent. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 to be updated. Required. - :type job_agent_name: str - :param parameters: The update to the job agent. Is either a JobAgentUpdate type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.sql.models.JobAgentUpdate or IO[bytes] - :return: An instance of LROPoller that returns either JobAgent or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.JobAgent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.JobAgent] = 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( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("JobAgent", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.JobAgent].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.JobAgent]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_credentials_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_credentials_operations.py deleted file mode 100644 index 2b0d394038a2..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_credentials_operations.py +++ /dev/null @@ -1,548 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_agent_request( - resource_group_name: str, server_name: str, job_agent_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/credentials", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - server_name: str, - job_agent_name: str, - credential_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/credentials/{credentialName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "credentialName": _SERIALIZER.url("credential_name", credential_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - server_name: str, - job_agent_name: str, - credential_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/credentials/{credentialName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "credentialName": _SERIALIZER.url("credential_name", credential_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - server_name: str, - job_agent_name: str, - credential_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/credentials/{credentialName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "credentialName": _SERIALIZER.url("credential_name", credential_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -class JobCredentialsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`job_credentials` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_agent( - self, resource_group_name: str, server_name: str, job_agent_name: str, **kwargs: Any - ) -> ItemPaged["_models.JobCredential"]: - """Gets a list of jobs credentials. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 - :return: An iterator like instance of either JobCredential or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobCredential] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobCredentialListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_agent_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("JobCredentialListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, server_name: str, job_agent_name: str, credential_name: str, **kwargs: Any - ) -> _models.JobCredential: - """Gets a jobs credential. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 credential_name: The name of the credential. Required. - :type credential_name: str - :return: JobCredential or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobCredential - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobCredential] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - credential_name=credential_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("JobCredential", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - credential_name: str, - parameters: _models.JobCredential, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.JobCredential: - """Creates or updates a job credential. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 credential_name: The name of the credential. Required. - :type credential_name: str - :param parameters: The requested job credential state. Required. - :type parameters: ~azure.mgmt.sql.models.JobCredential - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: JobCredential or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobCredential - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - credential_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.JobCredential: - """Creates or updates a job credential. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 credential_name: The name of the credential. Required. - :type credential_name: str - :param parameters: The requested job credential state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: JobCredential or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobCredential - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - credential_name: str, - parameters: Union[_models.JobCredential, IO[bytes]], - **kwargs: Any - ) -> _models.JobCredential: - """Creates or updates a job credential. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 credential_name: The name of the credential. Required. - :type credential_name: str - :param parameters: The requested job credential state. Is either a JobCredential type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.JobCredential or IO[bytes] - :return: JobCredential or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobCredential - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "JobCredential") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - credential_name=credential_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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) - - deserialized = self._deserialize("JobCredential", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, server_name: str, job_agent_name: str, credential_name: str, **kwargs: Any - ) -> None: - """Deletes a job credential. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 credential_name: The name of the credential. Required. - :type credential_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - credential_name=credential_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_executions_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_executions_operations.py deleted file mode 100644 index b34deef62ab4..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_executions_operations.py +++ /dev/null @@ -1,947 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -import datetime -from typing import Any, Callable, Iterator, Optional, TypeVar, Union, cast - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_agent_request( - resource_group_name: str, - server_name: str, - job_agent_name: str, - subscription_id: str, - *, - create_time_min: Optional[datetime.datetime] = None, - create_time_max: Optional[datetime.datetime] = None, - end_time_min: Optional[datetime.datetime] = None, - end_time_max: Optional[datetime.datetime] = None, - is_active: Optional[bool] = None, - skip: Optional[int] = None, - top: Optional[int] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/executions", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if create_time_min is not None: - _params["createTimeMin"] = _SERIALIZER.query("create_time_min", create_time_min, "iso-8601") - if create_time_max is not None: - _params["createTimeMax"] = _SERIALIZER.query("create_time_max", create_time_max, "iso-8601") - if end_time_min is not None: - _params["endTimeMin"] = _SERIALIZER.query("end_time_min", end_time_min, "iso-8601") - if end_time_max is not None: - _params["endTimeMax"] = _SERIALIZER.query("end_time_max", end_time_max, "iso-8601") - if is_active is not None: - _params["isActive"] = _SERIALIZER.query("is_active", is_active, "bool") - if skip is not None: - _params["$skip"] = _SERIALIZER.query("skip", skip, "int") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cancel_request( - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - job_execution_id: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/cancel", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "jobName": _SERIALIZER.url("job_name", job_name, "str"), - "jobExecutionId": _SERIALIZER.url("job_execution_id", job_execution_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_create_request( - resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "jobName": _SERIALIZER.url("job_name", job_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_job_request( - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - subscription_id: str, - *, - create_time_min: Optional[datetime.datetime] = None, - create_time_max: Optional[datetime.datetime] = None, - end_time_min: Optional[datetime.datetime] = None, - end_time_max: Optional[datetime.datetime] = None, - is_active: Optional[bool] = None, - skip: Optional[int] = None, - top: Optional[int] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "jobName": _SERIALIZER.url("job_name", job_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if create_time_min is not None: - _params["createTimeMin"] = _SERIALIZER.query("create_time_min", create_time_min, "iso-8601") - if create_time_max is not None: - _params["createTimeMax"] = _SERIALIZER.query("create_time_max", create_time_max, "iso-8601") - if end_time_min is not None: - _params["endTimeMin"] = _SERIALIZER.query("end_time_min", end_time_min, "iso-8601") - if end_time_max is not None: - _params["endTimeMax"] = _SERIALIZER.query("end_time_max", end_time_max, "iso-8601") - if is_active is not None: - _params["isActive"] = _SERIALIZER.query("is_active", is_active, "bool") - if skip is not None: - _params["$skip"] = _SERIALIZER.query("skip", skip, "int") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - job_execution_id: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "jobName": _SERIALIZER.url("job_name", job_name, "str"), - "jobExecutionId": _SERIALIZER.url("job_execution_id", job_execution_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _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, - job_agent_name: str, - job_name: str, - job_execution_id: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "jobName": _SERIALIZER.url("job_name", job_name, "str"), - "jobExecutionId": _SERIALIZER.url("job_execution_id", job_execution_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -class JobExecutionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`job_executions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_agent( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - create_time_min: Optional[datetime.datetime] = None, - create_time_max: Optional[datetime.datetime] = None, - end_time_min: Optional[datetime.datetime] = None, - end_time_max: Optional[datetime.datetime] = None, - is_active: Optional[bool] = None, - skip: Optional[int] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> ItemPaged["_models.JobExecution"]: - """Lists all executions in a job agent. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 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 - :return: An iterator like instance of either JobExecution or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobExecution] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobExecutionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_agent_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - subscription_id=self._config.subscription_id, - create_time_min=create_time_min, - create_time_max=create_time_max, - end_time_min=end_time_min, - end_time_max=end_time_max, - is_active=is_active, - skip=skip, - top=top, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace - def cancel( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - job_execution_id: str, - **kwargs: Any - ) -> None: - """Requests cancellation of a job execution. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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_execution_id: The id of the job execution to cancel. Required. - :type job_execution_id: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_cancel_request( - resource_group_name=resource_group_name, - server_name=server_name, - 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, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - def _create_initial( - self, resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_create_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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_create( - self, resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, **kwargs: Any - ) -> LROPoller[_models.JobExecution]: - """Starts an elastic job execution. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 - :return: An instance of LROPoller that returns either JobExecution or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.JobExecution] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobExecution] = kwargs.pop("cls", None) - 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( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - job_name=job_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("JobExecution", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.JobExecution].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.JobExecution]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 - ) -> ItemPaged["_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 - :return: An iterator like instance of either JobExecution or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobExecution] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobExecutionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - job_execution_id: str, - **kwargs: Any - ) -> _models.JobExecution: - """Gets a job execution. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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_execution_id: The id of the job execution. Required. - :type job_execution_id: str - :return: JobExecution or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobExecution - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobExecution] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - job_name=job_name, - job_execution_id=job_execution_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - 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 - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - ) -> LROPoller[_models.JobExecution]: - """Creates or updates a job execution. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 job execution id to create the job execution under. Required. - :type job_execution_id: str - :return: An instance of LROPoller that returns either JobExecution or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.JobExecution] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobExecution] = kwargs.pop("cls", None) - 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, - 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, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("JobExecution", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.JobExecution].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.JobExecution]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_private_endpoints_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_private_endpoints_operations.py deleted file mode 100644 index 3ea3d44f52a7..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_private_endpoints_operations.py +++ /dev/null @@ -1,676 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_agent_request( - resource_group_name: str, server_name: str, job_agent_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/privateEndpoints", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - server_name: str, - job_agent_name: str, - private_endpoint_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/privateEndpoints/{privateEndpointName}", - ) - 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"), - "privateEndpointName": _SERIALIZER.url("private_endpoint_name", private_endpoint_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # 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, - job_agent_name: str, - private_endpoint_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/privateEndpoints/{privateEndpointName}", - ) - 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"), - "privateEndpointName": _SERIALIZER.url("private_endpoint_name", private_endpoint_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # 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_delete_request( - resource_group_name: str, - server_name: str, - job_agent_name: str, - private_endpoint_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/privateEndpoints/{privateEndpointName}", - ) - 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"), - "privateEndpointName": _SERIALIZER.url("private_endpoint_name", private_endpoint_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -class JobPrivateEndpointsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`job_private_endpoints` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_agent( - self, resource_group_name: str, server_name: str, job_agent_name: str, **kwargs: Any - ) -> ItemPaged["_models.JobPrivateEndpoint"]: - """Gets a list of job agent private endpoints. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param job_agent_name: The name of the job agent. Required. - :type job_agent_name: str - :return: An iterator like instance of either JobPrivateEndpoint or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobPrivateEndpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - cls: ClsType[_models.JobPrivateEndpointListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_agent_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("JobPrivateEndpointListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, server_name: str, job_agent_name: str, private_endpoint_name: str, **kwargs: Any - ) -> _models.JobPrivateEndpoint: - """Gets a private endpoint. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param job_agent_name: The name of the job agent. Required. - :type job_agent_name: str - :param private_endpoint_name: The name of the private endpoint to get. Required. - :type private_endpoint_name: str - :return: JobPrivateEndpoint or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobPrivateEndpoint - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[_models.JobPrivateEndpoint] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - private_endpoint_name=private_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("JobPrivateEndpoint", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - private_endpoint_name: str, - parameters: Union[_models.JobPrivateEndpoint, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "JobPrivateEndpoint") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - private_endpoint_name=private_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - private_endpoint_name: str, - parameters: _models.JobPrivateEndpoint, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.JobPrivateEndpoint]: - """Creates or updates a private endpoint. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param job_agent_name: The name of the job agent. Required. - :type job_agent_name: str - :param private_endpoint_name: The name of the private endpoint. Required. - :type private_endpoint_name: str - :param parameters: The requested private endpoint state. Required. - :type parameters: ~azure.mgmt.sql.models.JobPrivateEndpoint - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either JobPrivateEndpoint or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.JobPrivateEndpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - private_endpoint_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.JobPrivateEndpoint]: - """Creates or updates a private endpoint. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param job_agent_name: The name of the job agent. Required. - :type job_agent_name: str - :param private_endpoint_name: The name of the private endpoint. Required. - :type private_endpoint_name: str - :param parameters: The requested private endpoint state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either JobPrivateEndpoint or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.JobPrivateEndpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - private_endpoint_name: str, - parameters: Union[_models.JobPrivateEndpoint, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.JobPrivateEndpoint]: - """Creates or updates a private endpoint. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param job_agent_name: The name of the job agent. Required. - :type job_agent_name: str - :param private_endpoint_name: The name of the private endpoint. Required. - :type private_endpoint_name: str - :param parameters: The requested private endpoint state. Is either a JobPrivateEndpoint type or - a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.JobPrivateEndpoint or IO[bytes] - :return: An instance of LROPoller that returns either JobPrivateEndpoint or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.JobPrivateEndpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.JobPrivateEndpoint] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - private_endpoint_name=private_endpoint_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("JobPrivateEndpoint", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.JobPrivateEndpoint].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.JobPrivateEndpoint]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, server_name: str, job_agent_name: str, private_endpoint_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - private_endpoint_name=private_endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, server_name: str, job_agent_name: str, private_endpoint_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes a private endpoint. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param job_agent_name: The name of the job agent. Required. - :type job_agent_name: str - :param private_endpoint_name: The name of the private endpoint to delete. Required. - :type private_endpoint_name: str - :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", "2023-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_initial( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - private_endpoint_name=private_endpoint_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_step_executions_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_step_executions_operations.py deleted file mode 100644 index 9c3d129eec85..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_step_executions_operations.py +++ /dev/null @@ -1,358 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -import datetime -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_job_execution_request( - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - job_execution_id: str, - subscription_id: str, - *, - create_time_min: Optional[datetime.datetime] = None, - create_time_max: Optional[datetime.datetime] = None, - end_time_min: Optional[datetime.datetime] = None, - end_time_max: Optional[datetime.datetime] = None, - is_active: Optional[bool] = None, - skip: Optional[int] = None, - top: Optional[int] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "jobName": _SERIALIZER.url("job_name", job_name, "str"), - "jobExecutionId": _SERIALIZER.url("job_execution_id", job_execution_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if create_time_min is not None: - _params["createTimeMin"] = _SERIALIZER.query("create_time_min", create_time_min, "iso-8601") - if create_time_max is not None: - _params["createTimeMax"] = _SERIALIZER.query("create_time_max", create_time_max, "iso-8601") - if end_time_min is not None: - _params["endTimeMin"] = _SERIALIZER.query("end_time_min", end_time_min, "iso-8601") - if end_time_max is not None: - _params["endTimeMax"] = _SERIALIZER.query("end_time_max", end_time_max, "iso-8601") - if is_active is not None: - _params["isActive"] = _SERIALIZER.query("is_active", is_active, "bool") - if skip is not None: - _params["$skip"] = _SERIALIZER.query("skip", skip, "int") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - job_execution_id: str, - step_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps/{stepName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "jobName": _SERIALIZER.url("job_name", job_name, "str"), - "jobExecutionId": _SERIALIZER.url("job_execution_id", job_execution_id, "str"), - "stepName": _SERIALIZER.url("step_name", step_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class JobStepExecutionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`job_step_executions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @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, - end_time_max: Optional[datetime.datetime] = None, - is_active: Optional[bool] = None, - skip: Optional[int] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> ItemPaged["_models.JobExecution"]: - """Lists the step executions 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. - :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 id of the job execution. Required. - :type job_execution_id: 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 - :return: An iterator like instance of either JobExecution or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobExecution] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobExecutionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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_execution_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - job_name=job_name, - job_execution_id=job_execution_id, - subscription_id=self._config.subscription_id, - create_time_min=create_time_min, - create_time_max=create_time_max, - end_time_min=end_time_min, - end_time_max=end_time_max, - is_active=is_active, - skip=skip, - top=top, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @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, - **kwargs: Any - ) -> _models.JobExecution: - """Gets a step execution of a job execution. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 - :return: JobExecution or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobExecution - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobExecution] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - job_name=job_name, - job_execution_id=job_execution_id, - step_name=step_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_steps_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_steps_operations.py deleted file mode 100644 index d69d853c481b..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_steps_operations.py +++ /dev/null @@ -1,831 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_version_request( - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - job_version: int, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions/{jobVersion}/steps", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "jobName": _SERIALIZER.url("job_name", job_name, "str"), - "jobVersion": _SERIALIZER.url("job_version", job_version, "int"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_by_version_request( - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - job_version: int, - step_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "jobName": _SERIALIZER.url("job_name", job_name, "str"), - "jobVersion": _SERIALIZER.url("job_version", job_version, "int"), - "stepName": _SERIALIZER.url("step_name", step_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_job_request( - resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "jobName": _SERIALIZER.url("job_name", job_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - step_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "jobName": _SERIALIZER.url("job_name", job_name, "str"), - "stepName": _SERIALIZER.url("step_name", step_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - step_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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/{stepName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "jobName": _SERIALIZER.url("job_name", job_name, "str"), - "stepName": _SERIALIZER.url("step_name", step_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - step_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps/{stepName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "jobName": _SERIALIZER.url("job_name", job_name, "str"), - "stepName": _SERIALIZER.url("step_name", step_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -class JobStepsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`job_steps` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_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 - :return: An iterator like instance of either JobStep or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobStep] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobStepListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @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 - :return: JobStep or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobStep] = kwargs.pop("cls", None) - - _request = build_get_by_version_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - job_name=job_name, - job_version=job_version, - step_name=step_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_job( - self, resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, **kwargs: Any - ) -> ItemPaged["_models.JobStep"]: - """Gets all job steps for a job's current version. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 - :return: An iterator like instance of either JobStep or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobStep] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobStepListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - step_name: str, - **kwargs: Any - ) -> _models.JobStep: - """Gets a job step in a job's current version. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 step_name: The name of the job step. Required. - :type step_name: str - :return: JobStep or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobStep] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - job_name=job_name, - step_name=step_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - step_name: str, - parameters: _models.JobStep, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.JobStep: - """Creates or updates a job step. This will implicitly create a new job version. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 step_name: The name of the job step. Required. - :type step_name: str - :param parameters: The requested state of the job step. Required. - :type parameters: ~azure.mgmt.sql.models.JobStep - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: JobStep or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - step_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.JobStep: - """Creates or updates a job step. This will implicitly create a new job version. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 step_name: The name of the job step. Required. - :type step_name: str - :param parameters: The requested state of the job step. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: JobStep or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - step_name: str, - parameters: Union[_models.JobStep, IO[bytes]], - **kwargs: Any - ) -> _models.JobStep: - """Creates or updates a job step. This will implicitly create a new job version. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 step_name: The name of the job step. Required. - :type step_name: str - :param parameters: The requested state of the job step. Is either a JobStep type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.sql.models.JobStep or IO[bytes] - :return: JobStep or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "JobStep") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - job_name=job_name, - step_name=step_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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) - - deserialized = self._deserialize("JobStep", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - step_name: str, - **kwargs: Any - ) -> None: - """Deletes a job step. This will implicitly create a new job version. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 step_name: The name of the job step to delete. Required. - :type step_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - job_name=job_name, - step_name=step_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_target_executions_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_target_executions_operations.py deleted file mode 100644 index a6d2074419d0..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_target_executions_operations.py +++ /dev/null @@ -1,552 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -import datetime -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_job_execution_request( - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - job_execution_id: str, - subscription_id: str, - *, - create_time_min: Optional[datetime.datetime] = None, - create_time_max: Optional[datetime.datetime] = None, - end_time_min: Optional[datetime.datetime] = None, - end_time_max: Optional[datetime.datetime] = None, - is_active: Optional[bool] = None, - skip: Optional[int] = None, - top: Optional[int] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/targets", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "jobName": _SERIALIZER.url("job_name", job_name, "str"), - "jobExecutionId": _SERIALIZER.url("job_execution_id", job_execution_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if create_time_min is not None: - _params["createTimeMin"] = _SERIALIZER.query("create_time_min", create_time_min, "iso-8601") - if create_time_max is not None: - _params["createTimeMax"] = _SERIALIZER.query("create_time_max", create_time_max, "iso-8601") - if end_time_min is not None: - _params["endTimeMin"] = _SERIALIZER.query("end_time_min", end_time_min, "iso-8601") - if end_time_max is not None: - _params["endTimeMax"] = _SERIALIZER.query("end_time_max", end_time_max, "iso-8601") - if is_active is not None: - _params["isActive"] = _SERIALIZER.query("is_active", is_active, "bool") - if skip is not None: - _params["$skip"] = _SERIALIZER.query("skip", skip, "int") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_step_request( - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - job_execution_id: str, - step_name: str, - subscription_id: str, - *, - create_time_min: Optional[datetime.datetime] = None, - create_time_max: Optional[datetime.datetime] = None, - end_time_min: Optional[datetime.datetime] = None, - end_time_max: Optional[datetime.datetime] = None, - is_active: Optional[bool] = None, - skip: Optional[int] = None, - top: Optional[int] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps/{stepName}/targets", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "jobName": _SERIALIZER.url("job_name", job_name, "str"), - "jobExecutionId": _SERIALIZER.url("job_execution_id", job_execution_id, "str"), - "stepName": _SERIALIZER.url("step_name", step_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if create_time_min is not None: - _params["createTimeMin"] = _SERIALIZER.query("create_time_min", create_time_min, "iso-8601") - if create_time_max is not None: - _params["createTimeMax"] = _SERIALIZER.query("create_time_max", create_time_max, "iso-8601") - if end_time_min is not None: - _params["endTimeMin"] = _SERIALIZER.query("end_time_min", end_time_min, "iso-8601") - if end_time_max is not None: - _params["endTimeMax"] = _SERIALIZER.query("end_time_max", end_time_max, "iso-8601") - if is_active is not None: - _params["isActive"] = _SERIALIZER.query("is_active", is_active, "bool") - if skip is not None: - _params["$skip"] = _SERIALIZER.query("skip", skip, "int") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - job_execution_id: str, - step_name: str, - target_id: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps/{stepName}/targets/{targetId}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "jobName": _SERIALIZER.url("job_name", job_name, "str"), - "jobExecutionId": _SERIALIZER.url("job_execution_id", job_execution_id, "str"), - "stepName": _SERIALIZER.url("step_name", step_name, "str"), - "targetId": _SERIALIZER.url("target_id", target_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class JobTargetExecutionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`job_target_executions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @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, - end_time_max: Optional[datetime.datetime] = None, - is_active: Optional[bool] = None, - skip: Optional[int] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> ItemPaged["_models.JobExecution"]: - """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. - :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 id of the job execution. Required. - :type job_execution_id: 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 - :return: An iterator like instance of either JobExecution or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobExecution] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobExecutionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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_execution_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - job_name=job_name, - job_execution_id=job_execution_id, - subscription_id=self._config.subscription_id, - create_time_min=create_time_min, - create_time_max=create_time_max, - end_time_min=end_time_min, - end_time_max=end_time_max, - is_active=is_active, - skip=skip, - top=top, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace - 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, - end_time_max: Optional[datetime.datetime] = None, - is_active: Optional[bool] = None, - skip: Optional[int] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> ItemPaged["_models.JobExecution"]: - """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. - :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 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 - :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 - :return: An iterator like instance of either JobExecution or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobExecution] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobExecutionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_step_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - job_name=job_name, - job_execution_id=job_execution_id, - step_name=step_name, - subscription_id=self._config.subscription_id, - create_time_min=create_time_min, - create_time_max=create_time_max, - end_time_min=end_time_min, - end_time_max=end_time_max, - is_active=is_active, - skip=skip, - top=top, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @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 - :return: JobExecution or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobExecution - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobExecution] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - job_name=job_name, - job_execution_id=job_execution_id, - step_name=step_name, - target_id=target_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_target_groups_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_target_groups_operations.py deleted file mode 100644 index 81c2e159f675..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_target_groups_operations.py +++ /dev/null @@ -1,548 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_agent_request( - resource_group_name: str, server_name: str, job_agent_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/targetGroups", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - server_name: str, - job_agent_name: str, - target_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/targetGroups/{targetGroupName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "targetGroupName": _SERIALIZER.url("target_group_name", target_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - server_name: str, - job_agent_name: str, - target_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/targetGroups/{targetGroupName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "targetGroupName": _SERIALIZER.url("target_group_name", target_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - server_name: str, - job_agent_name: str, - target_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/targetGroups/{targetGroupName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "targetGroupName": _SERIALIZER.url("target_group_name", target_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -class JobTargetGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`job_target_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_agent( - self, resource_group_name: str, server_name: str, job_agent_name: str, **kwargs: Any - ) -> ItemPaged["_models.JobTargetGroup"]: - """Gets all target groups in an agent. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 - :return: An iterator like instance of either JobTargetGroup or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobTargetGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobTargetGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_agent_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("JobTargetGroupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, server_name: str, job_agent_name: str, target_group_name: str, **kwargs: Any - ) -> _models.JobTargetGroup: - """Gets a target group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 target_group_name: The name of the target group. Required. - :type target_group_name: str - :return: JobTargetGroup or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobTargetGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobTargetGroup] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - target_group_name=target_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("JobTargetGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - target_group_name: str, - parameters: _models.JobTargetGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.JobTargetGroup: - """Creates or updates a target group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 target_group_name: The name of the target group. Required. - :type target_group_name: str - :param parameters: The requested state of the target group. Required. - :type parameters: ~azure.mgmt.sql.models.JobTargetGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: JobTargetGroup or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobTargetGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - target_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.JobTargetGroup: - """Creates or updates a target group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 target_group_name: The name of the target group. Required. - :type target_group_name: str - :param parameters: The requested state of the target group. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: JobTargetGroup or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobTargetGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - target_group_name: str, - parameters: Union[_models.JobTargetGroup, IO[bytes]], - **kwargs: Any - ) -> _models.JobTargetGroup: - """Creates or updates a target group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 target_group_name: The name of the target group. Required. - :type target_group_name: str - :param parameters: The requested state of the target group. Is either a JobTargetGroup type or - a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.JobTargetGroup or IO[bytes] - :return: JobTargetGroup or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobTargetGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "JobTargetGroup") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - target_group_name=target_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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) - - deserialized = self._deserialize("JobTargetGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, server_name: str, job_agent_name: str, target_group_name: str, **kwargs: Any - ) -> None: - """Deletes a target group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 target_group_name: The name of the target group. Required. - :type target_group_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - target_group_name=target_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_versions_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_versions_operations.py deleted file mode 100644 index b45ca5559402..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_versions_operations.py +++ /dev/null @@ -1,280 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_job_request( - resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "jobName": _SERIALIZER.url("job_name", job_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - job_version: int, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "jobName": _SERIALIZER.url("job_name", job_name, "str"), - "jobVersion": _SERIALIZER.url("job_version", job_version, "int"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class JobVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`job_versions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_job( - self, resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, **kwargs: Any - ) -> ItemPaged["_models.JobVersion"]: - """Gets all versions of a job. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 - :return: An iterator like instance of either JobVersion or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobVersionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("JobVersionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - job_version: int, - **kwargs: Any - ) -> _models.JobVersion: - """Gets a job version. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 - :return: JobVersion or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobVersion] = 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_version=job_version, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("JobVersion", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_jobs_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_jobs_operations.py deleted file mode 100644 index 4f972246bce3..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_jobs_operations.py +++ /dev/null @@ -1,532 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_agent_request( - resource_group_name: str, server_name: str, job_agent_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "jobName": _SERIALIZER.url("job_name", job_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "jobName": _SERIALIZER.url("job_name", job_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), - "jobName": _SERIALIZER.url("job_name", job_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -class JobsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`jobs` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_agent( - self, resource_group_name: str, server_name: str, job_agent_name: str, **kwargs: Any - ) -> ItemPaged["_models.Job"]: - """Gets a list of jobs. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 - :return: An iterator like instance of either Job or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.Job] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_agent_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("JobListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, **kwargs: Any - ) -> _models.Job: - """Gets a job. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 - :return: Job or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.Job - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.Job] = 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, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("Job", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - parameters: _models.Job, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Job: - """Creates or updates a job. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 parameters: The requested job state. Required. - :type parameters: ~azure.mgmt.sql.models.Job - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Job or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.Job - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Job: - """Creates or updates a job. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 parameters: The requested job state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: Job or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.Job - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - parameters: Union[_models.Job, IO[bytes]], - **kwargs: Any - ) -> _models.Job: - """Creates or updates a job. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 parameters: The requested job state. Is either a Job type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.Job or IO[bytes] - :return: Job or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.Job - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "Job") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - job_name=job_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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) - - deserialized = self._deserialize("Job", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, **kwargs: Any - ) -> None: - """Deletes a job. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 delete. Required. - :type job_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - job_agent_name=job_agent_name, - job_name=job_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_ledger_digest_uploads_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_ledger_digest_uploads_operations.py deleted file mode 100644 index d47c1a76a850..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_ledger_digest_uploads_operations.py +++ /dev/null @@ -1,701 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - server_name: str, - database_name: str, - ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "ledgerDigestUploads": _SERIALIZER.url("ledger_digest_uploads", ledger_digest_uploads, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - server_name: str, - database_name: str, - ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - 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/{ledgerDigestUploads}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "ledgerDigestUploads": _SERIALIZER.url("ledger_digest_uploads", ledger_digest_uploads, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_disable_request( - resource_group_name: str, - server_name: str, - database_name: str, - ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - 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}/disable", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "ledgerDigestUploads": _SERIALIZER.url("ledger_digest_uploads", ledger_digest_uploads, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class LedgerDigestUploadsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`ledger_digest_uploads` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], - **kwargs: Any - ) -> _models.LedgerDigestUploads: - """Gets the current ledger digest upload configuration for a database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 ledger_digest_uploads: "current" Required. - :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName - :return: LedgerDigestUploads or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.LedgerDigestUploads - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[_models.LedgerDigestUploads] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - ledger_digest_uploads=ledger_digest_uploads, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("LedgerDigestUploads", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], - parameters: Union[_models.LedgerDigestUploads, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2021-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "LedgerDigestUploads") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - ledger_digest_uploads=ledger_digest_uploads, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], - parameters: _models.LedgerDigestUploads, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.LedgerDigestUploads]: - """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger - instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 ledger_digest_uploads: "current" Required. - :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName - :param parameters: Required. - :type parameters: ~azure.mgmt.sql.models.LedgerDigestUploads - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either LedgerDigestUploads or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LedgerDigestUploads] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.LedgerDigestUploads]: - """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger - instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 ledger_digest_uploads: "current" Required. - :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName - :param parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either LedgerDigestUploads or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LedgerDigestUploads] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], - parameters: Union[_models.LedgerDigestUploads, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.LedgerDigestUploads]: - """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger - instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 ledger_digest_uploads: "current" Required. - :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName - :param parameters: Is either a LedgerDigestUploads type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.LedgerDigestUploads or IO[bytes] - :return: An instance of LROPoller that returns either LedgerDigestUploads or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LedgerDigestUploads] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - 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) - 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, - ledger_digest_uploads=ledger_digest_uploads, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LedgerDigestUploads", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LedgerDigestUploads].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.LedgerDigestUploads]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either LedgerDigestUploads or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LedgerDigestUploads] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[_models.LedgerDigestUploadsListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - def _disable_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disable_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - ledger_digest_uploads=ledger_digest_uploads, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_disable( - self, - resource_group_name: str, - server_name: str, - database_name: str, - ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], - **kwargs: Any - ) -> LROPoller[_models.LedgerDigestUploads]: - """Disables uploading ledger digests to an Azure Storage account or an Azure Confidential Ledger - instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 ledger_digest_uploads: "current" Required. - :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName - :return: An instance of LROPoller that returns either LedgerDigestUploads or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LedgerDigestUploads] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[_models.LedgerDigestUploads] = 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._disable_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - ledger_digest_uploads=ledger_digest_uploads, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LedgerDigestUploads", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LedgerDigestUploads].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.LedgerDigestUploads]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_long_term_retention_backups_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_long_term_retention_backups_operations.py deleted file mode 100644 index d5c0e8dd90f6..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_long_term_retention_backups_operations.py +++ /dev/null @@ -1,4510 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -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", "2024-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionBackups", - ) - path_format_arguments = { - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if only_latest_per_database is not None: - _params["onlyLatestPerDatabase"] = _SERIALIZER.query( - "only_latest_per_database", only_latest_per_database, "bool" - ) - if database_state is not None: - _params["databaseState"] = _SERIALIZER.query("database_state", database_state, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_server_request( - location_name: str, - long_term_retention_server_name: str, - 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", "2024-11-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", - ) - path_format_arguments = { - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "longTermRetentionServerName": _SERIALIZER.url( - "long_term_retention_server_name", long_term_retention_server_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if only_latest_per_database is not None: - _params["onlyLatestPerDatabase"] = _SERIALIZER.query( - "only_latest_per_database", only_latest_per_database, "bool" - ) - if database_state is not None: - _params["databaseState"] = _SERIALIZER.query("database_state", database_state, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_database_request( - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - subscription_id: str, - *, - only_latest_per_database: Optional[bool] = None, - database_state: Optional[Union[str, _models.DatabaseState]] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-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", - ) - path_format_arguments = { - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "longTermRetentionServerName": _SERIALIZER.url( - "long_term_retention_server_name", long_term_retention_server_name, "str" - ), - "longTermRetentionDatabaseName": _SERIALIZER.url( - "long_term_retention_database_name", long_term_retention_database_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if only_latest_per_database is not None: - _params["onlyLatestPerDatabase"] = _SERIALIZER.query( - "only_latest_per_database", only_latest_per_database, "bool" - ) - if database_state is not None: - _params["databaseState"] = _SERIALIZER.query("database_state", database_state, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-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}", - ) - path_format_arguments = { - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "longTermRetentionServerName": _SERIALIZER.url( - "long_term_retention_server_name", long_term_retention_server_name, "str" - ), - "longTermRetentionDatabaseName": _SERIALIZER.url( - "long_term_retention_database_name", long_term_retention_database_name, "str" - ), - "backupName": _SERIALIZER.url("backup_name", backup_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-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}", - ) - path_format_arguments = { - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "longTermRetentionServerName": _SERIALIZER.url( - "long_term_retention_server_name", long_term_retention_server_name, "str" - ), - "longTermRetentionDatabaseName": _SERIALIZER.url( - "long_term_retention_database_name", long_term_retention_database_name, "str" - ), - "backupName": _SERIALIZER.url("backup_name", backup_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_change_access_tier_request( - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-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/{backupName}/changeAccessTier", - ) - path_format_arguments = { - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "longTermRetentionServerName": _SERIALIZER.url( - "long_term_retention_server_name", long_term_retention_server_name, "str" - ), - "longTermRetentionDatabaseName": _SERIALIZER.url( - "long_term_retention_database_name", long_term_retention_database_name, "str" - ), - "backupName": _SERIALIZER.url("backup_name", backup_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_copy_request( - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-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/{backupName}/copy", - ) - path_format_arguments = { - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "longTermRetentionServerName": _SERIALIZER.url( - "long_term_retention_server_name", long_term_retention_server_name, "str" - ), - "longTermRetentionDatabaseName": _SERIALIZER.url( - "long_term_retention_database_name", long_term_retention_database_name, "str" - ), - "backupName": _SERIALIZER.url("backup_name", backup_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_lock_time_based_immutability_request( # pylint: disable=name-too-long - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-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}/lockTimeBasedImmutability", - ) - path_format_arguments = { - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "longTermRetentionServerName": _SERIALIZER.url( - "long_term_retention_server_name", long_term_retention_server_name, "str" - ), - "longTermRetentionDatabaseName": _SERIALIZER.url( - "long_term_retention_database_name", long_term_retention_database_name, "str" - ), - "backupName": _SERIALIZER.url("backup_name", backup_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_remove_legal_hold_immutability_request( # pylint: disable=name-too-long - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-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}/removeLegalHoldImmutability", - ) - path_format_arguments = { - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "longTermRetentionServerName": _SERIALIZER.url( - "long_term_retention_server_name", long_term_retention_server_name, "str" - ), - "longTermRetentionDatabaseName": _SERIALIZER.url( - "long_term_retention_database_name", long_term_retention_database_name, "str" - ), - "backupName": _SERIALIZER.url("backup_name", backup_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_remove_time_based_immutability_request( # pylint: disable=name-too-long - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-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}/removeTimeBasedImmutability", - ) - path_format_arguments = { - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "longTermRetentionServerName": _SERIALIZER.url( - "long_term_retention_server_name", long_term_retention_server_name, "str" - ), - "longTermRetentionDatabaseName": _SERIALIZER.url( - "long_term_retention_database_name", long_term_retention_database_name, "str" - ), - "backupName": _SERIALIZER.url("backup_name", backup_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_set_legal_hold_immutability_request( # pylint: disable=name-too-long - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-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}/setLegalHoldImmutability", - ) - path_format_arguments = { - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "longTermRetentionServerName": _SERIALIZER.url( - "long_term_retention_server_name", long_term_retention_server_name, "str" - ), - "longTermRetentionDatabaseName": _SERIALIZER.url( - "long_term_retention_database_name", long_term_retention_database_name, "str" - ), - "backupName": _SERIALIZER.url("backup_name", backup_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -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, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-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/{backupName}/update", - ) - path_format_arguments = { - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "longTermRetentionServerName": _SERIALIZER.url( - "long_term_retention_server_name", long_term_retention_server_name, "str" - ), - "longTermRetentionDatabaseName": _SERIALIZER.url( - "long_term_retention_database_name", long_term_retention_database_name, "str" - ), - "backupName": _SERIALIZER.url("backup_name", backup_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_location_request( # pylint: disable=name-too-long - resource_group_name: str, - location_name: str, - subscription_id: str, - *, - only_latest_per_database: Optional[bool] = None, - database_state: Optional[Union[str, _models.DatabaseState]] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionBackups", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if only_latest_per_database is not None: - _params["onlyLatestPerDatabase"] = _SERIALIZER.query( - "only_latest_per_database", only_latest_per_database, "bool" - ) - if database_state is not None: - _params["databaseState"] = _SERIALIZER.query("database_state", database_state, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_server_request( # pylint: disable=name-too-long - 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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-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", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "longTermRetentionServerName": _SERIALIZER.url( - "long_term_retention_server_name", long_term_retention_server_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if only_latest_per_database is not None: - _params["onlyLatestPerDatabase"] = _SERIALIZER.query( - "only_latest_per_database", only_latest_per_database, "bool" - ) - if database_state is not None: - _params["databaseState"] = _SERIALIZER.query("database_state", database_state, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_database_request( # pylint: disable=name-too-long - resource_group_name: str, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - subscription_id: str, - *, - only_latest_per_database: Optional[bool] = None, - database_state: Optional[Union[str, _models.DatabaseState]] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-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", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "longTermRetentionServerName": _SERIALIZER.url( - "long_term_retention_server_name", long_term_retention_server_name, "str" - ), - "longTermRetentionDatabaseName": _SERIALIZER.url( - "long_term_retention_database_name", long_term_retention_database_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if only_latest_per_database is not None: - _params["onlyLatestPerDatabase"] = _SERIALIZER.query( - "only_latest_per_database", only_latest_per_database, "bool" - ) - if database_state is not None: - _params["databaseState"] = _SERIALIZER.query("database_state", database_state, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_by_resource_group_request( - resource_group_name: str, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "longTermRetentionServerName": _SERIALIZER.url( - "long_term_retention_server_name", long_term_retention_server_name, "str" - ), - "longTermRetentionDatabaseName": _SERIALIZER.url( - "long_term_retention_database_name", long_term_retention_database_name, "str" - ), - "backupName": _SERIALIZER.url("backup_name", backup_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _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_delete_by_resource_group_request( - resource_group_name: str, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "longTermRetentionServerName": _SERIALIZER.url( - "long_term_retention_server_name", long_term_retention_server_name, "str" - ), - "longTermRetentionDatabaseName": _SERIALIZER.url( - "long_term_retention_database_name", long_term_retention_database_name, "str" - ), - "backupName": _SERIALIZER.url("backup_name", backup_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_change_access_tier_by_resource_group_request( # pylint: disable=name-too-long - resource_group_name: str, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-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/{backupName}/changeAccessTier", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "longTermRetentionServerName": _SERIALIZER.url( - "long_term_retention_server_name", long_term_retention_server_name, "str" - ), - "longTermRetentionDatabaseName": _SERIALIZER.url( - "long_term_retention_database_name", long_term_retention_database_name, "str" - ), - "backupName": _SERIALIZER.url("backup_name", backup_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_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, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-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/{backupName}/copy", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "longTermRetentionServerName": _SERIALIZER.url( - "long_term_retention_server_name", long_term_retention_server_name, "str" - ), - "longTermRetentionDatabaseName": _SERIALIZER.url( - "long_term_retention_database_name", long_term_retention_database_name, "str" - ), - "backupName": _SERIALIZER.url("backup_name", backup_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_lock_time_based_immutability_by_resource_group_request( # pylint: disable=name-too-long - resource_group_name: str, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-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}/lockTimeBasedImmutability", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "longTermRetentionServerName": _SERIALIZER.url( - "long_term_retention_server_name", long_term_retention_server_name, "str" - ), - "longTermRetentionDatabaseName": _SERIALIZER.url( - "long_term_retention_database_name", long_term_retention_database_name, "str" - ), - "backupName": _SERIALIZER.url("backup_name", backup_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _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_remove_legal_hold_immutability_by_resource_group_request( # pylint: disable=name-too-long - resource_group_name: str, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-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}/removeLegalHoldImmutability", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "longTermRetentionServerName": _SERIALIZER.url( - "long_term_retention_server_name", long_term_retention_server_name, "str" - ), - "longTermRetentionDatabaseName": _SERIALIZER.url( - "long_term_retention_database_name", long_term_retention_database_name, "str" - ), - "backupName": _SERIALIZER.url("backup_name", backup_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _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_remove_time_based_immutability_by_resource_group_request( # pylint: disable=name-too-long - resource_group_name: str, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-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}/removeTimeBasedImmutability", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "longTermRetentionServerName": _SERIALIZER.url( - "long_term_retention_server_name", long_term_retention_server_name, "str" - ), - "longTermRetentionDatabaseName": _SERIALIZER.url( - "long_term_retention_database_name", long_term_retention_database_name, "str" - ), - "backupName": _SERIALIZER.url("backup_name", backup_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _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_set_legal_hold_immutability_by_resource_group_request( # pylint: disable=name-too-long - resource_group_name: str, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-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}/setLegalHoldImmutability", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "longTermRetentionServerName": _SERIALIZER.url( - "long_term_retention_server_name", long_term_retention_server_name, "str" - ), - "longTermRetentionDatabaseName": _SERIALIZER.url( - "long_term_retention_database_name", long_term_retention_database_name, "str" - ), - "backupName": _SERIALIZER.url("backup_name", backup_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _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_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, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-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/{backupName}/update", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "longTermRetentionServerName": _SERIALIZER.url( - "long_term_retention_server_name", long_term_retention_server_name, "str" - ), - "longTermRetentionDatabaseName": _SERIALIZER.url( - "long_term_retention_database_name", long_term_retention_database_name, "str" - ), - "backupName": _SERIALIZER.url("backup_name", backup_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class LongTermRetentionBackupsOperations: # pylint: disable=too-many-public-methods - """ - .. 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. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_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 - :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", "2024-11-01-preview")) - cls: ClsType[_models.LongTermRetentionBackupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_server( - self, - location_name: str, - long_term_retention_server_name: str, - only_latest_per_database: Optional[bool] = None, - database_state: Optional[Union[str, _models.DatabaseState]] = None, - **kwargs: Any - ) -> ItemPaged["_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 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 - :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", "2024-11-01-preview")) - cls: ClsType[_models.LongTermRetentionBackupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_database( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - only_latest_per_database: Optional[bool] = None, - database_state: Optional[Union[str, _models.DatabaseState]] = None, - **kwargs: Any - ) -> ItemPaged["_models.LongTermRetentionBackup"]: - """Lists all long term retention backups for a database. - - :param location_name: The location of the database. Required. - :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. - :type long_term_retention_database_name: str - :param only_latest_per_database: Whether or not to only get the latest backup for each - database. Default value is None. - :type only_latest_per_database: bool - :param database_state: Whether to query against just live databases, just deleted databases, or - all databases. Known values are: "All", "Live", and "Deleted". Default value is None. - :type database_state: str or ~azure.mgmt.sql.models.DatabaseState - :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", "2024-11-01-preview")) - cls: ClsType[_models.LongTermRetentionBackupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - **kwargs: Any - ) -> _models.LongTermRetentionBackup: - """Gets a long term retention backup. - - :param location_name: The location of the database. 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 - :return: LongTermRetentionBackup or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.LongTermRetentionBackup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - 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, - headers=_headers, - params=_params, - ) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _delete_initial( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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", "2024-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _change_access_tier_initial( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: Union[_models.ChangeLongTermRetentionBackupAccessTierParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ChangeLongTermRetentionBackupAccessTierParameters") - - _request = build_change_access_tier_request( - location_name=location_name, - long_term_retention_server_name=long_term_retention_server_name, - long_term_retention_database_name=long_term_retention_database_name, - backup_name=backup_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_change_access_tier( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: _models.ChangeLongTermRetentionBackupAccessTierParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.LongTermRetentionBackup]: - """Change a long term retention backup access tier. - - :param location_name: Required. - :type location_name: str - :param long_term_retention_server_name: Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: Required. - :type long_term_retention_database_name: str - :param backup_name: Required. - :type backup_name: str - :param parameters: Required. - :type parameters: ~azure.mgmt.sql.models.ChangeLongTermRetentionBackupAccessTierParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either LongTermRetentionBackup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_change_access_tier( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.LongTermRetentionBackup]: - """Change a long term retention backup access tier. - - :param location_name: Required. - :type location_name: str - :param long_term_retention_server_name: Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: Required. - :type long_term_retention_database_name: str - :param backup_name: Required. - :type backup_name: str - :param parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either LongTermRetentionBackup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_change_access_tier( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: Union[_models.ChangeLongTermRetentionBackupAccessTierParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.LongTermRetentionBackup]: - """Change a long term retention backup access tier. - - :param location_name: Required. - :type location_name: str - :param long_term_retention_server_name: Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: Required. - :type long_term_retention_database_name: str - :param backup_name: Required. - :type backup_name: str - :param parameters: Is either a ChangeLongTermRetentionBackupAccessTierParameters type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ChangeLongTermRetentionBackupAccessTierParameters or - IO[bytes] - :return: An instance of LROPoller that returns either LongTermRetentionBackup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._change_access_tier_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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LongTermRetentionBackup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.LongTermRetentionBackup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - 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[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :return: An instance of LROPoller that returns either LongTermRetentionBackupOperationResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_copy( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: IO[bytes], - *, - 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: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either LongTermRetentionBackupOperationResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_copy( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: Union[_models.CopyLongTermRetentionBackupParameters, IO[bytes]], - **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. Is either a - CopyLongTermRetentionBackupParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.CopyLongTermRetentionBackupParameters or IO[bytes] - :return: An instance of LROPoller that returns either LongTermRetentionBackupOperationResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LongTermRetentionBackupOperationResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.LongTermRetentionBackupOperationResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _lock_time_based_immutability_initial( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_lock_time_based_immutability_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_lock_time_based_immutability( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - **kwargs: Any - ) -> LROPoller[_models.LongTermRetentionBackup]: - """Lock time based immutability of an existing long term retention backup. - - :param location_name: 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 - :return: An instance of LROPoller that returns either LongTermRetentionBackup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._lock_time_based_immutability_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, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LongTermRetentionBackup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.LongTermRetentionBackup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _remove_legal_hold_immutability_initial( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_remove_legal_hold_immutability_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_remove_legal_hold_immutability( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - **kwargs: Any - ) -> LROPoller[_models.LongTermRetentionBackup]: - """Remove legal hold immutability of an existing long term retention backup. - - :param location_name: 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 - :return: An instance of LROPoller that returns either LongTermRetentionBackup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._remove_legal_hold_immutability_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, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LongTermRetentionBackup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.LongTermRetentionBackup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _remove_time_based_immutability_initial( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_remove_time_based_immutability_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_remove_time_based_immutability( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - **kwargs: Any - ) -> LROPoller[_models.LongTermRetentionBackup]: - """Remove time based immutability of an existing long term retention backup. - - :param location_name: 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 - :return: An instance of LROPoller that returns either LongTermRetentionBackup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._remove_time_based_immutability_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, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LongTermRetentionBackup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.LongTermRetentionBackup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _set_legal_hold_immutability_initial( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_set_legal_hold_immutability_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_set_legal_hold_immutability( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - **kwargs: Any - ) -> LROPoller[_models.LongTermRetentionBackup]: - """Set legal hold immutability of an existing long term retention backup. - - :param location_name: 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 - :return: An instance of LROPoller that returns either LongTermRetentionBackup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._set_legal_hold_immutability_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, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LongTermRetentionBackup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.LongTermRetentionBackup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - 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[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "UpdateLongTermRetentionBackupParameters") - - _request = build_update_request( - location_name=location_name, - long_term_retention_server_name=long_term_retention_server_name, - long_term_retention_database_name=long_term_retention_database_name, - backup_name=backup_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: - """Updates an existing long term retention backup. - - :param location_name: The location of the database. Required. - :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. - :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. - :type backup_name: str - :param parameters: The requested backup resource state. Required. - :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either LongTermRetentionBackupOperationResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: - """Updates an existing long term retention backup. - - :param location_name: The location of the database. Required. - :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. - :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. - :type backup_name: str - :param parameters: The requested backup resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either LongTermRetentionBackupOperationResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: Union[_models.UpdateLongTermRetentionBackupParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: - """Updates an existing long term retention backup. - - :param location_name: The location of the database. Required. - :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. - :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. - :type backup_name: str - :param parameters: The requested backup resource state. Is either a - UpdateLongTermRetentionBackupParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters or IO[bytes] - :return: An instance of LROPoller that returns either LongTermRetentionBackupOperationResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.LongTermRetentionBackupOperationResult] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LongTermRetentionBackupOperationResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.LongTermRetentionBackupOperationResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 - ) -> ItemPaged["_models.LongTermRetentionBackup"]: - """Lists the long term retention backups for a given location based on resource group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param location_name: The location of the database. Required. - :type location_name: str - :param only_latest_per_database: Whether or not to only get the latest backup for each - database. Default value is None. - :type only_latest_per_database: bool - :param database_state: Whether to query against just live databases, just deleted databases, or - all databases. Known values are: "All", "Live", and "Deleted". Default value is None. - :type database_state: str or ~azure.mgmt.sql.models.DatabaseState - :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", "2024-11-01-preview")) - cls: ClsType[_models.LongTermRetentionBackupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @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 - ) -> ItemPaged["_models.LongTermRetentionBackup"]: - """Lists the long term retention backups for a given server based on resource groups. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :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 - :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", "2024-11-01-preview")) - cls: ClsType[_models.LongTermRetentionBackupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @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 - ) -> ItemPaged["_models.LongTermRetentionBackup"]: - """Lists all long term retention backups for a database based on a particular resource group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :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 - :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", "2024-11-01-preview")) - cls: ClsType[_models.LongTermRetentionBackupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @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 - :return: LongTermRetentionBackup or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.LongTermRetentionBackup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2024-11-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, - headers=_headers, - params=_params, - ) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _delete_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, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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", "2024-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_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, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _change_access_tier_by_resource_group_initial( # pylint: disable=name-too-long - 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.ChangeLongTermRetentionBackupAccessTierParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ChangeLongTermRetentionBackupAccessTierParameters") - - _request = build_change_access_tier_by_resource_group_request( - resource_group_name=resource_group_name, - location_name=location_name, - long_term_retention_server_name=long_term_retention_server_name, - long_term_retention_database_name=long_term_retention_database_name, - backup_name=backup_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_change_access_tier_by_resource_group( # pylint: disable=name-too-long - 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.ChangeLongTermRetentionBackupAccessTierParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.LongTermRetentionBackup]: - """Change a long term retention backup access tier. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param location_name: Required. - :type location_name: str - :param long_term_retention_server_name: Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: Required. - :type long_term_retention_database_name: str - :param backup_name: Required. - :type backup_name: str - :param parameters: Required. - :type parameters: ~azure.mgmt.sql.models.ChangeLongTermRetentionBackupAccessTierParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either LongTermRetentionBackup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_change_access_tier_by_resource_group( # pylint: disable=name-too-long - 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[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.LongTermRetentionBackup]: - """Change a long term retention backup access tier. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param location_name: Required. - :type location_name: str - :param long_term_retention_server_name: Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: Required. - :type long_term_retention_database_name: str - :param backup_name: Required. - :type backup_name: str - :param parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either LongTermRetentionBackup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_change_access_tier_by_resource_group( # pylint: disable=name-too-long - 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.ChangeLongTermRetentionBackupAccessTierParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.LongTermRetentionBackup]: - """Change a long term retention backup access tier. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param location_name: Required. - :type location_name: str - :param long_term_retention_server_name: Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: Required. - :type long_term_retention_database_name: str - :param backup_name: Required. - :type backup_name: str - :param parameters: Is either a ChangeLongTermRetentionBackupAccessTierParameters type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ChangeLongTermRetentionBackupAccessTierParameters or - IO[bytes] - :return: An instance of LROPoller that returns either LongTermRetentionBackup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._change_access_tier_by_resource_group_initial( - resource_group_name=resource_group_name, - location_name=location_name, - long_term_retention_server_name=long_term_retention_server_name, - long_term_retention_database_name=long_term_retention_database_name, - backup_name=backup_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LongTermRetentionBackup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.LongTermRetentionBackup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _copy_by_resource_group_initial( - self, - resource_group_name: str, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: Union[_models.CopyLongTermRetentionBackupParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "CopyLongTermRetentionBackupParameters") - - _request = build_copy_by_resource_group_request( - resource_group_name=resource_group_name, - location_name=location_name, - long_term_retention_server_name=long_term_retention_server_name, - long_term_retention_database_name=long_term_retention_database_name, - backup_name=backup_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_copy_by_resource_group( - self, - resource_group_name: str, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: _models.CopyLongTermRetentionBackupParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: - """Copy an existing long term retention backup to a different server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param location_name: The location of the database. Required. - :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. - :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. - :type backup_name: str - :param parameters: The parameters needed for long term retention copy request. Required. - :type parameters: ~azure.mgmt.sql.models.CopyLongTermRetentionBackupParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either LongTermRetentionBackupOperationResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_copy_by_resource_group( - self, - resource_group_name: str, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: - """Copy an existing long term retention backup to a different server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param location_name: The location of the database. Required. - :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. - :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. - :type backup_name: str - :param parameters: The parameters needed for long term retention copy request. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either LongTermRetentionBackupOperationResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_copy_by_resource_group( - self, - resource_group_name: str, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: Union[_models.CopyLongTermRetentionBackupParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: - """Copy an existing long term retention backup to a different server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param location_name: The location of the database. Required. - :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. - :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. - :type backup_name: str - :param parameters: The parameters needed for long term retention copy request. Is either a - CopyLongTermRetentionBackupParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.CopyLongTermRetentionBackupParameters or IO[bytes] - :return: An instance of LROPoller that returns either LongTermRetentionBackupOperationResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-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_by_resource_group_initial( - resource_group_name=resource_group_name, - location_name=location_name, - long_term_retention_server_name=long_term_retention_server_name, - long_term_retention_database_name=long_term_retention_database_name, - backup_name=backup_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LongTermRetentionBackupOperationResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.LongTermRetentionBackupOperationResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _lock_time_based_immutability_by_resource_group_initial( # pylint: disable=name-too-long - 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 - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_lock_time_based_immutability_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_lock_time_based_immutability_by_resource_group( # pylint: disable=name-too-long - 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[_models.LongTermRetentionBackup]: - """Lock time based immutability of an existing long term retention backup. - - :param resource_group_name: The resource group name of the database. Required. - :type resource_group_name: str - :param location_name: 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 - :return: An instance of LROPoller that returns either LongTermRetentionBackup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._lock_time_based_immutability_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, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LongTermRetentionBackup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.LongTermRetentionBackup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _remove_legal_hold_immutability_by_resource_group_initial( # pylint: disable=name-too-long - 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 - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_remove_legal_hold_immutability_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_remove_legal_hold_immutability_by_resource_group( # pylint: disable=name-too-long - 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[_models.LongTermRetentionBackup]: - """Remove legal hold immutability of an existing long term retention backup. - - :param resource_group_name: The resource group name of the database. Required. - :type resource_group_name: str - :param location_name: 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 - :return: An instance of LROPoller that returns either LongTermRetentionBackup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._remove_legal_hold_immutability_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, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LongTermRetentionBackup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.LongTermRetentionBackup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _remove_time_based_immutability_by_resource_group_initial( # pylint: disable=name-too-long - 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 - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_remove_time_based_immutability_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_remove_time_based_immutability_by_resource_group( # pylint: disable=name-too-long - 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[_models.LongTermRetentionBackup]: - """Remove time based immutability of an existing long term retention backup. - - :param resource_group_name: The resource group name of the database. Required. - :type resource_group_name: str - :param location_name: 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 - :return: An instance of LROPoller that returns either LongTermRetentionBackup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._remove_time_based_immutability_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, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LongTermRetentionBackup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.LongTermRetentionBackup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _set_legal_hold_immutability_by_resource_group_initial( # pylint: disable=name-too-long - 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 - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_set_legal_hold_immutability_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_set_legal_hold_immutability_by_resource_group( # pylint: disable=name-too-long - 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[_models.LongTermRetentionBackup]: - """Set legal hold immutability of an existing long term retention backup. - - :param resource_group_name: The resource group name of the database. Required. - :type resource_group_name: str - :param location_name: 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 - :return: An instance of LROPoller that returns either LongTermRetentionBackup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._set_legal_hold_immutability_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, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LongTermRetentionBackup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.LongTermRetentionBackup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - 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[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "UpdateLongTermRetentionBackupParameters") - - _request = build_update_by_resource_group_request( - resource_group_name=resource_group_name, - location_name=location_name, - long_term_retention_server_name=long_term_retention_server_name, - long_term_retention_database_name=long_term_retention_database_name, - backup_name=backup_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update_by_resource_group( - self, - resource_group_name: str, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: _models.UpdateLongTermRetentionBackupParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: - """Updates an existing long term retention backup. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param location_name: The location of the database. Required. - :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. - :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. - :type backup_name: str - :param parameters: The requested backup resource state. Required. - :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either LongTermRetentionBackupOperationResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update_by_resource_group( - self, - resource_group_name: str, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: - """Updates an existing long term retention backup. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param location_name: The location of the database. Required. - :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. - :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. - :type backup_name: str - :param parameters: The requested backup resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either LongTermRetentionBackupOperationResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update_by_resource_group( - self, - resource_group_name: str, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: Union[_models.UpdateLongTermRetentionBackupParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: - """Updates an existing long term retention backup. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param location_name: The location of the database. Required. - :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. - :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. - :type backup_name: str - :param parameters: The requested backup resource state. Is either a - UpdateLongTermRetentionBackupParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters or IO[bytes] - :return: An instance of LROPoller that returns either LongTermRetentionBackupOperationResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.LongTermRetentionBackupOperationResult] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_by_resource_group_initial( - resource_group_name=resource_group_name, - location_name=location_name, - long_term_retention_server_name=long_term_retention_server_name, - long_term_retention_database_name=long_term_retention_database_name, - backup_name=backup_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LongTermRetentionBackupOperationResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.LongTermRetentionBackupOperationResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 52ed006107e6..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_long_term_retention_managed_instance_backups_operations.py +++ /dev/null @@ -1,1375 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,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 collections.abc import MutableMapping -from typing import Any, Callable, Iterator, Optional, TypeVar, Union, cast - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - location_name: str, - managed_instance_name: str, - database_name: str, - backup_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}", - ) - path_format_arguments = { - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "backupName": _SERIALIZER.url("backup_name", backup_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - location_name: str, - managed_instance_name: str, - database_name: str, - backup_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}", - ) - path_format_arguments = { - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "backupName": _SERIALIZER.url("backup_name", backup_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_list_by_database_request( - location_name: str, - managed_instance_name: str, - database_name: str, - subscription_id: str, - *, - only_latest_per_database: Optional[bool] = None, - database_state: Optional[Union[str, _models.DatabaseState]] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups", - ) - path_format_arguments = { - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if only_latest_per_database is not None: - _params["onlyLatestPerDatabase"] = _SERIALIZER.query( - "only_latest_per_database", only_latest_per_database, "bool" - ) - if database_state is not None: - _params["databaseState"] = _SERIALIZER.query("database_state", database_state, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_instance_request( - location_name: str, - managed_instance_name: str, - subscription_id: str, - *, - only_latest_per_database: Optional[bool] = None, - database_state: Optional[Union[str, _models.DatabaseState]] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionManagedInstanceBackups", - ) - path_format_arguments = { - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if only_latest_per_database is not None: - _params["onlyLatestPerDatabase"] = _SERIALIZER.query( - "only_latest_per_database", only_latest_per_database, "bool" - ) - if database_state is not None: - _params["databaseState"] = _SERIALIZER.query("database_state", database_state, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_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", "2021-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstanceBackups", - ) - path_format_arguments = { - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if only_latest_per_database is not None: - _params["onlyLatestPerDatabase"] = _SERIALIZER.query( - "only_latest_per_database", only_latest_per_database, "bool" - ) - if database_state is not None: - _params["databaseState"] = _SERIALIZER.query("database_state", database_state, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_by_resource_group_request( - resource_group_name: str, - location_name: str, - managed_instance_name: str, - database_name: str, - backup_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "backupName": _SERIALIZER.url("backup_name", backup_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_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, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "backupName": _SERIALIZER.url("backup_name", backup_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_list_by_resource_group_database_request( # pylint: disable=name-too-long - resource_group_name: str, - location_name: str, - managed_instance_name: str, - database_name: str, - subscription_id: str, - *, - only_latest_per_database: Optional[bool] = None, - database_state: Optional[Union[str, _models.DatabaseState]] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if only_latest_per_database is not None: - _params["onlyLatestPerDatabase"] = _SERIALIZER.query( - "only_latest_per_database", only_latest_per_database, "bool" - ) - if database_state is not None: - _params["databaseState"] = _SERIALIZER.query("database_state", database_state, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_instance_request( # pylint: disable=name-too-long - resource_group_name: str, - location_name: str, - managed_instance_name: str, - subscription_id: str, - *, - only_latest_per_database: Optional[bool] = None, - database_state: Optional[Union[str, _models.DatabaseState]] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionManagedInstanceBackups", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if only_latest_per_database is not None: - _params["onlyLatestPerDatabase"] = _SERIALIZER.query( - "only_latest_per_database", only_latest_per_database, "bool" - ) - if database_state is not None: - _params["databaseState"] = _SERIALIZER.query("database_state", database_state, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_location_request( # pylint: disable=name-too-long - resource_group_name: str, - location_name: str, - subscription_id: str, - *, - only_latest_per_database: Optional[bool] = None, - database_state: Optional[Union[str, _models.DatabaseState]] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "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}/longTermRetentionManagedInstanceBackups", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if only_latest_per_database is not None: - _params["onlyLatestPerDatabase"] = _SERIALIZER.query( - "only_latest_per_database", only_latest_per_database, "bool" - ) - if database_state is not None: - _params["databaseState"] = _SERIALIZER.query("database_state", database_state, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class LongTermRetentionManagedInstanceBackupsOperations: # pylint: disable=name-too-long - """ - .. 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_managed_instance_backups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, location_name: str, managed_instance_name: str, database_name: str, backup_name: str, **kwargs: Any - ) -> _models.ManagedInstanceLongTermRetentionBackup: - """Gets a long term retention backup for a managed database. - - :param location_name: The location of the database. 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 backup_name: The backup name. Required. - :type backup_name: str - :return: ManagedInstanceLongTermRetentionBackup or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.ManagedInstanceLongTermRetentionBackup] = kwargs.pop("cls", None) - - _request = build_get_request( - location_name=location_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - backup_name=backup_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedInstanceLongTermRetentionBackup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _delete_initial( - self, location_name: str, managed_instance_name: str, database_name: str, backup_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - location_name=location_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - backup_name=backup_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, location_name: str, managed_instance_name: str, database_name: str, backup_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes a long term retention backup. - - :param location_name: The location of the database. 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 backup_name: The backup name. Required. - :type backup_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - location_name=location_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - backup_name=backup_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @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 - ) -> ItemPaged["_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 - :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackup or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.ManagedInstanceLongTermRetentionBackupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace - def list_by_instance( - self, - location_name: str, - managed_instance_name: str, - only_latest_per_database: Optional[bool] = None, - database_state: Optional[Union[str, _models.DatabaseState]] = None, - **kwargs: Any - ) -> ItemPaged["_models.ManagedInstanceLongTermRetentionBackup"]: - """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 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 - :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackup or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.ManagedInstanceLongTermRetentionBackupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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( - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @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 - ) -> ItemPaged["_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 - :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackup or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.ManagedInstanceLongTermRetentionBackupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace - def get_by_resource_group( - self, - resource_group_name: str, - location_name: str, - managed_instance_name: str, - database_name: str, - backup_name: str, - **kwargs: Any - ) -> _models.ManagedInstanceLongTermRetentionBackup: - """Gets a long term retention backup for a managed database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 backup_name: The backup name. Required. - :type backup_name: str - :return: ManagedInstanceLongTermRetentionBackup or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.ManagedInstanceLongTermRetentionBackup] = kwargs.pop("cls", None) - - _request = build_get_by_resource_group_request( - resource_group_name=resource_group_name, - location_name=location_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - backup_name=backup_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedInstanceLongTermRetentionBackup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _delete_by_resource_group_initial( - self, - resource_group_name: str, - location_name: str, - managed_instance_name: str, - database_name: str, - backup_name: str, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_by_resource_group_request( - resource_group_name=resource_group_name, - location_name=location_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - backup_name=backup_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete_by_resource_group( - self, - resource_group_name: str, - location_name: str, - managed_instance_name: str, - database_name: str, - backup_name: str, - **kwargs: Any - ) -> LROPoller[None]: - """Deletes a long term retention backup. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 backup_name: The backup name. Required. - :type backup_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_by_resource_group_initial( - resource_group_name=resource_group_name, - location_name=location_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - backup_name=backup_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @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 - ) -> ItemPaged["_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 - :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackup or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.ManagedInstanceLongTermRetentionBackupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace - def list_by_resource_group_instance( - 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 - ) -> ItemPaged["_models.ManagedInstanceLongTermRetentionBackup"]: - """Lists the long term retention backups for a given managed instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param location_name: The location of the database. Required. - :type location_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param only_latest_per_database: Whether or not to only get the latest backup for each - database. Default value is None. - :type only_latest_per_database: bool - :param database_state: Whether to query against just live databases, just deleted databases, or - all databases. Known values are: "All", "Live", and "Deleted". Default value is None. - :type database_state: str or ~azure.mgmt.sql.models.DatabaseState - :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackup or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.ManagedInstanceLongTermRetentionBackupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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_instance_request( - resource_group_name=resource_group_name, - location_name=location_name, - managed_instance_name=managed_instance_name, - subscription_id=self._config.subscription_id, - only_latest_per_database=only_latest_per_database, - database_state=database_state, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @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 - ) -> ItemPaged["_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 - :return: An iterator like instance of either ManagedInstanceLongTermRetentionBackup or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.ManagedInstanceLongTermRetentionBackupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 2ae534acf82f..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_long_term_retention_policies_operations.py +++ /dev/null @@ -1,540 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_database_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-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", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _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, - database_name: str, - policy_name: Union[str, _models.LongTermRetentionPolicyName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "policyName": _SERIALIZER.url("policy_name", policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - server_name: str, - database_name: str, - policy_name: Union[str, _models.LongTermRetentionPolicyName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-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/{policyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "policyName": _SERIALIZER.url("policy_name", policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -class LongTermRetentionPoliciesOperations: - """ - .. 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_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_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 - :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", "2024-11-01-preview")) - cls: ClsType[_models.LongTermRetentionPolicyListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - database_name: str, - policy_name: Union[str, _models.LongTermRetentionPolicyName], - **kwargs: Any - ) -> _models.LongTermRetentionPolicy: - """Gets a database's long term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 policy_name: The policy name. Should always be Default. "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.LongTermRetentionPolicyName - :return: LongTermRetentionPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.LongTermRetentionPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - cls: ClsType[_models.LongTermRetentionPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - policy_name=policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("LongTermRetentionPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - policy_name: Union[str, _models.LongTermRetentionPolicyName], - parameters: Union[_models.LongTermRetentionPolicy, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "LongTermRetentionPolicy") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - policy_name=policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - policy_name: Union[str, _models.LongTermRetentionPolicyName], - parameters: _models.LongTermRetentionPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.LongTermRetentionPolicy]: - """Set or update a database's long term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 policy_name: The policy name. Should always be Default. "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.LongTermRetentionPolicyName - :param parameters: The long term retention policy info. Required. - :type parameters: ~azure.mgmt.sql.models.LongTermRetentionPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either LongTermRetentionPolicy or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - policy_name: Union[str, _models.LongTermRetentionPolicyName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.LongTermRetentionPolicy]: - """Set or update a database's long term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 policy_name: The policy name. Should always be Default. "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.LongTermRetentionPolicyName - :param parameters: The long term retention policy info. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either LongTermRetentionPolicy or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - policy_name: Union[str, _models.LongTermRetentionPolicyName], - parameters: Union[_models.LongTermRetentionPolicy, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.LongTermRetentionPolicy]: - """Set or update a database's long term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 policy_name: The policy name. Should always be Default. "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.LongTermRetentionPolicyName - :param parameters: The long term retention policy info. Is either a LongTermRetentionPolicy - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.LongTermRetentionPolicy or IO[bytes] - :return: An instance of LROPoller that returns either LongTermRetentionPolicy or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - 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) - 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, - policy_name=policy_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionPolicy", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.LongTermRetentionPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.LongTermRetentionPolicy]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 55dc2b957b2f..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_maintenance_window_options_operations.py +++ /dev/null @@ -1,166 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - server_name: str, - database_name: str, - subscription_id: str, - *, - maintenance_window_options_name: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/maintenanceWindowOptions/current", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["maintenanceWindowOptionsName"] = _SERIALIZER.query( - "maintenance_window_options_name", maintenance_window_options_name, "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 MaintenanceWindowOptionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`maintenance_window_options` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - maintenance_window_options_name: str, - **kwargs: Any - ) -> _models.MaintenanceWindowOptions: - """Gets a list of available maintenance windows. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database to get maintenance windows options for. - Required. - :type database_name: str - :param maintenance_window_options_name: Maintenance window options name. Required. - :type maintenance_window_options_name: str - :return: MaintenanceWindowOptions or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.MaintenanceWindowOptions - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.MaintenanceWindowOptions] = 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, - maintenance_window_options_name=maintenance_window_options_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("MaintenanceWindowOptions", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_maintenance_windows_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_maintenance_windows_operations.py deleted file mode 100644 index 5af9893d7ad4..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_maintenance_windows_operations.py +++ /dev/null @@ -1,348 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - server_name: str, - database_name: str, - subscription_id: str, - *, - maintenance_window_name: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/maintenanceWindows/current", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["maintenanceWindowName"] = _SERIALIZER.query("maintenance_window_name", maintenance_window_name, "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_create_or_update_request( - resource_group_name: str, - server_name: str, - database_name: str, - subscription_id: str, - *, - maintenance_window_name: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/maintenanceWindows/current", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["maintenanceWindowName"] = _SERIALIZER.query("maintenance_window_name", maintenance_window_name, "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") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -class MaintenanceWindowsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`maintenance_windows` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - maintenance_window_name: str, - **kwargs: Any - ) -> _models.MaintenanceWindows: - """Gets maintenance windows settings for a database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database to get maintenance windows for. Required. - :type database_name: str - :param maintenance_window_name: Maintenance window name. Required. - :type maintenance_window_name: str - :return: MaintenanceWindows or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.MaintenanceWindows - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.MaintenanceWindows] = 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, - maintenance_window_name=maintenance_window_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("MaintenanceWindows", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - maintenance_window_name: str, - parameters: _models.MaintenanceWindows, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Sets maintenance windows settings for a database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database to set maintenance windows for. Required. - :type database_name: str - :param maintenance_window_name: Maintenance window name. Required. - :type maintenance_window_name: str - :param parameters: Required. - :type parameters: ~azure.mgmt.sql.models.MaintenanceWindows - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - maintenance_window_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Sets maintenance windows settings for a database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database to set maintenance windows for. Required. - :type database_name: str - :param maintenance_window_name: Maintenance window name. Required. - :type maintenance_window_name: str - :param parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - server_name: str, - database_name: str, - maintenance_window_name: str, - parameters: Union[_models.MaintenanceWindows, IO[bytes]], - **kwargs: Any - ) -> None: - """Sets maintenance windows settings for a database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database to set maintenance windows for. Required. - :type database_name: str - :param maintenance_window_name: Maintenance window name. Required. - :type maintenance_window_name: str - :param parameters: Is either a MaintenanceWindows type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.MaintenanceWindows or IO[bytes] - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, "MaintenanceWindows") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - maintenance_window_name=maintenance_window_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_backup_short_term_retention_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_backup_short_term_retention_policies_operations.py deleted file mode 100644 index dff2cdbb2679..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_backup_short_term_retention_policies_operations.py +++ /dev/null @@ -1,797 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "policyName": _SERIALIZER.url("policy_name", policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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/{policyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "policyName": _SERIALIZER.url("policy_name", policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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/{policyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "policyName": _SERIALIZER.url("policy_name", policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ManagedBackupShortTermRetentionPoliciesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_backup_short_term_retention_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - **kwargs: Any - ) -> _models.ManagedBackupShortTermRetentionPolicy: - """Gets a managed database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy_name: The policy name. "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName - :return: ManagedBackupShortTermRetentionPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedBackupShortTermRetentionPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - policy_name=policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedBackupShortTermRetentionPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - parameters: Union[_models.ManagedBackupShortTermRetentionPolicy, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ManagedBackupShortTermRetentionPolicy") - - _request = build_create_or_update_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - parameters: _models.ManagedBackupShortTermRetentionPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedBackupShortTermRetentionPolicy]: - """Updates a managed database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedBackupShortTermRetentionPolicy or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedBackupShortTermRetentionPolicy]: - """Updates a managed database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedBackupShortTermRetentionPolicy or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - parameters: Union[_models.ManagedBackupShortTermRetentionPolicy, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ManagedBackupShortTermRetentionPolicy]: - """Updates a managed database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Is either a - ManagedBackupShortTermRetentionPolicy type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy or IO[bytes] - :return: An instance of LROPoller that returns either ManagedBackupShortTermRetentionPolicy or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagedBackupShortTermRetentionPolicy] = 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, - managed_instance_name=managed_instance_name, - database_name=database_name, - policy_name=policy_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedBackupShortTermRetentionPolicy", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedBackupShortTermRetentionPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ManagedBackupShortTermRetentionPolicy]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - parameters: Union[_models.ManagedBackupShortTermRetentionPolicy, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ManagedBackupShortTermRetentionPolicy") - - _request = build_update_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - parameters: _models.ManagedBackupShortTermRetentionPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedBackupShortTermRetentionPolicy]: - """Updates a managed database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedBackupShortTermRetentionPolicy or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedBackupShortTermRetentionPolicy]: - """Updates a managed database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedBackupShortTermRetentionPolicy or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - parameters: Union[_models.ManagedBackupShortTermRetentionPolicy, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ManagedBackupShortTermRetentionPolicy]: - """Updates a managed database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Is either a - ManagedBackupShortTermRetentionPolicy type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy or IO[bytes] - :return: An instance of LROPoller that returns either ManagedBackupShortTermRetentionPolicy or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagedBackupShortTermRetentionPolicy] = 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( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - policy_name=policy_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedBackupShortTermRetentionPolicy", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedBackupShortTermRetentionPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ManagedBackupShortTermRetentionPolicy]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_by_database( - self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either ManagedBackupShortTermRetentionPolicy or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedBackupShortTermRetentionPolicyListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 03aa74f71a79..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_advanced_threat_protection_settings_operations.py +++ /dev/null @@ -1,476 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_database_request( - resource_group_name: str, managed_instance_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-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}/advancedThreatProtectionSettings", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-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}/advancedThreatProtectionSettings/{advancedThreatProtectionName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "advancedThreatProtectionName": _SERIALIZER.url( - "advanced_threat_protection_name", advanced_threat_protection_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) - 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}/advancedThreatProtectionSettings/{advancedThreatProtectionName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "advancedThreatProtectionName": _SERIALIZER.url( - "advanced_threat_protection_name", advanced_threat_protection_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -class ManagedDatabaseAdvancedThreatProtectionSettingsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_database_advanced_threat_protection_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.ManagedDatabaseAdvancedThreatProtection"]: - """Gets a list of managed database's Advanced Threat Protection states. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. 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 - :return: An iterator like instance of either ManagedDatabaseAdvancedThreatProtection or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) - cls: ClsType[_models.ManagedDatabaseAdvancedThreatProtectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedDatabaseAdvancedThreatProtectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - **kwargs: Any - ) -> _models.ManagedDatabaseAdvancedThreatProtection: - """Gets a managed database's Advanced Threat Protection state. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. 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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. - "Default" Required. - :type advanced_threat_protection_name: str or - ~azure.mgmt.sql.models.AdvancedThreatProtectionName - :return: ManagedDatabaseAdvancedThreatProtection or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-02-01-preview")) - cls: ClsType[_models.ManagedDatabaseAdvancedThreatProtection] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - advanced_threat_protection_name=advanced_threat_protection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedDatabaseAdvancedThreatProtection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: _models.ManagedDatabaseAdvancedThreatProtection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ManagedDatabaseAdvancedThreatProtection: - """Creates or updates a managed database's Advanced Threat Protection state. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. 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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. - "Default" Required. - :type advanced_threat_protection_name: str or - ~azure.mgmt.sql.models.AdvancedThreatProtectionName - :param parameters: The managed database Advanced Threat Protection state. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ManagedDatabaseAdvancedThreatProtection or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ManagedDatabaseAdvancedThreatProtection: - """Creates or updates a managed database's Advanced Threat Protection state. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. 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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. - "Default" Required. - :type advanced_threat_protection_name: str or - ~azure.mgmt.sql.models.AdvancedThreatProtectionName - :param parameters: The managed database Advanced Threat Protection state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ManagedDatabaseAdvancedThreatProtection or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: Union[_models.ManagedDatabaseAdvancedThreatProtection, IO[bytes]], - **kwargs: Any - ) -> _models.ManagedDatabaseAdvancedThreatProtection: - """Creates or updates a managed database's Advanced Threat Protection state. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. 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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. - "Default" Required. - :type advanced_threat_protection_name: str or - ~azure.mgmt.sql.models.AdvancedThreatProtectionName - :param parameters: The managed database Advanced Threat Protection state. Is either a - ManagedDatabaseAdvancedThreatProtection type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection or IO[bytes] - :return: ManagedDatabaseAdvancedThreatProtection or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-02-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ManagedDatabaseAdvancedThreatProtection") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - advanced_threat_protection_name=advanced_threat_protection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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) - - deserialized = self._deserialize("ManagedDatabaseAdvancedThreatProtection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index e41b197f32b5..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_columns_operations.py +++ /dev/null @@ -1,463 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_database_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - subscription_id: str, - *, - schema: Optional[List[str]] = None, - table: Optional[List[str]] = None, - column: Optional[List[str]] = None, - order_by: Optional[List[str]] = None, - skiptoken: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/columns", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if schema is not None: - _params["schema"] = [_SERIALIZER.query("schema", q, "str") if q is not None else "" for q in schema] - if table is not None: - _params["table"] = [_SERIALIZER.query("table", q, "str") if q is not None else "" for q in table] - if column is not None: - _params["column"] = [_SERIALIZER.query("column", q, "str") if q is not None else "" for q in column] - if order_by is not None: - _params["orderBy"] = [_SERIALIZER.query("order_by", q, "str") if q is not None else "" for q in order_by] - if skiptoken is not None: - _params["$skiptoken"] = _SERIALIZER.query("skiptoken", skiptoken, "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_table_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - schema_name: str, - table_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), - "tableName": _SERIALIZER.url("table_name", table_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), - "tableName": _SERIALIZER.url("table_name", table_name, "str"), - "columnName": _SERIALIZER.url("column_name", column_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ManagedDatabaseColumnsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_database_columns` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - schema: Optional[List[str]] = None, - table: Optional[List[str]] = None, - column: Optional[List[str]] = None, - order_by: Optional[List[str]] = None, - skiptoken: Optional[str] = None, - **kwargs: Any - ) -> ItemPaged["_models.DatabaseColumn"]: - """List managed database 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 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: Default value is None. - :type schema: list[str] - :param table: Default value is None. - :type table: list[str] - :param column: Default value is None. - :type column: list[str] - :param order_by: Default value is None. - :type order_by: list[str] - :param skiptoken: An opaque token that identifies a starting point in the collection. Default - value is None. - :type skiptoken: str - :return: An iterator like instance of either DatabaseColumn or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseColumn] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseColumnListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - schema=schema, - table=table, - column=column, - order_by=order_by, - skiptoken=skiptoken, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseColumnListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_table( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - schema_name: str, - table_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> ItemPaged["_models.DatabaseColumn"]: - """List managed database 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 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 filter: An OData filter expression that filters elements in the collection. Default - value is None. - :type filter: str - :return: An iterator like instance of either DatabaseColumn or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseColumn] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseColumnListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_table_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - schema_name=schema_name, - table_name=table_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseColumnListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @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, - **kwargs: Any - ) -> _models.DatabaseColumn: - """Get managed database 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 - :return: DatabaseColumn or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseColumn - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseColumn] = 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, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("DatabaseColumn", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 4d4965607109..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_move_operations_operations.py +++ /dev/null @@ -1,278 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_location_request( - resource_group_name: str, - location_name: str, - subscription_id: str, - *, - only_latest_per_database: Optional[bool] = None, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-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}/managedDatabaseMoveOperationResults", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if only_latest_per_database is not None: - _params["onlyLatestPerDatabase"] = _SERIALIZER.query( - "only_latest_per_database", only_latest_per_database, "bool" - ) - if 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) - - -def build_get_request( - resource_group_name: str, location_name: str, operation_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-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}/managedDatabaseMoveOperationResults/{operationId}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ManagedDatabaseMoveOperationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_database_move_operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - only_latest_per_database: Optional[bool] = None, - filter: Optional[str] = None, - **kwargs: Any - ) -> ItemPaged["_models.ManagedDatabaseMoveOperationResult"]: - """Lists managed database move operations. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param location_name: Required. - :type location_name: str - :param only_latest_per_database: Whether or not to only get the latest operation for each - database. Has higher priority than $filter. Default value is None. - :type only_latest_per_database: bool - :param filter: An OData filter expression that filters elements in the collection. Default - value is None. - :type filter: str - :return: An iterator like instance of either ManagedDatabaseMoveOperationResult or the result - of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedDatabaseMoveOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - cls: ClsType[_models.ManagedDatabaseMoveOperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - only_latest_per_database=only_latest_per_database, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedDatabaseMoveOperationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, location_name: str, operation_id: str, **kwargs: Any - ) -> _models.ManagedDatabaseMoveOperationResult: - """Gets a managed database move operation. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param location_name: Required. - :type location_name: str - :param operation_id: Required. - :type operation_id: str - :return: ManagedDatabaseMoveOperationResult or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedDatabaseMoveOperationResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-05-01-preview")) - cls: ClsType[_models.ManagedDatabaseMoveOperationResult] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - location_name=location_name, - operation_id=operation_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedDatabaseMoveOperationResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_queries_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_queries_operations.py deleted file mode 100644 index 10fc7f567a60..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_queries_operations.py +++ /dev/null @@ -1,302 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar, Union - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - query_id: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/queries/{queryId}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "queryId": _SERIALIZER.url("query_id", query_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_query_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - query_id: str, - subscription_id: str, - *, - start_time: Optional[str] = None, - end_time: Optional[str] = None, - interval: Optional[Union[str, _models.QueryTimeGrainType]] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/queries/{queryId}/statistics", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "queryId": _SERIALIZER.url("query_id", query_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if start_time is not None: - _params["startTime"] = _SERIALIZER.query("start_time", start_time, "str") - if end_time is not None: - _params["endTime"] = _SERIALIZER.query("end_time", end_time, "str") - if interval is not None: - _params["interval"] = _SERIALIZER.query("interval", interval, "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 ManagedDatabaseQueriesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_database_queries` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, resource_group_name: str, managed_instance_name: str, database_name: str, query_id: str, **kwargs: Any - ) -> _models.ManagedInstanceQuery: - """Get query by query id. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 query_id: Required. - :type query_id: str - :return: ManagedInstanceQuery or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstanceQuery - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceQuery] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - query_id=query_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedInstanceQuery", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_query( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - query_id: str, - start_time: Optional[str] = None, - end_time: Optional[str] = None, - interval: Optional[Union[str, _models.QueryTimeGrainType]] = None, - **kwargs: Any - ) -> ItemPaged["_models.QueryStatistics"]: - """Get query execution statistics by query id. - - :param resource_group_name: The name of the resource group that 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 query_id: Required. - :type query_id: str - :param start_time: Start time for observed period. Default value is None. - :type start_time: str - :param end_time: End time for observed period. Default value is None. - :type end_time: str - :param interval: The time step to be used to summarize the metric values. Known values are: - "PT1H" and "P1D". Default value is None. - :type interval: str or ~azure.mgmt.sql.models.QueryTimeGrainType - :return: An iterator like instance of either QueryStatistics or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.QueryStatistics] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceQueryStatistics] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_query_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - query_id=query_id, - subscription_id=self._config.subscription_id, - start_time=start_time, - end_time=end_time, - interval=interval, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedInstanceQueryStatistics", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_recommended_sensitivity_labels_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_recommended_sensitivity_labels_operations.py deleted file mode 100644 index 3d85158c33d7..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_recommended_sensitivity_labels_operations.py +++ /dev/null @@ -1,225 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_update_request( - resource_group_name: str, managed_instance_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/recommendedSensitivityLabels", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -class ManagedDatabaseRecommendedSensitivityLabelsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_database_recommended_sensitivity_labels` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: _models.RecommendedSensitivityLabelUpdateList, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Update recommended sensitivity labels states of a given database using an operations batch. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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.RecommendedSensitivityLabelUpdateList - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Update recommended sensitivity labels states of a given database using an operations batch. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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.RecommendedSensitivityLabelUpdateList, IO[bytes]], - **kwargs: Any - ) -> None: - """Update recommended sensitivity labels states of a given database using an operations batch. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 RecommendedSensitivityLabelUpdateList type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.sql.models.RecommendedSensitivityLabelUpdateList or IO[bytes] - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, "RecommendedSensitivityLabelUpdateList") - - _request = build_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_restore_details_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_restore_details_operations.py deleted file mode 100644 index 0af64cb9908f..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_restore_details_operations.py +++ /dev/null @@ -1,162 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar, Union - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - restore_details_name: Union[str, _models.RestoreDetailsName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/restoreDetails/{restoreDetailsName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "restoreDetailsName": _SERIALIZER.url("restore_details_name", restore_details_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ManagedDatabaseRestoreDetailsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_database_restore_details` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - restore_details_name: Union[str, _models.RestoreDetailsName], - **kwargs: Any - ) -> _models.ManagedDatabaseRestoreDetailsResult: - """Gets managed database restore details. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 restore_details_name: The name of the restore details to retrieve. "Default" Required. - :type restore_details_name: str or ~azure.mgmt.sql.models.RestoreDetailsName - :return: ManagedDatabaseRestoreDetailsResult or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedDatabaseRestoreDetailsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-05-01-preview")) - cls: ClsType[_models.ManagedDatabaseRestoreDetailsResult] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - restore_details_name=restore_details_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedDatabaseRestoreDetailsResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_schemas_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_schemas_operations.py deleted file mode 100644 index 9e7cdc4cdd68..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_schemas_operations.py +++ /dev/null @@ -1,282 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_database_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - schema_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ManagedDatabaseSchemasOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_database_schemas` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - filter: Optional[str] = None, - **kwargs: Any - ) -> ItemPaged["_models.DatabaseSchema"]: - """List managed database schemas. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param 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 filter: An OData filter expression that filters elements in the collection. Default - value is None. - :type filter: str - :return: An iterator like instance of either DatabaseSchema or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseSchema] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseSchemaListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseSchemaListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, managed_instance_name: str, database_name: str, schema_name: str, **kwargs: Any - ) -> _models.DatabaseSchema: - """Get managed database schema. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :return: DatabaseSchema or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSchema - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseSchema] = 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, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("DatabaseSchema", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_security_alert_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_security_alert_policies_operations.py deleted file mode 100644 index 4ef5f399e8c1..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_security_alert_policies_operations.py +++ /dev/null @@ -1,468 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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/{securityAlertPolicyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/securityAlertPolicies", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ManagedDatabaseSecurityAlertPoliciesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_database_security_alert_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - **kwargs: Any - ) -> _models.ManagedDatabaseSecurityAlertPolicy: - """Gets a managed database's security alert policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy is - defined. Required. - :type database_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 - :return: ManagedDatabaseSecurityAlertPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedDatabaseSecurityAlertPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - security_alert_policy_name=security_alert_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedDatabaseSecurityAlertPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - parameters: _models.ManagedDatabaseSecurityAlertPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ManagedDatabaseSecurityAlertPolicy: - """Creates or updates a database's security alert policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy is - defined. Required. - :type database_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 - :param parameters: The database security alert policy. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ManagedDatabaseSecurityAlertPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ManagedDatabaseSecurityAlertPolicy: - """Creates or updates a database's security alert policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy is - defined. Required. - :type database_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 - :param parameters: The database security alert policy. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ManagedDatabaseSecurityAlertPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - parameters: Union[_models.ManagedDatabaseSecurityAlertPolicy, IO[bytes]], - **kwargs: Any - ) -> _models.ManagedDatabaseSecurityAlertPolicy: - """Creates or updates a database's security alert policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy is - defined. Required. - :type database_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 - :param parameters: The database security alert policy. Is either a - ManagedDatabaseSecurityAlertPolicy type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy or IO[bytes] - :return: ManagedDatabaseSecurityAlertPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ManagedDatabaseSecurityAlertPolicy") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - security_alert_policy_name=security_alert_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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) - - deserialized = self._deserialize("ManagedDatabaseSecurityAlertPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_database( - self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either ManagedDatabaseSecurityAlertPolicy or the result - of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedDatabaseSecurityAlertPolicyListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 4b1099bfcb17..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_security_events_operations.py +++ /dev/null @@ -1,204 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_database_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - skip: Optional[int] = None, - top: Optional[int] = None, - skiptoken: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/securityEvents", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if skip is not None: - _params["$skip"] = _SERIALIZER.query("skip", skip, "int") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") - if skiptoken is not None: - _params["$skiptoken"] = _SERIALIZER.query("skiptoken", skiptoken, "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 ManagedDatabaseSecurityEventsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_database_security_events` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - filter: Optional[str] = None, - skip: Optional[int] = None, - top: Optional[int] = None, - skiptoken: Optional[str] = None, - **kwargs: Any - ) -> ItemPaged["_models.SecurityEvent"]: - """Gets a list of security events. - - :param resource_group_name: The name of the resource group that 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 events are - retrieved. Required. - :type database_name: str - :param filter: An OData filter expression that filters elements in the collection. Default - value is None. - :type filter: str - :param skip: The number of elements in the collection to skip. Default value is None. - :type skip: int - :param top: The number of elements to return from the collection. Default value is None. - :type top: int - :param skiptoken: An opaque token that identifies a starting point in the collection. Default - value is None. - :type skiptoken: str - :return: An iterator like instance of either SecurityEvent or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SecurityEvent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SecurityEventCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - filter=filter, - skip=skip, - top=top, - skiptoken=skiptoken, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityEventCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_sensitivity_labels_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_sensitivity_labels_operations.py deleted file mode 100644 index 9b7a0334506b..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_sensitivity_labels_operations.py +++ /dev/null @@ -1,1185 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Literal, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - sensitivity_label_source: Union[str, _models.SensitivityLabelSource], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), - "tableName": _SERIALIZER.url("table_name", table_name, "str"), - "columnName": _SERIALIZER.url("column_name", column_name, "str"), - "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), - "tableName": _SERIALIZER.url("table_name", table_name, "str"), - "columnName": _SERIALIZER.url("column_name", column_name, "str"), - "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), - "tableName": _SERIALIZER.url("table_name", table_name, "str"), - "columnName": _SERIALIZER.url("column_name", column_name, "str"), - "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_disable_recommendation_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/disable", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), - "tableName": _SERIALIZER.url("table_name", table_name, "str"), - "columnName": _SERIALIZER.url("column_name", column_name, "str"), - "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_enable_recommendation_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/enable", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), - "tableName": _SERIALIZER.url("table_name", table_name, "str"), - "columnName": _SERIALIZER.url("column_name", column_name, "str"), - "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_list_current_by_database_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - subscription_id: str, - *, - skip_token: Optional[str] = None, - count: Optional[bool] = None, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/currentSensitivityLabels", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if skip_token is not None: - _params["$skipToken"] = _SERIALIZER.query("skip_token", skip_token, "str") - if count is not None: - _params["$count"] = _SERIALIZER.query("count", count, "bool") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -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", "2020-11-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", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_recommended_by_database_request( # pylint: disable=name-too-long - resource_group_name: str, - managed_instance_name: str, - database_name: str, - subscription_id: str, - *, - skip_token: Optional[str] = None, - include_disabled_recommendations: Optional[bool] = None, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - 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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ManagedDatabaseSensitivityLabelsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_database_sensitivity_labels` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @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 - :return: SensitivityLabel or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SensitivityLabel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SensitivityLabel] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - parameters: _models.SensitivityLabel, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SensitivityLabel: - """Creates or updates the sensitivity label of a given column. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 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 - :return: SensitivityLabel or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SensitivityLabel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SensitivityLabel: - """Creates or updates the sensitivity label of a given column. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 parameters: The column sensitivity label resource. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: SensitivityLabel or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SensitivityLabel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - parameters: Union[_models.SensitivityLabel, IO[bytes]], - **kwargs: Any - ) -> _models.SensitivityLabel: - """Creates or updates the sensitivity label of a given column. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 parameters: The column sensitivity label resource. Is either a SensitivityLabel type or - a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.SensitivityLabel or IO[bytes] - :return: SensitivityLabel or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SensitivityLabel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 {}) - - sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SensitivityLabel] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SensitivityLabel") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - schema_name=schema_name, - table_name=table_name, - column_name=column_name, - subscription_id=self._config.subscription_id, - sensitivity_label_source=sensitivity_label_source, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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) - - deserialized = self._deserialize("SensitivityLabel", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - **kwargs: Any - ) -> None: - """Deletes the sensitivity label of a given column. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param database_name: The name of the database. Required. - :type database_name: str - :param schema_name: The name of the schema. Required. - :type schema_name: str - :param table_name: The name of the table. Required. - :type table_name: str - :param column_name: The name of the column. Required. - :type column_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - schema_name=schema_name, - table_name=table_name, - column_name=column_name, - subscription_id=self._config.subscription_id, - sensitivity_label_source=sensitivity_label_source, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_disable_recommendation_request( - resource_group_name=resource_group_name, - 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, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @distributed_trace - def enable_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: - """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 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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_enable_recommendation_request( - resource_group_name=resource_group_name, - 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, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @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 - ) -> ItemPaged["_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 - :return: An iterator like instance of either SensitivityLabel or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SensitivityLabel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SensitivityLabelListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @overload - def update( - 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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.SensitivityLabelUpdateList or IO[bytes] - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @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 - ) -> ItemPaged["_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 - :return: An iterator like instance of either SensitivityLabel or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SensitivityLabel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SensitivityLabelListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 304a71a78967..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_tables_operations.py +++ /dev/null @@ -1,299 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_schema_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - schema_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - schema_name: str, - table_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), - "tableName": _SERIALIZER.url("table_name", table_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ManagedDatabaseTablesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_database_tables` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_schema( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - schema_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> ItemPaged["_models.DatabaseTable"]: - """List managed database tables. - - :param resource_group_name: The name of the resource group that 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 filter: An OData filter expression that filters elements in the collection. Default - value is None. - :type filter: str - :return: An iterator like instance of either DatabaseTable or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseTable] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseTableListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_schema_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - schema_name=schema_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DatabaseTableListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - schema_name: str, - table_name: str, - **kwargs: Any - ) -> _models.DatabaseTable: - """Get managed database table. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :return: DatabaseTable or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseTable - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseTable] = 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, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("DatabaseTable", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_transparent_data_encryption_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_transparent_data_encryption_operations.py deleted file mode 100644 index da5824c7b233..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_transparent_data_encryption_operations.py +++ /dev/null @@ -1,468 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - tde_name: Union[str, _models.TransparentDataEncryptionName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/transparentDataEncryption/{tdeName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "tdeName": _SERIALIZER.url("tde_name", tde_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - tde_name: Union[str, _models.TransparentDataEncryptionName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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/{tdeName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "tdeName": _SERIALIZER.url("tde_name", tde_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/transparentDataEncryption", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ManagedDatabaseTransparentDataEncryptionOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_database_transparent_data_encryption` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - tde_name: Union[str, _models.TransparentDataEncryptionName], - **kwargs: Any - ) -> _models.ManagedTransparentDataEncryption: - """Gets a managed database's transparent data encryption. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param tde_name: The name of the transparent data encryption configuration. "current" Required. - :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName - :return: ManagedTransparentDataEncryption or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedTransparentDataEncryption - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedTransparentDataEncryption] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - tde_name=tde_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedTransparentDataEncryption", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - tde_name: Union[str, _models.TransparentDataEncryptionName], - parameters: _models.ManagedTransparentDataEncryption, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ManagedTransparentDataEncryption: - """Updates a database's transparent data encryption configuration. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy is - defined. Required. - :type database_name: str - :param tde_name: The name of the transparent data encryption configuration. "current" Required. - :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName - :param parameters: The database transparent data encryption. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedTransparentDataEncryption - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ManagedTransparentDataEncryption or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedTransparentDataEncryption - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - tde_name: Union[str, _models.TransparentDataEncryptionName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ManagedTransparentDataEncryption: - """Updates a database's transparent data encryption configuration. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy is - defined. Required. - :type database_name: str - :param tde_name: The name of the transparent data encryption configuration. "current" Required. - :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName - :param parameters: The database transparent data encryption. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ManagedTransparentDataEncryption or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedTransparentDataEncryption - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - tde_name: Union[str, _models.TransparentDataEncryptionName], - parameters: Union[_models.ManagedTransparentDataEncryption, IO[bytes]], - **kwargs: Any - ) -> _models.ManagedTransparentDataEncryption: - """Updates a database's transparent data encryption configuration. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy is - defined. Required. - :type database_name: str - :param tde_name: The name of the transparent data encryption configuration. "current" Required. - :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName - :param parameters: The database transparent data encryption. Is either a - ManagedTransparentDataEncryption type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedTransparentDataEncryption or IO[bytes] - :return: ManagedTransparentDataEncryption or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedTransparentDataEncryption - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ManagedTransparentDataEncryption") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - tde_name=tde_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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) - - deserialized = self._deserialize("ManagedTransparentDataEncryption", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_database( - self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either ManagedTransparentDataEncryption or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedTransparentDataEncryption] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedTransparentDataEncryptionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index e6c2c3f19ace..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_vulnerability_assessment_rule_baselines_operations.py +++ /dev/null @@ -1,525 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - rule_id: str, - baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), - "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - rule_id: str, - baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), - "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - rule_id: str, - baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), - "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -class ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_database_vulnerability_assessment_rule_baselines` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - rule_id: str, - baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: - """Gets a database's vulnerability assessment rule baseline. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 rule - baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a - baseline on a database level rule and master for server level rule). Known values are: "master" - and "default". Required. - :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName - :return: DatabaseVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseVulnerabilityAssessmentRuleBaseline] = 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, - rule_id=rule_id, - baseline_name=baseline_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("DatabaseVulnerabilityAssessmentRuleBaseline", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - rule_id: str, - baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - parameters: _models.DatabaseVulnerabilityAssessmentRuleBaseline, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: - """Creates or updates a database's vulnerability assessment rule baseline. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 rule - baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a - baseline on a database level rule and master for server level rule). Known values are: "master" - 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 - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - rule_id: str, - baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: - """Creates or updates a database's vulnerability assessment rule baseline. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 rule - baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a - baseline on a database level rule and master for server level rule). Known values are: "master" - and "default". Required. - :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName - :param parameters: The requested rule baseline resource. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - rule_id: str, - baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - parameters: Union[_models.DatabaseVulnerabilityAssessmentRuleBaseline, IO[bytes]], - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: - """Creates or updates a database's vulnerability assessment rule baseline. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 rule - baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a - baseline on a database level rule and master for server level rule). Known values are: "master" - 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[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline or - IO[bytes] - :return: DatabaseVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DatabaseVulnerabilityAssessmentRuleBaseline") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - rule_id=rule_id, - baseline_name=baseline_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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("DatabaseVulnerabilityAssessmentRuleBaseline", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - rule_id: str, - baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - **kwargs: Any - ) -> None: - """Removes the database's vulnerability assessment rule baseline. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 rule - baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a - baseline on a database level rule and master for server level rule). Known values are: "master" - and "default". Required. - :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - rule_id=rule_id, - baseline_name=baseline_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_vulnerability_assessment_scans_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_vulnerability_assessment_scans_operations.py deleted file mode 100644 index 7d95bf53f0c6..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_vulnerability_assessment_scans_operations.py +++ /dev/null @@ -1,582 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Iterator, Optional, TypeVar, Union, cast - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_initiate_scan_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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_export_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - scan_id: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/export", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_database_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - scan_id: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ManagedDatabaseVulnerabilityAssessmentScansOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_database_vulnerability_assessment_scans` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - def _initiate_scan_initial( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - scan_id: str, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_initiate_scan( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - scan_id: str, - **kwargs: Any - ) -> LROPoller[None]: - """Executes a Vulnerability Assessment database scan. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. Required. - :type scan_id: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._initiate_scan_initial( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def export( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - scan_id: str, - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessmentScansExport: - """Convert an existing scan result to a human readable format. If already exists nothing happens. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 scanned 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. Required. - :type scan_id: str - :return: DatabaseVulnerabilityAssessmentScansExport or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentScansExport - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseVulnerabilityAssessmentScansExport] = kwargs.pop("cls", None) - - _request = build_export_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - scan_id=scan_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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) - - deserialized = self._deserialize("DatabaseVulnerabilityAssessmentScansExport", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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], - **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either VulnerabilityAssessmentScanRecord or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecord] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.VulnerabilityAssessmentScanRecordListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - scan_id: str, - **kwargs: Any - ) -> _models.VulnerabilityAssessmentScanRecord: - """Gets a vulnerability assessment scan record of a database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. Required. - :type scan_id: str - :return: VulnerabilityAssessmentScanRecord or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecord - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.VulnerabilityAssessmentScanRecord] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - scan_id=scan_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_vulnerability_assessments_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_vulnerability_assessments_operations.py deleted file mode 100644 index 805285adf8c8..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_vulnerability_assessments_operations.py +++ /dev/null @@ -1,576 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_list_by_database_request( - resource_group_name: str, managed_instance_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ManagedDatabaseVulnerabilityAssessmentsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_database_vulnerability_assessments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessment: - """Gets the database's vulnerability assessment. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" - Required. - :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName - :return: DatabaseVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseVulnerabilityAssessment] = 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, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("DatabaseVulnerabilityAssessment", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: _models.DatabaseVulnerabilityAssessment, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessment: - """Creates or updates the database's vulnerability assessment. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" - Required. - :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName - :param parameters: The requested resource. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessment: - """Creates or updates the database's vulnerability assessment. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" - Required. - :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName - :param parameters: The requested resource. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: Union[_models.DatabaseVulnerabilityAssessment, IO[bytes]], - **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessment: - """Creates or updates the database's vulnerability assessment. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" - Required. - :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName - :param parameters: The requested resource. Is either a DatabaseVulnerabilityAssessment type or - a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment or IO[bytes] - :return: DatabaseVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DatabaseVulnerabilityAssessment") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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) - - deserialized = self._deserialize("DatabaseVulnerabilityAssessment", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **kwargs: Any - ) -> None: - """Removes the database's vulnerability assessment. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" - Required. - :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @distributed_trace - def list_by_database( - self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either DatabaseVulnerabilityAssessment or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 9a63a2c76ec1..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_databases_operations.py +++ /dev/null @@ -1,1891 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_instance_request( - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-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", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_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", "2022-08-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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_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", "2022-08-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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, managed_instance_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_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", "2022-08-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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cancel_move_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", "2022-08-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}/cancelMove", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_complete_move_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", "2022-08-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}/completeMove", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_complete_restore_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", "2022-08-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}/completeRestore", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_start_move_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", "2022-08-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}/startMove", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_inaccessible_by_instance_request( # pylint: disable=name-too-long - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/inaccessibleManagedDatabases", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ManagedDatabasesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_databases` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.ManagedDatabase"]: - """Gets a list of managed databases. - - :param resource_group_name: The name of the resource group that 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 - :return: An iterator like instance of either ManagedDatabase or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.ManagedDatabaseListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedDatabaseListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any - ) -> _models.ManagedDatabase: - """Gets a managed database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :return: ManagedDatabase or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedDatabase - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - cls: ClsType[_models.ManagedDatabase] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedDatabase", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: Union[_models.ManagedDatabase, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ManagedDatabase") - - _request = build_create_or_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: _models.ManagedDatabase, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedDatabase]: - """Creates a new database or updates an existing database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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: The requested database resource state. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedDatabase - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedDatabase or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedDatabase]: - """Creates a new database or updates an existing database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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: The requested database resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedDatabase or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: Union[_models.ManagedDatabase, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ManagedDatabase]: - """Creates a new database or updates an existing database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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: The requested database resource state. Is either a ManagedDatabase type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedDatabase or IO[bytes] - :return: An instance of LROPoller that returns either ManagedDatabase or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - 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) - 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, - managed_instance_name=managed_instance_name, - database_name=database_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedDatabase", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedDatabase].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ManagedDatabase]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes a managed database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :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", "2022-08-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( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: Union[_models.ManagedDatabaseUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ManagedDatabaseUpdate") - - _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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: _models.ManagedDatabaseUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedDatabase]: - """Updates an existing database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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: The requested database resource state. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedDatabase or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedDatabase]: - """Updates an existing database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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: The requested database resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedDatabase or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: Union[_models.ManagedDatabaseUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ManagedDatabase]: - """Updates an existing database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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: The requested database resource state. Is either a ManagedDatabaseUpdate - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseUpdate or IO[bytes] - :return: An instance of LROPoller that returns either ManagedDatabase or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - 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) - 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( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedDatabase", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedDatabase].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ManagedDatabase]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _cancel_move_initial( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: Union[_models.ManagedDatabaseMoveDefinition, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ManagedDatabaseMoveDefinition") - - _request = build_cancel_move_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_cancel_move( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: _models.ManagedDatabaseMoveDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Cancels a managed database move operation. - - :param resource_group_name: The name of the resource group that 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: Parameters of the cancel managed database move operation. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseMoveDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @overload - def begin_cancel_move( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Cancels a managed database move operation. - - :param resource_group_name: The name of the resource group that 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: Parameters of the cancel managed database move operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @distributed_trace - def begin_cancel_move( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: Union[_models.ManagedDatabaseMoveDefinition, IO[bytes]], - **kwargs: Any - ) -> LROPoller[None]: - """Cancels a managed database move operation. - - :param resource_group_name: The name of the resource group that 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: Parameters of the cancel managed database move operation. Is either a - ManagedDatabaseMoveDefinition type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseMoveDefinition or IO[bytes] - :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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - 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) - 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._cancel_move_initial( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _complete_move_initial( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: Union[_models.ManagedDatabaseMoveDefinition, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ManagedDatabaseMoveDefinition") - - _request = build_complete_move_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_complete_move( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: _models.ManagedDatabaseMoveDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Completes a managed database move operation. - - :param resource_group_name: The name of the resource group that 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: Parameters of the complete managed database move operation. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseMoveDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @overload - def begin_complete_move( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Completes a managed database move operation. - - :param resource_group_name: The name of the resource group that 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: Parameters of the complete managed database move operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @distributed_trace - def begin_complete_move( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: Union[_models.ManagedDatabaseMoveDefinition, IO[bytes]], - **kwargs: Any - ) -> LROPoller[None]: - """Completes a managed database move operation. - - :param resource_group_name: The name of the resource group that 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: Parameters of the complete managed database move operation. Is either a - ManagedDatabaseMoveDefinition type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseMoveDefinition or IO[bytes] - :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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - 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) - 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._complete_move_initial( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _complete_restore_initial( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: Union[_models.CompleteDatabaseRestoreDefinition, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "CompleteDatabaseRestoreDefinition") - - _request = build_complete_restore_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_complete_restore( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: _models.CompleteDatabaseRestoreDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Completes the restore operation on a managed database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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: The definition for completing the restore of this managed database. - Required. - :type parameters: ~azure.mgmt.sql.models.CompleteDatabaseRestoreDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @overload - def begin_complete_restore( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Completes the restore operation on a managed database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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: The definition for completing the restore of this managed database. - Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @distributed_trace - def begin_complete_restore( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: Union[_models.CompleteDatabaseRestoreDefinition, IO[bytes]], - **kwargs: Any - ) -> LROPoller[None]: - """Completes the restore operation on a managed database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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: The definition for completing the restore of this managed database. Is - either a CompleteDatabaseRestoreDefinition type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.CompleteDatabaseRestoreDefinition or IO[bytes] - :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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - 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) - 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._complete_restore_initial( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _start_move_initial( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: Union[_models.ManagedDatabaseStartMoveDefinition, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ManagedDatabaseStartMoveDefinition") - - _request = build_start_move_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_start_move( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: _models.ManagedDatabaseStartMoveDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Starts a managed database move operation. - - :param resource_group_name: The name of the resource group that 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: Parameters of the start managed database move operation. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseStartMoveDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @overload - def begin_start_move( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Starts a managed database move operation. - - :param resource_group_name: The name of the resource group that 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: Parameters of the start managed database move operation. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @distributed_trace - def begin_start_move( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: Union[_models.ManagedDatabaseStartMoveDefinition, IO[bytes]], - **kwargs: Any - ) -> LROPoller[None]: - """Starts a managed database move operation. - - :param resource_group_name: The name of the resource group that 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: Parameters of the start managed database move operation. Is either a - ManagedDatabaseStartMoveDefinition type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseStartMoveDefinition or IO[bytes] - :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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - 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) - 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_move_initial( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_inaccessible_by_instance( - self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> ItemPaged["_models.ManagedDatabase"]: - """Gets a list of inaccessible managed databases in a managed instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :return: An iterator like instance of either ManagedDatabase or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.ManagedDatabaseListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_inaccessible_by_instance_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedDatabaseListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_administrators_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_administrators_operations.py deleted file mode 100644 index 17d73ce51938..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_administrators_operations.py +++ /dev/null @@ -1,656 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_instance_request( - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/administrators", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - managed_instance_name: str, - administrator_name: Union[str, _models.AdministratorName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/administrators/{administratorName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "administratorName": _SERIALIZER.url("administrator_name", administrator_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - managed_instance_name: str, - administrator_name: Union[str, _models.AdministratorName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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}/administrators/{administratorName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "administratorName": _SERIALIZER.url("administrator_name", administrator_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - managed_instance_name: str, - administrator_name: Union[str, _models.AdministratorName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/administrators/{administratorName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "administratorName": _SERIALIZER.url("administrator_name", administrator_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -class ManagedInstanceAdministratorsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_instance_administrators` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.ManagedInstanceAdministrator"]: - """Gets a list of managed instance administrators. - - :param resource_group_name: The name of the resource group that 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 - :return: An iterator like instance of either ManagedInstanceAdministrator or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceAdministrator] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceAdministratorListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedInstanceAdministratorListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - managed_instance_name: str, - administrator_name: Union[str, _models.AdministratorName], - **kwargs: Any - ) -> _models.ManagedInstanceAdministrator: - """Gets a managed instance administrator. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 administrator_name: "ActiveDirectory" Required. - :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName - :return: ManagedInstanceAdministrator or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstanceAdministrator - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceAdministrator] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - administrator_name=administrator_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedInstanceAdministrator", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - administrator_name: Union[str, _models.AdministratorName], - parameters: Union[_models.ManagedInstanceAdministrator, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ManagedInstanceAdministrator") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - administrator_name=administrator_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - administrator_name: Union[str, _models.AdministratorName], - parameters: _models.ManagedInstanceAdministrator, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedInstanceAdministrator]: - """Creates or updates a managed instance administrator. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 administrator_name: "ActiveDirectory" Required. - :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName - :param parameters: The requested administrator parameters. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceAdministrator - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedInstanceAdministrator or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceAdministrator] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - administrator_name: Union[str, _models.AdministratorName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedInstanceAdministrator]: - """Creates or updates a managed instance administrator. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 administrator_name: "ActiveDirectory" Required. - :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName - :param parameters: The requested administrator parameters. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedInstanceAdministrator or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceAdministrator] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - administrator_name: Union[str, _models.AdministratorName], - parameters: Union[_models.ManagedInstanceAdministrator, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ManagedInstanceAdministrator]: - """Creates or updates a managed instance administrator. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 administrator_name: "ActiveDirectory" Required. - :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName - :param parameters: The requested administrator parameters. Is either a - ManagedInstanceAdministrator type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceAdministrator or IO[bytes] - :return: An instance of LROPoller that returns either ManagedInstanceAdministrator or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceAdministrator] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagedInstanceAdministrator] = 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, - managed_instance_name=managed_instance_name, - administrator_name=administrator_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedInstanceAdministrator", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedInstanceAdministrator].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ManagedInstanceAdministrator]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, - resource_group_name: str, - managed_instance_name: str, - administrator_name: Union[str, _models.AdministratorName], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - administrator_name=administrator_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, - resource_group_name: str, - managed_instance_name: str, - administrator_name: Union[str, _models.AdministratorName], - **kwargs: Any - ) -> LROPoller[None]: - """Deletes a managed instance administrator. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 administrator_name: "ActiveDirectory" Required. - :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - administrator_name=administrator_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_advanced_threat_protection_settings_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_advanced_threat_protection_settings_operations.py deleted file mode 100644 index b489c45a99f8..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_advanced_threat_protection_settings_operations.py +++ /dev/null @@ -1,525 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_instance_request( - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-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}/advancedThreatProtectionSettings", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - managed_instance_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-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}/advancedThreatProtectionSettings/{advancedThreatProtectionName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "advancedThreatProtectionName": _SERIALIZER.url( - "advanced_threat_protection_name", advanced_threat_protection_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - managed_instance_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-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}/advancedThreatProtectionSettings/{advancedThreatProtectionName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "advancedThreatProtectionName": _SERIALIZER.url( - "advanced_threat_protection_name", advanced_threat_protection_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -class ManagedInstanceAdvancedThreatProtectionSettingsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_instance_advanced_threat_protection_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.ManagedInstanceAdvancedThreatProtection"]: - """Get the managed instance's Advanced Threat Protection settings. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :return: An iterator like instance of either ManagedInstanceAdvancedThreatProtection or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) - cls: ClsType[_models.ManagedInstanceAdvancedThreatProtectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedInstanceAdvancedThreatProtectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - managed_instance_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - **kwargs: Any - ) -> _models.ManagedInstanceAdvancedThreatProtection: - """Get a managed instance's Advanced Threat Protection state. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. - "Default" Required. - :type advanced_threat_protection_name: str or - ~azure.mgmt.sql.models.AdvancedThreatProtectionName - :return: ManagedInstanceAdvancedThreatProtection or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-02-01-preview")) - cls: ClsType[_models.ManagedInstanceAdvancedThreatProtection] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - advanced_threat_protection_name=advanced_threat_protection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedInstanceAdvancedThreatProtection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: Union[_models.ManagedInstanceAdvancedThreatProtection, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2022-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ManagedInstanceAdvancedThreatProtection") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - advanced_threat_protection_name=advanced_threat_protection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: _models.ManagedInstanceAdvancedThreatProtection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedInstanceAdvancedThreatProtection]: - """Creates or updates Advanced Threat Protection settings. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. - "Default" Required. - :type advanced_threat_protection_name: str or - ~azure.mgmt.sql.models.AdvancedThreatProtectionName - :param parameters: The managed instance Advanced Threat Protection state. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedInstanceAdvancedThreatProtection - or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedInstanceAdvancedThreatProtection]: - """Creates or updates Advanced Threat Protection settings. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. - "Default" Required. - :type advanced_threat_protection_name: str or - ~azure.mgmt.sql.models.AdvancedThreatProtectionName - :param parameters: The managed instance Advanced Threat Protection state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedInstanceAdvancedThreatProtection - or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: Union[_models.ManagedInstanceAdvancedThreatProtection, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ManagedInstanceAdvancedThreatProtection]: - """Creates or updates Advanced Threat Protection settings. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. - "Default" Required. - :type advanced_threat_protection_name: str or - ~azure.mgmt.sql.models.AdvancedThreatProtectionName - :param parameters: The managed instance Advanced Threat Protection state. Is either a - ManagedInstanceAdvancedThreatProtection type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection or IO[bytes] - :return: An instance of LROPoller that returns either ManagedInstanceAdvancedThreatProtection - or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) - 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) - 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, - managed_instance_name=managed_instance_name, - advanced_threat_protection_name=advanced_threat_protection_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedInstanceAdvancedThreatProtection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedInstanceAdvancedThreatProtection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ManagedInstanceAdvancedThreatProtection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_azure_ad_only_authentications_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_azure_ad_only_authentications_operations.py deleted file mode 100644 index a33d12d6db86..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_azure_ad_only_authentications_operations.py +++ /dev/null @@ -1,673 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - managed_instance_name: str, - authentication_name: Union[str, _models.AuthenticationName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications/{authenticationName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "authenticationName": _SERIALIZER.url("authentication_name", authentication_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - managed_instance_name: str, - authentication_name: Union[str, _models.AuthenticationName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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}/azureADOnlyAuthentications/{authenticationName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "authenticationName": _SERIALIZER.url("authentication_name", authentication_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - managed_instance_name: str, - authentication_name: Union[str, _models.AuthenticationName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications/{authenticationName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "authenticationName": _SERIALIZER.url("authentication_name", authentication_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_list_by_instance_request( - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ManagedInstanceAzureADOnlyAuthenticationsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_instance_azure_ad_only_authentications` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, - resource_group_name: str, - managed_instance_name: str, - authentication_name: Union[str, _models.AuthenticationName], - **kwargs: Any - ) -> _models.ManagedInstanceAzureADOnlyAuthentication: - """Gets a specific Azure Active Directory only authentication property. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 authentication_name: The name of server azure active directory only authentication. - "Default" Required. - :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName - :return: ManagedInstanceAzureADOnlyAuthentication or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceAzureADOnlyAuthentication] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - authentication_name=authentication_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedInstanceAzureADOnlyAuthentication", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - authentication_name: Union[str, _models.AuthenticationName], - parameters: Union[_models.ManagedInstanceAzureADOnlyAuthentication, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ManagedInstanceAzureADOnlyAuthentication") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - authentication_name=authentication_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - authentication_name: Union[str, _models.AuthenticationName], - parameters: _models.ManagedInstanceAzureADOnlyAuthentication, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedInstanceAzureADOnlyAuthentication]: - """Sets Server Active Directory only authentication property or updates an existing server Active - Directory only authentication property. - - :param resource_group_name: The name of the resource group that 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 authentication_name: The name of server azure active directory only authentication. - "Default" Required. - :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName - :param parameters: The required parameters for creating or updating an Active Directory only - authentication property. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedInstanceAzureADOnlyAuthentication - or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - authentication_name: Union[str, _models.AuthenticationName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedInstanceAzureADOnlyAuthentication]: - """Sets Server Active Directory only authentication property or updates an existing server Active - Directory only authentication property. - - :param resource_group_name: The name of the resource group that 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 authentication_name: The name of server azure active directory only authentication. - "Default" Required. - :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName - :param parameters: The required parameters for creating or updating an Active Directory only - authentication property. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedInstanceAzureADOnlyAuthentication - or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - authentication_name: Union[str, _models.AuthenticationName], - parameters: Union[_models.ManagedInstanceAzureADOnlyAuthentication, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ManagedInstanceAzureADOnlyAuthentication]: - """Sets Server Active Directory only authentication property or updates an existing server Active - Directory only authentication property. - - :param resource_group_name: The name of the resource group that 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 authentication_name: The name of server azure active directory only authentication. - "Default" Required. - :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName - :param parameters: The required parameters for creating or updating an Active Directory only - authentication property. Is either a ManagedInstanceAzureADOnlyAuthentication type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication or IO[bytes] - :return: An instance of LROPoller that returns either ManagedInstanceAzureADOnlyAuthentication - or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagedInstanceAzureADOnlyAuthentication] = 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, - managed_instance_name=managed_instance_name, - authentication_name=authentication_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize( - "ManagedInstanceAzureADOnlyAuthentication", pipeline_response.http_response - ) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedInstanceAzureADOnlyAuthentication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ManagedInstanceAzureADOnlyAuthentication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, - resource_group_name: str, - managed_instance_name: str, - authentication_name: Union[str, _models.AuthenticationName], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - authentication_name=authentication_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, - resource_group_name: str, - managed_instance_name: str, - authentication_name: Union[str, _models.AuthenticationName], - **kwargs: Any - ) -> LROPoller[None]: - """Deletes an existing server Active Directory only authentication property. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 authentication_name: The name of server azure active directory only authentication. - "Default" Required. - :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - authentication_name=authentication_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_by_instance( - self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either ManagedInstanceAzureADOnlyAuthentication or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceAzureADOnlyAuthListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 5a40ec37715f..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_dtcs_operations.py +++ /dev/null @@ -1,504 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_managed_instance_request( - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dtc", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - managed_instance_name: str, - dtc_name: Union[str, _models.DtcName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dtc/{dtcName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "dtcName": _SERIALIZER.url("dtc_name", dtc_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - managed_instance_name: str, - dtc_name: Union[str, _models.DtcName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dtc/{dtcName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "dtcName": _SERIALIZER.url("dtc_name", dtc_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -class ManagedInstanceDtcsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_instance_dtcs` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.ManagedInstanceDtc"]: - """Gets a list of managed instance DTC settings. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :return: An iterator like instance of either ManagedInstanceDtc or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceDtc] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - cls: ClsType[_models.ManagedInstanceDtcListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedInstanceDtcListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, managed_instance_name: str, dtc_name: Union[str, _models.DtcName], **kwargs: Any - ) -> _models.ManagedInstanceDtc: - """Gets managed instance DTC settings. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param dtc_name: The name of the managed instance DTC. "current" Required. - :type dtc_name: str or ~azure.mgmt.sql.models.DtcName - :return: ManagedInstanceDtc or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstanceDtc - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-05-01-preview")) - cls: ClsType[_models.ManagedInstanceDtc] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - dtc_name=dtc_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedInstanceDtc", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - dtc_name: Union[str, _models.DtcName], - parameters: Union[_models.ManagedInstanceDtc, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2022-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ManagedInstanceDtc") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - dtc_name=dtc_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - dtc_name: Union[str, _models.DtcName], - parameters: _models.ManagedInstanceDtc, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedInstanceDtc]: - """Updates managed instance DTC settings. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param dtc_name: The name of the managed instance DTC. "current" Required. - :type dtc_name: str or ~azure.mgmt.sql.models.DtcName - :param parameters: Managed instance DTC settings. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceDtc - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedInstanceDtc or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceDtc] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - dtc_name: Union[str, _models.DtcName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedInstanceDtc]: - """Updates managed instance DTC settings. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param dtc_name: The name of the managed instance DTC. "current" Required. - :type dtc_name: str or ~azure.mgmt.sql.models.DtcName - :param parameters: Managed instance DTC settings. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedInstanceDtc or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceDtc] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - dtc_name: Union[str, _models.DtcName], - parameters: Union[_models.ManagedInstanceDtc, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ManagedInstanceDtc]: - """Updates managed instance DTC settings. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param dtc_name: The name of the managed instance DTC. "current" Required. - :type dtc_name: str or ~azure.mgmt.sql.models.DtcName - :param parameters: Managed instance DTC settings. Is either a ManagedInstanceDtc type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceDtc or IO[bytes] - :return: An instance of LROPoller that returns either ManagedInstanceDtc or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceDtc] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - 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) - 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, - managed_instance_name=managed_instance_name, - dtc_name=dtc_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedInstanceDtc", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedInstanceDtc].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ManagedInstanceDtc]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 68aa47e4da5c..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_encryption_protectors_operations.py +++ /dev/null @@ -1,664 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}/revalidate", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "encryptionProtectorName": _SERIALIZER.url("encryption_protector_name", encryption_protector_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_list_by_instance_request( - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - managed_instance_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "encryptionProtectorName": _SERIALIZER.url("encryption_protector_name", encryption_protector_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - managed_instance_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "encryptionProtectorName": _SERIALIZER.url("encryption_protector_name", encryption_protector_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -class ManagedInstanceEncryptionProtectorsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_instance_encryption_protectors` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - def _revalidate_initial( - self, - resource_group_name: str, - managed_instance_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._revalidate_initial( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_by_instance( - self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> ItemPaged["_models.ManagedInstanceEncryptionProtector"]: - """Gets a list of managed instance encryption protectors. - - :param resource_group_name: The name of the resource group that 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 - :return: An iterator like instance of either ManagedInstanceEncryptionProtector or the result - of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceEncryptionProtectorListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedInstanceEncryptionProtectorListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - managed_instance_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - **kwargs: Any - ) -> _models.ManagedInstanceEncryptionProtector: - """Gets a managed instance encryption protector. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 retrieved. - "current" Required. - :type encryption_protector_name: str or ~azure.mgmt.sql.models.EncryptionProtectorName - :return: ManagedInstanceEncryptionProtector or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceEncryptionProtector] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - encryption_protector_name=encryption_protector_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedInstanceEncryptionProtector", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - parameters: Union[_models.ManagedInstanceEncryptionProtector, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ManagedInstanceEncryptionProtector") - - _request = build_create_or_update_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - parameters: _models.ManagedInstanceEncryptionProtector, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedInstanceEncryptionProtector]: - """Updates an existing encryption protector. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param parameters: The requested encryption protector resource state. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedInstanceEncryptionProtector or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedInstanceEncryptionProtector]: - """Updates an existing encryption protector. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param parameters: The requested encryption protector resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedInstanceEncryptionProtector or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - parameters: Union[_models.ManagedInstanceEncryptionProtector, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ManagedInstanceEncryptionProtector]: - """Updates an existing encryption protector. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param parameters: The requested encryption protector resource state. Is either a - ManagedInstanceEncryptionProtector type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector or IO[bytes] - :return: An instance of LROPoller that returns either ManagedInstanceEncryptionProtector or the - result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagedInstanceEncryptionProtector] = 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, - managed_instance_name=managed_instance_name, - encryption_protector_name=encryption_protector_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedInstanceEncryptionProtector", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedInstanceEncryptionProtector].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ManagedInstanceEncryptionProtector]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_keys_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_keys_operations.py deleted file mode 100644 index 202cc4891d6d..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_keys_operations.py +++ /dev/null @@ -1,645 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_instance_request( - resource_group_name: str, - managed_instance_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/keys", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, managed_instance_name: str, key_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/keys/{keyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "keyName": _SERIALIZER.url("key_name", key_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, managed_instance_name: str, key_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/keys/{keyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "keyName": _SERIALIZER.url("key_name", key_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, managed_instance_name: str, key_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/keys/{keyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "keyName": _SERIALIZER.url("key_name", key_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -class ManagedInstanceKeysOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_instance_keys` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, filter: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_models.ManagedInstanceKey"]: - """Gets a list of managed instance keys. - - :param resource_group_name: The name of the resource group that 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 filter: An OData filter expression that filters elements in the collection. Default - value is None. - :type filter: str - :return: An iterator like instance of either ManagedInstanceKey or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceKey] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceKeyListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedInstanceKeyListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, managed_instance_name: str, key_name: str, **kwargs: Any - ) -> _models.ManagedInstanceKey: - """Gets a managed instance key. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 key_name: The name of the managed instance key to be retrieved. Required. - :type key_name: str - :return: ManagedInstanceKey or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstanceKey - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceKey] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - key_name=key_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedInstanceKey", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - key_name: str, - parameters: Union[_models.ManagedInstanceKey, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ManagedInstanceKey") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - key_name=key_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - key_name: str, - parameters: _models.ManagedInstanceKey, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedInstanceKey]: - """Creates or updates a managed instance key. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 key_name: The name of the managed instance key to be operated on (updated or created). - Required. - :type key_name: str - :param parameters: The requested managed instance key resource state. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceKey - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedInstanceKey or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceKey] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - key_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedInstanceKey]: - """Creates or updates a managed instance key. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 key_name: The name of the managed instance key to be operated on (updated or created). - Required. - :type key_name: str - :param parameters: The requested managed instance key resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedInstanceKey or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceKey] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - key_name: str, - parameters: Union[_models.ManagedInstanceKey, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ManagedInstanceKey]: - """Creates or updates a managed instance key. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 key_name: The name of the managed instance key to be operated on (updated or created). - Required. - :type key_name: str - :param parameters: The requested managed instance key resource state. Is either a - ManagedInstanceKey type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceKey or IO[bytes] - :return: An instance of LROPoller that returns either ManagedInstanceKey or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceKey] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagedInstanceKey] = 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, - managed_instance_name=managed_instance_name, - key_name=key_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedInstanceKey", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedInstanceKey].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ManagedInstanceKey]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, managed_instance_name: str, key_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - key_name=key_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, managed_instance_name: str, key_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes the managed instance key with the given name. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 key_name: The name of the managed instance key to be deleted. Required. - :type key_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - key_name=key_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_long_term_retention_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_long_term_retention_policies_operations.py deleted file mode 100644 index 674cbe4af1f7..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_long_term_retention_policies_operations.py +++ /dev/null @@ -1,537 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - policy_name: Union[str, _models.ManagedInstanceLongTermRetentionPolicyName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "policyName": _SERIALIZER.url("policy_name", policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - policy_name: Union[str, _models.ManagedInstanceLongTermRetentionPolicyName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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}/backupLongTermRetentionPolicies/{policyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "policyName": _SERIALIZER.url("policy_name", policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ManagedInstanceLongTermRetentionPoliciesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_instance_long_term_retention_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - policy_name: Union[str, _models.ManagedInstanceLongTermRetentionPolicyName], - **kwargs: Any - ) -> _models.ManagedInstanceLongTermRetentionPolicy: - """Gets a managed database's long term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy_name: The policy name. Should always be Default. "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicyName - :return: ManagedInstanceLongTermRetentionPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceLongTermRetentionPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - policy_name=policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedInstanceLongTermRetentionPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - policy_name: Union[str, _models.ManagedInstanceLongTermRetentionPolicyName], - parameters: Union[_models.ManagedInstanceLongTermRetentionPolicy, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ManagedInstanceLongTermRetentionPolicy") - - _request = build_create_or_update_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - policy_name: Union[str, _models.ManagedInstanceLongTermRetentionPolicyName], - parameters: _models.ManagedInstanceLongTermRetentionPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedInstanceLongTermRetentionPolicy]: - """Sets a managed database's long term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy_name: The policy name. Should always be Default. "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicyName - :param parameters: The long term retention policy info. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedInstanceLongTermRetentionPolicy or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - policy_name: Union[str, _models.ManagedInstanceLongTermRetentionPolicyName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedInstanceLongTermRetentionPolicy]: - """Sets a managed database's long term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy_name: The policy name. Should always be Default. "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicyName - :param parameters: The long term retention policy info. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedInstanceLongTermRetentionPolicy or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - policy_name: Union[str, _models.ManagedInstanceLongTermRetentionPolicyName], - parameters: Union[_models.ManagedInstanceLongTermRetentionPolicy, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ManagedInstanceLongTermRetentionPolicy]: - """Sets a managed database's long term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 policy_name: The policy name. Should always be Default. "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicyName - :param parameters: The long term retention policy info. Is either a - ManagedInstanceLongTermRetentionPolicy type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy or IO[bytes] - :return: An instance of LROPoller that returns either ManagedInstanceLongTermRetentionPolicy or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.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._create_or_update_initial( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - policy_name=policy_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedInstanceLongTermRetentionPolicy", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedInstanceLongTermRetentionPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ManagedInstanceLongTermRetentionPolicy]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_by_database( - self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :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", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceLongTermRetentionPolicyListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index fcb536c8d588..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_operations_operations.py +++ /dev/null @@ -1,335 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_managed_instance_request( - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/operations", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, managed_instance_name: str, operation_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/operations/{operationId}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cancel_request( - resource_group_name: str, managed_instance_name: str, operation_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/operations/{operationId}/cancel", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -class ManagedInstanceOperationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_instance_operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.ManagedInstanceOperation"]: - """Gets a list of operations performed on the managed instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :return: An iterator like instance of either ManagedInstanceOperation or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceOperation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceOperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedInstanceOperationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, managed_instance_name: str, operation_id: str, **kwargs: Any - ) -> _models.ManagedInstanceOperation: - """Gets a management operation on a managed instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 operation_id: Required. - :type operation_id: str - :return: ManagedInstanceOperation or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstanceOperation - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceOperation] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - operation_id=operation_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedInstanceOperation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def cancel( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, managed_instance_name: str, operation_id: str, **kwargs: Any - ) -> None: - """Cancels the asynchronous operation on the managed instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 operation_id: Required. - :type operation_id: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_cancel_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - operation_id=operation_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_private_endpoint_connections_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_private_endpoint_connections_operations.py deleted file mode 100644 index ab293b5e777e..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_private_endpoint_connections_operations.py +++ /dev/null @@ -1,656 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - managed_instance_name: str, - private_endpoint_connection_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", private_endpoint_connection_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - managed_instance_name: str, - private_endpoint_connection_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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}/privateEndpointConnections/{privateEndpointConnectionName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", private_endpoint_connection_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - managed_instance_name: str, - private_endpoint_connection_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", private_endpoint_connection_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_list_by_managed_instance_request( - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ManagedInstancePrivateEndpointConnectionsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_instance_private_endpoint_connections` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, resource_group_name: str, managed_instance_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> _models.ManagedInstancePrivateEndpointConnection: - """Gets a private endpoint connection. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :return: ManagedInstancePrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstancePrivateEndpointConnection] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedInstancePrivateEndpointConnection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - private_endpoint_connection_name: str, - parameters: Union[_models.ManagedInstancePrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ManagedInstancePrivateEndpointConnection") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - private_endpoint_connection_name: str, - parameters: _models.ManagedInstancePrivateEndpointConnection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedInstancePrivateEndpointConnection]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 private_endpoint_connection_name: Required. - :type private_endpoint_connection_name: str - :param parameters: Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedInstancePrivateEndpointConnection - or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - private_endpoint_connection_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedInstancePrivateEndpointConnection]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 private_endpoint_connection_name: Required. - :type private_endpoint_connection_name: str - :param parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedInstancePrivateEndpointConnection - or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - private_endpoint_connection_name: str, - parameters: Union[_models.ManagedInstancePrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ManagedInstancePrivateEndpointConnection]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 private_endpoint_connection_name: Required. - :type private_endpoint_connection_name: str - :param parameters: Is either a ManagedInstancePrivateEndpointConnection type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection or IO[bytes] - :return: An instance of LROPoller that returns either ManagedInstancePrivateEndpointConnection - or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagedInstancePrivateEndpointConnection] = 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, - managed_instance_name=managed_instance_name, - private_endpoint_connection_name=private_endpoint_connection_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize( - "ManagedInstancePrivateEndpointConnection", pipeline_response.http_response - ) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedInstancePrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ManagedInstancePrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, managed_instance_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, managed_instance_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 private_endpoint_connection_name: Required. - :type private_endpoint_connection_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - private_endpoint_connection_name=private_endpoint_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_by_managed_instance( - self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either ManagedInstancePrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstancePrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 0e3e343e6dc2..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_private_link_resources_operations.py +++ /dev/null @@ -1,253 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_managed_instance_request( - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateLinkResources", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, managed_instance_name: str, group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateLinkResources/{groupName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "groupName": _SERIALIZER.url("group_name", group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ManagedInstancePrivateLinkResourcesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_instance_private_link_resources` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.ManagedInstancePrivateLink"]: - """Gets the private link resources for SQL 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 - :return: An iterator like instance of either ManagedInstancePrivateLink or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstancePrivateLink] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstancePrivateLinkListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedInstancePrivateLinkListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, managed_instance_name: str, group_name: str, **kwargs: Any - ) -> _models.ManagedInstancePrivateLink: - """Gets a private link resource for SQL server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 group_name: The name of the private link resource. Required. - :type group_name: str - :return: ManagedInstancePrivateLink or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstancePrivateLink - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstancePrivateLink] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - group_name=group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedInstancePrivateLink", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_tde_certificates_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_tde_certificates_operations.py deleted file mode 100644 index f0463165439e..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_tde_certificates_operations.py +++ /dev/null @@ -1,277 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_request( - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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}/tdeCertificates", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class ManagedInstanceTdeCertificatesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_instance_tde_certificates` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - def _create_initial( - self, - resource_group_name: str, - managed_instance_name: str, - parameters: Union[_models.TdeCertificate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "TdeCertificate") - - _request = build_create_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create( - self, - resource_group_name: str, - managed_instance_name: str, - parameters: _models.TdeCertificate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Creates a TDE certificate for a given server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 parameters: The requested TDE certificate to be created or updated. Required. - :type parameters: ~azure.mgmt.sql.models.TdeCertificate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - managed_instance_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Creates a TDE certificate for a given server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 parameters: The requested TDE certificate to be created or updated. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @distributed_trace - def begin_create( - self, - resource_group_name: str, - managed_instance_name: str, - parameters: Union[_models.TdeCertificate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[None]: - """Creates a TDE certificate for a given server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 parameters: The requested TDE certificate to be created or updated. Is either a - TdeCertificate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.TdeCertificate or IO[bytes] - :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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[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._create_initial( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_vulnerability_assessments_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_vulnerability_assessments_operations.py deleted file mode 100644 index a8955c1c33c8..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_vulnerability_assessments_operations.py +++ /dev/null @@ -1,555 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - managed_instance_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - managed_instance_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - managed_instance_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_list_by_instance_request( - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/vulnerabilityAssessments", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ManagedInstanceVulnerabilityAssessmentsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_instance_vulnerability_assessments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, - resource_group_name: str, - managed_instance_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **kwargs: Any - ) -> _models.ManagedInstanceVulnerabilityAssessment: - """Gets the managed instance's vulnerability assessment. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - assessment is defined. Required. - :type managed_instance_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 - :return: ManagedInstanceVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceVulnerabilityAssessment] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedInstanceVulnerabilityAssessment", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: _models.ManagedInstanceVulnerabilityAssessment, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ManagedInstanceVulnerabilityAssessment: - """Creates or updates the managed instance's vulnerability assessment. Learn more about setting - SQL vulnerability assessment with managed identity - - https://docs.microsoft.com/azure/azure-sql/database/sql-database-vulnerability-assessment-storage. - - :param resource_group_name: The name of the resource group that 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 - assessment is defined. Required. - :type managed_instance_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 parameters: The requested resource. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ManagedInstanceVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ManagedInstanceVulnerabilityAssessment: - """Creates or updates the managed instance's vulnerability assessment. Learn more about setting - SQL vulnerability assessment with managed identity - - https://docs.microsoft.com/azure/azure-sql/database/sql-database-vulnerability-assessment-storage. - - :param resource_group_name: The name of the resource group that 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 - assessment is defined. Required. - :type managed_instance_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 parameters: The requested resource. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ManagedInstanceVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: Union[_models.ManagedInstanceVulnerabilityAssessment, IO[bytes]], - **kwargs: Any - ) -> _models.ManagedInstanceVulnerabilityAssessment: - """Creates or updates the managed instance's vulnerability assessment. Learn more about setting - SQL vulnerability assessment with managed identity - - https://docs.microsoft.com/azure/azure-sql/database/sql-database-vulnerability-assessment-storage. - - :param resource_group_name: The name of the resource group that 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 - assessment is defined. Required. - :type managed_instance_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 parameters: The requested resource. Is either a ManagedInstanceVulnerabilityAssessment - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment or IO[bytes] - :return: ManagedInstanceVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ManagedInstanceVulnerabilityAssessment") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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) - - deserialized = self._deserialize("ManagedInstanceVulnerabilityAssessment", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - managed_instance_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **kwargs: Any - ) -> None: - """Removes the managed instance's vulnerability assessment. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - assessment is defined. Required. - :type managed_instance_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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @distributed_trace - def list_by_instance( - self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either ManagedInstanceVulnerabilityAssessment or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 2013569b46c7..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instances_operations.py +++ /dev/null @@ -1,1894 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/managedInstances") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "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_instance_pool_request( - resource_group_name: str, - instance_pool_name: str, - subscription_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}/managedInstances", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "instancePoolName": _SERIALIZER.url("instance_pool_name", instance_pool_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "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_resource_group_request( - resource_group_name: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "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_get_request( - resource_group_name: str, - managed_instance_name: str, - subscription_id: str, - *, - expand: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "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_create_or_update_request( - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - 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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_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_delete_request( - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_update_request( - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - 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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_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_failover_request( - resource_group_name: str, - managed_instance_name: str, - subscription_id: str, - *, - replica_type: Optional[Union[str, _models.ReplicaType]] = None, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/failover", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if replica_type is not None: - _params["replicaType"] = _SERIALIZER.query("replica_type", replica_type, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_list_outbound_network_dependencies_by_managed_instance_request( # pylint: disable=name-too-long - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/outboundNetworkDependenciesEndpoints", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_refresh_status_request( - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/refreshExternalGovernanceStatus", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_start_request( - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/start", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_stop_request( - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/stop", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_managed_instance_request( - resource_group_name: str, - managed_instance_name: str, - subscription_id: str, - *, - number_of_queries: Optional[int] = None, - databases: Optional[str] = None, - start_time: Optional[str] = None, - end_time: Optional[str] = None, - interval: Optional[Union[str, _models.QueryTimeGrainType]] = None, - aggregation_function: Optional[Union[str, _models.AggregationFunctionType]] = None, - observation_metric: Optional[Union[str, _models.MetricType]] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/topqueries", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if number_of_queries is not None: - _params["numberOfQueries"] = _SERIALIZER.query("number_of_queries", number_of_queries, "int") - if databases is not None: - _params["databases"] = _SERIALIZER.query("databases", databases, "str") - if start_time is not None: - _params["startTime"] = _SERIALIZER.query("start_time", start_time, "str") - if end_time is not None: - _params["endTime"] = _SERIALIZER.query("end_time", end_time, "str") - if interval is not None: - _params["interval"] = _SERIALIZER.query("interval", interval, "str") - if aggregation_function is not None: - _params["aggregationFunction"] = _SERIALIZER.query("aggregation_function", aggregation_function, "str") - if observation_metric is not None: - _params["observationMetric"] = _SERIALIZER.query("observation_metric", observation_metric, "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 ManagedInstancesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_instances` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, expand: Optional[str] = None, **kwargs: Any) -> ItemPaged["_models.ManagedInstance"]: - """Gets a list of all managed instances in the subscription. - - :param expand: The child resources to include in the response. Default value is None. - :type expand: str - :return: An iterator like instance of either ManagedInstance or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - cls: ClsType[_models.ManagedInstanceListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedInstanceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_instance_pool( - self, resource_group_name: str, instance_pool_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_models.ManagedInstance"]: - """Gets a list of all managed instances in an instance pool. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param instance_pool_name: The instance pool name. Required. - :type instance_pool_name: str - :param expand: The child resources to include in the response. Default value is None. - :type expand: str - :return: An iterator like instance of either ManagedInstance or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - cls: ClsType[_models.ManagedInstanceListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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_pool_request( - resource_group_name=resource_group_name, - instance_pool_name=instance_pool_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedInstanceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_models.ManagedInstance"]: - """Gets a list of managed instances in a resource group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param expand: The child resources to include in the response. Default value is None. - :type expand: str - :return: An iterator like instance of either ManagedInstance or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - cls: ClsType[_models.ManagedInstanceListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedInstanceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, managed_instance_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> _models.ManagedInstance: - """Gets a managed instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 expand: The child resources to include in the response. Default value is None. - :type expand: str - :return: ManagedInstance or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedInstance - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[_models.ManagedInstance] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedInstance", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - parameters: Union[_models.ManagedInstance, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ManagedInstance") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - parameters: _models.ManagedInstance, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedInstance]: - """Creates or updates a managed instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 parameters: The requested managed instance resource state. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstance - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedInstance]: - """Creates or updates a managed instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 parameters: The requested managed instance resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - parameters: Union[_models.ManagedInstance, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ManagedInstance]: - """Creates or updates a managed instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 parameters: The requested managed instance resource state. Is either a ManagedInstance - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstance or IO[bytes] - :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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - 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._create_or_update_initial( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedInstance", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedInstance].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ManagedInstance]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial(self, resource_group_name: str, managed_instance_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete(self, resource_group_name: str, managed_instance_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes a managed instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :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", "2023-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_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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - parameters: Union[_models.ManagedInstanceUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ManagedInstanceUpdate") - - _request = build_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - managed_instance_name: str, - parameters: _models.ManagedInstanceUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedInstance]: - """Updates a managed instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 parameters: The requested managed instance resource state. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - managed_instance_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedInstance]: - """Updates a managed instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 parameters: The requested managed instance resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - managed_instance_name: str, - parameters: Union[_models.ManagedInstanceUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ManagedInstance]: - """Updates a managed instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 parameters: The requested managed instance resource state. Is either a - ManagedInstanceUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedInstanceUpdate or IO[bytes] - :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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - 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._update_initial( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedInstance", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedInstance].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ManagedInstance]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _failover_initial( - self, - resource_group_name: str, - managed_instance_name: str, - replica_type: Optional[Union[str, _models.ReplicaType]] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_failover_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - subscription_id=self._config.subscription_id, - replica_type=replica_type, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_failover( - self, - resource_group_name: str, - managed_instance_name: str, - replica_type: Optional[Union[str, _models.ReplicaType]] = None, - **kwargs: Any - ) -> LROPoller[None]: - """Failovers a managed instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 to failover. Required. - :type managed_instance_name: str - :param replica_type: The type of replica to be failed over. Known values are: "Primary" and - "ReadableSecondary". Default value is None. - :type replica_type: str or ~azure.mgmt.sql.models.ReplicaType - :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", "2023-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._failover_initial( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - replica_type=replica_type, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_outbound_network_dependencies_by_managed_instance( # pylint: disable=name-too-long - self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> ItemPaged["_models.OutboundEnvironmentEndpoint"]: - """Gets the collection of outbound network dependencies for the given managed instance. - - :param resource_group_name: The name of the resource group that 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 - :return: An iterator like instance of either OutboundEnvironmentEndpoint or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.OutboundEnvironmentEndpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - cls: ClsType[_models.OutboundEnvironmentEndpointCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_outbound_network_dependencies_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("OutboundEnvironmentEndpointCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _refresh_status_initial( - self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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", "2023-05-01-preview")) - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize( - "RefreshExternalGovernanceStatusOperationResultMI", pipeline_response.http_response - ) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.RefreshExternalGovernanceStatusOperationResultMI].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.RefreshExternalGovernanceStatusOperationResultMI]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _start_initial(self, resource_group_name: str, managed_instance_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_start_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - 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 - 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 - :return: An instance of LROPoller that returns either ManagedInstance or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - 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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedInstance", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedInstance].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ManagedInstance]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _stop_initial(self, resource_group_name: str, managed_instance_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_stop_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - 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 - 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 - :return: An instance of LROPoller that returns either ManagedInstance or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - 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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedInstance", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedInstance].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ManagedInstance]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_by_managed_instance( - self, - resource_group_name: str, - managed_instance_name: str, - number_of_queries: Optional[int] = None, - databases: Optional[str] = None, - start_time: Optional[str] = None, - end_time: Optional[str] = None, - interval: Optional[Union[str, _models.QueryTimeGrainType]] = None, - aggregation_function: Optional[Union[str, _models.AggregationFunctionType]] = None, - observation_metric: Optional[Union[str, _models.MetricType]] = None, - **kwargs: Any - ) -> ItemPaged["_models.TopQueries"]: - """Get top resource consuming queries of a managed instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 number_of_queries: How many 'top queries' to return. Default is 5. Default value is - None. - :type number_of_queries: int - :param databases: Comma separated list of databases to be included into search. All DB's are - included if this parameter is not specified. Default value is None. - :type databases: str - :param start_time: Start time for observed period. Default value is None. - :type start_time: str - :param end_time: End time for observed period. Default value is None. - :type end_time: str - :param interval: The time step to be used to summarize the metric values. Default value is - PT1H. Known values are: "PT1H" and "P1D". Default value is None. - :type interval: str or ~azure.mgmt.sql.models.QueryTimeGrainType - :param aggregation_function: Aggregation function to be used, default value is 'sum'. Known - values are: "avg", "min", "max", "stdev", and "sum". Default value is None. - :type aggregation_function: str or ~azure.mgmt.sql.models.AggregationFunctionType - :param observation_metric: Metric to be used for ranking top queries. Default is 'cpu'. Known - values are: "cpu", "io", "logIo", "duration", and "dtu". Default value is None. - :type observation_metric: str or ~azure.mgmt.sql.models.MetricType - :return: An iterator like instance of either TopQueries or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.TopQueries] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - cls: ClsType[_models.TopQueriesListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - number_of_queries=number_of_queries, - databases=databases, - start_time=start_time, - end_time=end_time, - interval=interval, - aggregation_function=aggregation_function, - observation_metric=observation_metric, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("TopQueriesListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) 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 deleted file mode 100644 index 8c1fcbc1f6f8..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_ledger_digest_uploads_operations.py +++ /dev/null @@ -1,706 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_database_request( - resource_group_name: str, managed_instance_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-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}/ledgerDigestUploads", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-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}/ledgerDigestUploads/{ledgerDigestUploads}", - ) - 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"), - "ledgerDigestUploads": _SERIALIZER.url("ledger_digest_uploads", ledger_digest_uploads, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-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}/ledgerDigestUploads/{ledgerDigestUploads}", - ) - 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"), - "ledgerDigestUploads": _SERIALIZER.url("ledger_digest_uploads", ledger_digest_uploads, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_disable_request( - resource_group_name: str, - managed_instance_name: str, - database_name: str, - ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-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}/ledgerDigestUploads/{ledgerDigestUploads}/disable", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "ledgerDigestUploads": _SERIALIZER.url("ledger_digest_uploads", ledger_digest_uploads, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class ManagedLedgerDigestUploadsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_ledger_digest_uploads` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.ManagedLedgerDigestUploads"]: - """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 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 - :return: An iterator like instance of either ManagedLedgerDigestUploads or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedLedgerDigestUploads] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.ManagedLedgerDigestUploadsListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedLedgerDigestUploadsListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], - **kwargs: Any - ) -> _models.ManagedLedgerDigestUploads: - """Gets the current ledger digest upload configuration for a database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 ledger_digest_uploads: "current" Required. - :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.ManagedLedgerDigestUploadsName - :return: ManagedLedgerDigestUploads or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedLedgerDigestUploads - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - cls: ClsType[_models.ManagedLedgerDigestUploads] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - ledger_digest_uploads=ledger_digest_uploads, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedLedgerDigestUploads", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], - parameters: Union[_models.ManagedLedgerDigestUploads, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ManagedLedgerDigestUploads") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - ledger_digest_uploads=ledger_digest_uploads, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], - parameters: _models.ManagedLedgerDigestUploads, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedLedgerDigestUploads]: - """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger - instance. - - :param resource_group_name: The name of the resource group that 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 ledger_digest_uploads: The name of the Ledger Digest Upload Configurations. "current" - Required. - :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.ManagedLedgerDigestUploadsName - :param parameters: The Ledger Digest Storage Endpoint. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedLedgerDigestUploads - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedLedgerDigestUploads or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedLedgerDigestUploads] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedLedgerDigestUploads]: - """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger - instance. - - :param resource_group_name: The name of the resource group that 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 ledger_digest_uploads: The name of the Ledger Digest Upload Configurations. "current" - Required. - :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.ManagedLedgerDigestUploadsName - :param parameters: The Ledger Digest Storage Endpoint. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedLedgerDigestUploads or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedLedgerDigestUploads] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], - parameters: Union[_models.ManagedLedgerDigestUploads, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ManagedLedgerDigestUploads]: - """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger - instance. - - :param resource_group_name: The name of the resource group that 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 ledger_digest_uploads: The name of the Ledger Digest Upload Configurations. "current" - Required. - :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.ManagedLedgerDigestUploadsName - :param parameters: The Ledger Digest Storage Endpoint. Is either a ManagedLedgerDigestUploads - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedLedgerDigestUploads or IO[bytes] - :return: An instance of LROPoller that returns either ManagedLedgerDigestUploads or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedLedgerDigestUploads] - :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", "2022-08-01-preview")) - 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) - 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, - managed_instance_name=managed_instance_name, - database_name=database_name, - ledger_digest_uploads=ledger_digest_uploads, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedLedgerDigestUploads", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedLedgerDigestUploads].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ManagedLedgerDigestUploads]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _disable_initial( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_disable_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - ledger_digest_uploads=ledger_digest_uploads, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_disable( - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], - **kwargs: Any - ) -> LROPoller[_models.ManagedLedgerDigestUploads]: - """Disables uploading ledger digests to an Azure Storage account or an Azure Confidential Ledger - instance. - - :param resource_group_name: The name of the resource group that 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 ledger_digest_uploads: "current" Required. - :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.ManagedLedgerDigestUploadsName - :return: An instance of LROPoller that returns either ManagedLedgerDigestUploads or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedLedgerDigestUploads] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.ManagedLedgerDigestUploads] = 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._disable_initial( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - ledger_digest_uploads=ledger_digest_uploads, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedLedgerDigestUploads", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedLedgerDigestUploads].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ManagedLedgerDigestUploads]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_restorable_dropped_database_backup_short_term_retention_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_restorable_dropped_database_backup_short_term_retention_policies_operations.py deleted file mode 100644 index 42f82eab53d2..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_restorable_dropped_database_backup_short_term_retention_policies_operations.py +++ /dev/null @@ -1,809 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - managed_instance_name: str, - restorable_dropped_database_id: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies/{policyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "restorableDroppedDatabaseId": _SERIALIZER.url( - "restorable_dropped_database_id", restorable_dropped_database_id, "str" - ), - "policyName": _SERIALIZER.url("policy_name", policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - managed_instance_name: str, - restorable_dropped_database_id: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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/{policyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "restorableDroppedDatabaseId": _SERIALIZER.url( - "restorable_dropped_database_id", restorable_dropped_database_id, "str" - ), - "policyName": _SERIALIZER.url("policy_name", policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, - managed_instance_name: str, - restorable_dropped_database_id: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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/{policyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "restorableDroppedDatabaseId": _SERIALIZER.url( - "restorable_dropped_database_id", restorable_dropped_database_id, "str" - ), - "policyName": _SERIALIZER.url("policy_name", policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_restorable_dropped_database_request( # pylint: disable=name-too-long - resource_group_name: str, - managed_instance_name: str, - restorable_dropped_database_id: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "restorableDroppedDatabaseId": _SERIALIZER.url( - "restorable_dropped_database_id", restorable_dropped_database_id, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_restorable_dropped_database_backup_short_term_retention_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, - resource_group_name: str, - managed_instance_name: str, - restorable_dropped_database_id: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - **kwargs: Any - ) -> _models.ManagedBackupShortTermRetentionPolicy: - """Gets a dropped database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param policy_name: The policy name. "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName - :return: ManagedBackupShortTermRetentionPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedBackupShortTermRetentionPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - restorable_dropped_database_id=restorable_dropped_database_id, - policy_name=policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedBackupShortTermRetentionPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - restorable_dropped_database_id: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - parameters: Union[_models.ManagedBackupShortTermRetentionPolicy, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ManagedBackupShortTermRetentionPolicy") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - restorable_dropped_database_id=restorable_dropped_database_id, - policy_name=policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - restorable_dropped_database_id: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - parameters: _models.ManagedBackupShortTermRetentionPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedBackupShortTermRetentionPolicy]: - """Sets a database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedBackupShortTermRetentionPolicy or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - restorable_dropped_database_id: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedBackupShortTermRetentionPolicy]: - """Sets a database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedBackupShortTermRetentionPolicy or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - restorable_dropped_database_id: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - parameters: Union[_models.ManagedBackupShortTermRetentionPolicy, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ManagedBackupShortTermRetentionPolicy]: - """Sets a database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Is either a - ManagedBackupShortTermRetentionPolicy type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy or IO[bytes] - :return: An instance of LROPoller that returns either ManagedBackupShortTermRetentionPolicy or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagedBackupShortTermRetentionPolicy] = 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, - managed_instance_name=managed_instance_name, - restorable_dropped_database_id=restorable_dropped_database_id, - policy_name=policy_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedBackupShortTermRetentionPolicy", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedBackupShortTermRetentionPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ManagedBackupShortTermRetentionPolicy]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - restorable_dropped_database_id: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - parameters: Union[_models.ManagedBackupShortTermRetentionPolicy, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ManagedBackupShortTermRetentionPolicy") - - _request = build_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - restorable_dropped_database_id=restorable_dropped_database_id, - policy_name=policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - managed_instance_name: str, - restorable_dropped_database_id: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - parameters: _models.ManagedBackupShortTermRetentionPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedBackupShortTermRetentionPolicy]: - """Sets a database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedBackupShortTermRetentionPolicy or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - managed_instance_name: str, - restorable_dropped_database_id: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedBackupShortTermRetentionPolicy]: - """Sets a database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedBackupShortTermRetentionPolicy or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - managed_instance_name: str, - restorable_dropped_database_id: str, - policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], - parameters: Union[_models.ManagedBackupShortTermRetentionPolicy, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ManagedBackupShortTermRetentionPolicy]: - """Sets a database's short term retention policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param policy_name: The policy name. Should always be "default". "default" Required. - :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName - :param parameters: The short term retention policy info. Is either a - ManagedBackupShortTermRetentionPolicy type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy or IO[bytes] - :return: An instance of LROPoller that returns either ManagedBackupShortTermRetentionPolicy or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagedBackupShortTermRetentionPolicy] = 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( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - restorable_dropped_database_id=restorable_dropped_database_id, - policy_name=policy_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedBackupShortTermRetentionPolicy", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedBackupShortTermRetentionPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ManagedBackupShortTermRetentionPolicy]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_by_restorable_dropped_database( - self, resource_group_name: str, managed_instance_name: str, restorable_dropped_database_id: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either ManagedBackupShortTermRetentionPolicy or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedBackupShortTermRetentionPolicyListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 4906176a111b..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_server_dns_aliases_operations.py +++ /dev/null @@ -1,871 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_managed_instance_request( - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dnsAliases", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, managed_instance_name: str, dns_alias_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dnsAliases/{dnsAliasName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "dnsAliasName": _SERIALIZER.url("dns_alias_name", dns_alias_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, managed_instance_name: str, dns_alias_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-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}/dnsAliases/{dnsAliasName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "dnsAliasName": _SERIALIZER.url("dns_alias_name", dns_alias_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, managed_instance_name: str, dns_alias_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dnsAliases/{dnsAliasName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "dnsAliasName": _SERIALIZER.url("dns_alias_name", dns_alias_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_acquire_request( - resource_group_name: str, managed_instance_name: str, dns_alias_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-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}/dnsAliases/{dnsAliasName}/acquire", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "dnsAliasName": _SERIALIZER.url("dns_alias_name", dns_alias_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class ManagedServerDnsAliasesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_server_dns_aliases` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.ManagedServerDnsAlias"]: - """Gets a list of managed server DNS aliases for a managed 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 - :return: An iterator like instance of either ManagedServerDnsAlias or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedServerDnsAlias] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.ManagedServerDnsAliasListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedServerDnsAliasListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, managed_instance_name: str, dns_alias_name: str, **kwargs: Any - ) -> _models.ManagedServerDnsAlias: - """Gets a server DNS alias. - - :param resource_group_name: The name of the resource group that 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 dns_alias_name: Required. - :type dns_alias_name: str - :return: ManagedServerDnsAlias or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedServerDnsAlias - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.ManagedServerDnsAlias] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - dns_alias_name=dns_alias_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedServerDnsAlias", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - dns_alias_name: str, - parameters: Union[_models.ManagedServerDnsAliasCreation, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2021-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ManagedServerDnsAliasCreation") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - dns_alias_name=dns_alias_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - dns_alias_name: str, - parameters: _models.ManagedServerDnsAliasCreation, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedServerDnsAlias]: - """Creates a managed server DNS alias. - - :param resource_group_name: The name of the resource group that 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 dns_alias_name: Required. - :type dns_alias_name: str - :param parameters: Required. - :type parameters: ~azure.mgmt.sql.models.ManagedServerDnsAliasCreation - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedServerDnsAlias or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedServerDnsAlias] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - dns_alias_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedServerDnsAlias]: - """Creates a managed server DNS alias. - - :param resource_group_name: The name of the resource group that 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 dns_alias_name: Required. - :type dns_alias_name: str - :param parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedServerDnsAlias or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedServerDnsAlias] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - dns_alias_name: str, - parameters: Union[_models.ManagedServerDnsAliasCreation, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ManagedServerDnsAlias]: - """Creates a managed server DNS alias. - - :param resource_group_name: The name of the resource group that 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 dns_alias_name: Required. - :type dns_alias_name: str - :param parameters: Is either a ManagedServerDnsAliasCreation type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.sql.models.ManagedServerDnsAliasCreation or IO[bytes] - :return: An instance of LROPoller that returns either ManagedServerDnsAlias or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedServerDnsAlias] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - 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) - 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, - managed_instance_name=managed_instance_name, - dns_alias_name=dns_alias_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedServerDnsAlias", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedServerDnsAlias].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ManagedServerDnsAlias]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, managed_instance_name: str, dns_alias_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - dns_alias_name=dns_alias_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, managed_instance_name: str, dns_alias_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes the managed server DNS alias with the 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 managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param dns_alias_name: Required. - :type dns_alias_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-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( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - dns_alias_name=dns_alias_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _acquire_initial( - self, - resource_group_name: str, - managed_instance_name: str, - dns_alias_name: str, - parameters: Union[_models.ManagedServerDnsAliasAcquisition, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2021-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ManagedServerDnsAliasAcquisition") - - _request = build_acquire_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - dns_alias_name=dns_alias_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_acquire( - self, - resource_group_name: str, - managed_instance_name: str, - dns_alias_name: str, - parameters: _models.ManagedServerDnsAliasAcquisition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedServerDnsAlias]: - """Acquires managed server DNS alias from another managed 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 - :param dns_alias_name: Required. - :type dns_alias_name: str - :param parameters: Required. - :type parameters: ~azure.mgmt.sql.models.ManagedServerDnsAliasAcquisition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedServerDnsAlias or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedServerDnsAlias] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_acquire( - self, - resource_group_name: str, - managed_instance_name: str, - dns_alias_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedServerDnsAlias]: - """Acquires managed server DNS alias from another managed 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 - :param dns_alias_name: Required. - :type dns_alias_name: str - :param parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedServerDnsAlias or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedServerDnsAlias] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_acquire( - self, - resource_group_name: str, - managed_instance_name: str, - dns_alias_name: str, - parameters: Union[_models.ManagedServerDnsAliasAcquisition, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ManagedServerDnsAlias]: - """Acquires managed server DNS alias from another managed 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 - :param dns_alias_name: Required. - :type dns_alias_name: str - :param parameters: Is either a ManagedServerDnsAliasAcquisition type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.sql.models.ManagedServerDnsAliasAcquisition or IO[bytes] - :return: An instance of LROPoller that returns either ManagedServerDnsAlias or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedServerDnsAlias] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - 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) - 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._acquire_initial( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - dns_alias_name=dns_alias_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedServerDnsAlias", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedServerDnsAlias].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ManagedServerDnsAlias]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index e89f552a036a..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_server_security_alert_policies_operations.py +++ /dev/null @@ -1,509 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - managed_instance_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/securityAlertPolicies/{securityAlertPolicyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - managed_instance_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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/{securityAlertPolicyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/securityAlertPolicies", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ManagedServerSecurityAlertPoliciesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`managed_server_security_alert_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, - resource_group_name: str, - managed_instance_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - **kwargs: Any - ) -> _models.ManagedServerSecurityAlertPolicy: - """Get a managed server's threat detection policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 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 - :return: ManagedServerSecurityAlertPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedServerSecurityAlertPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - security_alert_policy_name=security_alert_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ManagedServerSecurityAlertPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - parameters: Union[_models.ManagedServerSecurityAlertPolicy, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ManagedServerSecurityAlertPolicy") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - security_alert_policy_name=security_alert_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - parameters: _models.ManagedServerSecurityAlertPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedServerSecurityAlertPolicy]: - """Creates or updates a threat detection policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 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 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. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedServerSecurityAlertPolicy or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ManagedServerSecurityAlertPolicy]: - """Creates or updates a threat detection policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 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 managed server security alert policy. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ManagedServerSecurityAlertPolicy or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - parameters: Union[_models.ManagedServerSecurityAlertPolicy, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ManagedServerSecurityAlertPolicy]: - """Creates or updates a threat detection policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 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 managed server security alert policy. Is either a - ManagedServerSecurityAlertPolicy type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy or IO[bytes] - :return: An instance of LROPoller that returns either ManagedServerSecurityAlertPolicy or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagedServerSecurityAlertPolicy] = 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, - managed_instance_name=managed_instance_name, - security_alert_policy_name=security_alert_policy_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedServerSecurityAlertPolicy", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ManagedServerSecurityAlertPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ManagedServerSecurityAlertPolicy]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_by_instance( - self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either ManagedServerSecurityAlertPolicy or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedServerSecurityAlertPolicyListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 0f3453ef5710..eb0aefeb63d6 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 @@ -1,12 +1,17 @@ +# pylint: disable=line-too-long,useless-suppression,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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar +import datetime +from io import IOBase +import json +from typing import Any, Callable, IO, Iterator, Literal, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core import PipelineClient from azure.core.exceptions import ( @@ -15,36 +20,43 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest, HttpResponse 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 .._configuration import SqlManagementClientConfiguration +from .._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize from .._utils.serialization import Deserializer, Serializer +from .._validation import api_version_validation T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] +JSON = MutableMapping[str, Any] List = list _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request(**kwargs: Any) -> HttpRequest: +def build_operations_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Sql/operations") + _url = "/providers/Microsoft.Sql/operations" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -55,6 +67,18086 @@ def build_list_request(**kwargs: Any) -> HttpRequest: return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) +def build_backup_short_term_retention_policies_get_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.ShortTermRetentionPolicyName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}" + 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"), + "policyName": _SERIALIZER.url("policy_name", policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_backup_short_term_retention_policies_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}" + 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"), + "policyName": _SERIALIZER.url("policy_name", policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_backup_short_term_retention_policies_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}" + 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"), + "policyName": _SERIALIZER.url("policy_name", policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_backup_short_term_retention_policies_list_by_database_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_columns_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}" + 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"), + "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), + "tableName": _SERIALIZER.url("table_name", table_name, "str"), + "columnName": _SERIALIZER.url("column_name", column_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_columns_list_by_table_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns" + 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"), + "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), + "tableName": _SERIALIZER.url("table_name", table_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _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_database_columns_list_by_database_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + *, + schema: Optional[List[str]] = None, + table: Optional[List[str]] = None, + column: Optional[List[str]] = None, + order_by: Optional[List[str]] = None, + skiptoken: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/columns" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if schema is not None: + _params["schema"] = [_SERIALIZER.query("schema", q, "str") if q is not None else "" for q in schema] + if table is not None: + _params["table"] = [_SERIALIZER.query("table", q, "str") if q is not None else "" for q in table] + if column is not None: + _params["column"] = [_SERIALIZER.query("column", q, "str") if q is not None else "" for q in column] + if order_by is not None: + _params["orderBy"] = [_SERIALIZER.query("order_by", q, "str") if q is not None else "" for q in order_by] + if skiptoken is not None: + _params["$skiptoken"] = _SERIALIZER.query("skiptoken", skiptoken, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_restore_points_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + restore_point_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/restorePoints/{restorePointName}" + 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"), + "restorePointName": _SERIALIZER.url("restore_point_name", restore_point_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_restore_points_delete_request( + resource_group_name: str, + server_name: str, + database_name: str, + restore_point_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/restorePoints/{restorePointName}" + 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"), + "restorePointName": _SERIALIZER.url("restore_point_name", restore_point_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_restore_points_list_by_database_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/restorePoints" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_restore_points_create_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/restorePoints" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sensitivity_labels_list_current_by_database_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + *, + skip_token: Optional[str] = None, + count: Optional[bool] = None, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/currentSensitivityLabels" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + 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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sensitivity_labels_update_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/currentSensitivityLabels" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + 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_sensitivity_labels_list_recommended_by_database_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + *, + skip_token: Optional[str] = None, + include_disabled_recommendations: Optional[bool] = None, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/recommendedSensitivityLabels" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + 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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sensitivity_labels_list_by_database_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/sensitivityLabels" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _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_sensitivity_labels_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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}" + 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"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sensitivity_labels_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _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") + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}" + 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"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sensitivity_labels_delete_request( + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _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", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}" + 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"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_sensitivity_labels_disable_recommendation_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _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", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/disable" + 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"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_sensitivity_labels_enable_recommendation_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _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", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/enable" + 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"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_databases_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + *, + expand: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + if filter is not None: + _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_databases_create_or_update_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_databases_update_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_databases_delete_request( + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_databases_list_by_server_request( + resource_group_name: str, + server_name: str, + subscription_id: str, + *, + top: Optional[int] = None, + skip: Optional[int] = None, + filter: Optional[str] = None, + orderby: 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if orderby is not None: + _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_databases_export_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/export" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_databases_failover_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + *, + replica_type: Optional[Union[str, _models.ReplicaType]] = None, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/failover" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if replica_type is not None: + _params["replicaType"] = _SERIALIZER.query("replica_type", replica_type, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_databases_import_method_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/import" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_databases_rename_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/move" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_databases_pause_request( + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/pause" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_databases_resume_request( + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/resume" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_databases_upgrade_data_warehouse_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/upgradeDataWarehouse" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_databases_list_inaccessible_by_server_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/inaccessibleDatabases" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_databases_list_by_elastic_pool_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, elastic_pool_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/databases" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "elasticPoolName": _SERIALIZER.url("elastic_pool_name", elastic_pool_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_firewall_rules_get_request( + resource_group_name: str, server_name: str, firewall_rule_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}" + 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"), + "firewallRuleName": _SERIALIZER.url("firewall_rule_name", firewall_rule_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_firewall_rules_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}" + 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"), + "firewallRuleName": _SERIALIZER.url("firewall_rule_name", firewall_rule_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_firewall_rules_delete_request( + resource_group_name: str, server_name: str, firewall_rule_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}" + 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"), + "firewallRuleName": _SERIALIZER.url("firewall_rule_name", firewall_rule_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_firewall_rules_list_by_server_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_firewall_rules_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_replication_links_get_request( + resource_group_name: str, server_name: str, database_name: str, link_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "linkId": _SERIALIZER.url("link_id", link_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_replication_links_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, database_name: str, link_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "linkId": _SERIALIZER.url("link_id", link_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_replication_links_update_request( + resource_group_name: str, server_name: str, database_name: str, link_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "linkId": _SERIALIZER.url("link_id", link_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_replication_links_delete_request( + resource_group_name: str, server_name: str, database_name: str, link_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "linkId": _SERIALIZER.url("link_id", link_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_replication_links_list_by_database_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_replication_links_failover_request( + resource_group_name: str, server_name: str, database_name: str, link_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/failover" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "linkId": _SERIALIZER.url("link_id", link_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_replication_links_failover_allow_data_loss_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, database_name: str, link_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/forceFailoverAllowDataLoss" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "linkId": _SERIALIZER.url("link_id", link_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_replication_links_list_by_server_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/replicationLinks" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_servers_get_request( + resource_group_name: str, server_name: str, subscription_id: str, *, expand: 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_servers_create_or_update_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_servers_update_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_servers_delete_request( + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_servers_list_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, subscription_id: str, *, expand: 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_servers_list_request(subscription_id: str, *, expand: 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/servers" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_servers_import_database_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/import" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_servers_refresh_status_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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/refreshExternalGovernanceStatus" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_servers_check_name_availability_request( # pylint: disable=name-too-long + subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/checkNameAvailability" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_blob_auditing_policies_get_request( # pylint: disable=name-too-long + 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 {}) + + blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/auditingSettings/{blobAuditingPolicyName}" + 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"), + "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_blob_auditing_policies_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/auditingSettings/{blobAuditingPolicyName}" + 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"), + "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_server_blob_auditing_policies_list_by_server_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/auditingSettings" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_blob_auditing_policies_get_request( # pylint: disable=name-too-long + 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 {}) + + blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/auditingSettings/{blobAuditingPolicyName}" + 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"), + "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_blob_auditing_policies_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/auditingSettings/{blobAuditingPolicyName}" + 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"), + "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_database_blob_auditing_policies_list_by_database_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/auditingSettings" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_extended_database_blob_auditing_policies_get_request( # pylint: disable=name-too-long + 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 {}) + + blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extendedAuditingSettings/{blobAuditingPolicyName}" + 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"), + "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_extended_database_blob_auditing_policies_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extendedAuditingSettings/{blobAuditingPolicyName}" + 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"), + "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_extended_database_blob_auditing_policies_list_by_database_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extendedAuditingSettings" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_extended_server_blob_auditing_policies_get_request( # pylint: disable=name-too-long + 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 {}) + + blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/extendedAuditingSettings/{blobAuditingPolicyName}" + 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"), + "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_extended_server_blob_auditing_policies_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/extendedAuditingSettings/{blobAuditingPolicyName}" + 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"), + "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_extended_server_blob_auditing_policies_list_by_server_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/extendedAuditingSettings" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_advisors_get_request( + resource_group_name: str, server_name: str, advisor_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advisors/{advisorName}" + 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"), + "advisorName": _SERIALIZER.url("advisor_name", advisor_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_advisors_update_request( + resource_group_name: str, server_name: str, advisor_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advisors/{advisorName}" + 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"), + "advisorName": _SERIALIZER.url("advisor_name", advisor_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_server_advisors_list_by_server_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, subscription_id: str, *, expand: 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advisors" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_columns_get_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_columns_list_by_table_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _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_managed_database_columns_list_by_database_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + database_name: str, + subscription_id: str, + *, + schema: Optional[List[str]] = None, + table: Optional[List[str]] = None, + column: Optional[List[str]] = None, + order_by: Optional[List[str]] = None, + skiptoken: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/columns" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if schema is not None: + _params["schema"] = [_SERIALIZER.query("schema", q, "str") if q is not None else "" for q in schema] + if table is not None: + _params["table"] = [_SERIALIZER.query("table", q, "str") if q is not None else "" for q in table] + if column is not None: + _params["column"] = [_SERIALIZER.query("column", q, "str") if q is not None else "" for q in column] + if order_by is not None: + _params["orderBy"] = [_SERIALIZER.query("order_by", q, "str") if q is not None else "" for q in order_by] + if skiptoken is not None: + _params["$skiptoken"] = _SERIALIZER.query("skiptoken", skiptoken, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_tables_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}" + 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"), + "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), + "tableName": _SERIALIZER.url("table_name", table_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_tables_list_by_schema_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + schema_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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables" + 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"), + "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _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_managed_database_tables_get_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_tables_list_by_schema_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _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_database_schemas_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}" + 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"), + "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_schemas_list_by_database_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _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_managed_database_schemas_get_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_schemas_list_by_database_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _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_database_security_alert_policies_get_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}" + 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"), + "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_security_alert_policies_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}" + 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"), + "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_database_security_alert_policies_list_by_database_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/securityAlertPolicies" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sql_vulnerability_assessment_baseline_get_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + subscription_id: str, + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/baselines/{baselineName}" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["systemDatabaseName"] = _SERIALIZER.query("system_database_name", system_database_name, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sql_vulnerability_assessment_baseline_list_by_sql_vulnerability_assessment_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + subscription_id: str, + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/baselines" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["systemDatabaseName"] = _SERIALIZER.query("system_database_name", system_database_name, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sql_vulnerability_assessments_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_sql_vulnerability_assessments_settings_get_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sql_vulnerability_assessments_settings_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_sql_vulnerability_assessments_settings_list_by_server_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/sqlVulnerabilityAssessments" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_sql_vulnerability_assessment_rule_baselines_get_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + rule_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/baselines/{baselineName}/rules/{ruleId}" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), + "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_sql_vulnerability_assessment_rule_baselines_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + rule_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/baselines/{baselineName}/rules/{ruleId}" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), + "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_sql_vulnerability_assessment_rule_baselines_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + rule_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/baselines/{baselineName}/rules/{ruleId}" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), + "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_database_sql_vulnerability_assessment_rule_baselines_list_by_baseline_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/baselines/{baselineName}/rules" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sql_vulnerability_assessment_rule_baseline_get_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + rule_id: str, + subscription_id: str, + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/baselines/{baselineName}/rules/{ruleId}" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), + "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["systemDatabaseName"] = _SERIALIZER.query("system_database_name", system_database_name, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sql_vulnerability_assessment_rule_baseline_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + rule_id: str, + subscription_id: str, + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/baselines/{baselineName}/rules/{ruleId}" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), + "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["systemDatabaseName"] = _SERIALIZER.query("system_database_name", system_database_name, "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_sql_vulnerability_assessment_rule_baseline_list_by_baseline_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + subscription_id: str, + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/baselines/{baselineName}/rules" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["systemDatabaseName"] = _SERIALIZER.query("system_database_name", system_database_name, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_sql_vulnerability_assessment_scan_result_get_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], + scan_id: str, + scan_result_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/scanResults/{scanResultId}" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), + "scanResultId": _SERIALIZER.url("scan_result_id", scan_result_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_sql_vulnerability_assessment_scan_result_list_by_scan_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], + scan_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/scanResults" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sql_vulnerability_assessment_scan_result_get_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], + scan_id: str, + scan_result_id: str, + subscription_id: str, + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/scanResults/{scanResultId}" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), + "scanResultId": _SERIALIZER.url("scan_result_id", scan_result_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["systemDatabaseName"] = _SERIALIZER.query("system_database_name", system_database_name, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sql_vulnerability_assessment_scan_result_list_by_scan_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], + scan_id: str, + subscription_id: str, + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/scanResults" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["systemDatabaseName"] = _SERIALIZER.query("system_database_name", system_database_name, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sql_vulnerability_assessment_scans_get_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + scan_id: str, + subscription_id: str, + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["systemDatabaseName"] = _SERIALIZER.query("system_database_name", system_database_name, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sql_vulnerability_assessment_scans_list_by_sql_vulnerability_assessments_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + subscription_id: str, + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/scans" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["systemDatabaseName"] = _SERIALIZER.query("system_database_name", system_database_name, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_vulnerability_assessment_rule_baselines_get_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + rule_id: str, + baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), + "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_vulnerability_assessment_rule_baselines_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + rule_id: str, + baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), + "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_vulnerability_assessment_rule_baselines_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + rule_id: str, + baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), + "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_managed_database_vulnerability_assessment_rule_baselines_get_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + rule_id: str, + baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), + "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_vulnerability_assessment_rule_baselines_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + rule_id: str, + baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), + "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_vulnerability_assessment_rule_baselines_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + rule_id: str, + baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), + "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_database_vulnerability_assessments_get_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_vulnerability_assessments_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_database_vulnerability_assessments_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_database_vulnerability_assessments_list_by_database_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_vulnerability_assessments_get_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_vulnerability_assessments_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_vulnerability_assessments_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_managed_database_vulnerability_assessments_list_by_database_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_vulnerability_assessment_scans_get_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + scan_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_vulnerability_assessment_scans_list_by_database_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_vulnerability_assessment_scans_export_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + scan_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/export" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_vulnerability_assessment_scans_initiate_scan_request( # pylint: disable=name-too-long + 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: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_data_masking_policies_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + data_masking_policy_name: Union[str, _models.DataMaskingPolicyName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "dataMaskingPolicyName": _SERIALIZER.url("data_masking_policy_name", data_masking_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_data_masking_policies_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "dataMaskingPolicyName": _SERIALIZER.url("data_masking_policy_name", data_masking_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_deleted_servers_get_request( + location_name: str, deleted_server_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/deletedServers/{deletedServerName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str"), + "deletedServerName": _SERIALIZER.url("deleted_server_name", deleted_server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_deleted_servers_list_by_location_request( # pylint: disable=name-too-long + location_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/deletedServers" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_deleted_servers_recover_request( + location_name: str, deleted_server_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/deletedServers/{deletedServerName}/recover" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str"), + "deletedServerName": _SERIALIZER.url("deleted_server_name", deleted_server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_deleted_servers_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/deletedServers" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_distributed_availability_groups_get_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_distributed_availability_groups_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_distributed_availability_groups_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_distributed_availability_groups_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_distributed_availability_groups_list_by_instance_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_distributed_availability_groups_failover_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName}/failover" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_distributed_availability_groups_set_role_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName}/setRole" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_databases_get_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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_databases_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_databases_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_databases_delete_request( + resource_group_name: str, managed_instance_name: str, database_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_managed_databases_list_by_instance_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_databases_cancel_move_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/cancelMove" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_databases_complete_move_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/completeMove" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_databases_complete_restore_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/completeRestore" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_databases_reevaluate_inaccessible_database_state_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/reevaluateInaccessibleDatabaseState" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_databases_start_move_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/startMove" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_databases_list_inaccessible_by_instance_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/inaccessibleManagedDatabases" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_trust_groups_get_request( + resource_group_name: str, location_name: str, server_trust_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups/{serverTrustGroupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_trust_groups_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups/{serverTrustGroupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_trust_groups_delete_request( + resource_group_name: str, location_name: str, server_trust_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups/{serverTrustGroupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_server_trust_groups_list_by_location_request( # pylint: disable=name-too-long + resource_group_name: str, location_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_trust_groups_list_by_instance_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverTrustGroups" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instances_get_request( + resource_group_name: str, + managed_instance_name: str, + subscription_id: str, + *, + expand: 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instances_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_managed_instances_update_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_managed_instances_delete_request( + resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_managed_instances_list_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, subscription_id: str, *, expand: 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instances_list_request( + subscription_id: str, *, expand: 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/managedInstances" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instances_failover_request( + resource_group_name: str, + managed_instance_name: str, + subscription_id: str, + *, + replica_type: Optional[Union[str, _models.ReplicaType]] = None, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/failover" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if replica_type is not None: + _params["replicaType"] = _SERIALIZER.query("replica_type", replica_type, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_managed_instances_list_outbound_network_dependencies_by_managed_instance_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/outboundNetworkDependenciesEndpoints" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instances_reevaluate_inaccessible_database_state_request( # pylint: disable=name-too-long + resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/reevaluateInaccessibleDatabaseState" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_managed_instances_refresh_status_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/refreshExternalGovernanceStatus" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instances_start_request( + resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/start" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instances_stop_request( + resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/stop" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instances_list_by_managed_instance_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + subscription_id: str, + *, + number_of_queries: Optional[int] = None, + databases: Optional[str] = None, + start_time: Optional[str] = None, + end_time: Optional[str] = None, + interval: Optional[Union[str, _models.QueryTimeGrainType]] = None, + aggregation_function: Optional[Union[str, _models.AggregationFunctionType]] = None, + observation_metric: Optional[Union[str, _models.MetricType]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/topqueries" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if number_of_queries is not None: + _params["numberOfQueries"] = _SERIALIZER.query("number_of_queries", number_of_queries, "int") + if databases is not None: + _params["databases"] = _SERIALIZER.query("databases", databases, "str") + if start_time is not None: + _params["startTime"] = _SERIALIZER.query("start_time", start_time, "str") + if end_time is not None: + _params["endTime"] = _SERIALIZER.query("end_time", end_time, "str") + if interval is not None: + _params["interval"] = _SERIALIZER.query("interval", interval, "str") + if aggregation_function is not None: + _params["aggregationFunction"] = _SERIALIZER.query("aggregation_function", aggregation_function, "str") + if observation_metric is not None: + _params["observationMetric"] = _SERIALIZER.query("observation_metric", observation_metric, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instances_validate_azure_key_vault_encryption_key_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/validateAzureKeyVaultEncryptionKey" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instances_list_by_instance_pool_request( # pylint: disable=name-too-long + resource_group_name: str, + instance_pool_name: str, + subscription_id: str, + *, + expand: 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}/managedInstances" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "instancePoolName": _SERIALIZER.url("instance_pool_name", instance_pool_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_elastic_pools_get_request( + resource_group_name: str, server_name: str, elastic_pool_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "elasticPoolName": _SERIALIZER.url("elastic_pool_name", elastic_pool_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_elastic_pools_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "elasticPoolName": _SERIALIZER.url("elastic_pool_name", elastic_pool_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_elastic_pools_update_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "elasticPoolName": _SERIALIZER.url("elastic_pool_name", elastic_pool_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_elastic_pools_delete_request( + resource_group_name: str, server_name: str, elastic_pool_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "elasticPoolName": _SERIALIZER.url("elastic_pool_name", elastic_pool_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_elastic_pools_list_by_server_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, subscription_id: str, *, skip: Optional[int] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_elastic_pools_failover_request( + resource_group_name: str, server_name: str, elastic_pool_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/failover" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "elasticPoolName": _SERIALIZER.url("elastic_pool_name", elastic_pool_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_encryption_protectors_get_request( + resource_group_name: str, + server_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector/{encryptionProtectorName}" + 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"), + "encryptionProtectorName": _SERIALIZER.url("encryption_protector_name", encryption_protector_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_encryption_protectors_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + server_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector/{encryptionProtectorName}" + 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"), + "encryptionProtectorName": _SERIALIZER.url("encryption_protector_name", encryption_protector_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_encryption_protectors_list_by_server_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_encryption_protectors_revalidate_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector/{encryptionProtectorName}/revalidate" + 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"), + "encryptionProtectorName": _SERIALIZER.url("encryption_protector_name", encryption_protector_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_endpoint_certificates_get_request( + resource_group_name: str, managed_instance_name: str, endpoint_type: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/endpointCertificates/{endpointType}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "endpointType": _SERIALIZER.url("endpoint_type", endpoint_type, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_endpoint_certificates_list_by_instance_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/endpointCertificates" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_failover_groups_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: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}" + 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"), + "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_failover_groups_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}" + 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"), + "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_failover_groups_update_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}" + 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"), + "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_failover_groups_delete_request( + resource_group_name: str, server_name: str, failover_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}" + 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"), + "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_failover_groups_list_by_server_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_failover_groups_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: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/failover" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_failover_groups_force_failover_allow_data_loss_request( # pylint: disable=name-too-long + 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: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/forceFailoverAllowDataLoss" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_failover_groups_try_planned_before_forced_failover_request( # pylint: disable=name-too-long + 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: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/tryPlannedBeforeForcedFailover" + 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"), + "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_geo_backup_policies_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + geo_backup_policy_name: Union[str, _models.GeoBackupPolicyName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies/{geoBackupPolicyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "geoBackupPolicyName": _SERIALIZER.url("geo_backup_policy_name", geo_backup_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_geo_backup_policies_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies/{geoBackupPolicyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "geoBackupPolicyName": _SERIALIZER.url("geo_backup_policy_name", geo_backup_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_geo_backup_policies_list_request( + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_instance_failover_groups_get_request( # pylint: disable=name-too-long + resource_group_name: str, location_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: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str"), + "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_instance_failover_groups_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, location_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str"), + "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_instance_failover_groups_delete_request( # pylint: disable=name-too-long + resource_group_name: str, location_name: str, failover_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str"), + "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_instance_failover_groups_list_by_location_request( # pylint: disable=name-too-long + resource_group_name: str, location_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_instance_failover_groups_failover_request( # pylint: disable=name-too-long + resource_group_name: str, location_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: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}/failover" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str"), + "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_instance_failover_groups_force_failover_allow_data_loss_request( # pylint: disable=name-too-long + resource_group_name: str, location_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: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/instanceFailoverGroups/{failoverGroupName}/forceFailoverAllowDataLoss" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str"), + "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_instance_pool_operations_get_request( # pylint: disable=name-too-long + resource_group_name: str, instance_pool_name: str, operation_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}/operations/{operationId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "instancePoolName": _SERIALIZER.url("instance_pool_name", instance_pool_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_instance_pool_operations_list_by_instance_pool_request( # pylint: disable=name-too-long + resource_group_name: str, instance_pool_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}/operations" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "instancePoolName": _SERIALIZER.url("instance_pool_name", instance_pool_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_instance_pools_get_request( + resource_group_name: str, instance_pool_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "instancePoolName": _SERIALIZER.url("instance_pool_name", instance_pool_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_instance_pools_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "instancePoolName": _SERIALIZER.url("instance_pool_name", instance_pool_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_instance_pools_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "instancePoolName": _SERIALIZER.url("instance_pool_name", instance_pool_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_instance_pools_delete_request( + resource_group_name: str, instance_pool_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "instancePoolName": _SERIALIZER.url("instance_pool_name", instance_pool_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_instance_pools_list_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_instance_pools_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/instancePools" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_ipv6_firewall_rules_get_request( + resource_group_name: str, server_name: str, firewall_rule_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/ipv6FirewallRules/{firewallRuleName}" + 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"), + "firewallRuleName": _SERIALIZER.url("firewall_rule_name", firewall_rule_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_ipv6_firewall_rules_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/ipv6FirewallRules/{firewallRuleName}" + 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"), + "firewallRuleName": _SERIALIZER.url("firewall_rule_name", firewall_rule_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_ipv6_firewall_rules_delete_request( + resource_group_name: str, server_name: str, firewall_rule_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/ipv6FirewallRules/{firewallRuleName}" + 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"), + "firewallRuleName": _SERIALIZER.url("firewall_rule_name", firewall_rule_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_ipv6_firewall_rules_list_by_server_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/ipv6FirewallRules" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_job_executions_get_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_execution_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "jobName": _SERIALIZER.url("job_name", job_name, "str"), + "jobExecutionId": _SERIALIZER.url("job_execution_id", job_execution_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_job_executions_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_execution_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "jobName": _SERIALIZER.url("job_name", job_name, "str"), + "jobExecutionId": _SERIALIZER.url("job_execution_id", job_execution_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_job_executions_cancel_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_execution_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/cancel" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "jobName": _SERIALIZER.url("job_name", job_name, "str"), + "jobExecutionId": _SERIALIZER.url("job_execution_id", job_execution_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_job_executions_list_by_job_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + subscription_id: str, + *, + create_time_min: Optional[datetime.datetime] = None, + create_time_max: Optional[datetime.datetime] = None, + end_time_min: Optional[datetime.datetime] = None, + end_time_max: Optional[datetime.datetime] = None, + is_active: Optional[bool] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "jobName": _SERIALIZER.url("job_name", job_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + 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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_job_executions_list_by_agent_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + job_agent_name: str, + subscription_id: str, + *, + create_time_min: Optional[datetime.datetime] = None, + create_time_max: Optional[datetime.datetime] = None, + end_time_min: Optional[datetime.datetime] = None, + end_time_max: Optional[datetime.datetime] = None, + is_active: Optional[bool] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/executions" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + 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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_job_executions_create_request( + resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/start" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "jobName": _SERIALIZER.url("job_name", job_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_job_agents_get_request( + resource_group_name: str, server_name: str, job_agent_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_job_agents_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, job_agent_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_job_agents_update_request( + resource_group_name: str, server_name: str, job_agent_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_job_agents_delete_request( + resource_group_name: str, server_name: str, job_agent_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_job_agents_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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_job_credentials_get_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + credential_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/credentials/{credentialName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "credentialName": _SERIALIZER.url("credential_name", credential_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_job_credentials_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + job_agent_name: str, + credential_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/credentials/{credentialName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "credentialName": _SERIALIZER.url("credential_name", credential_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_job_credentials_delete_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + credential_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/credentials/{credentialName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "credentialName": _SERIALIZER.url("credential_name", credential_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_job_credentials_list_by_agent_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, job_agent_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/credentials" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_job_step_executions_get_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_execution_id: str, + step_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps/{stepName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_job_step_executions_list_by_job_execution_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_execution_id: str, + subscription_id: str, + *, + create_time_min: Optional[datetime.datetime] = None, + create_time_max: Optional[datetime.datetime] = None, + end_time_min: Optional[datetime.datetime] = None, + end_time_max: Optional[datetime.datetime] = None, + is_active: Optional[bool] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "jobName": _SERIALIZER.url("job_name", job_name, "str"), + "jobExecutionId": _SERIALIZER.url("job_execution_id", job_execution_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + 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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_job_target_executions_get_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_execution_id: str, + step_name: str, + target_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps/{stepName}/targets/{targetId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_job_target_executions_list_by_step_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_execution_id: str, + step_name: str, + subscription_id: str, + *, + create_time_min: Optional[datetime.datetime] = None, + create_time_max: Optional[datetime.datetime] = None, + end_time_min: Optional[datetime.datetime] = None, + end_time_max: Optional[datetime.datetime] = None, + is_active: Optional[bool] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps/{stepName}/targets" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + 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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_job_target_executions_list_by_job_execution_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_execution_id: str, + subscription_id: str, + *, + create_time_min: Optional[datetime.datetime] = None, + create_time_max: Optional[datetime.datetime] = None, + end_time_min: Optional[datetime.datetime] = None, + end_time_max: Optional[datetime.datetime] = None, + is_active: Optional[bool] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/targets" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "jobName": _SERIALIZER.url("job_name", job_name, "str"), + "jobExecutionId": _SERIALIZER.url("job_execution_id", job_execution_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + 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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_jobs_get_request( + resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "jobName": _SERIALIZER.url("job_name", job_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_jobs_create_or_update_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "jobName": _SERIALIZER.url("job_name", job_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_jobs_delete_request( + resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "jobName": _SERIALIZER.url("job_name", job_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_jobs_list_by_agent_request( + resource_group_name: str, server_name: str, job_agent_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_job_private_endpoints_get_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + private_endpoint_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/privateEndpoints/{privateEndpointName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "privateEndpointName": _SERIALIZER.url("private_endpoint_name", private_endpoint_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_job_private_endpoints_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + job_agent_name: str, + private_endpoint_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/privateEndpoints/{privateEndpointName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "privateEndpointName": _SERIALIZER.url("private_endpoint_name", private_endpoint_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_job_private_endpoints_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + job_agent_name: str, + private_endpoint_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/privateEndpoints/{privateEndpointName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "privateEndpointName": _SERIALIZER.url("private_endpoint_name", private_endpoint_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_job_private_endpoints_list_by_agent_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, job_agent_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/privateEndpoints" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_job_steps_get_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + step_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps/{stepName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "jobName": _SERIALIZER.url("job_name", job_name, "str"), + "stepName": _SERIALIZER.url("step_name", step_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_job_steps_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps/{stepName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "jobName": _SERIALIZER.url("job_name", job_name, "str"), + "stepName": _SERIALIZER.url("step_name", step_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_job_steps_delete_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + step_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps/{stepName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "jobName": _SERIALIZER.url("job_name", job_name, "str"), + "stepName": _SERIALIZER.url("step_name", step_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_job_steps_list_by_job_request( + resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "jobName": _SERIALIZER.url("job_name", job_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_job_steps_get_by_version_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_version: int, + step_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions/{jobVersion}/steps/{stepName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "jobName": _SERIALIZER.url("job_name", job_name, "str"), + "jobVersion": _SERIALIZER.url("job_version", job_version, "int"), + "stepName": _SERIALIZER.url("step_name", step_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_job_steps_list_by_version_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_version: int, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions/{jobVersion}/steps" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "jobName": _SERIALIZER.url("job_name", job_name, "str"), + "jobVersion": _SERIALIZER.url("job_version", job_version, "int"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_job_target_groups_get_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + target_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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/targetGroups/{targetGroupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "targetGroupName": _SERIALIZER.url("target_group_name", target_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_job_target_groups_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + job_agent_name: str, + target_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/targetGroups/{targetGroupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "targetGroupName": _SERIALIZER.url("target_group_name", target_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_job_target_groups_delete_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + target_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/targetGroups/{targetGroupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "targetGroupName": _SERIALIZER.url("target_group_name", target_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_job_target_groups_list_by_agent_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, job_agent_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/targetGroups" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_job_versions_get_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_version: int, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions/{jobVersion}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "jobName": _SERIALIZER.url("job_name", job_name, "str"), + "jobVersion": _SERIALIZER.url("job_version", job_version, "int"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_job_versions_list_by_job_request( + resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "jobName": _SERIALIZER.url("job_name", job_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_long_term_retention_backups_get_request( # pylint: disable=name-too-long + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_long_term_retention_backups_delete_request( # pylint: disable=name-too-long + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_long_term_retention_backups_list_by_database_request( # pylint: disable=name-too-long + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + subscription_id: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "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" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + 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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_long_term_retention_backups_change_access_tier_request( # pylint: disable=name-too-long + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/changeAccessTier" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_long_term_retention_backups_copy_request( # pylint: disable=name-too-long + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_long_term_retention_backups_lock_time_based_immutability_request( # pylint: disable=name-too-long + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/lockTimeBasedImmutability" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_long_term_retention_backups_remove_legal_hold_immutability_request( # pylint: disable=name-too-long + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/removeLegalHoldImmutability" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_long_term_retention_backups_remove_time_based_immutability_request( # pylint: disable=name-too-long + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/removeTimeBasedImmutability" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_long_term_retention_backups_set_legal_hold_immutability_request( # pylint: disable=name-too-long + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/setLegalHoldImmutability" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_long_term_retention_backups_update_request( # pylint: disable=name-too-long + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_long_term_retention_backups_get_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_long_term_retention_backups_delete_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_long_term_retention_backups_list_by_resource_group_database_request( # pylint: disable=name-too-long + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + subscription_id: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + 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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_long_term_retention_backups_change_access_tier_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/changeAccessTier" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_long_term_retention_backups_copy_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_long_term_retention_backups_lock_time_based_immutability_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/lockTimeBasedImmutability" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_long_term_retention_backups_remove_legal_hold_immutability_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/removeLegalHoldImmutability" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_long_term_retention_backups_remove_time_based_immutability_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/removeTimeBasedImmutability" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_long_term_retention_backups_set_legal_hold_immutability_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/setLegalHoldImmutability" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_long_term_retention_backups_update_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_long_term_retention_backups_list_by_location_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionBackups" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + 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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_long_term_retention_backups_list_by_server_request( # pylint: disable=name-too-long + 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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionBackups" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str"), + "longTermRetentionServerName": _SERIALIZER.url( + "long_term_retention_server_name", long_term_retention_server_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + 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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_long_term_retention_backups_list_by_resource_group_location_request( # pylint: disable=name-too-long + resource_group_name: str, + location_name: str, + subscription_id: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionBackups" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + 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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_long_term_retention_backups_list_by_resource_group_server_request( # pylint: disable=name-too-long + 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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionBackups" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + 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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_long_term_retention_managed_instance_backups_get_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, + location_name: str, + managed_instance_name: str, + database_name: str, + backup_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_long_term_retention_managed_instance_backups_delete_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, + location_name: str, + managed_instance_name: str, + database_name: str, + backup_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_long_term_retention_managed_instance_backups_list_by_resource_group_database_request( # pylint: disable=name-too-long + resource_group_name: str, + location_name: str, + managed_instance_name: str, + database_name: str, + subscription_id: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + 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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_long_term_retention_managed_instance_backups_get_request( # pylint: disable=name-too-long + location_name: str, + managed_instance_name: str, + database_name: str, + backup_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_long_term_retention_managed_instance_backups_delete_request( # pylint: disable=name-too-long + location_name: str, + managed_instance_name: str, + database_name: str, + backup_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_long_term_retention_managed_instance_backups_list_by_database_request( # pylint: disable=name-too-long + location_name: str, + managed_instance_name: str, + database_name: str, + subscription_id: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + 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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_long_term_retention_managed_instance_backups_list_by_location_request( # pylint: disable=name-too-long + location_name: str, + subscription_id: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstanceBackups" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if only_latest_per_database is not None: + _params["onlyLatestPerDatabase"] = _SERIALIZER.query( + "only_latest_per_database", only_latest_per_database, "bool" + ) + if database_state is not None: + _params["databaseState"] = _SERIALIZER.query("database_state", database_state, "str") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_long_term_retention_managed_instance_backups_list_by_instance_request( # pylint: disable=name-too-long + location_name: str, + managed_instance_name: str, + subscription_id: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionManagedInstanceBackups" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + 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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_long_term_retention_managed_instance_backups_list_by_resource_group_location_request( # pylint: disable=name-too-long + resource_group_name: str, + location_name: str, + subscription_id: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstanceBackups" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if only_latest_per_database is not None: + _params["onlyLatestPerDatabase"] = _SERIALIZER.query( + "only_latest_per_database", only_latest_per_database, "bool" + ) + if database_state is not None: + _params["databaseState"] = _SERIALIZER.query("database_state", database_state, "str") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_long_term_retention_managed_instance_backups_list_by_resource_group_instance_request( # pylint: disable=name-too-long + resource_group_name: str, + location_name: str, + managed_instance_name: str, + subscription_id: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionManagedInstanceBackups" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + 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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_long_term_retention_policies_get_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.LongTermRetentionPolicyName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}" + 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"), + "policyName": _SERIALIZER.url("policy_name", policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_long_term_retention_policies_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}" + 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"), + "policyName": _SERIALIZER.url("policy_name", policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_long_term_retention_policies_list_by_database_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupLongTermRetentionPolicies" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_backup_short_term_retention_policies_get_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_backup_short_term_retention_policies_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_backup_short_term_retention_policies_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_backup_short_term_retention_policies_list_by_database_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_restorable_dropped_database_backup_short_term_retention_policies_get_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies/{policyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "restorableDroppedDatabaseId": _SERIALIZER.url( + "restorable_dropped_database_id", restorable_dropped_database_id, "str" + ), + "policyName": _SERIALIZER.url("policy_name", policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_restorable_dropped_database_backup_short_term_retention_policies_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies/{policyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "restorableDroppedDatabaseId": _SERIALIZER.url( + "restorable_dropped_database_id", restorable_dropped_database_id, "str" + ), + "policyName": _SERIALIZER.url("policy_name", policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_restorable_dropped_database_backup_short_term_retention_policies_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies/{policyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "restorableDroppedDatabaseId": _SERIALIZER.url( + "restorable_dropped_database_id", restorable_dropped_database_id, "str" + ), + "policyName": _SERIALIZER.url("policy_name", policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_restorable_dropped_database_backup_short_term_retention_policies_list_by_restorable_dropped_database_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "restorableDroppedDatabaseId": _SERIALIZER.url( + "restorable_dropped_database_id", restorable_dropped_database_id, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_security_alert_policies_get_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + database_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_security_alert_policies_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_security_alert_policies_list_by_database_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/securityAlertPolicies" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instance_administrators_get_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + administrator_name: Union[str, _models.AdministratorName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/administrators/{administratorName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "administratorName": _SERIALIZER.url("administrator_name", administrator_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instance_administrators_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/administrators/{administratorName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "administratorName": _SERIALIZER.url("administrator_name", administrator_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instance_administrators_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + administrator_name: Union[str, _models.AdministratorName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/administrators/{administratorName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "administratorName": _SERIALIZER.url("administrator_name", administrator_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_managed_instance_administrators_list_by_instance_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/administrators" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instance_azure_ad_only_authentications_get_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + authentication_name: Union[str, _models.AuthenticationName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications/{authenticationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instance_azure_ad_only_authentications_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications/{authenticationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instance_azure_ad_only_authentications_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + authentication_name: Union[str, _models.AuthenticationName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications/{authenticationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_managed_instance_azure_ad_only_authentications_list_by_instance_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instance_dtcs_get_request( + resource_group_name: str, + managed_instance_name: str, + dtc_name: Union[str, _models.DtcName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dtc/{dtcName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "dtcName": _SERIALIZER.url("dtc_name", dtc_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instance_dtcs_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + dtc_name: Union[str, _models.DtcName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dtc/{dtcName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "dtcName": _SERIALIZER.url("dtc_name", dtc_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instance_dtcs_list_by_managed_instance_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dtc" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instance_encryption_protectors_get_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instance_encryption_protectors_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instance_encryption_protectors_list_by_instance_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instance_encryption_protectors_revalidate_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}/revalidate" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_managed_instance_keys_get_request( + resource_group_name: str, managed_instance_name: str, key_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/keys/{keyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "keyName": _SERIALIZER.url("key_name", key_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instance_keys_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, managed_instance_name: str, key_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/keys/{keyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "keyName": _SERIALIZER.url("key_name", key_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instance_keys_delete_request( # pylint: disable=name-too-long + resource_group_name: str, managed_instance_name: str, key_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/keys/{keyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "keyName": _SERIALIZER.url("key_name", key_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_managed_instance_keys_list_by_instance_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/keys" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _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_managed_instance_long_term_retention_policies_get_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedInstanceLongTermRetentionPolicyName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instance_long_term_retention_policies_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instance_long_term_retention_policies_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedInstanceLongTermRetentionPolicyName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instance_long_term_retention_policies_list_by_database_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instance_operations_get_request( # pylint: disable=name-too-long + resource_group_name: str, managed_instance_name: str, operation_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/operations/{operationId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instance_operations_list_by_managed_instance_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/operations" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instance_operations_cancel_request( # pylint: disable=name-too-long + resource_group_name: str, managed_instance_name: str, operation_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/operations/{operationId}/cancel" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_managed_instance_private_endpoint_connections_get_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections/{privateEndpointConnectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instance_private_endpoint_connections_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections/{privateEndpointConnectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instance_private_endpoint_connections_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections/{privateEndpointConnectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_managed_instance_private_endpoint_connections_list_by_managed_instance_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instance_vulnerability_assessments_get_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instance_vulnerability_assessments_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instance_vulnerability_assessments_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_managed_instance_vulnerability_assessments_list_by_instance_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/vulnerabilityAssessments" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_server_dns_aliases_get_request( # pylint: disable=name-too-long + resource_group_name: str, managed_instance_name: str, dns_alias_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dnsAliases/{dnsAliasName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "dnsAliasName": _SERIALIZER.url("dns_alias_name", dns_alias_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_server_dns_aliases_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, managed_instance_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dnsAliases/{dnsAliasName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "dnsAliasName": _SERIALIZER.url("dns_alias_name", dns_alias_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_managed_server_dns_aliases_delete_request( # pylint: disable=name-too-long + resource_group_name: str, managed_instance_name: str, dns_alias_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dnsAliases/{dnsAliasName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "dnsAliasName": _SERIALIZER.url("dns_alias_name", dns_alias_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_managed_server_dns_aliases_list_by_managed_instance_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dnsAliases" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_server_dns_aliases_acquire_request( # pylint: disable=name-too-long + resource_group_name: str, managed_instance_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dnsAliases/{dnsAliasName}/acquire" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "dnsAliasName": _SERIALIZER.url("dns_alias_name", dns_alias_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_server_security_alert_policies_get_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/securityAlertPolicies/{securityAlertPolicyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_server_security_alert_policies_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/securityAlertPolicies/{securityAlertPolicyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_server_security_alert_policies_list_by_instance_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/securityAlertPolicies" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_security_perimeter_configurations_get_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/networkSecurityPerimeterConfigurations/{nspConfigName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "nspConfigName": _SERIALIZER.url("nsp_config_name", nsp_config_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_security_perimeter_configurations_list_by_server_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/networkSecurityPerimeterConfigurations" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_security_perimeter_configurations_reconcile_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/networkSecurityPerimeterConfigurations/{nspConfigName}/reconcile" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "nspConfigName": _SERIALIZER.url("nsp_config_name", nsp_config_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_outbound_firewall_rules_get_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, outbound_rule_fqdn: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/outboundFirewallRules/{outboundRuleFqdn}" + 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"), + "outboundRuleFqdn": _SERIALIZER.url("outbound_rule_fqdn", outbound_rule_fqdn, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_outbound_firewall_rules_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, outbound_rule_fqdn: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/outboundFirewallRules/{outboundRuleFqdn}" + 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"), + "outboundRuleFqdn": _SERIALIZER.url("outbound_rule_fqdn", outbound_rule_fqdn, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_outbound_firewall_rules_delete_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, outbound_rule_fqdn: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/outboundFirewallRules/{outboundRuleFqdn}" + 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"), + "outboundRuleFqdn": _SERIALIZER.url("outbound_rule_fqdn", outbound_rule_fqdn, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_outbound_firewall_rules_list_by_server_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/outboundFirewallRules" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_private_endpoint_connections_get_request( # pylint: disable=name-too-long + 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: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}" + 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"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_private_endpoint_connections_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}" + 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"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_private_endpoint_connections_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}" + 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"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_private_endpoint_connections_list_by_server_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateEndpointConnections" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_private_link_resources_get_request( + resource_group_name: str, server_name: str, 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateLinkResources/{groupName}" + 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"), + "groupName": _SERIALIZER.url("group_name", group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_private_link_resources_list_by_server_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateLinkResources" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_recoverable_databases_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + *, + expand: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/recoverableDatabases/{databaseName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + if filter is not None: + _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_recoverable_databases_list_by_server_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/recoverableDatabases" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_recoverable_managed_databases_get_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + recoverable_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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/recoverableDatabases/{recoverableDatabaseName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "recoverableDatabaseName": _SERIALIZER.url("recoverable_database_name", recoverable_database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_recoverable_managed_databases_list_by_instance_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/recoverableDatabases" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_restorable_dropped_databases_get_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + restorable_dropped_database_id: str, + subscription_id: str, + *, + expand: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}" + 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"), + "restorableDroppedDatabaseId": _SERIALIZER.url( + "restorable_dropped_database_id", restorable_dropped_database_id, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + if filter is not None: + _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_restorable_dropped_databases_list_by_server_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/restorableDroppedDatabases" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_restorable_dropped_managed_databases_get_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "restorableDroppedDatabaseId": _SERIALIZER.url( + "restorable_dropped_database_id", restorable_dropped_database_id, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_restorable_dropped_managed_databases_list_by_instance_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_azure_ad_administrators_get_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + administrator_name: Union[str, _models.AdministratorName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators/{administratorName}" + 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"), + "administratorName": _SERIALIZER.url("administrator_name", administrator_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_azure_ad_administrators_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators/{administratorName}" + 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"), + "administratorName": _SERIALIZER.url("administrator_name", administrator_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_server_azure_ad_administrators_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + administrator_name: Union[str, _models.AdministratorName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators/{administratorName}" + 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"), + "administratorName": _SERIALIZER.url("administrator_name", administrator_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_server_azure_ad_administrators_list_by_server_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_azure_ad_only_authentications_get_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + authentication_name: Union[str, _models.AuthenticationName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/azureADOnlyAuthentications/{authenticationName}" + 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"), + "authenticationName": _SERIALIZER.url("authentication_name", authentication_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_azure_ad_only_authentications_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/azureADOnlyAuthentications/{authenticationName}" + 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"), + "authenticationName": _SERIALIZER.url("authentication_name", authentication_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_server_azure_ad_only_authentications_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + authentication_name: Union[str, _models.AuthenticationName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/azureADOnlyAuthentications/{authenticationName}" + 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"), + "authenticationName": _SERIALIZER.url("authentication_name", authentication_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_server_azure_ad_only_authentications_list_by_server_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/azureADOnlyAuthentications" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_configuration_options_get_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + server_configuration_option_name: Union[str, _models.ServerConfigurationOptionName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverConfigurationOptions/{serverConfigurationOptionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "serverConfigurationOptionName": _SERIALIZER.url( + "server_configuration_option_name", server_configuration_option_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_configuration_options_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + server_configuration_option_name: Union[str, _models.ServerConfigurationOptionName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverConfigurationOptions/{serverConfigurationOptionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "serverConfigurationOptionName": _SERIALIZER.url( + "server_configuration_option_name", server_configuration_option_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_server_configuration_options_list_by_managed_instance_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverConfigurationOptions" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_connection_policies_get_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + connection_policy_name: Union[str, _models.ConnectionPolicyName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}" + 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"), + "connectionPolicyName": _SERIALIZER.url("connection_policy_name", connection_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_connection_policies_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}" + 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"), + "connectionPolicyName": _SERIALIZER.url("connection_policy_name", connection_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_server_connection_policies_list_by_server_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_dev_ops_audit_settings_get_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + dev_ops_auditing_settings_name: Union[str, _models.DevOpsAuditingSettingsName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/devOpsAuditingSettings/{devOpsAuditingSettingsName}" + 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"), + "devOpsAuditingSettingsName": _SERIALIZER.url( + "dev_ops_auditing_settings_name", dev_ops_auditing_settings_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_dev_ops_audit_settings_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + dev_ops_auditing_settings_name: Union[str, _models.DevOpsAuditingSettingsName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/devOpsAuditingSettings/{devOpsAuditingSettingsName}" + 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"), + "devOpsAuditingSettingsName": _SERIALIZER.url( + "dev_ops_auditing_settings_name", dev_ops_auditing_settings_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_server_dev_ops_audit_settings_list_by_server_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/devOpsAuditingSettings" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_dns_aliases_get_request( + resource_group_name: str, server_name: str, dns_alias_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}" + 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"), + "dnsAliasName": _SERIALIZER.url("dns_alias_name", dns_alias_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_dns_aliases_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, dns_alias_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}" + 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"), + "dnsAliasName": _SERIALIZER.url("dns_alias_name", dns_alias_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_dns_aliases_delete_request( + resource_group_name: str, server_name: str, dns_alias_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}" + 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"), + "dnsAliasName": _SERIALIZER.url("dns_alias_name", dns_alias_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_server_dns_aliases_list_by_server_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_dns_aliases_acquire_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}/acquire" + 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"), + "dnsAliasName": _SERIALIZER.url("dns_alias_name", dns_alias_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_keys_get_request( + resource_group_name: str, server_name: str, key_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys/{keyName}" + 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"), + "keyName": _SERIALIZER.url("key_name", key_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_keys_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, key_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys/{keyName}" + 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"), + "keyName": _SERIALIZER.url("key_name", key_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_server_keys_delete_request( + resource_group_name: str, server_name: str, key_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys/{keyName}" + 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"), + "keyName": _SERIALIZER.url("key_name", key_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_server_keys_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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_security_alert_policies_get_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/securityAlertPolicies/{securityAlertPolicyName}" + 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"), + "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_security_alert_policies_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + server_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/securityAlertPolicies/{securityAlertPolicyName}" + 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"), + "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_server_security_alert_policies_list_by_server_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/securityAlertPolicies" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_trust_certificates_get_request( # pylint: disable=name-too-long + resource_group_name: str, managed_instance_name: str, certificate_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverTrustCertificates/{certificateName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_trust_certificates_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, managed_instance_name: str, certificate_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverTrustCertificates/{certificateName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_server_trust_certificates_delete_request( # pylint: disable=name-too-long + resource_group_name: str, managed_instance_name: str, certificate_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverTrustCertificates/{certificateName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_server_trust_certificates_list_by_instance_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverTrustCertificates" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_vulnerability_assessments_get_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_vulnerability_assessments_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_server_vulnerability_assessments_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_server_vulnerability_assessments_list_by_server_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/vulnerabilityAssessments" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_start_stop_managed_instance_schedules_get_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + start_stop_schedule_name: Union[str, _models.StartStopScheduleName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/startStopSchedules/{startStopScheduleName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "startStopScheduleName": _SERIALIZER.url("start_stop_schedule_name", start_stop_schedule_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_start_stop_managed_instance_schedules_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + start_stop_schedule_name: Union[str, _models.StartStopScheduleName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/startStopSchedules/{startStopScheduleName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "startStopScheduleName": _SERIALIZER.url("start_stop_schedule_name", start_stop_schedule_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_start_stop_managed_instance_schedules_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + start_stop_schedule_name: Union[str, _models.StartStopScheduleName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/startStopSchedules/{startStopScheduleName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "startStopScheduleName": _SERIALIZER.url("start_stop_schedule_name", start_stop_schedule_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_start_stop_managed_instance_schedules_list_by_instance_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/startStopSchedules" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_subscription_usages_get_request( + location_name: str, usage_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/usages/{usageName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str"), + "usageName": _SERIALIZER.url("usage_name", usage_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_subscription_usages_list_by_location_request( # pylint: disable=name-too-long + location_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/usages" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sync_agents_get_request( + resource_group_name: str, server_name: str, sync_agent_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}" + 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"), + "syncAgentName": _SERIALIZER.url("sync_agent_name", sync_agent_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sync_agents_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}" + 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"), + "syncAgentName": _SERIALIZER.url("sync_agent_name", sync_agent_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_sync_agents_delete_request( + resource_group_name: str, server_name: str, sync_agent_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}" + 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"), + "syncAgentName": _SERIALIZER.url("sync_agent_name", sync_agent_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_sync_agents_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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sync_agents_generate_key_request( + resource_group_name: str, server_name: str, sync_agent_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}/generateKey" + 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"), + "syncAgentName": _SERIALIZER.url("sync_agent_name", sync_agent_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sync_agents_list_linked_databases_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, sync_agent_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}/linkedDatabases" + 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"), + "syncAgentName": _SERIALIZER.url("sync_agent_name", sync_agent_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sync_groups_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}" + 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"), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sync_groups_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}" + 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"), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_sync_groups_update_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}" + 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"), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_sync_groups_delete_request( + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}" + 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"), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_sync_groups_list_by_database_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sync_groups_cancel_sync_request( + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/cancelSync" + 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"), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_sync_groups_list_hub_schemas_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/hubSchemas" + 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"), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sync_groups_list_logs_request( + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + subscription_id: str, + *, + start_time: str, + end_time: str, + type: Union[str, _models.SyncGroupsType], + continuation_token_parameter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/logs" + 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"), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _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" + ) + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sync_groups_refresh_hub_schema_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/refreshHubSchema" + 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"), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_sync_groups_trigger_sync_request( + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/triggerSync" + 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"), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_sync_groups_list_sync_database_ids_request( # pylint: disable=name-too-long + location_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/syncDatabaseIds" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sync_members_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}" + 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"), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, "str"), + "syncMemberName": _SERIALIZER.url("sync_member_name", sync_member_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sync_members_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}" + 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"), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, "str"), + "syncMemberName": _SERIALIZER.url("sync_member_name", sync_member_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_sync_members_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}" + 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"), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, "str"), + "syncMemberName": _SERIALIZER.url("sync_member_name", sync_member_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_sync_members_delete_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: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}" + 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"), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, "str"), + "syncMemberName": _SERIALIZER.url("sync_member_name", sync_member_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_sync_members_list_by_sync_group_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers" + 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"), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sync_members_refresh_member_schema_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}/refreshSchema" + 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"), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, "str"), + "syncMemberName": _SERIALIZER.url("sync_member_name", sync_member_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_sync_members_list_member_schemas_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}/schemas" + 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"), + "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, "str"), + "syncMemberName": _SERIALIZER.url("sync_member_name", sync_member_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_time_zones_get_request( + location_name: str, time_zone_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/timeZones/{timeZoneId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str"), + "timeZoneId": _SERIALIZER.url("time_zone_id", time_zone_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_time_zones_list_by_location_request( # pylint: disable=name-too-long + location_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/timeZones" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_virtual_clusters_get_request( + resource_group_name: str, virtual_cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters/{virtualClusterName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "virtualClusterName": _SERIALIZER.url("virtual_cluster_name", virtual_cluster_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_virtual_clusters_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, virtual_cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters/{virtualClusterName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "virtualClusterName": _SERIALIZER.url("virtual_cluster_name", virtual_cluster_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_virtual_clusters_update_request( + resource_group_name: str, virtual_cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters/{virtualClusterName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "virtualClusterName": _SERIALIZER.url("virtual_cluster_name", virtual_cluster_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_virtual_clusters_delete_request( + resource_group_name: str, virtual_cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters/{virtualClusterName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "virtualClusterName": _SERIALIZER.url("virtual_cluster_name", virtual_cluster_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_virtual_clusters_list_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_virtual_clusters_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/virtualClusters" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_virtual_clusters_update_dns_servers_request( # pylint: disable=name-too-long + resource_group_name: str, virtual_cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters/{virtualClusterName}/updateManagedInstanceDnsServers" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "virtualClusterName": _SERIALIZER.url("virtual_cluster_name", virtual_cluster_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_virtual_network_rules_get_request( + resource_group_name: str, server_name: str, virtual_network_rule_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}" + 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"), + "virtualNetworkRuleName": _SERIALIZER.url("virtual_network_rule_name", virtual_network_rule_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_virtual_network_rules_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}" + 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"), + "virtualNetworkRuleName": _SERIALIZER.url("virtual_network_rule_name", virtual_network_rule_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_virtual_network_rules_delete_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, virtual_network_rule_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}" + 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"), + "virtualNetworkRuleName": _SERIALIZER.url("virtual_network_rule_name", virtual_network_rule_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_virtual_network_rules_list_by_server_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workload_classifiers_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + workload_classifier_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}" + 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"), + "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, "str"), + "workloadClassifierName": _SERIALIZER.url("workload_classifier_name", workload_classifier_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workload_classifiers_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}" + 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"), + "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, "str"), + "workloadClassifierName": _SERIALIZER.url("workload_classifier_name", workload_classifier_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_workload_classifiers_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + workload_classifier_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}" + 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"), + "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, "str"), + "workloadClassifierName": _SERIALIZER.url("workload_classifier_name", workload_classifier_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_workload_classifiers_list_by_workload_group_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers" + 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"), + "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workload_groups_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}" + 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"), + "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workload_groups_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}" + 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"), + "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_workload_groups_delete_request( + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}" + 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"), + "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_workload_groups_list_by_database_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_sensitivity_labels_get_request( # pylint: disable=name-too-long + 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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_sensitivity_labels_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_sensitivity_labels_delete_request( # pylint: disable=name-too-long + 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: + _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", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_managed_database_sensitivity_labels_disable_recommendation_request( # pylint: disable=name-too-long + 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: + _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", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/disable" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_managed_database_sensitivity_labels_enable_recommendation_request( # pylint: disable=name-too-long + 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: + _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", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/enable" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_managed_database_sensitivity_labels_list_current_by_database_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + database_name: str, + subscription_id: str, + *, + skip_token: Optional[str] = None, + count: Optional[bool] = None, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/currentSensitivityLabels" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + 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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_sensitivity_labels_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/currentSensitivityLabels" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_sensitivity_labels_list_recommended_by_database_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + database_name: str, + subscription_id: str, + *, + skip_token: Optional[str] = None, + include_disabled_recommendations: Optional[bool] = None, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/recommendedSensitivityLabels" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + 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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_sensitivity_labels_list_by_database_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/sensitivityLabels" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _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_database_encryption_protectors_revalidate_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/encryptionProtector/{encryptionProtectorName}/revalidate" + 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"), + "encryptionProtectorName": _SERIALIZER.url("encryption_protector_name", encryption_protector_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_database_encryption_protectors_revert_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/encryptionProtector/{encryptionProtectorName}/revert" + 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"), + "encryptionProtectorName": _SERIALIZER.url("encryption_protector_name", encryption_protector_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_database_operations_list_by_database_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/operations" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_operations_cancel_request( + resource_group_name: str, + server_name: str, + database_name: str, + operation_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/operations/{operationId}/cancel" + 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"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_database_usages_list_by_database_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/usages" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_recommended_sensitivity_labels_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/recommendedSensitivityLabels" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + 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_synapse_link_workspaces_list_by_database_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/linkWorkspaces" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_operations_list_by_server_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/operations" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_usages_list_by_server_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/usages" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_tde_certificates_create_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/tdeCertificates" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_advanced_threat_protection_settings_get_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}" + 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"), + "advancedThreatProtectionName": _SERIALIZER.url( + "advanced_threat_protection_name", advanced_threat_protection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_advanced_threat_protection_settings_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}" + 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"), + "advancedThreatProtectionName": _SERIALIZER.url( + "advanced_threat_protection_name", advanced_threat_protection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_database_advanced_threat_protection_settings_list_by_database_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advancedThreatProtectionSettings" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_advisors_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + advisor_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advisors/{advisorName}" + 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"), + "advisorName": _SERIALIZER.url("advisor_name", advisor_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_advisors_update_request( + resource_group_name: str, + server_name: str, + database_name: str, + advisor_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advisors/{advisorName}" + 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"), + "advisorName": _SERIALIZER.url("advisor_name", advisor_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_database_advisors_list_by_database_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + *, + expand: 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advisors" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_automatic_tuning_get_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/automaticTuning/current" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_automatic_tuning_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/automaticTuning/current" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_database_extensions_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + extension_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extensions/{extensionName}" + 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"), + "extensionName": _SERIALIZER.url("extension_name", extension_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="GET", url=_url, params=_params, **kwargs) + + +def build_database_extensions_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extensions/{extensionName}" + 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"), + "extensionName": _SERIALIZER.url("extension_name", extension_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_database_extensions_list_by_database_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extensions" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_recommended_actions_get_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + advisor_name: str, + recommended_action_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advisors/{advisorName}/recommendedActions/{recommendedActionName}" + 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"), + "advisorName": _SERIALIZER.url("advisor_name", advisor_name, "str"), + "recommendedActionName": _SERIALIZER.url("recommended_action_name", recommended_action_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_recommended_actions_update_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + advisor_name: str, + recommended_action_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advisors/{advisorName}/recommendedActions/{recommendedActionName}" + 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"), + "advisorName": _SERIALIZER.url("advisor_name", advisor_name, "str"), + "recommendedActionName": _SERIALIZER.url("recommended_action_name", recommended_action_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_database_recommended_actions_list_by_database_advisor_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + advisor_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advisors/{advisorName}/recommendedActions" + 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"), + "advisorName": _SERIALIZER.url("advisor_name", advisor_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_sql_vulnerability_assessment_baselines_get_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/baselines/{baselineName}" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_sql_vulnerability_assessment_baselines_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/baselines/{baselineName}" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_database_sql_vulnerability_assessment_baselines_list_by_sql_vulnerability_assessment_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/baselines" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sql_vulnerability_assessment_baselines_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + subscription_id: str, + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/baselines/{baselineName}" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["systemDatabaseName"] = _SERIALIZER.query("system_database_name", system_database_name, "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_database_sql_vulnerability_assessments_settings_get_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_sql_vulnerability_assessments_settings_list_by_database_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/sqlVulnerabilityAssessments" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_sql_vulnerability_assessment_execute_scan_execute_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/initiateScan" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_sql_vulnerability_assessment_execute_scan_execute_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + subscription_id: str, + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/initiateScan" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["systemDatabaseName"] = _SERIALIZER.query("system_database_name", system_database_name, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_sql_vulnerability_assessment_rule_baselines_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + rule_id: str, + subscription_id: str, + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/baselines/{baselineName}/rules/{ruleId}" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), + "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["systemDatabaseName"] = _SERIALIZER.query("system_database_name", system_database_name, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_database_sql_vulnerability_assessment_scans_get_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + scan_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_sql_vulnerability_assessment_scans_list_by_sql_vulnerability_assessments_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/scans" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_vulnerability_assessment_scans_get_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + scan_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_vulnerability_assessment_scans_list_by_database_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_vulnerability_assessment_scans_export_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + scan_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/export" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_database_vulnerability_assessment_scans_initiate_scan_request( # pylint: disable=name-too-long + 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: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan" + 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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_data_masking_rules_list_by_database_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + data_masking_policy_name: Union[str, _models.DataMaskingPolicyName], + subscription_id: str, + *, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "dataMaskingPolicyName": _SERIALIZER.url("data_masking_policy_name", data_masking_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_data_masking_rules_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules/{dataMaskingRuleName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "dataMaskingPolicyName": _SERIALIZER.url("data_masking_policy_name", data_masking_policy_name, "str"), + "dataMaskingRuleName": _SERIALIZER.url("data_masking_rule_name", data_masking_rule_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_data_warehouse_user_activities_get_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + data_warehouse_user_activity_name: Union[str, _models.DataWarehouseUserActivityName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataWarehouseUserActivities/{dataWarehouseUserActivityName}" + 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"), + "dataWarehouseUserActivityName": _SERIALIZER.url( + "data_warehouse_user_activity_name", data_warehouse_user_activity_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_data_warehouse_user_activities_list_by_database_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataWarehouseUserActivities" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_security_events_list_by_database_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + database_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + skiptoken: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/securityEvents" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skiptoken is not None: + _params["$skiptoken"] = _SERIALIZER.query("skiptoken", skiptoken, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_recommended_sensitivity_labels_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/recommendedSensitivityLabels" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instance_tde_certificates_create_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/tdeCertificates" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_elastic_pool_operations_list_by_elastic_pool_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, elastic_pool_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/operations" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "elasticPoolName": _SERIALIZER.url("elastic_pool_name", elastic_pool_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_elastic_pool_operations_cancel_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + operation_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/operations/{operationId}/cancel" + 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"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_usages_list_by_instance_pool_request( # pylint: disable=name-too-long + resource_group_name: str, + instance_pool_name: str, + subscription_id: str, + *, + expand_children: Optional[bool] = 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}/usages" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "instancePoolName": _SERIALIZER.url("instance_pool_name", instance_pool_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand_children is not None: + _params["expandChildren"] = _SERIALIZER.query("expand_children", expand_children, "bool") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_ledger_digest_uploads_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}" + 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"), + "ledgerDigestUploads": _SERIALIZER.url("ledger_digest_uploads", ledger_digest_uploads, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_ledger_digest_uploads_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}" + 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"), + "ledgerDigestUploads": _SERIALIZER.url("ledger_digest_uploads", ledger_digest_uploads, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_ledger_digest_uploads_list_by_database_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_ledger_digest_uploads_disable_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}/disable" + 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"), + "ledgerDigestUploads": _SERIALIZER.url("ledger_digest_uploads", ledger_digest_uploads, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_maintenance_window_options_get_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + *, + maintenance_window_options_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/maintenanceWindowOptions/current" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["maintenanceWindowOptionsName"] = _SERIALIZER.query( + "maintenance_window_options_name", maintenance_window_options_name, "str" + ) + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_maintenance_windows_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + *, + maintenance_window_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/maintenanceWindows/current" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["maintenanceWindowName"] = _SERIALIZER.query("maintenance_window_name", maintenance_window_name, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_maintenance_windows_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + subscription_id: str, + *, + maintenance_window_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/maintenanceWindows/current" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["maintenanceWindowName"] = _SERIALIZER.query("maintenance_window_name", maintenance_window_name, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_advanced_threat_protection_settings_get_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + database_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "advancedThreatProtectionName": _SERIALIZER.url( + "advanced_threat_protection_name", advanced_threat_protection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_advanced_threat_protection_settings_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + database_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "advancedThreatProtectionName": _SERIALIZER.url( + "advanced_threat_protection_name", advanced_threat_protection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_advanced_threat_protection_settings_list_by_database_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/advancedThreatProtectionSettings" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_move_operations_get_request( # pylint: disable=name-too-long + resource_group_name: str, location_name: str, operation_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/managedDatabaseMoveOperationResults/{operationId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_move_operations_list_by_location_request( # pylint: disable=name-too-long + resource_group_name: str, + location_name: str, + subscription_id: str, + *, + only_latest_per_database: Optional[bool] = None, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/managedDatabaseMoveOperationResults" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if only_latest_per_database is not None: + _params["onlyLatestPerDatabase"] = _SERIALIZER.query( + "only_latest_per_database", only_latest_per_database, "bool" + ) + if filter is not None: + _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_managed_database_queries_get_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + database_name: str, + query_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/queries/{queryId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "queryId": _SERIALIZER.url("query_id", query_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_queries_list_by_query_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + database_name: str, + query_id: str, + subscription_id: str, + *, + start_time: Optional[str] = None, + end_time: Optional[str] = None, + interval: Optional[Union[str, _models.QueryTimeGrainType]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/queries/{queryId}/statistics" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "queryId": _SERIALIZER.url("query_id", query_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if start_time is not None: + _params["startTime"] = _SERIALIZER.query("start_time", start_time, "str") + if end_time is not None: + _params["endTime"] = _SERIALIZER.query("end_time", end_time, "str") + if interval is not None: + _params["interval"] = _SERIALIZER.query("interval", interval, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_restore_details_get_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + database_name: str, + restore_details_name: Union[str, _models.RestoreDetailsName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/restoreDetails/{restoreDetailsName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "restoreDetailsName": _SERIALIZER.url("restore_details_name", restore_details_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_transparent_data_encryption_get_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + database_name: str, + tde_name: Union[str, _models.TransparentDataEncryptionName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/transparentDataEncryption/{tdeName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_transparent_data_encryption_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/transparentDataEncryption/{tdeName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_database_transparent_data_encryption_list_by_database_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/transparentDataEncryption" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instance_advanced_threat_protection_settings_get_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "advancedThreatProtectionName": _SERIALIZER.url( + "advanced_threat_protection_name", advanced_threat_protection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instance_advanced_threat_protection_settings_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "advancedThreatProtectionName": _SERIALIZER.url( + "advanced_threat_protection_name", advanced_threat_protection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instance_advanced_threat_protection_settings_list_by_instance_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/advancedThreatProtectionSettings" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instance_private_link_resources_get_request( # pylint: disable=name-too-long + resource_group_name: str, managed_instance_name: str, 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateLinkResources/{groupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "groupName": _SERIALIZER.url("group_name", group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_instance_private_link_resources_list_by_managed_instance_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateLinkResources" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_ledger_digest_uploads_get_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + "ledgerDigestUploads": _SERIALIZER.url("ledger_digest_uploads", ledger_digest_uploads, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_ledger_digest_uploads_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + "ledgerDigestUploads": _SERIALIZER.url("ledger_digest_uploads", ledger_digest_uploads, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_ledger_digest_uploads_list_by_database_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/ledgerDigestUploads" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_ledger_digest_uploads_disable_request( # pylint: disable=name-too-long + resource_group_name: str, + managed_instance_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}/disable" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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"), + "ledgerDigestUploads": _SERIALIZER.url("ledger_digest_uploads", ledger_digest_uploads, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_advanced_threat_protection_settings_get_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}" + 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"), + "advancedThreatProtectionName": _SERIALIZER.url( + "advanced_threat_protection_name", advanced_threat_protection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_advanced_threat_protection_settings_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}" + 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"), + "advancedThreatProtectionName": _SERIALIZER.url( + "advanced_threat_protection_name", advanced_threat_protection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_server_advanced_threat_protection_settings_list_by_server_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advancedThreatProtectionSettings" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_automatic_tuning_get_request( # pylint: disable=name-too-long + 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/automaticTuning/current" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_server_automatic_tuning_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/automaticTuning/current" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_sql_agent_get_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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/sqlAgent/current" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sql_agent_create_or_update_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/sqlAgent/current" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_transparent_data_encryptions_get_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + tde_name: Union[str, _models.TransparentDataEncryptionName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{tdeName}" + 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"), + "tdeName": _SERIALIZER.url("tde_name", tde_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_transparent_data_encryptions_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + server_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{tdeName}" + 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"), + "tdeName": _SERIALIZER.url("tde_name", tde_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_transparent_data_encryptions_list_by_database_request( # pylint: disable=name-too-long + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_transparent_data_encryptions_resume_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + tde_name: Union[str, _models.TransparentDataEncryptionName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{tdeName}/resume" + 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"), + "tdeName": _SERIALIZER.url("tde_name", tde_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_transparent_data_encryptions_suspend_request( # pylint: disable=name-too-long + resource_group_name: str, + server_name: str, + database_name: str, + tde_name: Union[str, _models.TransparentDataEncryptionName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/transparentDataEncryption/{tdeName}/suspend" + 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"), + "tdeName": _SERIALIZER.url("tde_name", tde_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_capabilities_list_by_location_request( # pylint: disable=name-too-long + location_name: str, + subscription_id: str, + *, + include: Optional[Union[str, _models.CapabilityGroup]] = 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", "2025-02-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/capabilities" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if include is not None: + _params["include"] = _SERIALIZER.query("include", include, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + class Operations: """ .. warning:: @@ -62,11 +18154,74686 @@ class Operations: Instead, you should access the following operations through :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`operations` attribute. + :attr:`operations` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged["_models.Operation"]: + """Lists all of the available SQL Rest API operations. + + :return: An iterator like instance of Operation + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Operation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_operations_list_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Operation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class BackupShortTermRetentionPoliciesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`backup_short_term_retention_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + policy_name: Union[str, _models.ShortTermRetentionPolicyName], + **kwargs: Any + ) -> _models.BackupShortTermRetentionPolicy: + """Gets a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 policy_name: The policy name. Should always be default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ShortTermRetentionPolicyName + :return: BackupShortTermRetentionPolicy. The BackupShortTermRetentionPolicy is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.BackupShortTermRetentionPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.BackupShortTermRetentionPolicy] = kwargs.pop("cls", None) + + _request = build_backup_short_term_retention_policies_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.BackupShortTermRetentionPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.ShortTermRetentionPolicyName], + parameters: Union[_models.BackupShortTermRetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_backup_short_term_retention_policies_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.ShortTermRetentionPolicyName], + parameters: _models.BackupShortTermRetentionPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BackupShortTermRetentionPolicy]: + """Updates a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 policy_name: The policy name. Should always be default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: ~azure.mgmt.sql.models.BackupShortTermRetentionPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns BackupShortTermRetentionPolicy. The + BackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.ShortTermRetentionPolicyName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BackupShortTermRetentionPolicy]: + """Updates a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 policy_name: The policy name. Should always be default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns BackupShortTermRetentionPolicy. The + BackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.ShortTermRetentionPolicyName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BackupShortTermRetentionPolicy]: + """Updates a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 policy_name: The policy name. Should always be default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns BackupShortTermRetentionPolicy. The + BackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.ShortTermRetentionPolicyName], + parameters: Union[_models.BackupShortTermRetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.BackupShortTermRetentionPolicy]: + """Updates a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 policy_name: The policy name. Should always be default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Is one of the following types: + BackupShortTermRetentionPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.BackupShortTermRetentionPolicy or JSON or IO[bytes] + :return: An instance of LROPoller that returns BackupShortTermRetentionPolicy. The + BackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + policy_name=policy_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.BackupShortTermRetentionPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.BackupShortTermRetentionPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.BackupShortTermRetentionPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.ShortTermRetentionPolicyName], + parameters: Union[_models.BackupShortTermRetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_backup_short_term_retention_policies_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.ShortTermRetentionPolicyName], + parameters: _models.BackupShortTermRetentionPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BackupShortTermRetentionPolicy]: + """Updates a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 policy_name: The policy name. Should always be default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: ~azure.mgmt.sql.models.BackupShortTermRetentionPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns BackupShortTermRetentionPolicy. The + BackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.ShortTermRetentionPolicyName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BackupShortTermRetentionPolicy]: + """Updates a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 policy_name: The policy name. Should always be default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns BackupShortTermRetentionPolicy. The + BackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.ShortTermRetentionPolicyName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BackupShortTermRetentionPolicy]: + """Updates a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 policy_name: The policy name. Should always be default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns BackupShortTermRetentionPolicy. The + BackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.ShortTermRetentionPolicyName], + parameters: Union[_models.BackupShortTermRetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.BackupShortTermRetentionPolicy]: + """Updates a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 policy_name: The policy name. Should always be default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Is one of the following types: + BackupShortTermRetentionPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.BackupShortTermRetentionPolicy or JSON or IO[bytes] + :return: An instance of LROPoller that returns BackupShortTermRetentionPolicy. The + BackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + policy_name=policy_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.BackupShortTermRetentionPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.BackupShortTermRetentionPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.BackupShortTermRetentionPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> ItemPaged["_models.BackupShortTermRetentionPolicy"]: + """Gets a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of BackupShortTermRetentionPolicy + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.BackupShortTermRetentionPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_backup_short_term_retention_policies_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.BackupShortTermRetentionPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class DatabaseColumnsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`database_columns` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + schema_name: str, + table_name: str, + column_name: str, + **kwargs: Any + ) -> _models.DatabaseColumn: + """Get database column. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: DatabaseColumn. The DatabaseColumn is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseColumn + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseColumn] = kwargs.pop("cls", None) + + _request = build_database_columns_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, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseColumn, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_table( + self, + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + *, + filter: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.DatabaseColumn"]: + """List database columns. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :keyword filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of DatabaseColumn + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseColumn] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseColumn]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_database_columns_list_by_table_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseColumn], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_database( + self, + resource_group_name: str, + server_name: str, + database_name: str, + *, + schema: Optional[List[str]] = None, + table: Optional[List[str]] = None, + column: Optional[List[str]] = None, + order_by: Optional[List[str]] = None, + skiptoken: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.DatabaseColumn"]: + """List database columns. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 schema: Default value is None. + :paramtype schema: list[str] + :keyword table: Default value is None. + :paramtype table: list[str] + :keyword column: Default value is None. + :paramtype column: list[str] + :keyword order_by: Default value is None. + :paramtype order_by: list[str] + :keyword skiptoken: An opaque token that identifies a starting point in the collection. Default + value is None. + :paramtype skiptoken: str + :return: An iterator like instance of DatabaseColumn + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseColumn] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseColumn]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_database_columns_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + schema=schema, + table=table, + column=column, + order_by=order_by, + skiptoken=skiptoken, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseColumn], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class RestorePointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`restore_points` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, restore_point_name: str, **kwargs: Any + ) -> _models.RestorePoint: + """Gets a restore point. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 restore_point_name: The name of the restore point. Required. + :type restore_point_name: str + :return: RestorePoint. The RestorePoint is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.RestorePoint + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RestorePoint] = kwargs.pop("cls", None) + + _request = build_restore_points_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + restore_point_name=restore_point_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RestorePoint, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, server_name: str, database_name: str, restore_point_name: str, **kwargs: Any + ) -> None: + """Deletes a restore point. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 restore_point_name: The name of the restore point. Required. + :type restore_point_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_restore_points_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + restore_point_name=restore_point_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> ItemPaged["_models.RestorePoint"]: + """Gets a list of database restore points. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of RestorePoint + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.RestorePoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RestorePoint]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_restore_points_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RestorePoint], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _create_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.CreateDatabaseRestorePointDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_restore_points_create_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: _models.CreateDatabaseRestorePointDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RestorePoint]: + """Creates a restore point for a data warehouse. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The definition for creating the restore point of this database. Required. + :type parameters: ~azure.mgmt.sql.models.CreateDatabaseRestorePointDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns RestorePoint. The RestorePoint is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.RestorePoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RestorePoint]: + """Creates a restore point for a data warehouse. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The definition for creating the restore point of this database. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns RestorePoint. The RestorePoint is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.RestorePoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RestorePoint]: + """Creates a restore point for a data warehouse. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The definition for creating the restore point of this database. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns RestorePoint. The RestorePoint is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.RestorePoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.CreateDatabaseRestorePointDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.RestorePoint]: + """Creates a restore point for a data warehouse. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The definition for creating the restore point of this database. Is one of + the following types: CreateDatabaseRestorePointDefinition, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.CreateDatabaseRestorePointDefinition or JSON or + IO[bytes] + :return: An instance of LROPoller that returns RestorePoint. The RestorePoint is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.RestorePoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.RestorePoint, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.RestorePoint].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.RestorePoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class SensitivityLabelsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`sensitivity_labels` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_current_by_database( + self, + resource_group_name: str, + server_name: str, + database_name: str, + *, + skip_token: Optional[str] = None, + count: Optional[bool] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.SensitivityLabel"]: + """Gets the sensitivity labels of a given database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 skip_token: Default value is None. + :paramtype skip_token: str + :keyword count: Default value is None. + :paramtype count: bool + :keyword filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of SensitivityLabel + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SensitivityLabel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SensitivityLabel]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_sensitivity_labels_list_current_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + skip_token=skip_token, + count=count, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SensitivityLabel], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @overload + def update( + self, + resource_group_name: str, + server_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. The name is case insensitive. + Required. + :type resource_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 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 + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: JSON, + *, + 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. The name is case insensitive. + Required. + :type resource_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 parameters: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: IO[bytes], + *, + 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. The name is case insensitive. + Required. + :type resource_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 parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.SensitivityLabelUpdateList, JSON, IO[bytes]], + **kwargs: Any + ) -> None: + """Update sensitivity labels of a given database using an operations batch. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: Is one of the following types: SensitivityLabelUpdateList, JSON, IO[bytes] + Required. + :type parameters: ~azure.mgmt.sql.models.SensitivityLabelUpdateList or JSON or IO[bytes] + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_sensitivity_labels_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_recommended_by_database( + self, + resource_group_name: str, + server_name: str, + database_name: str, + *, + skip_token: Optional[str] = None, + include_disabled_recommendations: Optional[bool] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.SensitivityLabel"]: + """Gets the sensitivity labels of a given database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 skip_token: Default value is None. + :paramtype skip_token: str + :keyword include_disabled_recommendations: Specifies whether to include disabled + recommendations or not. Default value is None. + :paramtype include_disabled_recommendations: bool + :keyword filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of SensitivityLabel + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SensitivityLabel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SensitivityLabel]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_sensitivity_labels_list_recommended_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + skip_token=skip_token, + include_disabled_recommendations=include_disabled_recommendations, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SensitivityLabel], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_database( + self, + resource_group_name: str, + server_name: str, + database_name: str, + *, + filter: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.SensitivityLabel"]: + """Gets the sensitivity labels of a given database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of SensitivityLabel + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SensitivityLabel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SensitivityLabel]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_sensitivity_labels_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SensitivityLabel], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + sensitivity_label_source: Union[str, _models.SensitivityLabelSource], + **kwargs: Any + ) -> _models.SensitivityLabel: + """Gets the sensitivity label of a given column. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :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 + :return: SensitivityLabel. The SensitivityLabel is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SensitivityLabel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SensitivityLabel] = kwargs.pop("cls", None) + + _request = build_sensitivity_labels_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SensitivityLabel, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + parameters: _models.SensitivityLabel, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SensitivityLabel: + """Creates or updates the sensitivity label of a given column. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :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 + :return: SensitivityLabel. The SensitivityLabel is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SensitivityLabel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SensitivityLabel: + """Creates or updates the sensitivity label of a given column. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :param parameters: The column sensitivity label resource. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SensitivityLabel. The SensitivityLabel is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SensitivityLabel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SensitivityLabel: + """Creates or updates the sensitivity label of a given column. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :param parameters: The column sensitivity label resource. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SensitivityLabel. The SensitivityLabel is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SensitivityLabel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + parameters: Union[_models.SensitivityLabel, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.SensitivityLabel: + """Creates or updates the sensitivity label of a given column. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :param parameters: The column sensitivity label resource. Is one of the following types: + SensitivityLabel, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.SensitivityLabel or JSON or IO[bytes] + :return: SensitivityLabel. The SensitivityLabel is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SensitivityLabel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_sensitivity_labels_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = 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]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SensitivityLabel, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # 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: + """Deletes the sensitivity label of a given column. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_sensitivity_labels_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + 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. The name is case insensitive. + Required. + :type resource_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 + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_sensitivity_labels_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + 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. The name is case insensitive. + Required. + :type resource_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 + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_sensitivity_labels_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class DatabasesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`databases` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + *, + expand: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> _models.Database: + """Gets a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 expand: The child resources to include in the response. Default value is None. + :paramtype expand: str + :keyword filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: Database. The Database is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Database + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Database] = kwargs.pop("cls", None) + + _request = build_databases_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + expand=expand, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Database, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.Database, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_databases_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: _models.Database, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Database]: + """Creates a new database or updates an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The requested database resource state. Required. + :type parameters: ~azure.mgmt.sql.models.Database + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Database. The Database is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Database]: + """Creates a new database or updates an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The requested database resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Database. The Database is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Database]: + """Creates a new database or updates an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The requested database resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Database. The Database is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.Database, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Database]: + """Creates a new database or updates an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The requested database resource state. Is one of the following types: + Database, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.Database or JSON or IO[bytes] + :return: An instance of LROPoller that returns Database. The Database is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Database, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Database].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Database]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.DatabaseUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_databases_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: _models.DatabaseUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Database]: + """Updates an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The requested database resource state. Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Database. The Database is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Database]: + """Updates an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The requested database resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Database. The Database is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Database]: + """Updates an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The requested database resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Database. The Database is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.DatabaseUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Database]: + """Updates an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The requested database resource state. Is one of the following types: + DatabaseUpdate, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseUpdate or JSON or IO[bytes] + :return: An instance of LROPoller that returns Database. The Database is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Database, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Database].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Database]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_databases_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + @api_version_validation( + params_added_on={"2025-02-01-preview": ["top", "skip", "filter", "orderby"]}, + api_versions_list=["2025-01-01", "2025-02-01-preview"], + ) + def list_by_server( + self, + resource_group_name: str, + server_name: str, + *, + top: Optional[int] = None, + skip: Optional[int] = None, + filter: Optional[str] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.Database"]: + """Gets a list of databases. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :keyword top: The number of elements to return from the collection. Default value is None. + :paramtype top: int + :keyword skip: The number of elements in the collection to skip. Default value is None. + :paramtype skip: int + :keyword filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :keyword orderby: How the results should be ordered. Default value is None. + :paramtype orderby: str + :return: An iterator like instance of Database + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Database]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_databases_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + top=top, + skip=skip, + filter=filter, + orderby=orderby, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Database], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _export_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.ExportDatabaseDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_databases_export_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_export( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: _models.ExportDatabaseDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ImportExportOperationResult]: + """Exports a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The database export request parameters. Required. + :type parameters: ~azure.mgmt.sql.models.ExportDatabaseDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ImportExportOperationResult. The + ImportExportOperationResult is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_export( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ImportExportOperationResult]: + """Exports a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The database export request parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ImportExportOperationResult. The + ImportExportOperationResult is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_export( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ImportExportOperationResult]: + """Exports a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The database export request parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ImportExportOperationResult. The + ImportExportOperationResult is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_export( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.ExportDatabaseDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ImportExportOperationResult]: + """Exports a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The database export request parameters. Is one of the following types: + ExportDatabaseDefinition, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ExportDatabaseDefinition or JSON or IO[bytes] + :return: An instance of LROPoller that returns ImportExportOperationResult. The + ImportExportOperationResult is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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._export_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ImportExportOperationResult, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ImportExportOperationResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ImportExportOperationResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _failover_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + *, + replica_type: Optional[Union[str, _models.ReplicaType]] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_databases_failover_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + replica_type=replica_type, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_failover( + self, + resource_group_name: str, + server_name: str, + database_name: str, + *, + replica_type: Optional[Union[str, _models.ReplicaType]] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Failovers a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 replica_type: The type of replica to be failed over. Known values are: "Primary" and + "ReadableSecondary". Default value is None. + :paramtype replica_type: str or ~azure.mgmt.sql.models.ReplicaType + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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._failover_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + replica_type=replica_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _import_method_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.ImportExistingDatabaseDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_databases_import_method_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_import_method( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: _models.ImportExistingDatabaseDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ImportExportOperationResult]: + """Imports a bacpac into a new database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The database import request parameters. Required. + :type parameters: ~azure.mgmt.sql.models.ImportExistingDatabaseDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ImportExportOperationResult. The + ImportExportOperationResult is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_import_method( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ImportExportOperationResult]: + """Imports a bacpac into a new database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The database import request parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ImportExportOperationResult. The + ImportExportOperationResult is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_import_method( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ImportExportOperationResult]: + """Imports a bacpac into a new database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The database import request parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ImportExportOperationResult. The + ImportExportOperationResult is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_import_method( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.ImportExistingDatabaseDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ImportExportOperationResult]: + """Imports a bacpac into a new database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The database import request parameters. Is one of the following types: + ImportExistingDatabaseDefinition, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ImportExistingDatabaseDefinition or JSON or IO[bytes] + :return: An instance of LROPoller that returns ImportExportOperationResult. The + ImportExportOperationResult is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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._import_method_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ImportExportOperationResult, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ImportExportOperationResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ImportExportOperationResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @overload + def rename( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: _models.ResourceMoveDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Renames a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The resource move definition for renaming this database. Required. + :type parameters: ~azure.mgmt.sql.models.ResourceMoveDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def rename( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Renames a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The resource move definition for renaming this database. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def rename( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Renames a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The resource move definition for renaming this database. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def rename( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.ResourceMoveDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> None: + """Renames a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The resource move definition for renaming this database. Is one of the + following types: ResourceMoveDefinition, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ResourceMoveDefinition or JSON or IO[bytes] + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_databases_rename_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + def _pause_initial( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_databases_pause_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_pause( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> LROPoller[_models.Database]: + """Pauses a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An instance of LROPoller that returns Database. The Database is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._pause_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.Database, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Database].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Database]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _resume_initial( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_databases_resume_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_resume( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> LROPoller[_models.Database]: + """Resumes a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An instance of LROPoller that returns Database. The Database is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._resume_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.Database, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Database].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Database]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _upgrade_data_warehouse_initial( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_databases_upgrade_data_warehouse_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_upgrade_data_warehouse( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Upgrades a data warehouse. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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._upgrade_data_warehouse_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_inaccessible_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.Database"]: + """Gets a list of inaccessible databases in a logical server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of Database + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Database]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_databases_list_inaccessible_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Database], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_elastic_pool( + self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any + ) -> ItemPaged["_models.Database"]: + """Gets a list of databases in an elastic pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An iterator like instance of Database + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Database]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_databases_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Database], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class FirewallRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`firewall_rules` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: FirewallRule. The FirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.FirewallRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.FirewallRule] = kwargs.pop("cls", None) + + _request = build_firewall_rules_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.FirewallRule, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + parameters: _models.FirewallRule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FirewallRule: + """Creates or updates a firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: FirewallRule. The FirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.FirewallRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FirewallRule: + """Creates or updates a firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: FirewallRule. The FirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.FirewallRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FirewallRule: + """Creates or updates a firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: FirewallRule. The FirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.FirewallRule + :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, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.FirewallRule: + """Creates or updates a firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 one of + the following types: FirewallRule, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.FirewallRule or JSON or IO[bytes] + :return: FirewallRule. The FirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.FirewallRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.FirewallRule] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_firewall_rules_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + firewall_rule_name=firewall_rule_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = 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]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.FirewallRule, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @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. The name is case insensitive. + 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 + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_firewall_rules_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = 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) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.FirewallRule"]: + """Gets a list of firewall rules. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of FirewallRule + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.FirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.FirewallRule]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_firewall_rules_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.FirewallRule], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @overload + def replace( + self, + resource_group_name: str, + server_name: str, + parameters: _models.FirewallRuleList, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.FirewallRule]: + """Replaces all firewall rules on the server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: FirewallRule or None. The FirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.FirewallRule or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def replace( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.FirewallRule]: + """Replaces all firewall rules on the server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: FirewallRule or None. The FirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.FirewallRule or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def replace( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.FirewallRule]: + """Replaces all firewall rules on the server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: FirewallRule or None. The FirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.FirewallRule or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def replace( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.FirewallRuleList, JSON, IO[bytes]], + **kwargs: Any + ) -> Optional[_models.FirewallRule]: + """Replaces all firewall rules on the server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Is one of the following types: FirewallRuleList, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.FirewallRuleList or JSON or IO[bytes] + :return: FirewallRule or None. The FirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.FirewallRule or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.FirewallRule]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_firewall_rules_replace_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = 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]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.FirewallRule, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class ReplicationLinksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`replication_links` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, link_id: str, **kwargs: Any + ) -> _models.ReplicationLink: + """Gets a replication link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 link_id: The name of the replication link. Required. + :type link_id: str + :return: ReplicationLink. The ReplicationLink is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ReplicationLink + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ReplicationLink] = kwargs.pop("cls", None) + + _request = build_replication_links_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + link_id=link_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ReplicationLink, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + link_id: str, + parameters: Union[_models.ReplicationLink, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_replication_links_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + link_id=link_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + link_id: str, + parameters: _models.ReplicationLink, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ReplicationLink]: + """Updates the replication link type. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 link_id: The name of the replication link. Required. + :type link_id: str + :param parameters: Required. + :type parameters: ~azure.mgmt.sql.models.ReplicationLink + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ReplicationLink. The ReplicationLink is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ReplicationLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + link_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ReplicationLink]: + """Updates the replication link type. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 link_id: The name of the replication link. Required. + :type link_id: str + :param parameters: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ReplicationLink. The ReplicationLink is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ReplicationLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + link_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ReplicationLink]: + """Updates the replication link type. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 link_id: The name of the replication link. Required. + :type link_id: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ReplicationLink. The ReplicationLink is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ReplicationLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + link_id: str, + parameters: Union[_models.ReplicationLink, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ReplicationLink]: + """Updates the replication link type. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 link_id: The name of the replication link. Required. + :type link_id: str + :param parameters: Is one of the following types: ReplicationLink, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ReplicationLink or JSON or IO[bytes] + :return: An instance of LROPoller that returns ReplicationLink. The ReplicationLink is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ReplicationLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + 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) + 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, + link_id=link_id, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ReplicationLink, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ReplicationLink].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ReplicationLink]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + link_id: str, + parameters: Union[_models.ReplicationLinkUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_replication_links_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + link_id=link_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + link_id: str, + parameters: _models.ReplicationLinkUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ReplicationLink]: + """Updates the replication link type. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 link_id: The name of the replication link. Required. + :type link_id: str + :param parameters: Required. + :type parameters: ~azure.mgmt.sql.models.ReplicationLinkUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ReplicationLink. The ReplicationLink is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ReplicationLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + link_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ReplicationLink]: + """Updates the replication link type. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 link_id: The name of the replication link. Required. + :type link_id: str + :param parameters: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ReplicationLink. The ReplicationLink is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ReplicationLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + link_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ReplicationLink]: + """Updates the replication link type. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 link_id: The name of the replication link. Required. + :type link_id: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ReplicationLink. The ReplicationLink is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ReplicationLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + link_id: str, + parameters: Union[_models.ReplicationLinkUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ReplicationLink]: + """Updates the replication link type. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 link_id: The name of the replication link. Required. + :type link_id: str + :param parameters: Is one of the following types: ReplicationLinkUpdate, JSON, IO[bytes] + Required. + :type parameters: ~azure.mgmt.sql.models.ReplicationLinkUpdate or JSON or IO[bytes] + :return: An instance of LROPoller that returns ReplicationLink. The ReplicationLink is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ReplicationLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + 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) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + link_id=link_id, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ReplicationLink, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ReplicationLink].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ReplicationLink]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, server_name: str, database_name: str, link_id: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_replication_links_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + link_id=link_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, server_name: str, database_name: str, link_id: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the replication link. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 link_id: The name of the replication link. Required. + :type link_id: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + link_id=link_id, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> ItemPaged["_models.ReplicationLink"]: + """Gets a list of replication links on database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of ReplicationLink + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ReplicationLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ReplicationLink]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_replication_links_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ReplicationLink], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _failover_initial( + self, resource_group_name: str, server_name: str, database_name: str, link_id: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_replication_links_failover_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + link_id=link_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_failover( + self, resource_group_name: str, server_name: str, database_name: str, link_id: str, **kwargs: Any + ) -> LROPoller[_models.ReplicationLink]: + """Fails over from the current primary server to this server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 link_id: The name of the replication link. Required. + :type link_id: str + :return: An instance of LROPoller that returns ReplicationLink. The ReplicationLink is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ReplicationLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._failover_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + link_id=link_id, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ReplicationLink, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ReplicationLink].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ReplicationLink]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _failover_allow_data_loss_initial( + self, resource_group_name: str, server_name: str, database_name: str, link_id: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_replication_links_failover_allow_data_loss_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + link_id=link_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_failover_allow_data_loss( + self, resource_group_name: str, server_name: str, database_name: str, link_id: str, **kwargs: Any + ) -> LROPoller[_models.ReplicationLink]: + """Fails over from the current primary server to this server allowing data loss. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 link_id: The name of the replication link. Required. + :type link_id: str + :return: An instance of LROPoller that returns ReplicationLink. The ReplicationLink is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ReplicationLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._failover_allow_data_loss_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + link_id=link_id, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ReplicationLink, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ReplicationLink].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ReplicationLink]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.ReplicationLink"]: + """Gets a list of replication links. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of ReplicationLink + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ReplicationLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ReplicationLink]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_replication_links_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ReplicationLink], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ServersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`servers` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, server_name: str, *, expand: Optional[str] = None, **kwargs: Any + ) -> _models.Server: + """Gets a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :keyword expand: The child resources to include in the response. Default value is None. + :paramtype expand: str + :return: Server. The Server is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Server + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Server] = kwargs.pop("cls", None) + + _request = build_servers_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Server, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.Server, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_servers_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + parameters: _models.Server, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Server]: + """Creates or updates a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The requested server resource state. Required. + :type parameters: ~azure.mgmt.sql.models.Server + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Server]: + """Creates or updates a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The requested server resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Server]: + """Creates or updates a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The requested server resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.Server, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Server]: + """Creates or updates a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The requested server resource state. Is one of the following types: Server, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.Server or JSON or IO[bytes] + :return: An instance of LROPoller that returns Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Server, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Server].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Server]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_servers_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + parameters: _models.ServerUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Server]: + """Updates a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The requested server resource state. Required. + :type parameters: ~azure.mgmt.sql.models.ServerUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Server]: + """Updates a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The requested server resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Server]: + """Updates a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The requested server resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Server]: + """Updates a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The requested server resource state. Is one of the following types: + ServerUpdate, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ServerUpdate or JSON or IO[bytes] + :return: An instance of LROPoller that returns Server. The Server is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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( + resource_group_name=resource_group_name, + server_name=server_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Server, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Server].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Server]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial(self, resource_group_name: str, server_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_servers_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete(self, resource_group_name: str, server_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, *, expand: Optional[str] = None, **kwargs: Any + ) -> ItemPaged["_models.Server"]: + """Gets a list of servers in a resource groups. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword expand: The child resources to include in the response. Default value is None. + :paramtype expand: str + :return: An iterator like instance of Server + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Server]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_servers_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Server], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, *, expand: Optional[str] = None, **kwargs: Any) -> ItemPaged["_models.Server"]: + """Gets a list of all servers in the subscription. + + :keyword expand: The child resources to include in the response. Default value is None. + :paramtype expand: str + :return: An iterator like instance of Server + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.Server] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Server]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_servers_list_request( + subscription_id=self._config.subscription_id, + expand=expand, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Server], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _import_database_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ImportNewDatabaseDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_servers_import_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_import_database( + self, + resource_group_name: str, + server_name: str, + parameters: _models.ImportNewDatabaseDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ImportExportOperationResult]: + """Imports a bacpac into a new database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The database import request parameters. Required. + :type parameters: ~azure.mgmt.sql.models.ImportNewDatabaseDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ImportExportOperationResult. The + ImportExportOperationResult is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_import_database( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ImportExportOperationResult]: + """Imports a bacpac into a new database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The database import request parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ImportExportOperationResult. The + ImportExportOperationResult is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_import_database( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ImportExportOperationResult]: + """Imports a bacpac into a new database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The database import request parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ImportExportOperationResult. The + ImportExportOperationResult is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_import_database( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ImportNewDatabaseDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ImportExportOperationResult]: + """Imports a bacpac into a new database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The database import request parameters. Is one of the following types: + ImportNewDatabaseDefinition, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ImportNewDatabaseDefinition or JSON or IO[bytes] + :return: An instance of LROPoller that returns ImportExportOperationResult. The + ImportExportOperationResult is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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._import_database_initial( + resource_group_name=resource_group_name, + server_name=server_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ImportExportOperationResult, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ImportExportOperationResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ImportExportOperationResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _refresh_status_initial(self, resource_group_name: str, server_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_servers_refresh_status_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_refresh_status( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> LROPoller[_models.RefreshExternalGovernanceStatusOperationResult]: + """Refresh external governance enablement status. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An instance of LROPoller that returns RefreshExternalGovernanceStatusOperationResult. + The RefreshExternalGovernanceStatusOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.RefreshExternalGovernanceStatusOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + server_name=server_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.RefreshExternalGovernanceStatusOperationResult, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.RefreshExternalGovernanceStatusOperationResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.RefreshExternalGovernanceStatusOperationResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @overload + def check_name_availability( + self, parameters: _models.CheckNameAvailabilityRequest, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResponse: + """Determines whether a resource can be created with the specified name. + + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.sql.models.CheckNameAvailabilityRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityResponse. The CheckNameAvailabilityResponse is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.CheckNameAvailabilityResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResponse: + """Determines whether a resource can be created with the specified name. + + :param parameters: The request body. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityResponse. The CheckNameAvailabilityResponse is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.CheckNameAvailabilityResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResponse: + """Determines whether a resource can be created with the specified name. + + :param parameters: The request body. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityResponse. The CheckNameAvailabilityResponse is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.CheckNameAvailabilityResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, parameters: Union[_models.CheckNameAvailabilityRequest, JSON, IO[bytes]], **kwargs: Any + ) -> _models.CheckNameAvailabilityResponse: + """Determines whether a resource can be created with the specified name. + + :param parameters: The request body. Is one of the following types: + CheckNameAvailabilityRequest, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.CheckNameAvailabilityRequest or JSON or IO[bytes] + :return: CheckNameAvailabilityResponse. The CheckNameAvailabilityResponse is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.CheckNameAvailabilityResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_servers_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CheckNameAvailabilityResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class ServerBlobAuditingPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`server_blob_auditing_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, server_name: str, **kwargs: Any) -> _models.ServerBlobAuditingPolicy: + """Gets a server's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: ServerBlobAuditingPolicy. The ServerBlobAuditingPolicy is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerBlobAuditingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") + cls: ClsType[_models.ServerBlobAuditingPolicy] = kwargs.pop("cls", None) + + _request = build_server_blob_auditing_policies_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + blob_auditing_policy_name=blob_auditing_policy_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ServerBlobAuditingPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerBlobAuditingPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_server_blob_auditing_policies_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + blob_auditing_policy_name=blob_auditing_policy_name, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + parameters: _models.ServerBlobAuditingPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerBlobAuditingPolicy]: + """Creates or updates a server's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Properties of blob auditing policy. Required. + :type parameters: ~azure.mgmt.sql.models.ServerBlobAuditingPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerBlobAuditingPolicy. The + ServerBlobAuditingPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerBlobAuditingPolicy]: + """Creates or updates a server's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Properties of blob auditing policy. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerBlobAuditingPolicy. The + ServerBlobAuditingPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerBlobAuditingPolicy]: + """Creates or updates a server's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Properties of blob auditing policy. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerBlobAuditingPolicy. The + ServerBlobAuditingPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerBlobAuditingPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ServerBlobAuditingPolicy]: + """Creates or updates a server's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Properties of blob auditing policy. Is one of the following types: + ServerBlobAuditingPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ServerBlobAuditingPolicy or JSON or IO[bytes] + :return: An instance of LROPoller that returns ServerBlobAuditingPolicy. The + ServerBlobAuditingPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") + 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) + 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, + parameters=parameters, + blob_auditing_policy_name=blob_auditing_policy_name, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ServerBlobAuditingPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ServerBlobAuditingPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ServerBlobAuditingPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.ServerBlobAuditingPolicy"]: + """Lists auditing settings of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of ServerBlobAuditingPolicy + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerBlobAuditingPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_server_blob_auditing_policies_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ServerBlobAuditingPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class DatabaseBlobAuditingPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`database_blob_auditing_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, **kwargs: Any + ) -> _models.DatabaseBlobAuditingPolicy: + """Gets a database's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: DatabaseBlobAuditingPolicy. The DatabaseBlobAuditingPolicy is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseBlobAuditingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") + cls: ClsType[_models.DatabaseBlobAuditingPolicy] = kwargs.pop("cls", None) + + _request = build_database_blob_auditing_policies_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + blob_auditing_policy_name=blob_auditing_policy_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseBlobAuditingPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: _models.DatabaseBlobAuditingPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseBlobAuditingPolicy: + """Creates or updates a database's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The database blob auditing policy. Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseBlobAuditingPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseBlobAuditingPolicy. The DatabaseBlobAuditingPolicy is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseBlobAuditingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseBlobAuditingPolicy: + """Creates or updates a database's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The database blob auditing policy. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseBlobAuditingPolicy. The DatabaseBlobAuditingPolicy is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseBlobAuditingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseBlobAuditingPolicy: + """Creates or updates a database's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The database blob auditing policy. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseBlobAuditingPolicy. The DatabaseBlobAuditingPolicy is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseBlobAuditingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.DatabaseBlobAuditingPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.DatabaseBlobAuditingPolicy: + """Creates or updates a database's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The database blob auditing policy. Is one of the following types: + DatabaseBlobAuditingPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseBlobAuditingPolicy or JSON or IO[bytes] + :return: DatabaseBlobAuditingPolicy. The DatabaseBlobAuditingPolicy is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseBlobAuditingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_database_blob_auditing_policies_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + blob_auditing_policy_name=blob_auditing_policy_name, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = 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]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseBlobAuditingPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> ItemPaged["_models.DatabaseBlobAuditingPolicy"]: + """Lists auditing settings of a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of DatabaseBlobAuditingPolicy + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseBlobAuditingPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_database_blob_auditing_policies_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseBlobAuditingPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ExtendedDatabaseBlobAuditingPoliciesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`extended_database_blob_auditing_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, **kwargs: Any + ) -> _models.ExtendedDatabaseBlobAuditingPolicy: + """Gets an extended database's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: ExtendedDatabaseBlobAuditingPolicy. The ExtendedDatabaseBlobAuditingPolicy is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") + cls: ClsType[_models.ExtendedDatabaseBlobAuditingPolicy] = kwargs.pop("cls", None) + + _request = build_extended_database_blob_auditing_policies_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + blob_auditing_policy_name=blob_auditing_policy_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ExtendedDatabaseBlobAuditingPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: _models.ExtendedDatabaseBlobAuditingPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ExtendedDatabaseBlobAuditingPolicy: + """Creates or updates an extended database's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The extended database blob auditing policy. Required. + :type parameters: ~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ExtendedDatabaseBlobAuditingPolicy. The ExtendedDatabaseBlobAuditingPolicy is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ExtendedDatabaseBlobAuditingPolicy: + """Creates or updates an extended database's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The extended database blob auditing policy. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ExtendedDatabaseBlobAuditingPolicy. The ExtendedDatabaseBlobAuditingPolicy is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ExtendedDatabaseBlobAuditingPolicy: + """Creates or updates an extended database's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The extended database blob auditing policy. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ExtendedDatabaseBlobAuditingPolicy. The ExtendedDatabaseBlobAuditingPolicy is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.ExtendedDatabaseBlobAuditingPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ExtendedDatabaseBlobAuditingPolicy: + """Creates or updates an extended database's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The extended database blob auditing policy. Is one of the following types: + ExtendedDatabaseBlobAuditingPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicy or JSON or + IO[bytes] + :return: ExtendedDatabaseBlobAuditingPolicy. The ExtendedDatabaseBlobAuditingPolicy is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_extended_database_blob_auditing_policies_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + blob_auditing_policy_name=blob_auditing_policy_name, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = 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]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ExtendedDatabaseBlobAuditingPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> ItemPaged["_models.ExtendedDatabaseBlobAuditingPolicy"]: + """Lists extended auditing settings of a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of ExtendedDatabaseBlobAuditingPolicy + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ExtendedDatabaseBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ExtendedDatabaseBlobAuditingPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_extended_database_blob_auditing_policies_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ExtendedDatabaseBlobAuditingPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ExtendedServerBlobAuditingPoliciesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`extended_server_blob_auditing_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> _models.ExtendedServerBlobAuditingPolicy: + """Gets an extended server's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: ExtendedServerBlobAuditingPolicy. The ExtendedServerBlobAuditingPolicy is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") + cls: ClsType[_models.ExtendedServerBlobAuditingPolicy] = kwargs.pop("cls", None) + + _request = build_extended_server_blob_auditing_policies_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + blob_auditing_policy_name=blob_auditing_policy_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ExtendedServerBlobAuditingPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ExtendedServerBlobAuditingPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_extended_server_blob_auditing_policies_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + blob_auditing_policy_name=blob_auditing_policy_name, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + parameters: _models.ExtendedServerBlobAuditingPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ExtendedServerBlobAuditingPolicy]: + """Creates or updates an extended server's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Properties of extended blob auditing policy. Required. + :type parameters: ~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ExtendedServerBlobAuditingPolicy. The + ExtendedServerBlobAuditingPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ExtendedServerBlobAuditingPolicy]: + """Creates or updates an extended server's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Properties of extended blob auditing policy. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ExtendedServerBlobAuditingPolicy. The + ExtendedServerBlobAuditingPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ExtendedServerBlobAuditingPolicy]: + """Creates or updates an extended server's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Properties of extended blob auditing policy. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ExtendedServerBlobAuditingPolicy. The + ExtendedServerBlobAuditingPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ExtendedServerBlobAuditingPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ExtendedServerBlobAuditingPolicy]: + """Creates or updates an extended server's blob auditing policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: Properties of extended blob auditing policy. Is one of the following types: + ExtendedServerBlobAuditingPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy or JSON or IO[bytes] + :return: An instance of LROPoller that returns ExtendedServerBlobAuditingPolicy. The + ExtendedServerBlobAuditingPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") + 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) + 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, + parameters=parameters, + blob_auditing_policy_name=blob_auditing_policy_name, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ExtendedServerBlobAuditingPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ExtendedServerBlobAuditingPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ExtendedServerBlobAuditingPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.ExtendedServerBlobAuditingPolicy"]: + """Lists extended auditing settings of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of ExtendedServerBlobAuditingPolicy + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ExtendedServerBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ExtendedServerBlobAuditingPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_extended_server_blob_auditing_policies_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ExtendedServerBlobAuditingPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ServerAdvisorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`server_advisors` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, server_name: str, advisor_name: str, **kwargs: Any) -> _models.Advisor: + """Gets a server advisor. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param advisor_name: The name of the Server Advisor. Required. + :type advisor_name: str + :return: Advisor. The Advisor is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Advisor + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Advisor] = kwargs.pop("cls", None) + + _request = build_server_advisors_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + advisor_name=advisor_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Advisor, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + server_name: str, + advisor_name: str, + parameters: _models.Advisor, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Advisor: + """Updates a server advisor. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param advisor_name: The name of the Server Advisor. Required. + :type advisor_name: str + :param parameters: The requested advisor resource state. Required. + :type parameters: ~azure.mgmt.sql.models.Advisor + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Advisor. The Advisor is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Advisor + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + server_name: str, + advisor_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Advisor: + """Updates a server advisor. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param advisor_name: The name of the Server Advisor. Required. + :type advisor_name: str + :param parameters: The requested advisor resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Advisor. The Advisor is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Advisor + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + server_name: str, + advisor_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Advisor: + """Updates a server advisor. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param advisor_name: The name of the Server Advisor. Required. + :type advisor_name: str + :param parameters: The requested advisor resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Advisor. The Advisor is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Advisor + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + server_name: str, + advisor_name: str, + parameters: Union[_models.Advisor, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.Advisor: + """Updates a server advisor. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param advisor_name: The name of the Server Advisor. Required. + :type advisor_name: str + :param parameters: The requested advisor resource state. Is one of the following types: + Advisor, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.Advisor or JSON or IO[bytes] + :return: Advisor. The Advisor is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Advisor + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_server_advisors_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + advisor_name=advisor_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Advisor, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, *, expand: Optional[str] = None, **kwargs: Any + ) -> List[_models.Advisor]: + """Gets a list of server advisors. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :keyword expand: The child resources to include in the response. Default value is None. + :paramtype expand: str + :return: list of Advisor + :rtype: list[~azure.mgmt.sql.models.Advisor] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Advisor]] = kwargs.pop("cls", None) + + _request = build_server_advisors_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(List[_models.Advisor], response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class ManagedDatabaseColumnsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_database_columns` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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, + **kwargs: Any + ) -> _models.DatabaseColumn: + """Get managed database column. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: DatabaseColumn. The DatabaseColumn is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseColumn + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseColumn] = kwargs.pop("cls", None) + + _request = build_managed_database_columns_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + column_name=column_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseColumn, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_table( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + *, + filter: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.DatabaseColumn"]: + """List managed database columns. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :keyword filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of DatabaseColumn + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseColumn] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseColumn]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_database_columns_list_by_table_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseColumn], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_database( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + *, + schema: Optional[List[str]] = None, + table: Optional[List[str]] = None, + column: Optional[List[str]] = None, + order_by: Optional[List[str]] = None, + skiptoken: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.DatabaseColumn"]: + """List managed database columns. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 schema: Default value is None. + :paramtype schema: list[str] + :keyword table: Default value is None. + :paramtype table: list[str] + :keyword column: Default value is None. + :paramtype column: list[str] + :keyword order_by: Default value is None. + :paramtype order_by: list[str] + :keyword skiptoken: An opaque token that identifies a starting point in the collection. Default + value is None. + :paramtype skiptoken: str + :return: An iterator like instance of DatabaseColumn + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseColumn] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseColumn]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_database_columns_list_by_database_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + schema=schema, + table=table, + column=column, + order_by=order_by, + skiptoken=skiptoken, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseColumn], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class DatabaseTablesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`database_tables` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + schema_name: str, + table_name: str, + **kwargs: Any + ) -> _models.DatabaseTable: + """Get database table. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: DatabaseTable. The DatabaseTable is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseTable + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseTable] = kwargs.pop("cls", None) + + _request = build_database_tables_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseTable, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_schema( + self, + resource_group_name: str, + server_name: str, + database_name: str, + schema_name: str, + *, + filter: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.DatabaseTable"]: + """List database tables. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :keyword filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of DatabaseTable + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseTable] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseTable]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_database_tables_list_by_schema_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + schema_name=schema_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseTable], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ManagedDatabaseTablesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_database_tables` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + **kwargs: Any + ) -> _models.DatabaseTable: + """Get managed database table. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: DatabaseTable. The DatabaseTable is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseTable + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseTable] = kwargs.pop("cls", None) + + _request = build_managed_database_tables_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseTable, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_schema( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + *, + filter: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.DatabaseTable"]: + """List managed database tables. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :keyword filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of DatabaseTable + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseTable] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseTable]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_database_tables_list_by_schema_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseTable], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class DatabaseSchemasOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`database_schemas` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, schema_name: str, **kwargs: Any + ) -> _models.DatabaseSchema: + """Get database schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: DatabaseSchema. The DatabaseSchema is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSchema + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseSchema] = kwargs.pop("cls", None) + + _request = build_database_schemas_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + schema_name=schema_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseSchema, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_database( + self, + resource_group_name: str, + server_name: str, + database_name: str, + *, + filter: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.DatabaseSchema"]: + """List database schemas. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of DatabaseSchema + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseSchema] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseSchema]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_database_schemas_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseSchema], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ManagedDatabaseSchemasOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_database_schemas` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, managed_instance_name: str, database_name: str, schema_name: str, **kwargs: Any + ) -> _models.DatabaseSchema: + """Get managed database schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: DatabaseSchema. The DatabaseSchema is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSchema + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseSchema] = kwargs.pop("cls", None) + + _request = build_managed_database_schemas_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseSchema, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_database( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + *, + filter: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.DatabaseSchema"]: + """List managed database schemas. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of DatabaseSchema + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseSchema] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseSchema]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_database_schemas_list_by_database_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseSchema], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class DatabaseSecurityAlertPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`database_security_alert_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + **kwargs: Any + ) -> _models.DatabaseSecurityAlertPolicy: + """Gets a database's security alert policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 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 + :return: DatabaseSecurityAlertPolicy. The DatabaseSecurityAlertPolicy is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSecurityAlertPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseSecurityAlertPolicy] = kwargs.pop("cls", None) + + _request = build_database_security_alert_policies_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + security_alert_policy_name=security_alert_policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseSecurityAlertPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: _models.DatabaseSecurityAlertPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseSecurityAlertPolicy: + """Creates or updates a database's security alert policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseSecurityAlertPolicy. The DatabaseSecurityAlertPolicy is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSecurityAlertPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseSecurityAlertPolicy: + """Creates or updates a database's security alert policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseSecurityAlertPolicy. The DatabaseSecurityAlertPolicy is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSecurityAlertPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseSecurityAlertPolicy: + """Creates or updates a database's security alert policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 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[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseSecurityAlertPolicy. The DatabaseSecurityAlertPolicy is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSecurityAlertPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: Union[_models.DatabaseSecurityAlertPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.DatabaseSecurityAlertPolicy: + """Creates or updates a database's security alert policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 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 one of the following types: + DatabaseSecurityAlertPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseSecurityAlertPolicy or JSON or IO[bytes] + :return: DatabaseSecurityAlertPolicy. The DatabaseSecurityAlertPolicy is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSecurityAlertPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_database_security_alert_policies_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + security_alert_policy_name=security_alert_policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = 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]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseSecurityAlertPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> ItemPaged["_models.DatabaseSecurityAlertPolicy"]: + """Gets a list of database's security alert policies. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of DatabaseSecurityAlertPolicy + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseSecurityAlertPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_database_security_alert_policies_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseSecurityAlertPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class SqlVulnerabilityAssessmentBaselineOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`sql_vulnerability_assessment_baseline` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: + """Gets a list of database's sql vulnerability assessment rule baselines. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :keyword system_database_name: The vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :return: DatabaseSqlVulnerabilityAssessmentBaselineSet. The + DatabaseSqlVulnerabilityAssessmentBaselineSet is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentBaselineSet] = kwargs.pop("cls", None) + + _request = build_sql_vulnerability_assessment_baseline_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + system_database_name=system_database_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseSqlVulnerabilityAssessmentBaselineSet, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_sql_vulnerability_assessment( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any + ) -> ItemPaged["_models.DatabaseSqlVulnerabilityAssessmentBaselineSet"]: + """Gets a list of database's sql vulnerability assessment rule baselines. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 system_database_name: The vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :return: An iterator like instance of DatabaseSqlVulnerabilityAssessmentBaselineSet + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseSqlVulnerabilityAssessmentBaselineSet]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_sql_vulnerability_assessment_baseline_list_by_sql_vulnerability_assessment_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + system_database_name=system_database_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseSqlVulnerabilityAssessmentBaselineSet], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class SqlVulnerabilityAssessmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`sql_vulnerability_assessments` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + **kwargs: Any + ) -> None: + """Removes SQL Vulnerability Assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" + Required. + :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_sql_vulnerability_assessments_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = 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) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class SqlVulnerabilityAssessmentsSettingsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`sql_vulnerability_assessments_settings` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], + **kwargs: Any + ) -> _models.SqlVulnerabilityAssessment: + """Gets SQL Vulnerability Assessment policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" + Required. + :type vulnerability_assessment_name: str or + ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentName + :return: SqlVulnerabilityAssessment. The SqlVulnerabilityAssessment is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SqlVulnerabilityAssessment] = kwargs.pop("cls", None) + + _request = build_sql_vulnerability_assessments_settings_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SqlVulnerabilityAssessment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: _models.SqlVulnerabilityAssessment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SqlVulnerabilityAssessment: + """Creates or updates SQL Vulnerability Assessment policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" + Required. + :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName + :param parameters: The requested resource. Required. + :type parameters: ~azure.mgmt.sql.models.SqlVulnerabilityAssessment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SqlVulnerabilityAssessment. The SqlVulnerabilityAssessment is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SqlVulnerabilityAssessment: + """Creates or updates SQL Vulnerability Assessment policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" + Required. + :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName + :param parameters: The requested resource. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SqlVulnerabilityAssessment. The SqlVulnerabilityAssessment is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SqlVulnerabilityAssessment: + """Creates or updates SQL Vulnerability Assessment policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" + Required. + :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName + :param parameters: The requested resource. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SqlVulnerabilityAssessment. The SqlVulnerabilityAssessment is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: Union[_models.SqlVulnerabilityAssessment, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.SqlVulnerabilityAssessment: + """Creates or updates SQL Vulnerability Assessment policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" + Required. + :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName + :param parameters: The requested resource. Is one of the following types: + SqlVulnerabilityAssessment, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.SqlVulnerabilityAssessment or JSON or IO[bytes] + :return: SqlVulnerabilityAssessment. The SqlVulnerabilityAssessment is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_sql_vulnerability_assessments_settings_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = 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]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SqlVulnerabilityAssessment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.SqlVulnerabilityAssessment"]: + """Lists SQL Vulnerability Assessment policies associated with a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of SqlVulnerabilityAssessment + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SqlVulnerabilityAssessment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SqlVulnerabilityAssessment]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_sql_vulnerability_assessments_settings_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SqlVulnerabilityAssessment], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`database_sql_vulnerability_assessment_rule_baselines` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + rule_id: str, + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: + """Gets a database's sql vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline. The + DatabaseSqlVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) + + _request = build_database_sql_vulnerability_assessment_rule_baselines_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + baseline_name=baseline_name, + rule_id=rule_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + rule_id: str, + parameters: _models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: + """Creates or updates a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param parameters: The requested rule baseline resource. Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline. The + DatabaseSqlVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + rule_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: + """Creates or updates a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param parameters: The requested rule baseline resource. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline. The + DatabaseSqlVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + rule_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: + """Creates or updates a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param parameters: The requested rule baseline resource. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline. The + DatabaseSqlVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + rule_id: str, + parameters: Union[_models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: + """Creates or updates a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param parameters: The requested rule baseline resource. Is one of the following types: + DatabaseSqlVulnerabilityAssessmentRuleBaselineInput, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput or + JSON or IO[bytes] + :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline. The + DatabaseSqlVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_database_sql_vulnerability_assessment_rule_baselines_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + baseline_name=baseline_name, + rule_id=rule_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + rule_id: str, + **kwargs: Any + ) -> None: + """Removes the database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_database_sql_vulnerability_assessment_rule_baselines_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + baseline_name=baseline_name, + rule_id=rule_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = 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) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_baseline( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + **kwargs: Any + ) -> ItemPaged["_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline"]: + """Gets a list of database's sql vulnerability assessment rule baselines. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :return: An iterator like instance of DatabaseSqlVulnerabilityAssessmentRuleBaseline + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_database_sql_vulnerability_assessment_rule_baselines_list_by_baseline_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class SqlVulnerabilityAssessmentRuleBaselineOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`sql_vulnerability_assessment_rule_baseline` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + rule_id: str, + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: + """Gets a system database's sql vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :keyword system_database_name: The vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline. The + DatabaseSqlVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) + + _request = build_sql_vulnerability_assessment_rule_baseline_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + baseline_name=baseline_name, + rule_id=rule_id, + subscription_id=self._config.subscription_id, + system_database_name=system_database_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + rule_id: str, + parameters: _models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput, + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: + """Creates or updates a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param parameters: The requested rule baseline resource. Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput + :keyword system_database_name: The vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline. The + DatabaseSqlVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + rule_id: str, + parameters: JSON, + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: + """Creates or updates a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param parameters: The requested rule baseline resource. Required. + :type parameters: JSON + :keyword system_database_name: The vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline. The + DatabaseSqlVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + rule_id: str, + parameters: IO[bytes], + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: + """Creates or updates a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param parameters: The requested rule baseline resource. Required. + :type parameters: IO[bytes] + :keyword system_database_name: The vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline. The + DatabaseSqlVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + rule_id: str, + parameters: Union[_models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput, JSON, IO[bytes]], + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: + """Creates or updates a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param parameters: The requested rule baseline resource. Is one of the following types: + DatabaseSqlVulnerabilityAssessmentRuleBaselineInput, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput or + JSON or IO[bytes] + :keyword system_database_name: The vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline. The + DatabaseSqlVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_sql_vulnerability_assessment_rule_baseline_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + baseline_name=baseline_name, + rule_id=rule_id, + subscription_id=self._config.subscription_id, + system_database_name=system_database_name, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_baseline( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any + ) -> ItemPaged["_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline"]: + """Gets a system database's sql vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :keyword system_database_name: The vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :return: An iterator like instance of DatabaseSqlVulnerabilityAssessmentRuleBaseline + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_sql_vulnerability_assessment_rule_baseline_list_by_baseline_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + system_database_name=system_database_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class DatabaseSqlVulnerabilityAssessmentScanResultOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`database_sql_vulnerability_assessment_scan_result` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], + scan_id: str, + scan_result_id: str, + **kwargs: Any + ) -> _models.SqlVulnerabilityAssessmentScanResults: + """Gets a vulnerability assessment scan record of a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 SQL Vulnerability Assessment. "default" + Required. + :type vulnerability_assessment_name: str or + ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentName + :param scan_id: The scan id of the SQL Vulnerability Assessment scan to retrieve result from. + Required. + :type scan_id: str + :param scan_result_id: The scan result id of the specific result to retrieve. Required. + :type scan_result_id: str + :return: SqlVulnerabilityAssessmentScanResults. The SqlVulnerabilityAssessmentScanResults is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanResults + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SqlVulnerabilityAssessmentScanResults] = kwargs.pop("cls", None) + + _request = build_database_sql_vulnerability_assessment_scan_result_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + scan_id=scan_id, + scan_result_id=scan_result_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SqlVulnerabilityAssessmentScanResults, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_scan( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], + scan_id: str, + **kwargs: Any + ) -> ItemPaged["_models.SqlVulnerabilityAssessmentScanResults"]: + """Gets a vulnerability assessment scan record of a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 SQL Vulnerability Assessment. "default" + Required. + :type vulnerability_assessment_name: str or + ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentName + :param scan_id: The scan id of the SQL Vulnerability Assessment scan to retrieve result from. + Required. + :type scan_id: str + :return: An iterator like instance of SqlVulnerabilityAssessmentScanResults + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SqlVulnerabilityAssessmentScanResults]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_database_sql_vulnerability_assessment_scan_result_list_by_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SqlVulnerabilityAssessmentScanResults], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class SqlVulnerabilityAssessmentScanResultOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`sql_vulnerability_assessment_scan_result` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], + scan_id: str, + scan_result_id: str, + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any + ) -> _models.SqlVulnerabilityAssessmentScanResults: + """Gets a vulnerability assessment scan record of a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" + Required. + :type vulnerability_assessment_name: str or + ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentName + :param scan_id: The scan id of the SQL Vulnerability Assessment scan to retrieve result from. + Required. + :type scan_id: str + :param scan_result_id: The scan result id of the specific result to retrieve. Required. + :type scan_result_id: str + :keyword system_database_name: The SQL vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :return: SqlVulnerabilityAssessmentScanResults. The SqlVulnerabilityAssessmentScanResults is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanResults + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SqlVulnerabilityAssessmentScanResults] = kwargs.pop("cls", None) + + _request = build_sql_vulnerability_assessment_scan_result_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + scan_id=scan_id, + scan_result_id=scan_result_id, + subscription_id=self._config.subscription_id, + system_database_name=system_database_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SqlVulnerabilityAssessmentScanResults, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_scan( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], + scan_id: str, + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any + ) -> ItemPaged["_models.SqlVulnerabilityAssessmentScanResults"]: + """Gets a vulnerability assessment scan record of a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" + Required. + :type vulnerability_assessment_name: str or + ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentName + :param scan_id: The scan id of the SQL Vulnerability Assessment scan to retrieve result from. + Required. + :type scan_id: str + :keyword system_database_name: The SQL vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :return: An iterator like instance of SqlVulnerabilityAssessmentScanResults + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SqlVulnerabilityAssessmentScanResults]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_sql_vulnerability_assessment_scan_result_list_by_scan_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + scan_id=scan_id, + subscription_id=self._config.subscription_id, + system_database_name=system_database_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SqlVulnerabilityAssessmentScanResults], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class SqlVulnerabilityAssessmentScansOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`sql_vulnerability_assessment_scans` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + scan_id: str, + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any + ) -> _models.SqlVulnerabilityAssessmentScanRecord: + """Get a system database vulnerability assessment scan record. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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: Required. + :type scan_id: str + :keyword system_database_name: The vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :return: SqlVulnerabilityAssessmentScanRecord. The SqlVulnerabilityAssessmentScanRecord is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanRecord + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SqlVulnerabilityAssessmentScanRecord] = kwargs.pop("cls", None) + + _request = build_sql_vulnerability_assessment_scans_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + scan_id=scan_id, + subscription_id=self._config.subscription_id, + system_database_name=system_database_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SqlVulnerabilityAssessmentScanRecord, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_sql_vulnerability_assessments( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any + ) -> ItemPaged["_models.SqlVulnerabilityAssessmentScanRecord"]: + """Lists the vulnerability assessment scans of a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 system_database_name: The vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :return: An iterator like instance of SqlVulnerabilityAssessmentScanRecord + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanRecord] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SqlVulnerabilityAssessmentScanRecord]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_sql_vulnerability_assessment_scans_list_by_sql_vulnerability_assessments_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + system_database_name=system_database_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SqlVulnerabilityAssessmentScanRecord], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class DatabaseVulnerabilityAssessmentRuleBaselinesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`database_vulnerability_assessment_rule_baselines` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + rule_id: str, + baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: + """Gets a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 rule + baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a + baseline on a database level rule and master for server level rule). Known values are: "master" + and "default". Required. + :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName + :return: DatabaseVulnerabilityAssessmentRuleBaseline. The + DatabaseVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) + + _request = build_database_vulnerability_assessment_rule_baselines_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + rule_id=rule_id, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseVulnerabilityAssessmentRuleBaseline, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + rule_id: str, + baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], + parameters: _models.DatabaseVulnerabilityAssessmentRuleBaseline, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: + """Creates or updates a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 rule + baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a + baseline on a database level rule and master for server level rule). Known values are: "master" + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseVulnerabilityAssessmentRuleBaseline. The + DatabaseVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + rule_id: str, + baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: + """Creates or updates a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 rule + baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a + baseline on a database level rule and master for server level rule). Known values are: "master" + and "default". Required. + :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName + :param parameters: The requested rule baseline resource. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseVulnerabilityAssessmentRuleBaseline. The + DatabaseVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + rule_id: str, + baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: + """Creates or updates a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 rule + baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a + baseline on a database level rule and master for server level rule). Known values are: "master" + and "default". Required. + :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName + :param parameters: The requested rule baseline resource. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseVulnerabilityAssessmentRuleBaseline. The + DatabaseVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + rule_id: str, + baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], + parameters: Union[_models.DatabaseVulnerabilityAssessmentRuleBaseline, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: + """Creates or updates a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 rule + baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a + baseline on a database level rule and master for server level rule). Known values are: "master" + and "default". Required. + :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName + :param parameters: The requested rule baseline resource. Is one of the following types: + DatabaseVulnerabilityAssessmentRuleBaseline, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline or JSON or + IO[bytes] + :return: DatabaseVulnerabilityAssessmentRuleBaseline. The + DatabaseVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_database_vulnerability_assessment_rule_baselines_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + rule_id=rule_id, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseVulnerabilityAssessmentRuleBaseline, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + rule_id: str, + baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], + **kwargs: Any + ) -> None: + """Removes the database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 rule + baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a + baseline on a database level rule and master for server level rule). Known values are: "master" + and "default". Required. + :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_database_vulnerability_assessment_rule_baselines_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + rule_id=rule_id, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_database_vulnerability_assessment_rule_baselines` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + rule_id: str, + baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: + """Gets a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 rule + baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a + baseline on a database level rule and master for server level rule). Known values are: "master" + and "default". Required. + :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName + :return: DatabaseVulnerabilityAssessmentRuleBaseline. The + DatabaseVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) + + _request = build_managed_database_vulnerability_assessment_rule_baselines_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + rule_id=rule_id, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseVulnerabilityAssessmentRuleBaseline, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + rule_id: str, + baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], + parameters: _models.DatabaseVulnerabilityAssessmentRuleBaseline, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: + """Creates or updates a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 rule + baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a + baseline on a database level rule and master for server level rule). Known values are: "master" + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseVulnerabilityAssessmentRuleBaseline. The + DatabaseVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + rule_id: str, + baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: + """Creates or updates a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 rule + baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a + baseline on a database level rule and master for server level rule). Known values are: "master" + and "default". Required. + :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName + :param parameters: The requested rule baseline resource. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseVulnerabilityAssessmentRuleBaseline. The + DatabaseVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + rule_id: str, + baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: + """Creates or updates a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 rule + baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a + baseline on a database level rule and master for server level rule). Known values are: "master" + and "default". Required. + :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName + :param parameters: The requested rule baseline resource. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseVulnerabilityAssessmentRuleBaseline. The + DatabaseVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + rule_id: str, + baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], + parameters: Union[_models.DatabaseVulnerabilityAssessmentRuleBaseline, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: + """Creates or updates a database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 rule + baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a + baseline on a database level rule and master for server level rule). Known values are: "master" + and "default". Required. + :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName + :param parameters: The requested rule baseline resource. Is one of the following types: + DatabaseVulnerabilityAssessmentRuleBaseline, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline or JSON or + IO[bytes] + :return: DatabaseVulnerabilityAssessmentRuleBaseline. The + DatabaseVulnerabilityAssessmentRuleBaseline is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_database_vulnerability_assessment_rule_baselines_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + rule_id=rule_id, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseVulnerabilityAssessmentRuleBaseline, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + rule_id: str, + baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], + **kwargs: Any + ) -> None: + """Removes the database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 rule + baseline is defined. 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 rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a + baseline on a database level rule and master for server level rule). Known values are: "master" + and "default". Required. + :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_managed_database_vulnerability_assessment_rule_baselines_delete_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + rule_id=rule_id, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class DatabaseVulnerabilityAssessmentsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`database_vulnerability_assessments` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessment: + """Gets the database's vulnerability assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 is + defined. 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 + :return: DatabaseVulnerabilityAssessment. The DatabaseVulnerabilityAssessment is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseVulnerabilityAssessment] = kwargs.pop("cls", None) + + _request = build_database_vulnerability_assessments_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseVulnerabilityAssessment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: _models.DatabaseVulnerabilityAssessment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessment: + """Creates or updates the database's vulnerability assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 is + defined. 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 parameters: The requested resource. Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseVulnerabilityAssessment. The DatabaseVulnerabilityAssessment is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessment: + """Creates or updates the database's vulnerability assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 is + defined. 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 parameters: The requested resource. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseVulnerabilityAssessment. The DatabaseVulnerabilityAssessment is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessment: + """Creates or updates the database's vulnerability assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 is + defined. 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 parameters: The requested resource. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseVulnerabilityAssessment. The DatabaseVulnerabilityAssessment is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: Union[_models.DatabaseVulnerabilityAssessment, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessment: + """Creates or updates the database's vulnerability assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 is + defined. 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 parameters: The requested resource. Is one of the following types: + DatabaseVulnerabilityAssessment, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment or JSON or IO[bytes] + :return: DatabaseVulnerabilityAssessment. The DatabaseVulnerabilityAssessment is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_database_vulnerability_assessments_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = 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]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseVulnerabilityAssessment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + **kwargs: Any + ) -> None: + """Removes the database's vulnerability assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 is + defined. 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 + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_database_vulnerability_assessments_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> ItemPaged["_models.DatabaseVulnerabilityAssessment"]: + """Lists the vulnerability assessment policies associated with a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 is + defined. Required. + :type database_name: str + :return: An iterator like instance of DatabaseVulnerabilityAssessment + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseVulnerabilityAssessment]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_database_vulnerability_assessments_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseVulnerabilityAssessment], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ManagedDatabaseVulnerabilityAssessmentsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_database_vulnerability_assessments` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessment: + """Gets the database's vulnerability assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. + :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName + :return: DatabaseVulnerabilityAssessment. The DatabaseVulnerabilityAssessment is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseVulnerabilityAssessment] = kwargs.pop("cls", None) + + _request = build_managed_database_vulnerability_assessments_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseVulnerabilityAssessment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: _models.DatabaseVulnerabilityAssessment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessment: + """Creates or updates the database's vulnerability assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. + :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName + :param parameters: The requested resource. Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseVulnerabilityAssessment. The DatabaseVulnerabilityAssessment is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessment: + """Creates or updates the database's vulnerability assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. + :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName + :param parameters: The requested resource. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseVulnerabilityAssessment. The DatabaseVulnerabilityAssessment is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessment: + """Creates or updates the database's vulnerability assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. + :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName + :param parameters: The requested resource. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseVulnerabilityAssessment. The DatabaseVulnerabilityAssessment is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: Union[_models.DatabaseVulnerabilityAssessment, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessment: + """Creates or updates the database's vulnerability assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. + :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName + :param parameters: The requested resource. Is one of the following types: + DatabaseVulnerabilityAssessment, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment or JSON or IO[bytes] + :return: DatabaseVulnerabilityAssessment. The DatabaseVulnerabilityAssessment is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_database_vulnerability_assessments_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = 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]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseVulnerabilityAssessment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + **kwargs: Any + ) -> None: + """Removes the database's vulnerability assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. + :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_managed_database_vulnerability_assessments_delete_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_database( + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> ItemPaged["_models.DatabaseVulnerabilityAssessment"]: + """Lists the vulnerability assessments of a managed database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An iterator like instance of DatabaseVulnerabilityAssessment + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseVulnerabilityAssessment]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_database_vulnerability_assessments_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseVulnerabilityAssessment], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ManagedDatabaseVulnerabilityAssessmentScansOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_database_vulnerability_assessment_scans` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + scan_id: str, + **kwargs: Any + ) -> _models.VulnerabilityAssessmentScanRecord: + """Gets a vulnerability assessment scan record of a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. Required. + :type scan_id: str + :return: VulnerabilityAssessmentScanRecord. The VulnerabilityAssessmentScanRecord is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecord + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.VulnerabilityAssessmentScanRecord] = kwargs.pop("cls", None) + + _request = build_managed_database_vulnerability_assessment_scans_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.VulnerabilityAssessmentScanRecord, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @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], + **kwargs: Any + ) -> ItemPaged["_models.VulnerabilityAssessmentScanRecord"]: + """Lists the vulnerability assessment scans of a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An iterator like instance of VulnerabilityAssessmentScanRecord + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecord] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.VulnerabilityAssessmentScanRecord]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_database_vulnerability_assessment_scans_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.VulnerabilityAssessmentScanRecord], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def export( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + scan_id: str, + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessmentScansExport: + """Convert an existing scan result to a human readable format. If already exists nothing happens. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. Required. + :type scan_id: str + :return: DatabaseVulnerabilityAssessmentScansExport. The + DatabaseVulnerabilityAssessmentScansExport is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentScansExport + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseVulnerabilityAssessmentScansExport] = kwargs.pop("cls", None) + + _request = build_managed_database_vulnerability_assessment_scans_export_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + scan_id=scan_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = 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]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseVulnerabilityAssessmentScansExport, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _initiate_scan_initial( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + scan_id: str, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_database_vulnerability_assessment_scans_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_initiate_scan( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + scan_id: str, + **kwargs: Any + ) -> LROPoller[None]: + """Executes a Vulnerability Assessment database scan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. Required. + :type scan_id: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class DataMaskingPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`data_masking_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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. The name is case insensitive. + Required. + :type resource_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 + :return: DataMaskingPolicy. The DataMaskingPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DataMaskingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DataMaskingPolicy] = kwargs.pop("cls", None) + + _request = build_data_masking_policies_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DataMaskingPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @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", + **kwargs: Any + ) -> _models.DataMaskingPolicy: + """Creates or updates a database data masking policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :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 + :return: DataMaskingPolicy. The DataMaskingPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DataMaskingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataMaskingPolicy: + """Creates or updates a database data masking policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :param parameters: Parameters for creating or updating a data masking policy. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DataMaskingPolicy. The DataMaskingPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DataMaskingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataMaskingPolicy: + """Creates or updates a database data masking policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :param parameters: Parameters for creating or updating a data masking policy. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DataMaskingPolicy. The DataMaskingPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DataMaskingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + data_masking_policy_name: Union[str, _models.DataMaskingPolicyName], + parameters: Union[_models.DataMaskingPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.DataMaskingPolicy: + """Creates or updates a database data masking policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :param parameters: Parameters for creating or updating a data masking policy. Is one of the + following types: DataMaskingPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DataMaskingPolicy or JSON or IO[bytes] + :return: DataMaskingPolicy. The DataMaskingPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DataMaskingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_data_masking_policies_create_or_update_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = 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]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DataMaskingPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class DeletedServersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`deleted_servers` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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 + :return: DeletedServer. The DeletedServer is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DeletedServer + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DeletedServer] = kwargs.pop("cls", None) + + _request = build_deleted_servers_get_request( + location_name=location_name, + deleted_server_name=deleted_server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DeletedServer, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_location(self, location_name: str, **kwargs: Any) -> ItemPaged["_models.DeletedServer"]: + """Gets a list of deleted servers for a location. + + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :return: An iterator like instance of DeletedServer + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DeletedServer] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DeletedServer]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_deleted_servers_list_by_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DeletedServer], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _recover_initial(self, location_name: str, deleted_server_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_deleted_servers_recover_request( + location_name=location_name, + deleted_server_name=deleted_server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_recover( + self, location_name: str, deleted_server_name: str, **kwargs: Any + ) -> LROPoller[_models.DeletedServer]: + """Recovers a deleted server. + + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :param deleted_server_name: The name of the deleted server. Required. + :type deleted_server_name: str + :return: An instance of LROPoller that returns DeletedServer. The DeletedServer is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.DeletedServer] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._recover_initial( + location_name=location_name, + deleted_server_name=deleted_server_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.DeletedServer, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.DeletedServer].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.DeletedServer]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged["_models.DeletedServer"]: + """Gets a list of all deleted servers in a subscription. + + :return: An iterator like instance of DeletedServer + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DeletedServer] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DeletedServer]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_deleted_servers_list_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DeletedServer], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class DistributedAvailabilityGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`distributed_availability_groups` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + **kwargs: Any + ) -> _models.DistributedAvailabilityGroup: + """Gets a distributed availability group info. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: DistributedAvailabilityGroup. The DistributedAvailabilityGroup is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.DistributedAvailabilityGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DistributedAvailabilityGroup] = kwargs.pop("cls", None) + + _request = build_distributed_availability_groups_get_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DistributedAvailabilityGroup, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: Union[_models.DistributedAvailabilityGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_distributed_availability_groups_create_or_update_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: _models.DistributedAvailabilityGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DistributedAvailabilityGroup]: + """Creates a distributed availability group between Sql On-Prem and Sql Managed Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 info. Required. + :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns DistributedAvailabilityGroup. The + DistributedAvailabilityGroup is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DistributedAvailabilityGroup]: + """Creates a distributed availability group between Sql On-Prem and Sql Managed Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 info. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns DistributedAvailabilityGroup. The + DistributedAvailabilityGroup is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DistributedAvailabilityGroup]: + """Creates a distributed availability group between Sql On-Prem and Sql Managed Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 info. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns DistributedAvailabilityGroup. The + DistributedAvailabilityGroup is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: Union[_models.DistributedAvailabilityGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.DistributedAvailabilityGroup]: + """Creates a distributed availability group between Sql On-Prem and Sql Managed Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 info. Is one of the following types: + DistributedAvailabilityGroup, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroup or JSON or IO[bytes] + :return: An instance of LROPoller that returns DistributedAvailabilityGroup. The + DistributedAvailabilityGroup is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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._create_or_update_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + distributed_availability_group_name=distributed_availability_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.DistributedAvailabilityGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.DistributedAvailabilityGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.DistributedAvailabilityGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: Union[_models.DistributedAvailabilityGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_distributed_availability_groups_update_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: _models.DistributedAvailabilityGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DistributedAvailabilityGroup]: + """Updates a distributed availability group replication mode. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 info. Required. + :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns DistributedAvailabilityGroup. The + DistributedAvailabilityGroup is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DistributedAvailabilityGroup]: + """Updates a distributed availability group replication mode. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 info. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns DistributedAvailabilityGroup. The + DistributedAvailabilityGroup is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DistributedAvailabilityGroup]: + """Updates a distributed availability group replication mode. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 info. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns DistributedAvailabilityGroup. The + DistributedAvailabilityGroup is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: Union[_models.DistributedAvailabilityGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.DistributedAvailabilityGroup]: + """Updates a distributed availability group replication mode. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 info. Is one of the following types: + DistributedAvailabilityGroup, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroup or JSON or IO[bytes] + :return: An instance of LROPoller that returns DistributedAvailabilityGroup. The + DistributedAvailabilityGroup is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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._update_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + distributed_availability_group_name=distributed_availability_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.DistributedAvailabilityGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.DistributedAvailabilityGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.DistributedAvailabilityGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_distributed_availability_groups_delete_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Drops a distributed availability group between Sql On-Prem and Sql Managed Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + distributed_availability_group_name=distributed_availability_group_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> ItemPaged["_models.DistributedAvailabilityGroup"]: + """Gets a list of a distributed availability groups in instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of DistributedAvailabilityGroup + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DistributedAvailabilityGroup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_distributed_availability_groups_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DistributedAvailabilityGroup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _failover_initial( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: Union[_models.DistributedAvailabilityGroupsFailoverRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_distributed_availability_groups_failover_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_failover( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: _models.DistributedAvailabilityGroupsFailoverRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DistributedAvailabilityGroup]: + """Performs requested failover type in this distributed availability group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 failover request parameters. Required. + :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroupsFailoverRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns DistributedAvailabilityGroup. The + DistributedAvailabilityGroup is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_failover( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DistributedAvailabilityGroup]: + """Performs requested failover type in this distributed availability group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 failover request parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns DistributedAvailabilityGroup. The + DistributedAvailabilityGroup is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_failover( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DistributedAvailabilityGroup]: + """Performs requested failover type in this distributed availability group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 failover request parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns DistributedAvailabilityGroup. The + DistributedAvailabilityGroup is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_failover( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: Union[_models.DistributedAvailabilityGroupsFailoverRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.DistributedAvailabilityGroup]: + """Performs requested failover type in this distributed availability group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 failover request parameters. Is one of + the following types: DistributedAvailabilityGroupsFailoverRequest, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroupsFailoverRequest or JSON + or IO[bytes] + :return: An instance of LROPoller that returns DistributedAvailabilityGroup. The + DistributedAvailabilityGroup is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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._failover_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + distributed_availability_group_name=distributed_availability_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.DistributedAvailabilityGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.DistributedAvailabilityGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.DistributedAvailabilityGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _set_role_initial( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: Union[_models.DistributedAvailabilityGroupSetRole, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_distributed_availability_groups_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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. The name is case insensitive. + 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 + :return: An instance of LROPoller that returns DistributedAvailabilityGroup. The + DistributedAvailabilityGroup is compatible with MutableMapping + :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: JSON, + *, + 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. The name is case insensitive. + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns DistributedAvailabilityGroup. The + DistributedAvailabilityGroup is compatible with MutableMapping + :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[bytes], + *, + 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. The name is case insensitive. + 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[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns DistributedAvailabilityGroup. The + DistributedAvailabilityGroup is compatible with MutableMapping + :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, JSON, IO[bytes]], + **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. The name is case insensitive. + 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 one of + the following types: DistributedAvailabilityGroupSetRole, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroupSetRole or JSON or + IO[bytes] + :return: An instance of LROPoller that returns DistributedAvailabilityGroup. The + DistributedAvailabilityGroup is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.DistributedAvailabilityGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.DistributedAvailabilityGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.DistributedAvailabilityGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class ManagedDatabasesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_databases` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> _models.ManagedDatabase: + """Gets a managed database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: ManagedDatabase. The ManagedDatabase is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedDatabase + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedDatabase] = kwargs.pop("cls", None) + + _request = build_managed_databases_get_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedDatabase, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: Union[_models.ManagedDatabase, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_databases_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: _models.ManagedDatabase, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedDatabase]: + """Creates a new database or updates an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: The requested database resource state. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedDatabase + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedDatabase. The ManagedDatabase is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedDatabase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedDatabase]: + """Creates a new database or updates an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: The requested database resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedDatabase. The ManagedDatabase is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedDatabase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedDatabase]: + """Creates a new database or updates an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: The requested database resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedDatabase. The ManagedDatabase is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedDatabase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: Union[_models.ManagedDatabase, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ManagedDatabase]: + """Creates a new database or updates an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: The requested database resource state. Is one of the following types: + ManagedDatabase, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedDatabase or JSON or IO[bytes] + :return: An instance of LROPoller that returns ManagedDatabase. The ManagedDatabase is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedDatabase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + database_name=database_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedDatabase, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ManagedDatabase].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ManagedDatabase]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: Union[_models.ManagedDatabaseUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_databases_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: _models.ManagedDatabaseUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedDatabase]: + """Updates an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: The requested database resource state. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedDatabase. The ManagedDatabase is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedDatabase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedDatabase]: + """Updates an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: The requested database resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedDatabase. The ManagedDatabase is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedDatabase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedDatabase]: + """Updates an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: The requested database resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedDatabase. The ManagedDatabase is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedDatabase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: Union[_models.ManagedDatabaseUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ManagedDatabase]: + """Updates an existing database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: The requested database resource state. Is one of the following types: + ManagedDatabaseUpdate, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseUpdate or JSON or IO[bytes] + :return: An instance of LROPoller that returns ManagedDatabase. The ManagedDatabase is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedDatabase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedDatabase, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ManagedDatabase].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ManagedDatabase]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_databases_delete_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a managed database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> ItemPaged["_models.ManagedDatabase"]: + """Gets a list of managed databases. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of ManagedDatabase + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedDatabase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedDatabase]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_databases_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedDatabase], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _cancel_move_initial( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: Union[_models.ManagedDatabaseMoveDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_databases_cancel_move_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_cancel_move( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: _models.ManagedDatabaseMoveDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Cancels a managed database move operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: Parameters of the cancel managed database move operation. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseMoveDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_cancel_move( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Cancels a managed database move operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: Parameters of the cancel managed database move operation. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_cancel_move( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Cancels a managed database move operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: Parameters of the cancel managed database move operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_cancel_move( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: Union[_models.ManagedDatabaseMoveDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[None]: + """Cancels a managed database move operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: Parameters of the cancel managed database move operation. Is one of the + following types: ManagedDatabaseMoveDefinition, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseMoveDefinition or JSON or IO[bytes] + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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._cancel_move_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _complete_move_initial( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: Union[_models.ManagedDatabaseMoveDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_databases_complete_move_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_complete_move( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: _models.ManagedDatabaseMoveDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Completes a managed database move operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: Parameters of the complete managed database move operation. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseMoveDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_complete_move( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Completes a managed database move operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: Parameters of the complete managed database move operation. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_complete_move( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Completes a managed database move operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: Parameters of the complete managed database move operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_complete_move( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: Union[_models.ManagedDatabaseMoveDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[None]: + """Completes a managed database move operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: Parameters of the complete managed database move operation. Is one of the + following types: ManagedDatabaseMoveDefinition, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseMoveDefinition or JSON or IO[bytes] + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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._complete_move_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _complete_restore_initial( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: Union[_models.CompleteDatabaseRestoreDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_databases_complete_restore_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_complete_restore( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: _models.CompleteDatabaseRestoreDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Completes the restore operation on a managed database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: The definition for completing the restore of this managed database. + Required. + :type parameters: ~azure.mgmt.sql.models.CompleteDatabaseRestoreDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_complete_restore( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Completes the restore operation on a managed database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: The definition for completing the restore of this managed database. + Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_complete_restore( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Completes the restore operation on a managed database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: The definition for completing the restore of this managed database. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_complete_restore( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: Union[_models.CompleteDatabaseRestoreDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[None]: + """Completes the restore operation on a managed database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: The definition for completing the restore of this managed database. Is one + of the following types: CompleteDatabaseRestoreDefinition, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.CompleteDatabaseRestoreDefinition or JSON or IO[bytes] + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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._complete_restore_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _reevaluate_inaccessible_database_state_initial( # pylint: disable=name-too-long + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_databases_reevaluate_inaccessible_database_state_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_reevaluate_inaccessible_database_state( # pylint: disable=name-too-long + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> LROPoller[_models.ManagedDatabase]: + """Reevaluates the inaccessibility state of a managed database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An instance of LROPoller that returns ManagedDatabase. The ManagedDatabase is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedDatabase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedDatabase] = 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._reevaluate_inaccessible_database_state_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ManagedDatabase, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ManagedDatabase].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ManagedDatabase]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _start_move_initial( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: Union[_models.ManagedDatabaseStartMoveDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_databases_start_move_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_start_move( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: _models.ManagedDatabaseStartMoveDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Starts a managed database move operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: Parameters of the start managed database move operation. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseStartMoveDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_start_move( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Starts a managed database move operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: Parameters of the start managed database move operation. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_start_move( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Starts a managed database move operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: Parameters of the start managed database move operation. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_start_move( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: Union[_models.ManagedDatabaseStartMoveDefinition, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[None]: + """Starts a managed database move operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: Parameters of the start managed database move operation. Is one of the + following types: ManagedDatabaseStartMoveDefinition, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseStartMoveDefinition or JSON or + IO[bytes] + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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_move_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_inaccessible_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> ItemPaged["_models.ManagedDatabase"]: + """Gets a list of inaccessible managed databases in a managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of ManagedDatabase + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedDatabase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedDatabase]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_databases_list_inaccessible_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedDatabase], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ServerTrustGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`server_trust_groups` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, location_name: str, server_trust_group_name: str, **kwargs: Any + ) -> _models.ServerTrustGroup: + """Gets a server trust group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :param server_trust_group_name: The name of the server trust group. Required. + :type server_trust_group_name: str + :return: ServerTrustGroup. The ServerTrustGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerTrustGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ServerTrustGroup] = kwargs.pop("cls", None) + + _request = build_server_trust_groups_get_request( + resource_group_name=resource_group_name, + location_name=location_name, + server_trust_group_name=server_trust_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ServerTrustGroup, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + location_name: str, + server_trust_group_name: str, + parameters: Union[_models.ServerTrustGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_server_trust_groups_create_or_update_request( + resource_group_name=resource_group_name, + location_name=location_name, + server_trust_group_name=server_trust_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + location_name: str, + server_trust_group_name: str, + parameters: _models.ServerTrustGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerTrustGroup]: + """Creates or updates a server trust group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :param server_trust_group_name: The name of the server trust group. Required. + :type server_trust_group_name: str + :param parameters: The server trust group parameters. Required. + :type parameters: ~azure.mgmt.sql.models.ServerTrustGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerTrustGroup. The ServerTrustGroup is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerTrustGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + location_name: str, + server_trust_group_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerTrustGroup]: + """Creates or updates a server trust group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :param server_trust_group_name: The name of the server trust group. Required. + :type server_trust_group_name: str + :param parameters: The server trust group parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerTrustGroup. The ServerTrustGroup is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerTrustGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + location_name: str, + server_trust_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerTrustGroup]: + """Creates or updates a server trust group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :param server_trust_group_name: The name of the server trust group. Required. + :type server_trust_group_name: str + :param parameters: The server trust group parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerTrustGroup. The ServerTrustGroup is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerTrustGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + location_name: str, + server_trust_group_name: str, + parameters: Union[_models.ServerTrustGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ServerTrustGroup]: + """Creates or updates a server trust group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :param server_trust_group_name: The name of the server trust group. Required. + :type server_trust_group_name: str + :param parameters: The server trust group parameters. Is one of the following types: + ServerTrustGroup, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ServerTrustGroup or JSON or IO[bytes] + :return: An instance of LROPoller that returns ServerTrustGroup. The ServerTrustGroup is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerTrustGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + location_name=location_name, + server_trust_group_name=server_trust_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ServerTrustGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ServerTrustGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ServerTrustGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, location_name: str, server_trust_group_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_server_trust_groups_delete_request( + resource_group_name=resource_group_name, + location_name=location_name, + server_trust_group_name=server_trust_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, location_name: str, server_trust_group_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a server trust group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :param server_trust_group_name: The name of the server trust group. Required. + :type server_trust_group_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + location_name=location_name, + server_trust_group_name=server_trust_group_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_location( + self, resource_group_name: str, location_name: str, **kwargs: Any + ) -> ItemPaged["_models.ServerTrustGroup"]: + """Lists a server trust group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :return: An iterator like instance of ServerTrustGroup + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerTrustGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerTrustGroup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_server_trust_groups_list_by_location_request( + resource_group_name=resource_group_name, + location_name=location_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ServerTrustGroup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> ItemPaged["_models.ServerTrustGroup"]: + """Gets a server trust groups by instance name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of ServerTrustGroup + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerTrustGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerTrustGroup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_server_trust_groups_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ServerTrustGroup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ManagedInstancesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_instances` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, managed_instance_name: str, *, expand: Optional[str] = None, **kwargs: Any + ) -> _models.ManagedInstance: + """Gets a managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :keyword expand: The child resources to include in the response. Default value is None. + :paramtype expand: str + :return: ManagedInstance. The ManagedInstance is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedInstance] = kwargs.pop("cls", None) + + _request = build_managed_instances_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedInstance, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: Union[_models.ManagedInstance, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_instances_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: _models.ManagedInstance, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedInstance]: + """Creates or updates a managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: The requested managed instance resource state. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstance + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedInstance. The ManagedInstance is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedInstance]: + """Creates or updates a managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: The requested managed instance resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedInstance. The ManagedInstance is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedInstance]: + """Creates or updates a managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: The requested managed instance resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedInstance. The ManagedInstance is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: Union[_models.ManagedInstance, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ManagedInstance]: + """Creates or updates a managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: The requested managed instance resource state. Is one of the following + types: ManagedInstance, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstance or JSON or IO[bytes] + :return: An instance of LROPoller that returns ManagedInstance. The ManagedInstance is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedInstance, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ManagedInstance].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ManagedInstance]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: Union[_models.ManagedInstanceUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_instances_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: _models.ManagedInstanceUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedInstance]: + """Updates a managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: The requested managed instance resource state. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedInstance. The ManagedInstance is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedInstance]: + """Updates a managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: The requested managed instance resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedInstance. The ManagedInstance is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedInstance]: + """Updates a managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: The requested managed instance resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedInstance. The ManagedInstance is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: Union[_models.ManagedInstanceUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ManagedInstance]: + """Updates a managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: The requested managed instance resource state. Is one of the following + types: ManagedInstanceUpdate, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceUpdate or JSON or IO[bytes] + :return: An instance of LROPoller that returns ManagedInstance. The ManagedInstance is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedInstance, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ManagedInstance].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ManagedInstance]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial(self, resource_group_name: str, managed_instance_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_instances_delete_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete(self, resource_group_name: str, managed_instance_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes a managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, *, expand: Optional[str] = None, **kwargs: Any + ) -> ItemPaged["_models.ManagedInstance"]: + """Gets a list of managed instances in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword expand: The child resources to include in the response. Default value is None. + :paramtype expand: str + :return: An iterator like instance of ManagedInstance + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstance]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_instances_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstance], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, *, expand: Optional[str] = None, **kwargs: Any) -> ItemPaged["_models.ManagedInstance"]: + """Gets a list of all managed instances in the subscription. + + :keyword expand: The child resources to include in the response. Default value is None. + :paramtype expand: str + :return: An iterator like instance of ManagedInstance + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstance]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_instances_list_request( + subscription_id=self._config.subscription_id, + expand=expand, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstance], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _failover_initial( + self, + resource_group_name: str, + managed_instance_name: str, + *, + replica_type: Optional[Union[str, _models.ReplicaType]] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_instances_failover_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + replica_type=replica_type, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_failover( + self, + resource_group_name: str, + managed_instance_name: str, + *, + replica_type: Optional[Union[str, _models.ReplicaType]] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Failovers a managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :keyword replica_type: The type of replica to be failed over. Known values are: "Primary" and + "ReadableSecondary". Default value is None. + :paramtype replica_type: str or ~azure.mgmt.sql.models.ReplicaType + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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._failover_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + replica_type=replica_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_outbound_network_dependencies_by_managed_instance( # pylint: disable=name-too-long + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> ItemPaged["_models.OutboundEnvironmentEndpoint"]: + """Gets the collection of outbound network dependencies for the given managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of OutboundEnvironmentEndpoint + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.OutboundEnvironmentEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.OutboundEnvironmentEndpoint]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_instances_list_outbound_network_dependencies_by_managed_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.OutboundEnvironmentEndpoint], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _reevaluate_inaccessible_database_state_initial( # pylint: disable=name-too-long + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_instances_reevaluate_inaccessible_database_state_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_reevaluate_inaccessible_database_state( # pylint: disable=name-too-long + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Reevaluates the inaccessibility state of all managed databases. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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._reevaluate_inaccessible_database_state_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _refresh_status_initial( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_instances_refresh_status_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An instance of LROPoller that returns + RefreshExternalGovernanceStatusOperationResultMI. The + RefreshExternalGovernanceStatusOperationResultMI is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.RefreshExternalGovernanceStatusOperationResultMI] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.RefreshExternalGovernanceStatusOperationResultMI, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.RefreshExternalGovernanceStatusOperationResultMI].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.RefreshExternalGovernanceStatusOperationResultMI]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _start_initial(self, resource_group_name: str, managed_instance_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_instances_start_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + 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. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An instance of LROPoller that returns ManagedInstance. The ManagedInstance is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ManagedInstance, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ManagedInstance].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ManagedInstance]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _stop_initial(self, resource_group_name: str, managed_instance_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_instances_stop_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + 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. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An instance of LROPoller that returns ManagedInstance. The ManagedInstance is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ManagedInstance, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ManagedInstance].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ManagedInstance]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_managed_instance( + self, + resource_group_name: str, + managed_instance_name: str, + *, + number_of_queries: Optional[int] = None, + databases: Optional[str] = None, + start_time: Optional[str] = None, + end_time: Optional[str] = None, + interval: Optional[Union[str, _models.QueryTimeGrainType]] = None, + aggregation_function: Optional[Union[str, _models.AggregationFunctionType]] = None, + observation_metric: Optional[Union[str, _models.MetricType]] = None, + **kwargs: Any + ) -> ItemPaged["_models.TopQueries"]: + """Get top resource consuming queries of a managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :keyword number_of_queries: How many 'top queries' to return. Default is 5. Default value is + None. + :paramtype number_of_queries: int + :keyword databases: Comma separated list of databases to be included into search. All DB's are + included if this parameter is not specified. Default value is None. + :paramtype databases: str + :keyword start_time: Start time for observed period. Default value is None. + :paramtype start_time: str + :keyword end_time: End time for observed period. Default value is None. + :paramtype end_time: str + :keyword interval: The time step to be used to summarize the metric values. Default value is + PT1H. Known values are: "PT1H" and "P1D". Default value is None. + :paramtype interval: str or ~azure.mgmt.sql.models.QueryTimeGrainType + :keyword aggregation_function: Aggregation function to be used, default value is 'sum'. Known + values are: "avg", "min", "max", "stdev", and "sum". Default value is None. + :paramtype aggregation_function: str or ~azure.mgmt.sql.models.AggregationFunctionType + :keyword observation_metric: Metric to be used for ranking top queries. Default is 'cpu'. Known + values are: "cpu", "io", "logIo", "duration", and "dtu". Default value is None. + :paramtype observation_metric: str or ~azure.mgmt.sql.models.MetricType + :return: An iterator like instance of TopQueries + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.TopQueries] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TopQueries]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_instances_list_by_managed_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + number_of_queries=number_of_queries, + databases=databases, + start_time=start_time, + end_time=end_time, + interval=interval, + aggregation_function=aggregation_function, + observation_metric=observation_metric, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TopQueries], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _validate_azure_key_vault_encryption_key_initial( # pylint: disable=name-too-long + self, + resource_group_name: str, + managed_instance_name: str, + parameters: Union[_models.ManagedInstanceValidateAzureKeyVaultEncryptionKeyRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_instances_validate_azure_key_vault_encryption_key_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_validate_azure_key_vault_encryption_key( # pylint: disable=name-too-long + self, + resource_group_name: str, + managed_instance_name: str, + parameters: _models.ManagedInstanceValidateAzureKeyVaultEncryptionKeyRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Validates customer managed key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: The validate azure key vault encryption key parameters. Required. + :type parameters: + ~azure.mgmt.sql.models.ManagedInstanceValidateAzureKeyVaultEncryptionKeyRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_validate_azure_key_vault_encryption_key( # pylint: disable=name-too-long + self, + resource_group_name: str, + managed_instance_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Validates customer managed key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: The validate azure key vault encryption key parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_validate_azure_key_vault_encryption_key( # pylint: disable=name-too-long + self, + resource_group_name: str, + managed_instance_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Validates customer managed key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: The validate azure key vault encryption key parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_azure_key_vault_encryption_key( # pylint: disable=name-too-long + self, + resource_group_name: str, + managed_instance_name: str, + parameters: Union[_models.ManagedInstanceValidateAzureKeyVaultEncryptionKeyRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[None]: + """Validates customer managed key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: The validate azure key vault encryption key parameters. Is one of the + following types: ManagedInstanceValidateAzureKeyVaultEncryptionKeyRequest, JSON, IO[bytes] + Required. + :type parameters: + ~azure.mgmt.sql.models.ManagedInstanceValidateAzureKeyVaultEncryptionKeyRequest or JSON or + IO[bytes] + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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._validate_azure_key_vault_encryption_key_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_instance_pool( + self, resource_group_name: str, instance_pool_name: str, *, expand: Optional[str] = None, **kwargs: Any + ) -> ItemPaged["_models.ManagedInstance"]: + """Gets a list of all managed instances in an instance pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param instance_pool_name: The name of the instance pool to be retrieved. Required. + :type instance_pool_name: str + :keyword expand: The child resources to include in the response. Default value is None. + :paramtype expand: str + :return: An iterator like instance of ManagedInstance + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstance] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstance]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_instances_list_by_instance_pool_request( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstance], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ElasticPoolsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`elastic_pools` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any + ) -> _models.ElasticPool: + """Gets an elastic pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: ElasticPool. The ElasticPool is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ElasticPool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ElasticPool] = kwargs.pop("cls", None) + + _request = build_elastic_pools_get_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ElasticPool, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + parameters: Union[_models.ElasticPool, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_elastic_pools_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + parameters: _models.ElasticPool, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ElasticPool]: + """Creates or updates an elastic pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 parameters: The elastic pool parameters. Required. + :type parameters: ~azure.mgmt.sql.models.ElasticPool + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ElasticPool. The ElasticPool is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ElasticPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ElasticPool]: + """Creates or updates an elastic pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 parameters: The elastic pool parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ElasticPool. The ElasticPool is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ElasticPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ElasticPool]: + """Creates or updates an elastic pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 parameters: The elastic pool parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ElasticPool. The ElasticPool is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ElasticPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + parameters: Union[_models.ElasticPool, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ElasticPool]: + """Creates or updates an elastic pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 parameters: The elastic pool parameters. Is one of the following types: ElasticPool, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ElasticPool or JSON or IO[bytes] + :return: An instance of LROPoller that returns ElasticPool. The ElasticPool is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ElasticPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + elastic_pool_name=elastic_pool_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ElasticPool, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ElasticPool].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ElasticPool]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + parameters: Union[_models.ElasticPoolUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_elastic_pools_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + parameters: _models.ElasticPoolUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ElasticPool]: + """Updates an elastic pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 parameters: The elastic pool update parameters. Required. + :type parameters: ~azure.mgmt.sql.models.ElasticPoolUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ElasticPool. The ElasticPool is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ElasticPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ElasticPool]: + """Updates an elastic pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 parameters: The elastic pool update parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ElasticPool. The ElasticPool is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ElasticPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ElasticPool]: + """Updates an elastic pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 parameters: The elastic pool update parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ElasticPool. The ElasticPool is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ElasticPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + parameters: Union[_models.ElasticPoolUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ElasticPool]: + """Updates an elastic pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 parameters: The elastic pool update parameters. Is one of the following types: + ElasticPoolUpdate, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ElasticPoolUpdate or JSON or IO[bytes] + :return: An instance of LROPoller that returns ElasticPool. The ElasticPool is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ElasticPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ElasticPool, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ElasticPool].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ElasticPool]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_elastic_pools_delete_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes an elastic pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, *, skip: Optional[int] = None, **kwargs: Any + ) -> ItemPaged["_models.ElasticPool"]: + """Gets all elastic pools in a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :keyword skip: The number of elements in the collection to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ElasticPool + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ElasticPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ElasticPool]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_elastic_pools_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ElasticPool], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _failover_initial( + self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_elastic_pools_failover_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_failover( + self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Failovers an elastic pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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._failover_initial( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class EncryptionProtectorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`encryption_protectors` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + server_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + **kwargs: Any + ) -> _models.EncryptionProtector: + """Gets a server encryption protector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param encryption_protector_name: The name of the encryption protector to be retrieved. + "current" Required. + :type encryption_protector_name: str or ~azure.mgmt.sql.models.EncryptionProtectorName + :return: EncryptionProtector. The EncryptionProtector is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.EncryptionProtector + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.EncryptionProtector] = kwargs.pop("cls", None) + + _request = build_encryption_protectors_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + encryption_protector_name=encryption_protector_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.EncryptionProtector, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + parameters: Union[_models.EncryptionProtector, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_encryption_protectors_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + encryption_protector_name=encryption_protector_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + parameters: _models.EncryptionProtector, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EncryptionProtector]: + """Updates an existing encryption protector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param encryption_protector_name: The name of the encryption protector to be retrieved. + "current" Required. + :type encryption_protector_name: str or ~azure.mgmt.sql.models.EncryptionProtectorName + :param parameters: The requested encryption protector resource state. Required. + :type parameters: ~azure.mgmt.sql.models.EncryptionProtector + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns EncryptionProtector. The EncryptionProtector is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.EncryptionProtector] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EncryptionProtector]: + """Updates an existing encryption protector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param encryption_protector_name: The name of the encryption protector to be retrieved. + "current" Required. + :type encryption_protector_name: str or ~azure.mgmt.sql.models.EncryptionProtectorName + :param parameters: The requested encryption protector resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns EncryptionProtector. The EncryptionProtector is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.EncryptionProtector] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EncryptionProtector]: + """Updates an existing encryption protector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param encryption_protector_name: The name of the encryption protector to be retrieved. + "current" Required. + :type encryption_protector_name: str or ~azure.mgmt.sql.models.EncryptionProtectorName + :param parameters: The requested encryption protector resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns EncryptionProtector. The EncryptionProtector is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.EncryptionProtector] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + parameters: Union[_models.EncryptionProtector, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.EncryptionProtector]: + """Updates an existing encryption protector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param encryption_protector_name: The name of the encryption protector to be retrieved. + "current" Required. + :type encryption_protector_name: str or ~azure.mgmt.sql.models.EncryptionProtectorName + :param parameters: The requested encryption protector resource state. Is one of the following + types: EncryptionProtector, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.EncryptionProtector or JSON or IO[bytes] + :return: An instance of LROPoller that returns EncryptionProtector. The EncryptionProtector is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.EncryptionProtector] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + encryption_protector_name=encryption_protector_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.EncryptionProtector, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.EncryptionProtector].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.EncryptionProtector]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.EncryptionProtector"]: + """Gets a list of server encryption protectors. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of EncryptionProtector + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.EncryptionProtector] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.EncryptionProtector]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_encryption_protectors_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.EncryptionProtector], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _revalidate_initial( + self, + resource_group_name: str, + server_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_encryption_protectors_revalidate_request( + resource_group_name=resource_group_name, + server_name=server_name, + encryption_protector_name=encryption_protector_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_revalidate( + self, + resource_group_name: str, + server_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + **kwargs: Any + ) -> LROPoller[None]: + """Revalidates an existing encryption protector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param encryption_protector_name: The name of the encryption protector to be retrieved. + "current" Required. + :type encryption_protector_name: str or ~azure.mgmt.sql.models.EncryptionProtectorName + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + encryption_protector_name=encryption_protector_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class EndpointCertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`endpoint_certificates` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, managed_instance_name: str, endpoint_type: str, **kwargs: Any + ) -> _models.EndpointCertificate: + """Gets a certificate used on the endpoint with the given id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param endpoint_type: Type of the endpoint whose certificate the customer is looking for. + Required. + :type endpoint_type: str + :return: EndpointCertificate. The EndpointCertificate is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.EndpointCertificate + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.EndpointCertificate] = kwargs.pop("cls", None) + + _request = build_endpoint_certificates_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + endpoint_type=endpoint_type, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.EndpointCertificate, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> ItemPaged["_models.EndpointCertificate"]: + """List certificates used on endpoints on the target instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of EndpointCertificate + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.EndpointCertificate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.EndpointCertificate]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_endpoint_certificates_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.EndpointCertificate], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class FailoverGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`failover_groups` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, server_name: str, failover_group_name: str, **kwargs: Any + ) -> _models.FailoverGroup: + """Gets a failover group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: FailoverGroup. The FailoverGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.FailoverGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.FailoverGroup] = kwargs.pop("cls", None) + + _request = build_failover_groups_get_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.FailoverGroup, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + failover_group_name: str, + parameters: Union[_models.FailoverGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_failover_groups_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + failover_group_name: str, + parameters: _models.FailoverGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FailoverGroup]: + """Creates or updates a failover group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param parameters: The failover group parameters. Required. + :type parameters: ~azure.mgmt.sql.models.FailoverGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns FailoverGroup. The FailoverGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.FailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + failover_group_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FailoverGroup]: + """Creates or updates a failover group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param parameters: The failover group parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns FailoverGroup. The FailoverGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.FailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + failover_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FailoverGroup]: + """Creates or updates a failover group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param parameters: The failover group parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns FailoverGroup. The FailoverGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.FailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + failover_group_name: str, + parameters: Union[_models.FailoverGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.FailoverGroup]: + """Creates or updates a failover group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param parameters: The failover group parameters. Is one of the following types: FailoverGroup, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.FailoverGroup or JSON or IO[bytes] + :return: An instance of LROPoller that returns FailoverGroup. The FailoverGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.FailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + failover_group_name=failover_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.FailoverGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.FailoverGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.FailoverGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + server_name: str, + failover_group_name: str, + parameters: Union[_models.FailoverGroupUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_failover_groups_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + failover_group_name: str, + parameters: _models.FailoverGroupUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FailoverGroup]: + """Updates a failover group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param parameters: The failover group parameters. Required. + :type parameters: ~azure.mgmt.sql.models.FailoverGroupUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns FailoverGroup. The FailoverGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.FailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + failover_group_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FailoverGroup]: + """Updates a failover group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param parameters: The failover group parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns FailoverGroup. The FailoverGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.FailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + failover_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.FailoverGroup]: + """Updates a failover group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param parameters: The failover group parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns FailoverGroup. The FailoverGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.FailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + server_name: str, + failover_group_name: str, + parameters: Union[_models.FailoverGroupUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.FailoverGroup]: + """Updates a failover group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param parameters: The failover group parameters. Is one of the following types: + FailoverGroupUpdate, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.FailoverGroupUpdate or JSON or IO[bytes] + :return: An instance of LROPoller that returns FailoverGroup. The FailoverGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.FailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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( + resource_group_name=resource_group_name, + server_name=server_name, + failover_group_name=failover_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.FailoverGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.FailoverGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.FailoverGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, server_name: str, failover_group_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_failover_groups_delete_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, server_name: str, failover_group_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a failover group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + failover_group_name=failover_group_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.FailoverGroup"]: + """Lists the failover groups in a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of FailoverGroup + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.FailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.FailoverGroup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_failover_groups_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.FailoverGroup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _failover_initial( + self, resource_group_name: str, server_name: str, failover_group_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_failover_groups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An instance of LROPoller that returns FailoverGroup. The FailoverGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.FailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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._failover_initial( + resource_group_name=resource_group_name, + server_name=server_name, + failover_group_name=failover_group_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.FailoverGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.FailoverGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.FailoverGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _force_failover_allow_data_loss_initial( + self, resource_group_name: str, server_name: str, failover_group_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_failover_groups_force_failover_allow_data_loss_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_force_failover_allow_data_loss( + 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 might result in data + loss. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An instance of LROPoller that returns FailoverGroup. The FailoverGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.FailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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._force_failover_allow_data_loss_initial( + resource_group_name=resource_group_name, + server_name=server_name, + failover_group_name=failover_group_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.FailoverGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.FailoverGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.FailoverGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _try_planned_before_forced_failover_initial( # pylint: disable=name-too-long + self, resource_group_name: str, server_name: str, failover_group_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_failover_groups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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. The name is case insensitive. + 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 + :return: An instance of LROPoller that returns FailoverGroup. The FailoverGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.FailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.FailoverGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.FailoverGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.FailoverGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class GeoBackupPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`geo_backup_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + 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. The name is case insensitive. + Required. + :type resource_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 + :return: GeoBackupPolicy. The GeoBackupPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.GeoBackupPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.GeoBackupPolicy] = kwargs.pop("cls", None) + + _request = build_geo_backup_policies_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GeoBackupPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + geo_backup_policy_name: Union[str, _models.GeoBackupPolicyName], + parameters: _models.GeoBackupPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GeoBackupPolicy: + """Create or update a database default Geo backup policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :param parameters: The required parameters for creating or updating the geo backup policy. + Required. + :type parameters: ~azure.mgmt.sql.models.GeoBackupPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GeoBackupPolicy. The GeoBackupPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.GeoBackupPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + geo_backup_policy_name: Union[str, _models.GeoBackupPolicyName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GeoBackupPolicy: + """Create or update a database default Geo backup policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :param parameters: The required parameters for creating or updating the geo backup policy. + Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GeoBackupPolicy. The GeoBackupPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.GeoBackupPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + geo_backup_policy_name: Union[str, _models.GeoBackupPolicyName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GeoBackupPolicy: + """Create or update a database default Geo backup policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :param parameters: The required parameters for creating or updating the geo backup policy. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: GeoBackupPolicy. The GeoBackupPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.GeoBackupPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + geo_backup_policy_name: Union[str, _models.GeoBackupPolicyName], + parameters: Union[_models.GeoBackupPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.GeoBackupPolicy: + """Create or update a database default Geo backup policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :param parameters: The required parameters for creating or updating the geo backup policy. Is + one of the following types: GeoBackupPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.GeoBackupPolicy or JSON or IO[bytes] + :return: GeoBackupPolicy. The GeoBackupPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.GeoBackupPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_geo_backup_policies_create_or_update_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = 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]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GeoBackupPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> ItemPaged["_models.GeoBackupPolicy"]: + """Gets a list of Geo backup policies for the given database resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of GeoBackupPolicy + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.GeoBackupPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.GeoBackupPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_geo_backup_policies_list_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.GeoBackupPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class InstanceFailoverGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`instance_failover_groups` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, location_name: str, failover_group_name: str, **kwargs: Any + ) -> _models.InstanceFailoverGroup: + """Gets a failover group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :param failover_group_name: The name of the failover group. Required. + :type failover_group_name: str + :return: InstanceFailoverGroup. The InstanceFailoverGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.InstanceFailoverGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.InstanceFailoverGroup] = kwargs.pop("cls", None) + + _request = build_instance_failover_groups_get_request( + resource_group_name=resource_group_name, + location_name=location_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.InstanceFailoverGroup, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + location_name: str, + failover_group_name: str, + parameters: Union[_models.InstanceFailoverGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_instance_failover_groups_create_or_update_request( + resource_group_name=resource_group_name, + location_name=location_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + location_name: str, + failover_group_name: str, + parameters: _models.InstanceFailoverGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.InstanceFailoverGroup]: + """Creates or updates a failover group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :param failover_group_name: The name of the failover group. Required. + :type failover_group_name: str + :param parameters: The failover group parameters. Required. + :type parameters: ~azure.mgmt.sql.models.InstanceFailoverGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns InstanceFailoverGroup. The InstanceFailoverGroup + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.InstanceFailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + location_name: str, + failover_group_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.InstanceFailoverGroup]: + """Creates or updates a failover group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :param failover_group_name: The name of the failover group. Required. + :type failover_group_name: str + :param parameters: The failover group parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns InstanceFailoverGroup. The InstanceFailoverGroup + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.InstanceFailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + location_name: str, + failover_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.InstanceFailoverGroup]: + """Creates or updates a failover group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :param failover_group_name: The name of the failover group. Required. + :type failover_group_name: str + :param parameters: The failover group parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns InstanceFailoverGroup. The InstanceFailoverGroup + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.InstanceFailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + location_name: str, + failover_group_name: str, + parameters: Union[_models.InstanceFailoverGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.InstanceFailoverGroup]: + """Creates or updates a failover group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :param failover_group_name: The name of the failover group. Required. + :type failover_group_name: str + :param parameters: The failover group parameters. Is one of the following types: + InstanceFailoverGroup, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.InstanceFailoverGroup or JSON or IO[bytes] + :return: An instance of LROPoller that returns InstanceFailoverGroup. The InstanceFailoverGroup + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.InstanceFailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + location_name=location_name, + failover_group_name=failover_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.InstanceFailoverGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.InstanceFailoverGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.InstanceFailoverGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, location_name: str, failover_group_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_instance_failover_groups_delete_request( + resource_group_name=resource_group_name, + location_name=location_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, location_name: str, failover_group_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a failover group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :param failover_group_name: The name of the failover group. Required. + :type failover_group_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + location_name=location_name, + failover_group_name=failover_group_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_location( + self, resource_group_name: str, location_name: str, **kwargs: Any + ) -> ItemPaged["_models.InstanceFailoverGroup"]: + """Lists the failover groups in a location. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :return: An iterator like instance of InstanceFailoverGroup + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.InstanceFailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.InstanceFailoverGroup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_instance_failover_groups_list_by_location_request( + resource_group_name=resource_group_name, + location_name=location_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.InstanceFailoverGroup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _failover_initial( + self, resource_group_name: str, location_name: str, failover_group_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_instance_failover_groups_failover_request( + resource_group_name=resource_group_name, + location_name=location_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_failover( + self, resource_group_name: str, location_name: str, failover_group_name: str, **kwargs: Any + ) -> LROPoller[_models.InstanceFailoverGroup]: + """Fails over from the current primary managed instance to this managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :param failover_group_name: The name of the failover group. Required. + :type failover_group_name: str + :return: An instance of LROPoller that returns InstanceFailoverGroup. The InstanceFailoverGroup + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.InstanceFailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._failover_initial( + resource_group_name=resource_group_name, + location_name=location_name, + failover_group_name=failover_group_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.InstanceFailoverGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.InstanceFailoverGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.InstanceFailoverGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _force_failover_allow_data_loss_initial( + self, resource_group_name: str, location_name: str, failover_group_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_instance_failover_groups_force_failover_allow_data_loss_request( + resource_group_name=resource_group_name, + location_name=location_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_force_failover_allow_data_loss( + self, resource_group_name: str, location_name: str, failover_group_name: str, **kwargs: Any + ) -> LROPoller[_models.InstanceFailoverGroup]: + """Fails over from the current primary managed instance to this managed instance. This operation + might result in data loss. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :param failover_group_name: The name of the failover group. Required. + :type failover_group_name: str + :return: An instance of LROPoller that returns InstanceFailoverGroup. The InstanceFailoverGroup + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.InstanceFailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._force_failover_allow_data_loss_initial( + resource_group_name=resource_group_name, + location_name=location_name, + failover_group_name=failover_group_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.InstanceFailoverGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.InstanceFailoverGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.InstanceFailoverGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class InstancePoolOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`instance_pool_operations` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, instance_pool_name: str, operation_id: str, **kwargs: Any + ) -> _models.InstancePoolOperation: + """Gets a management operation on a instance pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param instance_pool_name: The name of the instance pool to be retrieved. Required. + :type instance_pool_name: str + :param operation_id: Required. + :type operation_id: str + :return: InstancePoolOperation. The InstancePoolOperation is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.InstancePoolOperation + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.InstancePoolOperation] = kwargs.pop("cls", None) + + _request = build_instance_pool_operations_get_request( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.InstancePoolOperation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_instance_pool( + self, resource_group_name: str, instance_pool_name: str, **kwargs: Any + ) -> ItemPaged["_models.InstancePoolOperation"]: + """Gets a list of operations performed on the instance pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param instance_pool_name: The name of the instance pool to be retrieved. Required. + :type instance_pool_name: str + :return: An iterator like instance of InstancePoolOperation + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.InstancePoolOperation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.InstancePoolOperation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_instance_pool_operations_list_by_instance_pool_request( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.InstancePoolOperation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class InstancePoolsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`instance_pools` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, instance_pool_name: str, **kwargs: Any) -> _models.InstancePool: + """Gets an instance pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param instance_pool_name: The name of the instance pool to be retrieved. Required. + :type instance_pool_name: str + :return: InstancePool. The InstancePool is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.InstancePool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.InstancePool] = kwargs.pop("cls", None) + + _request = build_instance_pools_get_request( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.InstancePool, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + instance_pool_name: str, + parameters: Union[_models.InstancePool, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_instance_pools_create_or_update_request( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + instance_pool_name: str, + parameters: _models.InstancePool, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.InstancePool]: + """Creates or updates an instance pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param instance_pool_name: The name of the instance pool to be retrieved. Required. + :type instance_pool_name: str + :param parameters: The requested instance pool resource state. Required. + :type parameters: ~azure.mgmt.sql.models.InstancePool + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns InstancePool. The InstancePool is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.InstancePool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + instance_pool_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.InstancePool]: + """Creates or updates an instance pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param instance_pool_name: The name of the instance pool to be retrieved. Required. + :type instance_pool_name: str + :param parameters: The requested instance pool resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns InstancePool. The InstancePool is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.InstancePool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + instance_pool_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.InstancePool]: + """Creates or updates an instance pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param instance_pool_name: The name of the instance pool to be retrieved. Required. + :type instance_pool_name: str + :param parameters: The requested instance pool resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns InstancePool. The InstancePool is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.InstancePool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + instance_pool_name: str, + parameters: Union[_models.InstancePool, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.InstancePool]: + """Creates or updates an instance pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param instance_pool_name: The name of the instance pool to be retrieved. Required. + :type instance_pool_name: str + :param parameters: The requested instance pool resource state. Is one of the following types: + InstancePool, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.InstancePool or JSON or IO[bytes] + :return: An instance of LROPoller that returns InstancePool. The InstancePool is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.InstancePool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + instance_pool_name=instance_pool_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.InstancePool, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.InstancePool].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.InstancePool]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + instance_pool_name: str, + parameters: Union[_models.InstancePoolUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_instance_pools_update_request( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + instance_pool_name: str, + parameters: _models.InstancePoolUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.InstancePool]: + """Updates an instance pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param instance_pool_name: The name of the instance pool to be retrieved. Required. + :type instance_pool_name: str + :param parameters: The requested instance pool resource state. Required. + :type parameters: ~azure.mgmt.sql.models.InstancePoolUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns InstancePool. The InstancePool is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.InstancePool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + instance_pool_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.InstancePool]: + """Updates an instance pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param instance_pool_name: The name of the instance pool to be retrieved. Required. + :type instance_pool_name: str + :param parameters: The requested instance pool resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns InstancePool. The InstancePool is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.InstancePool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + instance_pool_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.InstancePool]: + """Updates an instance pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param instance_pool_name: The name of the instance pool to be retrieved. Required. + :type instance_pool_name: str + :param parameters: The requested instance pool resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns InstancePool. The InstancePool is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.InstancePool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + instance_pool_name: str, + parameters: Union[_models.InstancePoolUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.InstancePool]: + """Updates an instance pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param instance_pool_name: The name of the instance pool to be retrieved. Required. + :type instance_pool_name: str + :param parameters: The requested instance pool resource state. Is one of the following types: + InstancePoolUpdate, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.InstancePoolUpdate or JSON or IO[bytes] + :return: An instance of LROPoller that returns InstancePool. The InstancePool is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.InstancePool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.InstancePool, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.InstancePool].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.InstancePool]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial(self, resource_group_name: str, instance_pool_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_instance_pools_delete_request( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete(self, resource_group_name: str, instance_pool_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes an instance pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param instance_pool_name: The name of the instance pool to be retrieved. Required. + :type instance_pool_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.InstancePool"]: + """Gets a list of instance pools in the resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of InstancePool + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.InstancePool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.InstancePool]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_instance_pools_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.InstancePool], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged["_models.InstancePool"]: + """Gets a list of all instance pools in the subscription. + + :return: An iterator like instance of InstancePool + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.InstancePool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.InstancePool]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_instance_pools_list_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.InstancePool], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class IPv6FirewallRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`ipv6_firewall_rules` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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.IPv6FirewallRule: + """Gets an IPv6 firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: IPv6FirewallRule. The IPv6FirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.IPv6FirewallRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.IPv6FirewallRule] = kwargs.pop("cls", None) + + _request = build_ipv6_firewall_rules_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.IPv6FirewallRule, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + parameters: _models.IPv6FirewallRule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IPv6FirewallRule: + """Creates or updates an IPv6 firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 an IPv6 firewall rule. + Required. + :type parameters: ~azure.mgmt.sql.models.IPv6FirewallRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: IPv6FirewallRule. The IPv6FirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.IPv6FirewallRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IPv6FirewallRule: + """Creates or updates an IPv6 firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 an IPv6 firewall rule. + Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: IPv6FirewallRule. The IPv6FirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.IPv6FirewallRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IPv6FirewallRule: + """Creates or updates an IPv6 firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 an IPv6 firewall rule. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: IPv6FirewallRule. The IPv6FirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.IPv6FirewallRule + :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.IPv6FirewallRule, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.IPv6FirewallRule: + """Creates or updates an IPv6 firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 an IPv6 firewall rule. Is + one of the following types: IPv6FirewallRule, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.IPv6FirewallRule or JSON or IO[bytes] + :return: IPv6FirewallRule. The IPv6FirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.IPv6FirewallRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_ipv6_firewall_rules_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + firewall_rule_name=firewall_rule_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = 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]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.IPv6FirewallRule, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @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 an IPv6 firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_ipv6_firewall_rules_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = 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) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.IPv6FirewallRule"]: + """Gets a list of IPv6 firewall rules. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of IPv6FirewallRule + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.IPv6FirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.IPv6FirewallRule]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_ipv6_firewall_rules_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.IPv6FirewallRule], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class JobExecutionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`job_executions` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_execution_id: str, + **kwargs: Any + ) -> _models.JobExecution: + """Gets a job execution. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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_execution_id: The id of the job execution. Required. + :type job_execution_id: str + :return: JobExecution. The JobExecution is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobExecution + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.JobExecution] = kwargs.pop("cls", None) + + _request = build_job_executions_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JobExecution, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + 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 + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_job_executions_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 + ) -> LROPoller[_models.JobExecution]: + """Creates or updates a job execution. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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_execution_id: The id of the job execution. Required. + :type job_execution_id: str + :return: An instance of LROPoller that returns JobExecution. The JobExecution is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.JobExecution] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.JobExecution, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.JobExecution].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.JobExecution]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def cancel( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_execution_id: str, + **kwargs: Any + ) -> None: + """Requests cancellation of a job execution. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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_execution_id: The id of the job execution. Required. + :type job_execution_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_job_executions_cancel_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_models.JobExecution"]: + """Lists a job's executions. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :keyword create_time_min: If specified, only job executions created at or after the specified + time are included. Default value is None. + :paramtype create_time_min: ~datetime.datetime + :keyword create_time_max: If specified, only job executions created before the specified time + are included. Default value is None. + :paramtype create_time_max: ~datetime.datetime + :keyword end_time_min: If specified, only job executions completed at or after the specified + time are included. Default value is None. + :paramtype end_time_min: ~datetime.datetime + :keyword end_time_max: If specified, only job executions completed before the specified time + are included. Default value is None. + :paramtype end_time_max: ~datetime.datetime + :keyword is_active: If specified, only active or only completed job executions are included. + Default value is None. + :paramtype is_active: bool + :keyword skip: The number of elements in the collection to skip. Default value is None. + :paramtype skip: int + :keyword top: The number of elements to return from the collection. Default value is None. + :paramtype top: int + :return: An iterator like instance of JobExecution + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobExecution] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.JobExecution]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_job_executions_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.JobExecution], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_agent( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + *, + create_time_min: Optional[datetime.datetime] = None, + create_time_max: Optional[datetime.datetime] = None, + end_time_min: Optional[datetime.datetime] = None, + end_time_max: Optional[datetime.datetime] = None, + is_active: Optional[bool] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_models.JobExecution"]: + """Lists all executions in a job agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :keyword create_time_min: If specified, only job executions created at or after the specified + time are included. Default value is None. + :paramtype create_time_min: ~datetime.datetime + :keyword create_time_max: If specified, only job executions created before the specified time + are included. Default value is None. + :paramtype create_time_max: ~datetime.datetime + :keyword end_time_min: If specified, only job executions completed at or after the specified + time are included. Default value is None. + :paramtype end_time_min: ~datetime.datetime + :keyword end_time_max: If specified, only job executions completed before the specified time + are included. Default value is None. + :paramtype end_time_max: ~datetime.datetime + :keyword is_active: If specified, only active or only completed job executions are included. + Default value is None. + :paramtype is_active: bool + :keyword skip: The number of elements in the collection to skip. Default value is None. + :paramtype skip: int + :keyword top: The number of elements to return from the collection. Default value is None. + :paramtype top: int + :return: An iterator like instance of JobExecution + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobExecution] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.JobExecution]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_job_executions_list_by_agent_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + create_time_min=create_time_min, + create_time_max=create_time_max, + end_time_min=end_time_min, + end_time_max=end_time_max, + is_active=is_active, + skip=skip, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.JobExecution], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _create_initial( + self, resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_job_executions_create_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, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_create( + self, resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, **kwargs: Any + ) -> LROPoller[_models.JobExecution]: + """Starts an elastic job execution. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param job_name: The name of the job to get. Required. + :type job_name: str + :return: An instance of LROPoller that returns JobExecution. The JobExecution is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.JobExecution] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.JobExecution, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.JobExecution].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.JobExecution]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class JobAgentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`job_agents` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, server_name: str, job_agent_name: str, **kwargs: Any) -> _models.JobAgent: + """Gets a job agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :return: JobAgent. The JobAgent is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobAgent + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.JobAgent] = kwargs.pop("cls", None) + + _request = build_job_agents_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JobAgent, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + parameters: Union[_models.JobAgent, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_job_agents_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + parameters: _models.JobAgent, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.JobAgent]: + """Creates or updates a job agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param parameters: The requested job agent resource state. Required. + :type parameters: ~azure.mgmt.sql.models.JobAgent + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns JobAgent. The JobAgent is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.JobAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.JobAgent]: + """Creates or updates a job agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param parameters: The requested job agent resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns JobAgent. The JobAgent is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.JobAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.JobAgent]: + """Creates or updates a job agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param parameters: The requested job agent resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns JobAgent. The JobAgent is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.JobAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + parameters: Union[_models.JobAgent, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.JobAgent]: + """Creates or updates a job agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param parameters: The requested job agent resource state. Is one of the following types: + JobAgent, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.JobAgent or JSON or IO[bytes] + :return: An instance of LROPoller that returns JobAgent. The JobAgent is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.JobAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + job_agent_name=job_agent_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.JobAgent, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.JobAgent].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.JobAgent]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + parameters: Union[_models.JobAgentUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_job_agents_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + parameters: _models.JobAgentUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.JobAgent]: + """Updates a job agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param parameters: The update to the job agent. Required. + :type parameters: ~azure.mgmt.sql.models.JobAgentUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns JobAgent. The JobAgent is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.JobAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.JobAgent]: + """Updates a job agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param parameters: The update to the job agent. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns JobAgent. The JobAgent is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.JobAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.JobAgent]: + """Updates a job agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param parameters: The update to the job agent. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns JobAgent. The JobAgent is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.JobAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + parameters: Union[_models.JobAgentUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.JobAgent]: + """Updates a job agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param parameters: The update to the job agent. Is one of the following types: JobAgentUpdate, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.JobAgentUpdate or JSON or IO[bytes] + :return: An instance of LROPoller that returns JobAgent. The JobAgent is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.JobAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.JobAgent, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.JobAgent].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.JobAgent]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, server_name: str, job_agent_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_job_agents_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, server_name: str, job_agent_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a job agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.JobAgent"]: + """Gets a list of job agents in a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of JobAgent + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.JobAgent]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_job_agents_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.JobAgent], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class JobCredentialsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`job_credentials` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, server_name: str, job_agent_name: str, credential_name: str, **kwargs: Any + ) -> _models.JobCredential: + """Gets a jobs credential. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param credential_name: The name of the credential. Required. + :type credential_name: str + :return: JobCredential. The JobCredential is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobCredential + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.JobCredential] = kwargs.pop("cls", None) + + _request = build_job_credentials_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + credential_name=credential_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JobCredential, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + credential_name: str, + parameters: _models.JobCredential, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobCredential: + """Creates or updates a job credential. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param credential_name: The name of the credential. Required. + :type credential_name: str + :param parameters: The requested job credential state. Required. + :type parameters: ~azure.mgmt.sql.models.JobCredential + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JobCredential. The JobCredential is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobCredential + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + credential_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobCredential: + """Creates or updates a job credential. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param credential_name: The name of the credential. Required. + :type credential_name: str + :param parameters: The requested job credential state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JobCredential. The JobCredential is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobCredential + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + credential_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobCredential: + """Creates or updates a job credential. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param credential_name: The name of the credential. Required. + :type credential_name: str + :param parameters: The requested job credential state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JobCredential. The JobCredential is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobCredential + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + credential_name: str, + parameters: Union[_models.JobCredential, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.JobCredential: + """Creates or updates a job credential. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param credential_name: The name of the credential. Required. + :type credential_name: str + :param parameters: The requested job credential state. Is one of the following types: + JobCredential, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.JobCredential or JSON or IO[bytes] + :return: JobCredential. The JobCredential is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobCredential + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_job_credentials_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + credential_name=credential_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = 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]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JobCredential, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, server_name: str, job_agent_name: str, credential_name: str, **kwargs: Any + ) -> None: + """Deletes a job credential. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param credential_name: The name of the credential. Required. + :type credential_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_job_credentials_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + credential_name=credential_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = 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) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_agent( + self, resource_group_name: str, server_name: str, job_agent_name: str, **kwargs: Any + ) -> ItemPaged["_models.JobCredential"]: + """Gets a list of jobs credentials. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :return: An iterator like instance of JobCredential + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.JobCredential]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_job_credentials_list_by_agent_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.JobCredential], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class JobStepExecutionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`job_step_executions` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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, + **kwargs: Any + ) -> _models.JobExecution: + """Gets a step execution of a job execution. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: JobExecution. The JobExecution is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobExecution + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.JobExecution] = kwargs.pop("cls", None) + + _request = build_job_step_executions_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + step_name=step_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JobExecution, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_job_execution( # pylint: disable=too-many-locals + 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, + end_time_max: Optional[datetime.datetime] = None, + is_active: Optional[bool] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_models.JobExecution"]: + """Lists the step executions of a job execution. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :keyword create_time_min: If specified, only job executions created at or after the specified + time are included. Default value is None. + :paramtype create_time_min: ~datetime.datetime + :keyword create_time_max: If specified, only job executions created before the specified time + are included. Default value is None. + :paramtype create_time_max: ~datetime.datetime + :keyword end_time_min: If specified, only job executions completed at or after the specified + time are included. Default value is None. + :paramtype end_time_min: ~datetime.datetime + :keyword end_time_max: If specified, only job executions completed before the specified time + are included. Default value is None. + :paramtype end_time_max: ~datetime.datetime + :keyword is_active: If specified, only active or only completed job executions are included. + Default value is None. + :paramtype is_active: bool + :keyword skip: The number of elements in the collection to skip. Default value is None. + :paramtype skip: int + :keyword top: The number of elements to return from the collection. Default value is None. + :paramtype top: int + :return: An iterator like instance of JobExecution + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobExecution] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.JobExecution]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_job_step_executions_list_by_job_execution_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + subscription_id=self._config.subscription_id, + create_time_min=create_time_min, + create_time_max=create_time_max, + end_time_min=end_time_min, + end_time_max=end_time_max, + is_active=is_active, + skip=skip, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.JobExecution], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class JobTargetExecutionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`job_target_executions` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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. The name is case insensitive. + 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 + :return: JobExecution. The JobExecution is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobExecution + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.JobExecution] = kwargs.pop("cls", None) + + _request = build_job_target_executions_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JobExecution, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_step( # pylint: disable=too-many-locals + 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, + end_time_max: Optional[datetime.datetime] = None, + is_active: Optional[bool] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_models.JobExecution"]: + """Lists the target executions of a job step execution. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :keyword create_time_min: If specified, only job executions created at or after the specified + time are included. Default value is None. + :paramtype create_time_min: ~datetime.datetime + :keyword create_time_max: If specified, only job executions created before the specified time + are included. Default value is None. + :paramtype create_time_max: ~datetime.datetime + :keyword end_time_min: If specified, only job executions completed at or after the specified + time are included. Default value is None. + :paramtype end_time_min: ~datetime.datetime + :keyword end_time_max: If specified, only job executions completed before the specified time + are included. Default value is None. + :paramtype end_time_max: ~datetime.datetime + :keyword is_active: If specified, only active or only completed job executions are included. + Default value is None. + :paramtype is_active: bool + :keyword skip: The number of elements in the collection to skip. Default value is None. + :paramtype skip: int + :keyword top: The number of elements to return from the collection. Default value is None. + :paramtype top: int + :return: An iterator like instance of JobExecution + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobExecution] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.JobExecution]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_job_target_executions_list_by_step_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + step_name=step_name, + subscription_id=self._config.subscription_id, + create_time_min=create_time_min, + create_time_max=create_time_max, + end_time_min=end_time_min, + end_time_max=end_time_max, + is_active=is_active, + skip=skip, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.JobExecution], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_job_execution( # pylint: disable=too-many-locals + 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, + end_time_max: Optional[datetime.datetime] = None, + is_active: Optional[bool] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_models.JobExecution"]: + """Lists target executions for all steps of a job execution. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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_execution_id: The id of the job execution. Required. + :type job_execution_id: str + :keyword create_time_min: If specified, only job executions created at or after the specified + time are included. Default value is None. + :paramtype create_time_min: ~datetime.datetime + :keyword create_time_max: If specified, only job executions created before the specified time + are included. Default value is None. + :paramtype create_time_max: ~datetime.datetime + :keyword end_time_min: If specified, only job executions completed at or after the specified + time are included. Default value is None. + :paramtype end_time_min: ~datetime.datetime + :keyword end_time_max: If specified, only job executions completed before the specified time + are included. Default value is None. + :paramtype end_time_max: ~datetime.datetime + :keyword is_active: If specified, only active or only completed job executions are included. + Default value is None. + :paramtype is_active: bool + :keyword skip: The number of elements in the collection to skip. Default value is None. + :paramtype skip: int + :keyword top: The number of elements to return from the collection. Default value is None. + :paramtype top: int + :return: An iterator like instance of JobExecution + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobExecution] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.JobExecution]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_job_target_executions_list_by_job_execution_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_execution_id=job_execution_id, + subscription_id=self._config.subscription_id, + create_time_min=create_time_min, + create_time_max=create_time_max, + end_time_min=end_time_min, + end_time_max=end_time_max, + is_active=is_active, + skip=skip, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.JobExecution], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class JobsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`jobs` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, **kwargs: Any + ) -> _models.Job: + """Gets a job. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param job_name: The name of the job to get. Required. + :type job_name: str + :return: Job. The Job is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Job + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + _request = build_jobs_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Job, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + parameters: _models.Job, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Job: + """Creates or updates a job. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param job_name: The name of the job to get. Required. + :type job_name: str + :param parameters: The requested job state. Required. + :type parameters: ~azure.mgmt.sql.models.Job + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Job. The Job is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Job + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Job: + """Creates or updates a job. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param job_name: The name of the job to get. Required. + :type job_name: str + :param parameters: The requested job state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Job. The Job is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Job + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Job: + """Creates or updates a job. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param job_name: The name of the job to get. Required. + :type job_name: str + :param parameters: The requested job state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Job. The Job is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Job + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + parameters: Union[_models.Job, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.Job: + """Creates or updates a job. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param job_name: The name of the job to get. Required. + :type job_name: str + :param parameters: The requested job state. Is one of the following types: Job, JSON, IO[bytes] + Required. + :type parameters: ~azure.mgmt.sql.models.Job or JSON or IO[bytes] + :return: Job. The Job is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Job + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_jobs_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = 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]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Job, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, **kwargs: Any + ) -> None: + """Deletes a job. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param job_name: The name of the job to get. Required. + :type job_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_jobs_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = 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) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_agent( + self, resource_group_name: str, server_name: str, job_agent_name: str, **kwargs: Any + ) -> ItemPaged["_models.Job"]: + """Gets a list of jobs. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :return: An iterator like instance of Job + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.Job] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Job]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_jobs_list_by_agent_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Job], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class JobPrivateEndpointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`job_private_endpoints` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, server_name: str, job_agent_name: str, private_endpoint_name: str, **kwargs: Any + ) -> _models.JobPrivateEndpoint: + """Gets a private endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param private_endpoint_name: The name of the private endpoint to get. Required. + :type private_endpoint_name: str + :return: JobPrivateEndpoint. The JobPrivateEndpoint is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobPrivateEndpoint + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.JobPrivateEndpoint] = kwargs.pop("cls", None) + + _request = build_job_private_endpoints_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + private_endpoint_name=private_endpoint_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JobPrivateEndpoint, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + private_endpoint_name: str, + parameters: Union[_models.JobPrivateEndpoint, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_job_private_endpoints_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + private_endpoint_name=private_endpoint_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + private_endpoint_name: str, + parameters: _models.JobPrivateEndpoint, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.JobPrivateEndpoint]: + """Creates or updates a private endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param private_endpoint_name: The name of the private endpoint to get. Required. + :type private_endpoint_name: str + :param parameters: The requested private endpoint state. Required. + :type parameters: ~azure.mgmt.sql.models.JobPrivateEndpoint + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns JobPrivateEndpoint. The JobPrivateEndpoint is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.JobPrivateEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + private_endpoint_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.JobPrivateEndpoint]: + """Creates or updates a private endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param private_endpoint_name: The name of the private endpoint to get. Required. + :type private_endpoint_name: str + :param parameters: The requested private endpoint state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns JobPrivateEndpoint. The JobPrivateEndpoint is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.JobPrivateEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + private_endpoint_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.JobPrivateEndpoint]: + """Creates or updates a private endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param private_endpoint_name: The name of the private endpoint to get. Required. + :type private_endpoint_name: str + :param parameters: The requested private endpoint state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns JobPrivateEndpoint. The JobPrivateEndpoint is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.JobPrivateEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + private_endpoint_name: str, + parameters: Union[_models.JobPrivateEndpoint, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.JobPrivateEndpoint]: + """Creates or updates a private endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param private_endpoint_name: The name of the private endpoint to get. Required. + :type private_endpoint_name: str + :param parameters: The requested private endpoint state. Is one of the following types: + JobPrivateEndpoint, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.JobPrivateEndpoint or JSON or IO[bytes] + :return: An instance of LROPoller that returns JobPrivateEndpoint. The JobPrivateEndpoint is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.JobPrivateEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.JobPrivateEndpoint] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + private_endpoint_name=private_endpoint_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.JobPrivateEndpoint, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.JobPrivateEndpoint].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.JobPrivateEndpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, server_name: str, job_agent_name: str, private_endpoint_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_job_private_endpoints_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + private_endpoint_name=private_endpoint_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, server_name: str, job_agent_name: str, private_endpoint_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a private endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param private_endpoint_name: The name of the private endpoint to get. Required. + :type private_endpoint_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + private_endpoint_name=private_endpoint_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_agent( + self, resource_group_name: str, server_name: str, job_agent_name: str, **kwargs: Any + ) -> ItemPaged["_models.JobPrivateEndpoint"]: + """Gets a list of job agent private endpoints. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :return: An iterator like instance of JobPrivateEndpoint + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobPrivateEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.JobPrivateEndpoint]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_job_private_endpoints_list_by_agent_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.JobPrivateEndpoint], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class JobStepsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`job_steps` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + step_name: str, + **kwargs: Any + ) -> _models.JobStep: + """Gets a job step in a job's current version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 step_name: The name of the job step. Required. + :type step_name: str + :return: JobStep. The JobStep is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobStep + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.JobStep] = kwargs.pop("cls", None) + + _request = build_job_steps_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + step_name=step_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JobStep, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + step_name: str, + parameters: _models.JobStep, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobStep: + """Creates or updates a job step. This will implicitly create a new job version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 step_name: The name of the job step. Required. + :type step_name: str + :param parameters: The requested state of the job step. Required. + :type parameters: ~azure.mgmt.sql.models.JobStep + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JobStep. The JobStep is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobStep + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + step_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobStep: + """Creates or updates a job step. This will implicitly create a new job version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 step_name: The name of the job step. Required. + :type step_name: str + :param parameters: The requested state of the job step. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JobStep. The JobStep is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobStep + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + step_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobStep: + """Creates or updates a job step. This will implicitly create a new job version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 step_name: The name of the job step. Required. + :type step_name: str + :param parameters: The requested state of the job step. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JobStep. The JobStep is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobStep + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + step_name: str, + parameters: Union[_models.JobStep, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.JobStep: + """Creates or updates a job step. This will implicitly create a new job version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 step_name: The name of the job step. Required. + :type step_name: str + :param parameters: The requested state of the job step. Is one of the following types: JobStep, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.JobStep or JSON or IO[bytes] + :return: JobStep. The JobStep is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobStep + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_job_steps_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + step_name=step_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = 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]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JobStep, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + step_name: str, + **kwargs: Any + ) -> None: + """Deletes a job step. This will implicitly create a new job version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 step_name: The name of the job step. Required. + :type step_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_job_steps_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + step_name=step_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = 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) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_job( + self, resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, **kwargs: Any + ) -> ItemPaged["_models.JobStep"]: + """Gets all job steps for a job's current version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An iterator like instance of JobStep + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobStep] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.JobStep]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_job_steps_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, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.JobStep], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @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. The name is case insensitive. + 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 + :return: JobStep. The JobStep is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobStep + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.JobStep] = kwargs.pop("cls", None) + + _request = build_job_steps_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JobStep, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @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 + ) -> ItemPaged["_models.JobStep"]: + """Gets all job steps in the specified job version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An iterator like instance of JobStep + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobStep] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.JobStep]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_job_steps_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.JobStep], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class JobTargetGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`job_target_groups` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, server_name: str, job_agent_name: str, target_group_name: str, **kwargs: Any + ) -> _models.JobTargetGroup: + """Gets a target group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param target_group_name: The name of the target group. Required. + :type target_group_name: str + :return: JobTargetGroup. The JobTargetGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobTargetGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.JobTargetGroup] = kwargs.pop("cls", None) + + _request = build_job_target_groups_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + target_group_name=target_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JobTargetGroup, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + target_group_name: str, + parameters: _models.JobTargetGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobTargetGroup: + """Creates or updates a target group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param target_group_name: The name of the target group. Required. + :type target_group_name: str + :param parameters: The requested state of the target group. Required. + :type parameters: ~azure.mgmt.sql.models.JobTargetGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JobTargetGroup. The JobTargetGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobTargetGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + target_group_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobTargetGroup: + """Creates or updates a target group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param target_group_name: The name of the target group. Required. + :type target_group_name: str + :param parameters: The requested state of the target group. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JobTargetGroup. The JobTargetGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobTargetGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + target_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobTargetGroup: + """Creates or updates a target group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param target_group_name: The name of the target group. Required. + :type target_group_name: str + :param parameters: The requested state of the target group. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JobTargetGroup. The JobTargetGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobTargetGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + target_group_name: str, + parameters: Union[_models.JobTargetGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.JobTargetGroup: + """Creates or updates a target group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param target_group_name: The name of the target group. Required. + :type target_group_name: str + :param parameters: The requested state of the target group. Is one of the following types: + JobTargetGroup, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.JobTargetGroup or JSON or IO[bytes] + :return: JobTargetGroup. The JobTargetGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobTargetGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_job_target_groups_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + target_group_name=target_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = 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]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JobTargetGroup, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, server_name: str, job_agent_name: str, target_group_name: str, **kwargs: Any + ) -> None: + """Deletes a target group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param target_group_name: The name of the target group. Required. + :type target_group_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_job_target_groups_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + target_group_name=target_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = 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) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_agent( + self, resource_group_name: str, server_name: str, job_agent_name: str, **kwargs: Any + ) -> ItemPaged["_models.JobTargetGroup"]: + """Gets all target groups in an agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :return: An iterator like instance of JobTargetGroup + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobTargetGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.JobTargetGroup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_job_target_groups_list_by_agent_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.JobTargetGroup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class JobVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`job_versions` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_version: int, + **kwargs: Any + ) -> _models.JobVersion: + """Gets a job version. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: JobVersion. The JobVersion is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.JobVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.JobVersion] = kwargs.pop("cls", None) + + _request = build_job_versions_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + job_name=job_name, + job_version=job_version, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.JobVersion, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_job( + self, resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, **kwargs: Any + ) -> ItemPaged["_models.JobVersion"]: + """Gets all versions of a job. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 to be retrieved. Required. + :type job_agent_name: str + :param job_name: The name of the job to get. Required. + :type job_name: str + :return: An iterator like instance of JobVersion + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.JobVersion]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_job_versions_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, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.JobVersion], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class LongTermRetentionBackupsOperations: # pylint: disable=too-many-public-methods + """ + .. 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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + **kwargs: Any + ) -> _models.LongTermRetentionBackup: + """Gets a long term retention backup. + + :param location_name: The location of the database. 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 + :return: LongTermRetentionBackup. The LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.LongTermRetentionBackup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) + + _request = build_long_term_retention_backups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.LongTermRetentionBackup, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _delete_initial( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_long_term_retention_backups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_database( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, + **kwargs: Any + ) -> ItemPaged["_models.LongTermRetentionBackup"]: + """Lists all long term retention backups for a database. + + :param location_name: The location of the database. Required. + :type location_name: str + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :keyword only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :paramtype only_latest_per_database: bool + :keyword 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. + :paramtype database_state: str or ~azure.mgmt.sql.models.DatabaseState + :return: An iterator like instance of LongTermRetentionBackup + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.LongTermRetentionBackup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_long_term_retention_backups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.LongTermRetentionBackup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _change_access_tier_initial( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: Union[_models.ChangeLongTermRetentionBackupAccessTierParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_long_term_retention_backups_change_access_tier_request( + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_change_access_tier( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: _models.ChangeLongTermRetentionBackupAccessTierParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LongTermRetentionBackup]: + """Change a long term retention backup access tier. + + :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: Required. + :type parameters: ~azure.mgmt.sql.models.ChangeLongTermRetentionBackupAccessTierParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns LongTermRetentionBackup. The + LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_change_access_tier( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LongTermRetentionBackup]: + """Change a long term retention backup access tier. + + :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: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns LongTermRetentionBackup. The + LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_change_access_tier( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LongTermRetentionBackup]: + """Change a long term retention backup access tier. + + :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: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns LongTermRetentionBackup. The + LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_change_access_tier( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: Union[_models.ChangeLongTermRetentionBackupAccessTierParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.LongTermRetentionBackup]: + """Change a long term retention backup access tier. + + :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: Is one of the following types: + ChangeLongTermRetentionBackupAccessTierParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ChangeLongTermRetentionBackupAccessTierParameters or + JSON or IO[bytes] + :return: An instance of LROPoller that returns LongTermRetentionBackup. The + LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._change_access_tier_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, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LongTermRetentionBackup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.LongTermRetentionBackup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.LongTermRetentionBackup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + 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, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_long_term_retention_backups_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 + :return: An instance of LROPoller that returns LongTermRetentionBackupOperationResult. The + LongTermRetentionBackupOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_copy( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: JSON, + *, + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns LongTermRetentionBackupOperationResult. The + LongTermRetentionBackupOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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[bytes], + *, + 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: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns LongTermRetentionBackupOperationResult. The + LongTermRetentionBackupOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_copy( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: Union[_models.CopyLongTermRetentionBackupParameters, JSON, IO[bytes]], + **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. Is one of the + following types: CopyLongTermRetentionBackupParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.CopyLongTermRetentionBackupParameters or JSON or + IO[bytes] + :return: An instance of LROPoller that returns LongTermRetentionBackupOperationResult. The + LongTermRetentionBackupOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LongTermRetentionBackupOperationResult, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.LongTermRetentionBackupOperationResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.LongTermRetentionBackupOperationResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _lock_time_based_immutability_initial( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_long_term_retention_backups_lock_time_based_immutability_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_lock_time_based_immutability( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + **kwargs: Any + ) -> LROPoller[_models.LongTermRetentionBackup]: + """Lock time based immutability of 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 + :return: An instance of LROPoller that returns LongTermRetentionBackup. The + LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._lock_time_based_immutability_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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LongTermRetentionBackup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.LongTermRetentionBackup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.LongTermRetentionBackup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _remove_legal_hold_immutability_initial( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_long_term_retention_backups_remove_legal_hold_immutability_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_remove_legal_hold_immutability( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + **kwargs: Any + ) -> LROPoller[_models.LongTermRetentionBackup]: + """Remove legal hold immutability of 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 + :return: An instance of LROPoller that returns LongTermRetentionBackup. The + LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._remove_legal_hold_immutability_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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LongTermRetentionBackup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.LongTermRetentionBackup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.LongTermRetentionBackup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _remove_time_based_immutability_initial( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_long_term_retention_backups_remove_time_based_immutability_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_remove_time_based_immutability( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + **kwargs: Any + ) -> LROPoller[_models.LongTermRetentionBackup]: + """Remove time based immutability of 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 + :return: An instance of LROPoller that returns LongTermRetentionBackup. The + LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._remove_time_based_immutability_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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LongTermRetentionBackup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.LongTermRetentionBackup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.LongTermRetentionBackup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _set_legal_hold_immutability_initial( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_long_term_retention_backups_set_legal_hold_immutability_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_set_legal_hold_immutability( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + **kwargs: Any + ) -> LROPoller[_models.LongTermRetentionBackup]: + """Set legal hold immutability of 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 + :return: An instance of LROPoller that returns LongTermRetentionBackup. The + LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._set_legal_hold_immutability_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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LongTermRetentionBackup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.LongTermRetentionBackup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.LongTermRetentionBackup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + 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, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_long_term_retention_backups_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 + ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: + """Updates an existing long term retention backup. + + :param location_name: The location of the database. Required. + :type location_name: str + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :param parameters: The requested backup resource state. Required. + :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns LongTermRetentionBackupOperationResult. The + LongTermRetentionBackupOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: + """Updates an existing long term retention backup. + + :param location_name: The location of the database. Required. + :type location_name: str + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :param parameters: The requested backup resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns LongTermRetentionBackupOperationResult. The + LongTermRetentionBackupOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: + """Updates an existing long term retention backup. + + :param location_name: The location of the database. Required. + :type location_name: str + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :param parameters: The requested backup resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns LongTermRetentionBackupOperationResult. The + LongTermRetentionBackupOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + 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, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: + """Updates an existing long term retention backup. + + :param location_name: The location of the database. Required. + :type location_name: str + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :param parameters: The requested backup resource state. Is one of the following types: + UpdateLongTermRetentionBackupParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters or JSON or + IO[bytes] + :return: An instance of LROPoller that returns LongTermRetentionBackupOperationResult. The + LongTermRetentionBackupOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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( + 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, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LongTermRetentionBackupOperationResult, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.LongTermRetentionBackupOperationResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.LongTermRetentionBackupOperationResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @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. The name is case insensitive. + 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 + :return: LongTermRetentionBackup. The LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.LongTermRetentionBackup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) + + _request = build_long_term_retention_backups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.LongTermRetentionBackup, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _delete_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, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_long_term_retention_backups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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. The name is case insensitive. + 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 + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @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 + ) -> ItemPaged["_models.LongTermRetentionBackup"]: + """Lists all long term retention backups for a database based on a particular resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :keyword only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :paramtype only_latest_per_database: bool + :keyword 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. + :paramtype database_state: str or ~azure.mgmt.sql.models.DatabaseState + :return: An iterator like instance of LongTermRetentionBackup + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.LongTermRetentionBackup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_long_term_retention_backups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.LongTermRetentionBackup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _change_access_tier_by_resource_group_initial( # pylint: disable=name-too-long + 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.ChangeLongTermRetentionBackupAccessTierParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_long_term_retention_backups_change_access_tier_by_resource_group_request( + resource_group_name=resource_group_name, + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_change_access_tier_by_resource_group( # pylint: disable=name-too-long + 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.ChangeLongTermRetentionBackupAccessTierParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LongTermRetentionBackup]: + """Change a long term retention backup access tier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: Required. + :type parameters: ~azure.mgmt.sql.models.ChangeLongTermRetentionBackupAccessTierParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns LongTermRetentionBackup. The + LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_change_access_tier_by_resource_group( # pylint: disable=name-too-long + self, + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LongTermRetentionBackup]: + """Change a long term retention backup access tier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns LongTermRetentionBackup. The + LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_change_access_tier_by_resource_group( # pylint: disable=name-too-long + 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[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LongTermRetentionBackup]: + """Change a long term retention backup access tier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns LongTermRetentionBackup. The + LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_change_access_tier_by_resource_group( # pylint: disable=name-too-long + 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.ChangeLongTermRetentionBackupAccessTierParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.LongTermRetentionBackup]: + """Change a long term retention backup access tier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: Is one of the following types: + ChangeLongTermRetentionBackupAccessTierParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ChangeLongTermRetentionBackupAccessTierParameters or + JSON or IO[bytes] + :return: An instance of LROPoller that returns LongTermRetentionBackup. The + LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._change_access_tier_by_resource_group_initial( + resource_group_name=resource_group_name, + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + backup_name=backup_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LongTermRetentionBackup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.LongTermRetentionBackup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.LongTermRetentionBackup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _copy_by_resource_group_initial( + self, + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: Union[_models.CopyLongTermRetentionBackupParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_long_term_retention_backups_copy_by_resource_group_request( + resource_group_name=resource_group_name, + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_copy_by_resource_group( + self, + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: _models.CopyLongTermRetentionBackupParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: + """Copy an existing long term retention backup to a different server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An instance of LROPoller that returns LongTermRetentionBackupOperationResult. The + LongTermRetentionBackupOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_copy_by_resource_group( + self, + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: + """Copy an existing long term retention backup to a different server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns LongTermRetentionBackupOperationResult. The + LongTermRetentionBackupOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_copy_by_resource_group( + self, + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: + """Copy an existing long term retention backup to a different server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The location of the database. Required. + :type location_name: str + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :param parameters: The parameters needed for long term retention copy request. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns LongTermRetentionBackupOperationResult. The + LongTermRetentionBackupOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_copy_by_resource_group( + self, + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: Union[_models.CopyLongTermRetentionBackupParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: + """Copy an existing long term retention backup to a different server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 one of the + following types: CopyLongTermRetentionBackupParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.CopyLongTermRetentionBackupParameters or JSON or + IO[bytes] + :return: An instance of LROPoller that returns LongTermRetentionBackupOperationResult. The + LongTermRetentionBackupOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LongTermRetentionBackupOperationResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._copy_by_resource_group_initial( + resource_group_name=resource_group_name, + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + backup_name=backup_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LongTermRetentionBackupOperationResult, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.LongTermRetentionBackupOperationResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.LongTermRetentionBackupOperationResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _lock_time_based_immutability_by_resource_group_initial( # pylint: disable=name-too-long + 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 + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_long_term_retention_backups_lock_time_based_immutability_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_lock_time_based_immutability_by_resource_group( # pylint: disable=name-too-long + 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[_models.LongTermRetentionBackup]: + """Lock time based immutability of an existing long term retention backup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An instance of LROPoller that returns LongTermRetentionBackup. The + LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._lock_time_based_immutability_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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LongTermRetentionBackup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.LongTermRetentionBackup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.LongTermRetentionBackup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _remove_legal_hold_immutability_by_resource_group_initial( # pylint: disable=name-too-long + 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 + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_long_term_retention_backups_remove_legal_hold_immutability_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_remove_legal_hold_immutability_by_resource_group( # pylint: disable=name-too-long + 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[_models.LongTermRetentionBackup]: + """Remove legal hold immutability of an existing long term retention backup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An instance of LROPoller that returns LongTermRetentionBackup. The + LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._remove_legal_hold_immutability_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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LongTermRetentionBackup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.LongTermRetentionBackup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.LongTermRetentionBackup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _remove_time_based_immutability_by_resource_group_initial( # pylint: disable=name-too-long + 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 + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_long_term_retention_backups_remove_time_based_immutability_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_remove_time_based_immutability_by_resource_group( # pylint: disable=name-too-long + 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[_models.LongTermRetentionBackup]: + """Remove time based immutability of an existing long term retention backup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An instance of LROPoller that returns LongTermRetentionBackup. The + LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._remove_time_based_immutability_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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LongTermRetentionBackup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.LongTermRetentionBackup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.LongTermRetentionBackup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _set_legal_hold_immutability_by_resource_group_initial( # pylint: disable=name-too-long + 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 + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_long_term_retention_backups_set_legal_hold_immutability_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_set_legal_hold_immutability_by_resource_group( # pylint: disable=name-too-long + 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[_models.LongTermRetentionBackup]: + """Set legal hold immutability of an existing long term retention backup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An instance of LROPoller that returns LongTermRetentionBackup. The + LongTermRetentionBackup is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._set_legal_hold_immutability_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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LongTermRetentionBackup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.LongTermRetentionBackup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.LongTermRetentionBackup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + 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, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_long_term_retention_backups_update_by_resource_group_request( + resource_group_name=resource_group_name, + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update_by_resource_group( + self, + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: _models.UpdateLongTermRetentionBackupParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: + """Updates an existing long term retention backup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An instance of LROPoller that returns LongTermRetentionBackupOperationResult. The + LongTermRetentionBackupOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_by_resource_group( + self, + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: + """Updates an existing long term retention backup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns LongTermRetentionBackupOperationResult. The + LongTermRetentionBackupOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_by_resource_group( + self, + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: + """Updates an existing long term retention backup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The location of the database. Required. + :type location_name: str + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :param parameters: The requested backup resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns LongTermRetentionBackupOperationResult. The + LongTermRetentionBackupOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_by_resource_group( + self, + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: Union[_models.UpdateLongTermRetentionBackupParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: + """Updates an existing long term retention backup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 one of the following types: + UpdateLongTermRetentionBackupParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters or JSON or + IO[bytes] + :return: An instance of LROPoller that returns LongTermRetentionBackupOperationResult. The + LongTermRetentionBackupOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LongTermRetentionBackupOperationResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_by_resource_group_initial( + resource_group_name=resource_group_name, + location_name=location_name, + long_term_retention_server_name=long_term_retention_server_name, + long_term_retention_database_name=long_term_retention_database_name, + backup_name=backup_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LongTermRetentionBackupOperationResult, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.LongTermRetentionBackupOperationResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.LongTermRetentionBackupOperationResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @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 + ) -> ItemPaged["_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 + :keyword only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :paramtype only_latest_per_database: bool + :keyword 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. + :paramtype database_state: str or ~azure.mgmt.sql.models.DatabaseState + :return: An iterator like instance of LongTermRetentionBackup + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.LongTermRetentionBackup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_long_term_retention_backups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.LongTermRetentionBackup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_server( + self, + location_name: str, + long_term_retention_server_name: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, + **kwargs: Any + ) -> ItemPaged["_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 + :keyword only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :paramtype only_latest_per_database: bool + :keyword 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. + :paramtype database_state: str or ~azure.mgmt.sql.models.DatabaseState + :return: An iterator like instance of LongTermRetentionBackup + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.LongTermRetentionBackup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_long_term_retention_backups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.LongTermRetentionBackup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @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 + ) -> ItemPaged["_models.LongTermRetentionBackup"]: + """Lists the long term retention backups for a given location based on resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The location of the database. Required. + :type location_name: str + :keyword only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :paramtype only_latest_per_database: bool + :keyword 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. + :paramtype database_state: str or ~azure.mgmt.sql.models.DatabaseState + :return: An iterator like instance of LongTermRetentionBackup + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.LongTermRetentionBackup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_long_term_retention_backups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.LongTermRetentionBackup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @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 + ) -> ItemPaged["_models.LongTermRetentionBackup"]: + """Lists the long term retention backups for a given server based on resource groups. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :keyword only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :paramtype only_latest_per_database: bool + :keyword 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. + :paramtype database_state: str or ~azure.mgmt.sql.models.DatabaseState + :return: An iterator like instance of LongTermRetentionBackup + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.LongTermRetentionBackup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_long_term_retention_backups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.LongTermRetentionBackup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class LongTermRetentionManagedInstanceBackupsOperations: # pylint: disable=name-too-long + """ + .. 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_managed_instance_backups` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get_by_resource_group( + self, + resource_group_name: str, + location_name: str, + managed_instance_name: str, + database_name: str, + backup_name: str, + **kwargs: Any + ) -> _models.ManagedInstanceLongTermRetentionBackup: + """Gets a long term retention backup for a managed database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 backup_name: The backup name. Required. + :type backup_name: str + :return: ManagedInstanceLongTermRetentionBackup. The ManagedInstanceLongTermRetentionBackup is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedInstanceLongTermRetentionBackup] = kwargs.pop("cls", None) + + _request = build_long_term_retention_managed_instance_backups_get_by_resource_group_request( + resource_group_name=resource_group_name, + location_name=location_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedInstanceLongTermRetentionBackup, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _delete_by_resource_group_initial( + self, + resource_group_name: str, + location_name: str, + managed_instance_name: str, + database_name: str, + backup_name: str, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_long_term_retention_managed_instance_backups_delete_by_resource_group_request( + resource_group_name=resource_group_name, + location_name=location_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete_by_resource_group( + self, + resource_group_name: str, + location_name: str, + managed_instance_name: str, + database_name: str, + backup_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes a long term retention backup. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 backup_name: The backup name. Required. + :type backup_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + location_name=location_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + backup_name=backup_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @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 + ) -> ItemPaged["_models.ManagedInstanceLongTermRetentionBackup"]: + """Lists all long term retention backups for a managed database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :keyword only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :paramtype only_latest_per_database: bool + :keyword 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. + :paramtype database_state: str or ~azure.mgmt.sql.models.DatabaseState + :return: An iterator like instance of ManagedInstanceLongTermRetentionBackup + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstanceLongTermRetentionBackup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_long_term_retention_managed_instance_backups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstanceLongTermRetentionBackup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, location_name: str, managed_instance_name: str, database_name: str, backup_name: str, **kwargs: Any + ) -> _models.ManagedInstanceLongTermRetentionBackup: + """Gets a long term retention backup for a managed database. + + :param location_name: The location of the database. 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 backup_name: The backup name. Required. + :type backup_name: str + :return: ManagedInstanceLongTermRetentionBackup. The ManagedInstanceLongTermRetentionBackup is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedInstanceLongTermRetentionBackup] = kwargs.pop("cls", None) + + _request = build_long_term_retention_managed_instance_backups_get_request( + location_name=location_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedInstanceLongTermRetentionBackup, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _delete_initial( + self, location_name: str, managed_instance_name: str, database_name: str, backup_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_long_term_retention_managed_instance_backups_delete_request( + location_name=location_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, location_name: str, managed_instance_name: str, database_name: str, backup_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a long term retention backup. + + :param location_name: The location of the database. 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 backup_name: The backup name. Required. + :type backup_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + location_name=location_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + backup_name=backup_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @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 + ) -> ItemPaged["_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 + :keyword only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :paramtype only_latest_per_database: bool + :keyword 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. + :paramtype database_state: str or ~azure.mgmt.sql.models.DatabaseState + :return: An iterator like instance of ManagedInstanceLongTermRetentionBackup + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstanceLongTermRetentionBackup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_long_term_retention_managed_instance_backups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstanceLongTermRetentionBackup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_location( + self, + location_name: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_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 + :keyword only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :paramtype only_latest_per_database: bool + :keyword 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. + :paramtype database_state: str or ~azure.mgmt.sql.models.DatabaseState + :keyword skip: The number of elements in the collection to skip. Default value is None. + :paramtype skip: int + :keyword top: The number of elements to return from the collection. Default value is None. + :paramtype top: int + :keyword filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of ManagedInstanceLongTermRetentionBackup + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstanceLongTermRetentionBackup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_long_term_retention_managed_instance_backups_list_by_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + skip=skip, + top=top, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstanceLongTermRetentionBackup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_instance( + self, + location_name: str, + managed_instance_name: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, + **kwargs: Any + ) -> ItemPaged["_models.ManagedInstanceLongTermRetentionBackup"]: + """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 + :keyword only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :paramtype only_latest_per_database: bool + :keyword 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. + :paramtype database_state: str or ~azure.mgmt.sql.models.DatabaseState + :return: An iterator like instance of ManagedInstanceLongTermRetentionBackup + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstanceLongTermRetentionBackup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_long_term_retention_managed_instance_backups_list_by_instance_request( + location_name=location_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstanceLongTermRetentionBackup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @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, + skip: Optional[int] = None, + top: Optional[int] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_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. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The location of the database. Required. + :type location_name: str + :keyword only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :paramtype only_latest_per_database: bool + :keyword 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. + :paramtype database_state: str or ~azure.mgmt.sql.models.DatabaseState + :keyword skip: The number of elements in the collection to skip. Default value is None. + :paramtype skip: int + :keyword top: The number of elements to return from the collection. Default value is None. + :paramtype top: int + :keyword filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of ManagedInstanceLongTermRetentionBackup + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstanceLongTermRetentionBackup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_long_term_retention_managed_instance_backups_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, + skip=skip, + top=top, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstanceLongTermRetentionBackup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group_instance( + 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 + ) -> ItemPaged["_models.ManagedInstanceLongTermRetentionBackup"]: + """Lists the long term retention backups for a given managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :keyword only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :paramtype only_latest_per_database: bool + :keyword 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. + :paramtype database_state: str or ~azure.mgmt.sql.models.DatabaseState + :return: An iterator like instance of ManagedInstanceLongTermRetentionBackup + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstanceLongTermRetentionBackup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_long_term_retention_managed_instance_backups_list_by_resource_group_instance_request( + resource_group_name=resource_group_name, + location_name=location_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + only_latest_per_database=only_latest_per_database, + database_state=database_state, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstanceLongTermRetentionBackup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class LongTermRetentionPoliciesOperations: + """ + .. 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_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + policy_name: Union[str, _models.LongTermRetentionPolicyName], + **kwargs: Any + ) -> _models.LongTermRetentionPolicy: + """Gets a database's long term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 policy_name: The policy name. Should always be Default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.LongTermRetentionPolicyName + :return: LongTermRetentionPolicy. The LongTermRetentionPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.LongTermRetentionPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LongTermRetentionPolicy] = kwargs.pop("cls", None) + + _request = build_long_term_retention_policies_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.LongTermRetentionPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.LongTermRetentionPolicyName], + parameters: Union[_models.LongTermRetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_long_term_retention_policies_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.LongTermRetentionPolicyName], + parameters: _models.LongTermRetentionPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LongTermRetentionPolicy]: + """Set or update a database's long term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 policy_name: The policy name. Should always be Default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.LongTermRetentionPolicyName + :param parameters: The long term retention policy info. Required. + :type parameters: ~azure.mgmt.sql.models.LongTermRetentionPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns LongTermRetentionPolicy. The + LongTermRetentionPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.LongTermRetentionPolicyName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LongTermRetentionPolicy]: + """Set or update a database's long term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 policy_name: The policy name. Should always be Default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.LongTermRetentionPolicyName + :param parameters: The long term retention policy info. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns LongTermRetentionPolicy. The + LongTermRetentionPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.LongTermRetentionPolicyName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LongTermRetentionPolicy]: + """Set or update a database's long term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 policy_name: The policy name. Should always be Default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.LongTermRetentionPolicyName + :param parameters: The long term retention policy info. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns LongTermRetentionPolicy. The + LongTermRetentionPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.LongTermRetentionPolicyName], + parameters: Union[_models.LongTermRetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.LongTermRetentionPolicy]: + """Set or update a database's long term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 policy_name: The policy name. Should always be Default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.LongTermRetentionPolicyName + :param parameters: The long term retention policy info. Is one of the following types: + LongTermRetentionPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.LongTermRetentionPolicy or JSON or IO[bytes] + :return: An instance of LROPoller that returns LongTermRetentionPolicy. The + LongTermRetentionPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + policy_name=policy_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LongTermRetentionPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.LongTermRetentionPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.LongTermRetentionPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> ItemPaged["_models.LongTermRetentionPolicy"]: + """Gets a database's long term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of LongTermRetentionPolicy + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LongTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.LongTermRetentionPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_long_term_retention_policies_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.LongTermRetentionPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ManagedBackupShortTermRetentionPoliciesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_backup_short_term_retention_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + **kwargs: Any + ) -> _models.ManagedBackupShortTermRetentionPolicy: + """Gets a managed database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :return: ManagedBackupShortTermRetentionPolicy. The ManagedBackupShortTermRetentionPolicy is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedBackupShortTermRetentionPolicy] = kwargs.pop("cls", None) + + _request = build_managed_backup_short_term_retention_policies_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedBackupShortTermRetentionPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: Union[_models.ManagedBackupShortTermRetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_backup_short_term_retention_policies_create_or_update_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: _models.ManagedBackupShortTermRetentionPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedBackupShortTermRetentionPolicy]: + """Updates a managed database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedBackupShortTermRetentionPolicy. The + ManagedBackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedBackupShortTermRetentionPolicy]: + """Updates a managed database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedBackupShortTermRetentionPolicy. The + ManagedBackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedBackupShortTermRetentionPolicy]: + """Updates a managed database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedBackupShortTermRetentionPolicy. The + ManagedBackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: Union[_models.ManagedBackupShortTermRetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ManagedBackupShortTermRetentionPolicy]: + """Updates a managed database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Is one of the following types: + ManagedBackupShortTermRetentionPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy or JSON or + IO[bytes] + :return: An instance of LROPoller that returns ManagedBackupShortTermRetentionPolicy. The + ManagedBackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + database_name=database_name, + policy_name=policy_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedBackupShortTermRetentionPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ManagedBackupShortTermRetentionPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ManagedBackupShortTermRetentionPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: Union[_models.ManagedBackupShortTermRetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_backup_short_term_retention_policies_update_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: _models.ManagedBackupShortTermRetentionPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedBackupShortTermRetentionPolicy]: + """Updates a managed database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedBackupShortTermRetentionPolicy. The + ManagedBackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedBackupShortTermRetentionPolicy]: + """Updates a managed database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedBackupShortTermRetentionPolicy. The + ManagedBackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedBackupShortTermRetentionPolicy]: + """Updates a managed database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedBackupShortTermRetentionPolicy. The + ManagedBackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: Union[_models.ManagedBackupShortTermRetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ManagedBackupShortTermRetentionPolicy]: + """Updates a managed database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Is one of the following types: + ManagedBackupShortTermRetentionPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy or JSON or + IO[bytes] + :return: An instance of LROPoller that returns ManagedBackupShortTermRetentionPolicy. The + ManagedBackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + policy_name=policy_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedBackupShortTermRetentionPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ManagedBackupShortTermRetentionPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ManagedBackupShortTermRetentionPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_database( + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> ItemPaged["_models.ManagedBackupShortTermRetentionPolicy"]: + """Gets a managed database's short term retention policy list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An iterator like instance of ManagedBackupShortTermRetentionPolicy + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedBackupShortTermRetentionPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_backup_short_term_retention_policies_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedBackupShortTermRetentionPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_restorable_dropped_database_backup_short_term_retention_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + **kwargs: Any + ) -> _models.ManagedBackupShortTermRetentionPolicy: + """Gets a dropped database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :return: ManagedBackupShortTermRetentionPolicy. The ManagedBackupShortTermRetentionPolicy is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedBackupShortTermRetentionPolicy] = kwargs.pop("cls", None) + + _request = build_managed_restorable_dropped_database_backup_short_term_retention_policies_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + restorable_dropped_database_id=restorable_dropped_database_id, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedBackupShortTermRetentionPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: Union[_models.ManagedBackupShortTermRetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = ( + build_managed_restorable_dropped_database_backup_short_term_retention_policies_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + restorable_dropped_database_id=restorable_dropped_database_id, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: _models.ManagedBackupShortTermRetentionPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedBackupShortTermRetentionPolicy]: + """Sets a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedBackupShortTermRetentionPolicy. The + ManagedBackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedBackupShortTermRetentionPolicy]: + """Sets a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedBackupShortTermRetentionPolicy. The + ManagedBackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedBackupShortTermRetentionPolicy]: + """Sets a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedBackupShortTermRetentionPolicy. The + ManagedBackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: Union[_models.ManagedBackupShortTermRetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ManagedBackupShortTermRetentionPolicy]: + """Sets a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Is one of the following types: + ManagedBackupShortTermRetentionPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy or JSON or + IO[bytes] + :return: An instance of LROPoller that returns ManagedBackupShortTermRetentionPolicy. The + ManagedBackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + restorable_dropped_database_id=restorable_dropped_database_id, + policy_name=policy_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedBackupShortTermRetentionPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ManagedBackupShortTermRetentionPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ManagedBackupShortTermRetentionPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: Union[_models.ManagedBackupShortTermRetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_restorable_dropped_database_backup_short_term_retention_policies_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + restorable_dropped_database_id=restorable_dropped_database_id, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: _models.ManagedBackupShortTermRetentionPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedBackupShortTermRetentionPolicy]: + """Sets a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedBackupShortTermRetentionPolicy. The + ManagedBackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedBackupShortTermRetentionPolicy]: + """Sets a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedBackupShortTermRetentionPolicy. The + ManagedBackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedBackupShortTermRetentionPolicy]: + """Sets a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedBackupShortTermRetentionPolicy. The + ManagedBackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + managed_instance_name: str, + restorable_dropped_database_id: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + parameters: Union[_models.ManagedBackupShortTermRetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ManagedBackupShortTermRetentionPolicy]: + """Sets a database's short term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :param policy_name: The policy name. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedShortTermRetentionPolicyName + :param parameters: The short term retention policy info. Is one of the following types: + ManagedBackupShortTermRetentionPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy or JSON or + IO[bytes] + :return: An instance of LROPoller that returns ManagedBackupShortTermRetentionPolicy. The + ManagedBackupShortTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + restorable_dropped_database_id=restorable_dropped_database_id, + policy_name=policy_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedBackupShortTermRetentionPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ManagedBackupShortTermRetentionPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ManagedBackupShortTermRetentionPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_restorable_dropped_database( + self, resource_group_name: str, managed_instance_name: str, restorable_dropped_database_id: str, **kwargs: Any + ) -> ItemPaged["_models.ManagedBackupShortTermRetentionPolicy"]: + """Gets a dropped database's short term retention policy list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An iterator like instance of ManagedBackupShortTermRetentionPolicy + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedBackupShortTermRetentionPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_restorable_dropped_database_backup_short_term_retention_policies_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedBackupShortTermRetentionPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ManagedDatabaseSecurityAlertPoliciesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_database_security_alert_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + **kwargs: Any + ) -> _models.ManagedDatabaseSecurityAlertPolicy: + """Gets a managed database's security alert policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 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 + :return: ManagedDatabaseSecurityAlertPolicy. The ManagedDatabaseSecurityAlertPolicy is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedDatabaseSecurityAlertPolicy] = kwargs.pop("cls", None) + + _request = build_managed_database_security_alert_policies_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + security_alert_policy_name=security_alert_policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedDatabaseSecurityAlertPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: _models.ManagedDatabaseSecurityAlertPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedDatabaseSecurityAlertPolicy: + """Creates or updates a database's security alert policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedDatabaseSecurityAlertPolicy. The ManagedDatabaseSecurityAlertPolicy is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedDatabaseSecurityAlertPolicy: + """Creates or updates a database's security alert policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedDatabaseSecurityAlertPolicy. The ManagedDatabaseSecurityAlertPolicy is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedDatabaseSecurityAlertPolicy: + """Creates or updates a database's security alert policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 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[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedDatabaseSecurityAlertPolicy. The ManagedDatabaseSecurityAlertPolicy is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: Union[_models.ManagedDatabaseSecurityAlertPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ManagedDatabaseSecurityAlertPolicy: + """Creates or updates a database's security alert policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 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 one of the following types: + ManagedDatabaseSecurityAlertPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy or JSON or + IO[bytes] + :return: ManagedDatabaseSecurityAlertPolicy. The ManagedDatabaseSecurityAlertPolicy is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_database_security_alert_policies_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + security_alert_policy_name=security_alert_policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = 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]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedDatabaseSecurityAlertPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_database( + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> ItemPaged["_models.ManagedDatabaseSecurityAlertPolicy"]: + """Gets a list of managed database's security alert policies. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An iterator like instance of ManagedDatabaseSecurityAlertPolicy + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedDatabaseSecurityAlertPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_database_security_alert_policies_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedDatabaseSecurityAlertPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ManagedInstanceAdministratorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_instance_administrators` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + managed_instance_name: str, + administrator_name: Union[str, _models.AdministratorName], + **kwargs: Any + ) -> _models.ManagedInstanceAdministrator: + """Gets a managed instance administrator. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param administrator_name: "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName + :return: ManagedInstanceAdministrator. The ManagedInstanceAdministrator is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstanceAdministrator + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedInstanceAdministrator] = kwargs.pop("cls", None) + + _request = build_managed_instance_administrators_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + administrator_name=administrator_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedInstanceAdministrator, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + administrator_name: Union[str, _models.AdministratorName], + parameters: Union[_models.ManagedInstanceAdministrator, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_instance_administrators_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + administrator_name=administrator_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + administrator_name: Union[str, _models.AdministratorName], + parameters: _models.ManagedInstanceAdministrator, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedInstanceAdministrator]: + """Creates or updates a managed instance administrator. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param administrator_name: "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName + :param parameters: The requested administrator parameters. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceAdministrator + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedInstanceAdministrator. The + ManagedInstanceAdministrator is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceAdministrator] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + administrator_name: Union[str, _models.AdministratorName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedInstanceAdministrator]: + """Creates or updates a managed instance administrator. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param administrator_name: "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName + :param parameters: The requested administrator parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedInstanceAdministrator. The + ManagedInstanceAdministrator is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceAdministrator] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + administrator_name: Union[str, _models.AdministratorName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedInstanceAdministrator]: + """Creates or updates a managed instance administrator. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param administrator_name: "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName + :param parameters: The requested administrator parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedInstanceAdministrator. The + ManagedInstanceAdministrator is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceAdministrator] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + administrator_name: Union[str, _models.AdministratorName], + parameters: Union[_models.ManagedInstanceAdministrator, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ManagedInstanceAdministrator]: + """Creates or updates a managed instance administrator. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param administrator_name: "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName + :param parameters: The requested administrator parameters. Is one of the following types: + ManagedInstanceAdministrator, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceAdministrator or JSON or IO[bytes] + :return: An instance of LROPoller that returns ManagedInstanceAdministrator. The + ManagedInstanceAdministrator is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceAdministrator] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + administrator_name=administrator_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedInstanceAdministrator, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ManagedInstanceAdministrator].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ManagedInstanceAdministrator]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, + resource_group_name: str, + managed_instance_name: str, + administrator_name: Union[str, _models.AdministratorName], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_instance_administrators_delete_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + administrator_name=administrator_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + managed_instance_name: str, + administrator_name: Union[str, _models.AdministratorName], + **kwargs: Any + ) -> LROPoller[None]: + """Deletes a managed instance administrator. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param administrator_name: "ActiveDirectory" Required. + :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + administrator_name=administrator_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> ItemPaged["_models.ManagedInstanceAdministrator"]: + """Gets a list of managed instance administrators. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of ManagedInstanceAdministrator + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceAdministrator] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstanceAdministrator]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_instance_administrators_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstanceAdministrator], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ManagedInstanceAzureADOnlyAuthenticationsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_instance_azure_ad_only_authentications` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + managed_instance_name: str, + authentication_name: Union[str, _models.AuthenticationName], + **kwargs: Any + ) -> _models.ManagedInstanceAzureADOnlyAuthentication: + """Gets a specific Azure Active Directory only authentication property. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param authentication_name: The name of server azure active directory only authentication. + "Default" Required. + :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName + :return: ManagedInstanceAzureADOnlyAuthentication. The ManagedInstanceAzureADOnlyAuthentication + is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedInstanceAzureADOnlyAuthentication] = kwargs.pop("cls", None) + + _request = build_managed_instance_azure_ad_only_authentications_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + authentication_name=authentication_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedInstanceAzureADOnlyAuthentication, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + authentication_name: Union[str, _models.AuthenticationName], + parameters: Union[_models.ManagedInstanceAzureADOnlyAuthentication, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_instance_azure_ad_only_authentications_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + authentication_name=authentication_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + authentication_name: Union[str, _models.AuthenticationName], + parameters: _models.ManagedInstanceAzureADOnlyAuthentication, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedInstanceAzureADOnlyAuthentication]: + """Sets Server Active Directory only authentication property or updates an existing server Active + Directory only authentication property. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param authentication_name: The name of server azure active directory only authentication. + "Default" Required. + :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName + :param parameters: The required parameters for creating or updating an Active Directory only + authentication property. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedInstanceAzureADOnlyAuthentication. The + ManagedInstanceAzureADOnlyAuthentication is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + authentication_name: Union[str, _models.AuthenticationName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedInstanceAzureADOnlyAuthentication]: + """Sets Server Active Directory only authentication property or updates an existing server Active + Directory only authentication property. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param authentication_name: The name of server azure active directory only authentication. + "Default" Required. + :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName + :param parameters: The required parameters for creating or updating an Active Directory only + authentication property. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedInstanceAzureADOnlyAuthentication. The + ManagedInstanceAzureADOnlyAuthentication is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + authentication_name: Union[str, _models.AuthenticationName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedInstanceAzureADOnlyAuthentication]: + """Sets Server Active Directory only authentication property or updates an existing server Active + Directory only authentication property. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param authentication_name: The name of server azure active directory only authentication. + "Default" Required. + :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName + :param parameters: The required parameters for creating or updating an Active Directory only + authentication property. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedInstanceAzureADOnlyAuthentication. The + ManagedInstanceAzureADOnlyAuthentication is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + authentication_name: Union[str, _models.AuthenticationName], + parameters: Union[_models.ManagedInstanceAzureADOnlyAuthentication, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ManagedInstanceAzureADOnlyAuthentication]: + """Sets Server Active Directory only authentication property or updates an existing server Active + Directory only authentication property. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param authentication_name: The name of server azure active directory only authentication. + "Default" Required. + :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName + :param parameters: The required parameters for creating or updating an Active Directory only + authentication property. Is one of the following types: + ManagedInstanceAzureADOnlyAuthentication, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication or JSON or + IO[bytes] + :return: An instance of LROPoller that returns ManagedInstanceAzureADOnlyAuthentication. The + ManagedInstanceAzureADOnlyAuthentication is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + authentication_name=authentication_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedInstanceAzureADOnlyAuthentication, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ManagedInstanceAzureADOnlyAuthentication].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ManagedInstanceAzureADOnlyAuthentication]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, + resource_group_name: str, + managed_instance_name: str, + authentication_name: Union[str, _models.AuthenticationName], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_instance_azure_ad_only_authentications_delete_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + authentication_name=authentication_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + managed_instance_name: str, + authentication_name: Union[str, _models.AuthenticationName], + **kwargs: Any + ) -> LROPoller[None]: + """Deletes an existing server Active Directory only authentication property. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param authentication_name: The name of server azure active directory only authentication. + "Default" Required. + :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + authentication_name=authentication_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> ItemPaged["_models.ManagedInstanceAzureADOnlyAuthentication"]: + """Gets a list of server Azure Active Directory only authentications. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of ManagedInstanceAzureADOnlyAuthentication + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstanceAzureADOnlyAuthentication]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_instance_azure_ad_only_authentications_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstanceAzureADOnlyAuthentication], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ManagedInstanceDtcsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_instance_dtcs` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, managed_instance_name: str, dtc_name: Union[str, _models.DtcName], **kwargs: Any + ) -> _models.ManagedInstanceDtc: + """Gets managed instance DTC settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param dtc_name: The name of the managed instance DTC. "current" Required. + :type dtc_name: str or ~azure.mgmt.sql.models.DtcName + :return: ManagedInstanceDtc. The ManagedInstanceDtc is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstanceDtc + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedInstanceDtc] = kwargs.pop("cls", None) + + _request = build_managed_instance_dtcs_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + dtc_name=dtc_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedInstanceDtc, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + dtc_name: Union[str, _models.DtcName], + parameters: Union[_models.ManagedInstanceDtc, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_instance_dtcs_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + dtc_name=dtc_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + dtc_name: Union[str, _models.DtcName], + parameters: _models.ManagedInstanceDtc, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedInstanceDtc]: + """Updates managed instance DTC settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param dtc_name: The name of the managed instance DTC. "current" Required. + :type dtc_name: str or ~azure.mgmt.sql.models.DtcName + :param parameters: Managed instance DTC settings. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceDtc + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedInstanceDtc. The ManagedInstanceDtc is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceDtc] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + dtc_name: Union[str, _models.DtcName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedInstanceDtc]: + """Updates managed instance DTC settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param dtc_name: The name of the managed instance DTC. "current" Required. + :type dtc_name: str or ~azure.mgmt.sql.models.DtcName + :param parameters: Managed instance DTC settings. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedInstanceDtc. The ManagedInstanceDtc is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceDtc] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + dtc_name: Union[str, _models.DtcName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedInstanceDtc]: + """Updates managed instance DTC settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param dtc_name: The name of the managed instance DTC. "current" Required. + :type dtc_name: str or ~azure.mgmt.sql.models.DtcName + :param parameters: Managed instance DTC settings. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedInstanceDtc. The ManagedInstanceDtc is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceDtc] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + dtc_name: Union[str, _models.DtcName], + parameters: Union[_models.ManagedInstanceDtc, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ManagedInstanceDtc]: + """Updates managed instance DTC settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param dtc_name: The name of the managed instance DTC. "current" Required. + :type dtc_name: str or ~azure.mgmt.sql.models.DtcName + :param parameters: Managed instance DTC settings. Is one of the following types: + ManagedInstanceDtc, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceDtc or JSON or IO[bytes] + :return: An instance of LROPoller that returns ManagedInstanceDtc. The ManagedInstanceDtc is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceDtc] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + dtc_name=dtc_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = _deserialize(_models.ManagedInstanceDtc, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ManagedInstanceDtc].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ManagedInstanceDtc]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_managed_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> ItemPaged["_models.ManagedInstanceDtc"]: + """Gets a list of managed instance DTC settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of ManagedInstanceDtc + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceDtc] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstanceDtc]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_instance_dtcs_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstanceDtc], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ManagedInstanceEncryptionProtectorsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_instance_encryption_protectors` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + managed_instance_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + **kwargs: Any + ) -> _models.ManagedInstanceEncryptionProtector: + """Gets a managed instance encryption protector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 retrieved. + "current" Required. + :type encryption_protector_name: str or ~azure.mgmt.sql.models.EncryptionProtectorName + :return: ManagedInstanceEncryptionProtector. The ManagedInstanceEncryptionProtector is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedInstanceEncryptionProtector] = kwargs.pop("cls", None) + + _request = build_managed_instance_encryption_protectors_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + encryption_protector_name=encryption_protector_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedInstanceEncryptionProtector, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + parameters: Union[_models.ManagedInstanceEncryptionProtector, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_instance_encryption_protectors_create_or_update_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + parameters: _models.ManagedInstanceEncryptionProtector, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedInstanceEncryptionProtector]: + """Updates an existing encryption protector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 retrieved. + "current" Required. + :type encryption_protector_name: str or ~azure.mgmt.sql.models.EncryptionProtectorName + :param parameters: The requested encryption protector resource state. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedInstanceEncryptionProtector. The + ManagedInstanceEncryptionProtector is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedInstanceEncryptionProtector]: + """Updates an existing encryption protector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 retrieved. + "current" Required. + :type encryption_protector_name: str or ~azure.mgmt.sql.models.EncryptionProtectorName + :param parameters: The requested encryption protector resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedInstanceEncryptionProtector. The + ManagedInstanceEncryptionProtector is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedInstanceEncryptionProtector]: + """Updates an existing encryption protector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 retrieved. + "current" Required. + :type encryption_protector_name: str or ~azure.mgmt.sql.models.EncryptionProtectorName + :param parameters: The requested encryption protector resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedInstanceEncryptionProtector. The + ManagedInstanceEncryptionProtector is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + parameters: Union[_models.ManagedInstanceEncryptionProtector, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ManagedInstanceEncryptionProtector]: + """Updates an existing encryption protector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 retrieved. + "current" Required. + :type encryption_protector_name: str or ~azure.mgmt.sql.models.EncryptionProtectorName + :param parameters: The requested encryption protector resource state. Is one of the following + types: ManagedInstanceEncryptionProtector, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector or JSON or + IO[bytes] + :return: An instance of LROPoller that returns ManagedInstanceEncryptionProtector. The + ManagedInstanceEncryptionProtector is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + encryption_protector_name=encryption_protector_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedInstanceEncryptionProtector, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ManagedInstanceEncryptionProtector].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ManagedInstanceEncryptionProtector]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> ItemPaged["_models.ManagedInstanceEncryptionProtector"]: + """Gets a list of managed instance encryption protectors. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of ManagedInstanceEncryptionProtector + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceEncryptionProtector] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstanceEncryptionProtector]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_instance_encryption_protectors_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstanceEncryptionProtector], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _revalidate_initial( + self, + resource_group_name: str, + managed_instance_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_instance_encryption_protectors_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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. The name is case insensitive. + 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 retrieved. + "current" Required. + :type encryption_protector_name: str or ~azure.mgmt.sql.models.EncryptionProtectorName + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + encryption_protector_name=encryption_protector_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class ManagedInstanceKeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_instance_keys` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, managed_instance_name: str, key_name: str, **kwargs: Any + ) -> _models.ManagedInstanceKey: + """Gets a managed instance key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param key_name: The name of the managed instance key to be retrieved. Required. + :type key_name: str + :return: ManagedInstanceKey. The ManagedInstanceKey is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstanceKey + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedInstanceKey] = kwargs.pop("cls", None) + + _request = build_managed_instance_keys_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedInstanceKey, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + key_name: str, + parameters: Union[_models.ManagedInstanceKey, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_instance_keys_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + key_name: str, + parameters: _models.ManagedInstanceKey, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedInstanceKey]: + """Creates or updates a managed instance key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param key_name: The name of the managed instance key to be retrieved. Required. + :type key_name: str + :param parameters: The requested managed instance key resource state. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceKey + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedInstanceKey. The ManagedInstanceKey is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceKey] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + key_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedInstanceKey]: + """Creates or updates a managed instance key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param key_name: The name of the managed instance key to be retrieved. Required. + :type key_name: str + :param parameters: The requested managed instance key resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedInstanceKey. The ManagedInstanceKey is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceKey] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + key_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedInstanceKey]: + """Creates or updates a managed instance key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param key_name: The name of the managed instance key to be retrieved. Required. + :type key_name: str + :param parameters: The requested managed instance key resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedInstanceKey. The ManagedInstanceKey is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceKey] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + key_name: str, + parameters: Union[_models.ManagedInstanceKey, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ManagedInstanceKey]: + """Creates or updates a managed instance key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param key_name: The name of the managed instance key to be retrieved. Required. + :type key_name: str + :param parameters: The requested managed instance key resource state. Is one of the following + types: ManagedInstanceKey, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceKey or JSON or IO[bytes] + :return: An instance of LROPoller that returns ManagedInstanceKey. The ManagedInstanceKey is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceKey] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + key_name=key_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedInstanceKey, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ManagedInstanceKey].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ManagedInstanceKey]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, managed_instance_name: str, key_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_instance_keys_delete_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, managed_instance_name: str, key_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the managed instance key with the given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param key_name: The name of the managed instance key to be retrieved. Required. + :type key_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + key_name=key_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, *, filter: Optional[str] = None, **kwargs: Any + ) -> ItemPaged["_models.ManagedInstanceKey"]: + """Gets a list of managed instance keys. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :keyword filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of ManagedInstanceKey + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceKey] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstanceKey]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_instance_keys_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstanceKey], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ManagedInstanceLongTermRetentionPoliciesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_instance_long_term_retention_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedInstanceLongTermRetentionPolicyName], + **kwargs: Any + ) -> _models.ManagedInstanceLongTermRetentionPolicy: + """Gets a managed database's long term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 policy_name: The policy name. Should always be Default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicyName + :return: ManagedInstanceLongTermRetentionPolicy. The ManagedInstanceLongTermRetentionPolicy is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedInstanceLongTermRetentionPolicy] = kwargs.pop("cls", None) + + _request = build_managed_instance_long_term_retention_policies_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedInstanceLongTermRetentionPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedInstanceLongTermRetentionPolicyName], + parameters: Union[_models.ManagedInstanceLongTermRetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_instance_long_term_retention_policies_create_or_update_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedInstanceLongTermRetentionPolicyName], + parameters: _models.ManagedInstanceLongTermRetentionPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedInstanceLongTermRetentionPolicy]: + """Sets a managed database's long term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 policy_name: The policy name. Should always be Default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicyName + :param parameters: The long term retention policy info. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedInstanceLongTermRetentionPolicy. The + ManagedInstanceLongTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedInstanceLongTermRetentionPolicyName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedInstanceLongTermRetentionPolicy]: + """Sets a managed database's long term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 policy_name: The policy name. Should always be Default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicyName + :param parameters: The long term retention policy info. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedInstanceLongTermRetentionPolicy. The + ManagedInstanceLongTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedInstanceLongTermRetentionPolicyName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedInstanceLongTermRetentionPolicy]: + """Sets a managed database's long term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 policy_name: The policy name. Should always be Default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicyName + :param parameters: The long term retention policy info. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedInstanceLongTermRetentionPolicy. The + ManagedInstanceLongTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedInstanceLongTermRetentionPolicyName], + parameters: Union[_models.ManagedInstanceLongTermRetentionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ManagedInstanceLongTermRetentionPolicy]: + """Sets a managed database's long term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 policy_name: The policy name. Should always be Default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicyName + :param parameters: The long term retention policy info. Is one of the following types: + ManagedInstanceLongTermRetentionPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy or JSON or + IO[bytes] + :return: An instance of LROPoller that returns ManagedInstanceLongTermRetentionPolicy. The + ManagedInstanceLongTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + database_name=database_name, + policy_name=policy_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedInstanceLongTermRetentionPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ManagedInstanceLongTermRetentionPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ManagedInstanceLongTermRetentionPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedInstanceLongTermRetentionPolicyName], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_instance_long_term_retention_policies_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + 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. The name is case insensitive. + 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 policy_name: The policy name. Should always be Default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicyName + :return: An instance of LROPoller that returns ManagedInstanceLongTermRetentionPolicy. The + ManagedInstanceLongTermRetentionPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedInstanceLongTermRetentionPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ManagedInstanceLongTermRetentionPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ManagedInstanceLongTermRetentionPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_database( + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> ItemPaged["_models.ManagedInstanceLongTermRetentionPolicy"]: + """Gets a database's long term retention policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An iterator like instance of ManagedInstanceLongTermRetentionPolicy + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstanceLongTermRetentionPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_instance_long_term_retention_policies_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstanceLongTermRetentionPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ManagedInstanceOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_instance_operations` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, managed_instance_name: str, operation_id: str, **kwargs: Any + ) -> _models.ManagedInstanceOperation: + """Gets a management operation on a managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param operation_id: Required. + :type operation_id: str + :return: ManagedInstanceOperation. The ManagedInstanceOperation is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstanceOperation + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedInstanceOperation] = kwargs.pop("cls", None) + + _request = build_managed_instance_operations_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedInstanceOperation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_managed_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> ItemPaged["_models.ManagedInstanceOperation"]: + """Gets a list of operations performed on the managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of ManagedInstanceOperation + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceOperation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstanceOperation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_instance_operations_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstanceOperation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def cancel( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, managed_instance_name: str, operation_id: str, **kwargs: Any + ) -> None: + """Cancels the asynchronous operation on the managed instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param operation_id: Required. + :type operation_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_managed_instance_operations_cancel_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class ManagedInstancePrivateEndpointConnectionsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_instance_private_endpoint_connections` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, managed_instance_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.ManagedInstancePrivateEndpointConnection: + """Gets a private endpoint connection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :return: ManagedInstancePrivateEndpointConnection. The ManagedInstancePrivateEndpointConnection + is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedInstancePrivateEndpointConnection] = kwargs.pop("cls", None) + + _request = build_managed_instance_private_endpoint_connections_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedInstancePrivateEndpointConnection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.ManagedInstancePrivateEndpointConnection, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_instance_private_endpoint_connections_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + private_endpoint_connection_name: str, + parameters: _models.ManagedInstancePrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedInstancePrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedInstancePrivateEndpointConnection. The + ManagedInstancePrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + private_endpoint_connection_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedInstancePrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedInstancePrivateEndpointConnection. The + ManagedInstancePrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + private_endpoint_connection_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedInstancePrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedInstancePrivateEndpointConnection. The + ManagedInstancePrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.ManagedInstancePrivateEndpointConnection, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ManagedInstancePrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Is one of the following types: ManagedInstancePrivateEndpointConnection, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection or JSON or + IO[bytes] + :return: An instance of LROPoller that returns ManagedInstancePrivateEndpointConnection. The + ManagedInstancePrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + private_endpoint_connection_name=private_endpoint_connection_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedInstancePrivateEndpointConnection, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ManagedInstancePrivateEndpointConnection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ManagedInstancePrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, managed_instance_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_instance_private_endpoint_connections_delete_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, managed_instance_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + private_endpoint_connection_name=private_endpoint_connection_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_managed_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> ItemPaged["_models.ManagedInstancePrivateEndpointConnection"]: + """Gets all private endpoint connections on a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of ManagedInstancePrivateEndpointConnection + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstancePrivateEndpointConnection]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_instance_private_endpoint_connections_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstancePrivateEndpointConnection], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ManagedInstanceVulnerabilityAssessmentsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_instance_vulnerability_assessments` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + managed_instance_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + **kwargs: Any + ) -> _models.ManagedInstanceVulnerabilityAssessment: + """Gets the managed instance's vulnerability assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_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 + :return: ManagedInstanceVulnerabilityAssessment. The ManagedInstanceVulnerabilityAssessment is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedInstanceVulnerabilityAssessment] = kwargs.pop("cls", None) + + _request = build_managed_instance_vulnerability_assessments_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedInstanceVulnerabilityAssessment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: _models.ManagedInstanceVulnerabilityAssessment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedInstanceVulnerabilityAssessment: + """Creates or updates the managed instance's vulnerability assessment. Learn more about setting + SQL vulnerability assessment with managed identity - + `https://docs.microsoft.com/azure/azure-sql/database/sql-database-vulnerability-assessment-storage + `_. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_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 parameters: The requested resource. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedInstanceVulnerabilityAssessment. The ManagedInstanceVulnerabilityAssessment is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedInstanceVulnerabilityAssessment: + """Creates or updates the managed instance's vulnerability assessment. Learn more about setting + SQL vulnerability assessment with managed identity - + `https://docs.microsoft.com/azure/azure-sql/database/sql-database-vulnerability-assessment-storage + `_. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_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 parameters: The requested resource. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedInstanceVulnerabilityAssessment. The ManagedInstanceVulnerabilityAssessment is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedInstanceVulnerabilityAssessment: + """Creates or updates the managed instance's vulnerability assessment. Learn more about setting + SQL vulnerability assessment with managed identity - + `https://docs.microsoft.com/azure/azure-sql/database/sql-database-vulnerability-assessment-storage + `_. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_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 parameters: The requested resource. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedInstanceVulnerabilityAssessment. The ManagedInstanceVulnerabilityAssessment is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: Union[_models.ManagedInstanceVulnerabilityAssessment, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ManagedInstanceVulnerabilityAssessment: + """Creates or updates the managed instance's vulnerability assessment. Learn more about setting + SQL vulnerability assessment with managed identity - + `https://docs.microsoft.com/azure/azure-sql/database/sql-database-vulnerability-assessment-storage + `_. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_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 parameters: The requested resource. Is one of the following types: + ManagedInstanceVulnerabilityAssessment, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment or JSON or + IO[bytes] + :return: ManagedInstanceVulnerabilityAssessment. The ManagedInstanceVulnerabilityAssessment is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_instance_vulnerability_assessments_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = 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]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedInstanceVulnerabilityAssessment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + managed_instance_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + **kwargs: Any + ) -> None: + """Removes the managed instance's vulnerability assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_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 + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_managed_instance_vulnerability_assessments_delete_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> ItemPaged["_models.ManagedInstanceVulnerabilityAssessment"]: + """Gets the managed instance's vulnerability assessment policies. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of ManagedInstanceVulnerabilityAssessment + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstanceVulnerabilityAssessment]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_instance_vulnerability_assessments_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstanceVulnerabilityAssessment], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ManagedServerDnsAliasesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_server_dns_aliases` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, managed_instance_name: str, dns_alias_name: str, **kwargs: Any + ) -> _models.ManagedServerDnsAlias: + """Gets a server DNS alias. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param dns_alias_name: Required. + :type dns_alias_name: str + :return: ManagedServerDnsAlias. The ManagedServerDnsAlias is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedServerDnsAlias + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedServerDnsAlias] = kwargs.pop("cls", None) + + _request = build_managed_server_dns_aliases_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + dns_alias_name=dns_alias_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedServerDnsAlias, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + dns_alias_name: str, + parameters: Union[_models.ManagedServerDnsAliasCreation, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_server_dns_aliases_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + dns_alias_name=dns_alias_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + dns_alias_name: str, + parameters: _models.ManagedServerDnsAliasCreation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedServerDnsAlias]: + """Creates a managed server DNS alias. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param dns_alias_name: Required. + :type dns_alias_name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.sql.models.ManagedServerDnsAliasCreation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedServerDnsAlias. The ManagedServerDnsAlias + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedServerDnsAlias] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + dns_alias_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedServerDnsAlias]: + """Creates a managed server DNS alias. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param dns_alias_name: Required. + :type dns_alias_name: str + :param parameters: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedServerDnsAlias. The ManagedServerDnsAlias + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedServerDnsAlias] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + dns_alias_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedServerDnsAlias]: + """Creates a managed server DNS alias. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param dns_alias_name: Required. + :type dns_alias_name: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedServerDnsAlias. The ManagedServerDnsAlias + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedServerDnsAlias] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + dns_alias_name: str, + parameters: Union[_models.ManagedServerDnsAliasCreation, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ManagedServerDnsAlias]: + """Creates a managed server DNS alias. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param dns_alias_name: Required. + :type dns_alias_name: str + :param parameters: Is one of the following types: ManagedServerDnsAliasCreation, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedServerDnsAliasCreation or JSON or IO[bytes] + :return: An instance of LROPoller that returns ManagedServerDnsAlias. The ManagedServerDnsAlias + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedServerDnsAlias] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + dns_alias_name=dns_alias_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedServerDnsAlias, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ManagedServerDnsAlias].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ManagedServerDnsAlias]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, managed_instance_name: str, dns_alias_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_server_dns_aliases_delete_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + dns_alias_name=dns_alias_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, managed_instance_name: str, dns_alias_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the managed server DNS alias with the given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param dns_alias_name: Required. + :type dns_alias_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + dns_alias_name=dns_alias_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_managed_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> ItemPaged["_models.ManagedServerDnsAlias"]: + """Gets a list of managed server DNS aliases for a managed server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of ManagedServerDnsAlias + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedServerDnsAlias] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedServerDnsAlias]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_server_dns_aliases_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedServerDnsAlias], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _acquire_initial( + self, + resource_group_name: str, + managed_instance_name: str, + dns_alias_name: str, + parameters: Union[_models.ManagedServerDnsAliasAcquisition, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_server_dns_aliases_acquire_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + dns_alias_name=dns_alias_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_acquire( + self, + resource_group_name: str, + managed_instance_name: str, + dns_alias_name: str, + parameters: _models.ManagedServerDnsAliasAcquisition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedServerDnsAlias]: + """Acquires managed server DNS alias from another managed server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param dns_alias_name: Required. + :type dns_alias_name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.sql.models.ManagedServerDnsAliasAcquisition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedServerDnsAlias. The ManagedServerDnsAlias + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedServerDnsAlias] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_acquire( + self, + resource_group_name: str, + managed_instance_name: str, + dns_alias_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedServerDnsAlias]: + """Acquires managed server DNS alias from another managed server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param dns_alias_name: Required. + :type dns_alias_name: str + :param parameters: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedServerDnsAlias. The ManagedServerDnsAlias + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedServerDnsAlias] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_acquire( + self, + resource_group_name: str, + managed_instance_name: str, + dns_alias_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedServerDnsAlias]: + """Acquires managed server DNS alias from another managed server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param dns_alias_name: Required. + :type dns_alias_name: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedServerDnsAlias. The ManagedServerDnsAlias + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedServerDnsAlias] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_acquire( + self, + resource_group_name: str, + managed_instance_name: str, + dns_alias_name: str, + parameters: Union[_models.ManagedServerDnsAliasAcquisition, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ManagedServerDnsAlias]: + """Acquires managed server DNS alias from another managed server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param dns_alias_name: Required. + :type dns_alias_name: str + :param parameters: Is one of the following types: ManagedServerDnsAliasAcquisition, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedServerDnsAliasAcquisition or JSON or IO[bytes] + :return: An instance of LROPoller that returns ManagedServerDnsAlias. The ManagedServerDnsAlias + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedServerDnsAlias] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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._acquire_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + dns_alias_name=dns_alias_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ManagedServerDnsAlias, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ManagedServerDnsAlias].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ManagedServerDnsAlias]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class ManagedServerSecurityAlertPoliciesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_server_security_alert_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + managed_instance_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + **kwargs: Any + ) -> _models.ManagedServerSecurityAlertPolicy: + """Get a managed server's threat detection policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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 + :return: ManagedServerSecurityAlertPolicy. The ManagedServerSecurityAlertPolicy is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedServerSecurityAlertPolicy] = kwargs.pop("cls", None) + + _request = build_managed_server_security_alert_policies_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + security_alert_policy_name=security_alert_policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedServerSecurityAlertPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: Union[_models.ManagedServerSecurityAlertPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_server_security_alert_policies_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + security_alert_policy_name=security_alert_policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: _models.ManagedServerSecurityAlertPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedServerSecurityAlertPolicy]: + """Creates or updates a threat detection policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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 + :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. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedServerSecurityAlertPolicy. The + ManagedServerSecurityAlertPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedServerSecurityAlertPolicy]: + """Creates or updates a threat detection policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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 + :param parameters: The managed server security alert policy. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedServerSecurityAlertPolicy. The + ManagedServerSecurityAlertPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedServerSecurityAlertPolicy]: + """Creates or updates a threat detection policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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 + :param parameters: The managed server security alert policy. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedServerSecurityAlertPolicy. The + ManagedServerSecurityAlertPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: Union[_models.ManagedServerSecurityAlertPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ManagedServerSecurityAlertPolicy]: + """Creates or updates a threat detection policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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 + :param parameters: The managed server security alert policy. Is one of the following types: + ManagedServerSecurityAlertPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy or JSON or IO[bytes] + :return: An instance of LROPoller that returns ManagedServerSecurityAlertPolicy. The + ManagedServerSecurityAlertPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + security_alert_policy_name=security_alert_policy_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedServerSecurityAlertPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ManagedServerSecurityAlertPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ManagedServerSecurityAlertPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> ItemPaged["_models.ManagedServerSecurityAlertPolicy"]: + """Get the managed server's threat detection policies. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of ManagedServerSecurityAlertPolicy + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedServerSecurityAlertPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_server_security_alert_policies_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedServerSecurityAlertPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class NetworkSecurityPerimeterConfigurationsOperations: # pylint: disable=name-too-long + """ + .. 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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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. The name is case insensitive. + 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 + :return: NetworkSecurityPerimeterConfiguration. The NetworkSecurityPerimeterConfiguration is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.NetworkSecurityPerimeterConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NetworkSecurityPerimeterConfiguration] = kwargs.pop("cls", None) + + _request = build_network_security_perimeter_configurations_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.NetworkSecurityPerimeterConfiguration, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.NetworkSecurityPerimeterConfiguration"]: + """Gets a list of NSP configurations for a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of NetworkSecurityPerimeterConfiguration + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.NetworkSecurityPerimeterConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.NetworkSecurityPerimeterConfiguration]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_network_security_perimeter_configurations_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.NetworkSecurityPerimeterConfiguration], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _reconcile_initial( + self, resource_group_name: str, server_name: str, nsp_config_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_network_security_perimeter_configurations_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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. The name is case insensitive. + 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 + :return: An instance of LROPoller that returns NetworkSecurityPerimeterConfiguration. The + NetworkSecurityPerimeterConfiguration is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.NetworkSecurityPerimeterConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.NetworkSecurityPerimeterConfiguration, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.NetworkSecurityPerimeterConfiguration].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.NetworkSecurityPerimeterConfiguration]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class OutboundFirewallRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`outbound_firewall_rules` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, server_name: str, outbound_rule_fqdn: str, **kwargs: Any + ) -> _models.OutboundFirewallRule: + """Gets an outbound firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: OutboundFirewallRule. The OutboundFirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.OutboundFirewallRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.OutboundFirewallRule] = kwargs.pop("cls", None) + + _request = build_outbound_firewall_rules_get_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.OutboundFirewallRule, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, resource_group_name: str, server_name: str, outbound_rule_fqdn: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_outbound_firewall_rules_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_create_or_update( + 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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An instance of LROPoller that returns OutboundFirewallRule. The OutboundFirewallRule + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.OutboundFirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + outbound_rule_fqdn=outbound_rule_fqdn, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.OutboundFirewallRule, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.OutboundFirewallRule].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.OutboundFirewallRule]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, server_name: str, outbound_rule_fqdn: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_outbound_firewall_rules_delete_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, server_name: str, outbound_rule_fqdn: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a outbound firewall rule with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + outbound_rule_fqdn=outbound_rule_fqdn, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.OutboundFirewallRule"]: + """Gets all outbound firewall rules on a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of OutboundFirewallRule + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.OutboundFirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.OutboundFirewallRule]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_outbound_firewall_rules_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.OutboundFirewallRule], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`private_endpoint_connections` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, server_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets a private endpoint connection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :return: PrivateEndpointConnection. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + _request = build_private_endpoint_connections_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PrivateEndpointConnection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_private_endpoint_connections_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + private_endpoint_connection_name: str, + parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.sql.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + private_endpoint_connection_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + private_endpoint_connection_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Is one of the following types: PrivateEndpointConnection, JSON, IO[bytes] + Required. + :type parameters: ~azure.mgmt.sql.models.PrivateEndpointConnection or JSON or IO[bytes] + :return: An instance of LROPoller that returns PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + private_endpoint_connection_name=private_endpoint_connection_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.PrivateEndpointConnection, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.PrivateEndpointConnection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, server_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_private_endpoint_connections_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, server_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + private_endpoint_connection_name=private_endpoint_connection_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.PrivateEndpointConnection"]: + """Gets all private endpoint connections on a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of PrivateEndpointConnection + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_private_endpoint_connections_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PrivateEndpointConnection], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`private_link_resources` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, server_name: str, group_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: + """Gets a private link resource for SQL server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param group_name: The name of the private link resource. Required. + :type group_name: str + :return: PrivateLinkResource. The PrivateLinkResource is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.PrivateLinkResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) + + _request = build_private_link_resources_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + group_name=group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PrivateLinkResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.PrivateLinkResource"]: + """Gets the private link resources for SQL server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of PrivateLinkResource + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PrivateLinkResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_private_link_resources_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PrivateLinkResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class RecoverableDatabasesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`recoverable_databases` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + *, + expand: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> _models.RecoverableDatabase: + """Gets a recoverable database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 expand: The child resources to include in the response. Default value is None. + :paramtype expand: str + :keyword filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: RecoverableDatabase. The RecoverableDatabase is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.RecoverableDatabase + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RecoverableDatabase] = kwargs.pop("cls", None) + + _request = build_recoverable_databases_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + expand=expand, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RecoverableDatabase, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.RecoverableDatabase"]: + """Gets a list of recoverable databases. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of RecoverableDatabase + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.RecoverableDatabase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RecoverableDatabase]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_recoverable_databases_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RecoverableDatabase], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class RecoverableManagedDatabasesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`recoverable_managed_databases` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, managed_instance_name: str, recoverable_database_name: str, **kwargs: Any + ) -> _models.RecoverableManagedDatabase: + """Gets a recoverable managed database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param recoverable_database_name: Required. + :type recoverable_database_name: str + :return: RecoverableManagedDatabase. The RecoverableManagedDatabase is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.RecoverableManagedDatabase + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RecoverableManagedDatabase] = kwargs.pop("cls", None) + + _request = build_recoverable_managed_databases_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + recoverable_database_name=recoverable_database_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RecoverableManagedDatabase, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> ItemPaged["_models.RecoverableManagedDatabase"]: + """Gets a list of recoverable managed databases. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of RecoverableManagedDatabase + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.RecoverableManagedDatabase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RecoverableManagedDatabase]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_recoverable_managed_databases_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RecoverableManagedDatabase], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class RestorableDroppedDatabasesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`restorable_dropped_databases` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + server_name: str, + restorable_dropped_database_id: str, + *, + expand: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> _models.RestorableDroppedDatabase: + """Gets a restorable dropped database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param restorable_dropped_database_id: Required. + :type restorable_dropped_database_id: str + :keyword expand: The child resources to include in the response. Default value is None. + :paramtype expand: str + :keyword filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: RestorableDroppedDatabase. The RestorableDroppedDatabase is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.RestorableDroppedDatabase + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RestorableDroppedDatabase] = kwargs.pop("cls", None) + + _request = build_restorable_dropped_databases_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + restorable_dropped_database_id=restorable_dropped_database_id, + subscription_id=self._config.subscription_id, + expand=expand, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RestorableDroppedDatabase, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.RestorableDroppedDatabase"]: + """Gets a list of restorable dropped databases. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of RestorableDroppedDatabase + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.RestorableDroppedDatabase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RestorableDroppedDatabase]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_restorable_dropped_databases_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RestorableDroppedDatabase], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class RestorableDroppedManagedDatabasesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`restorable_dropped_managed_databases` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, managed_instance_name: str, restorable_dropped_database_id: str, **kwargs: Any + ) -> _models.RestorableDroppedManagedDatabase: + """Gets a restorable dropped managed database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: RestorableDroppedManagedDatabase. The RestorableDroppedManagedDatabase is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.RestorableDroppedManagedDatabase + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RestorableDroppedManagedDatabase] = kwargs.pop("cls", None) + + _request = build_restorable_dropped_managed_databases_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + restorable_dropped_database_id=restorable_dropped_database_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RestorableDroppedManagedDatabase, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> ItemPaged["_models.RestorableDroppedManagedDatabase"]: + """Gets a list of restorable dropped managed databases. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of RestorableDroppedManagedDatabase + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.RestorableDroppedManagedDatabase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RestorableDroppedManagedDatabase]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_restorable_dropped_managed_databases_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RestorableDroppedManagedDatabase], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ServerAzureADAdministratorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`server_azure_ad_administrators` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + server_name: str, + administrator_name: Union[str, _models.AdministratorName], + **kwargs: Any + ) -> _models.ServerAzureADAdministrator: + """Gets a Azure Active Directory administrator. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param administrator_name: The name of server active directory administrator. "ActiveDirectory" + Required. + :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName + :return: ServerAzureADAdministrator. The ServerAzureADAdministrator is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerAzureADAdministrator + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ServerAzureADAdministrator] = kwargs.pop("cls", None) + + _request = build_server_azure_ad_administrators_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + administrator_name=administrator_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ServerAzureADAdministrator, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + administrator_name: Union[str, _models.AdministratorName], + parameters: Union[_models.ServerAzureADAdministrator, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_server_azure_ad_administrators_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + administrator_name=administrator_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + administrator_name: Union[str, _models.AdministratorName], + parameters: _models.ServerAzureADAdministrator, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerAzureADAdministrator]: + """Creates or updates an existing Azure Active Directory administrator. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param administrator_name: The name of server active directory administrator. "ActiveDirectory" + Required. + :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName + :param parameters: The requested Azure Active Directory administrator Resource state. Required. + :type parameters: ~azure.mgmt.sql.models.ServerAzureADAdministrator + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerAzureADAdministrator. The + ServerAzureADAdministrator is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerAzureADAdministrator] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + administrator_name: Union[str, _models.AdministratorName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerAzureADAdministrator]: + """Creates or updates an existing Azure Active Directory administrator. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param administrator_name: The name of server active directory administrator. "ActiveDirectory" + Required. + :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName + :param parameters: The requested Azure Active Directory administrator Resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerAzureADAdministrator. The + ServerAzureADAdministrator is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerAzureADAdministrator] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + administrator_name: Union[str, _models.AdministratorName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerAzureADAdministrator]: + """Creates or updates an existing Azure Active Directory administrator. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param administrator_name: The name of server active directory administrator. "ActiveDirectory" + Required. + :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName + :param parameters: The requested Azure Active Directory administrator Resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerAzureADAdministrator. The + ServerAzureADAdministrator is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerAzureADAdministrator] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + administrator_name: Union[str, _models.AdministratorName], + parameters: Union[_models.ServerAzureADAdministrator, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ServerAzureADAdministrator]: + """Creates or updates an existing Azure Active Directory administrator. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param administrator_name: The name of server active directory administrator. "ActiveDirectory" + Required. + :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName + :param parameters: The requested Azure Active Directory administrator Resource state. Is one of + the following types: ServerAzureADAdministrator, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ServerAzureADAdministrator or JSON or IO[bytes] + :return: An instance of LROPoller that returns ServerAzureADAdministrator. The + ServerAzureADAdministrator is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerAzureADAdministrator] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + administrator_name=administrator_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ServerAzureADAdministrator, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ServerAzureADAdministrator].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ServerAzureADAdministrator]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, + resource_group_name: str, + server_name: str, + administrator_name: Union[str, _models.AdministratorName], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_server_azure_ad_administrators_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + administrator_name=administrator_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + server_name: str, + administrator_name: Union[str, _models.AdministratorName], + **kwargs: Any + ) -> LROPoller[None]: + """Deletes the Azure Active Directory administrator with the given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param administrator_name: The name of server active directory administrator. "ActiveDirectory" + Required. + :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + administrator_name=administrator_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.ServerAzureADAdministrator"]: + """Gets a list of Azure Active Directory administrators in a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of ServerAzureADAdministrator + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerAzureADAdministrator] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerAzureADAdministrator]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_server_azure_ad_administrators_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ServerAzureADAdministrator], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ServerAzureADOnlyAuthenticationsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`server_azure_ad_only_authentications` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + server_name: str, + authentication_name: Union[str, _models.AuthenticationName], + **kwargs: Any + ) -> _models.ServerAzureADOnlyAuthentication: + """Gets a specific Azure Active Directory only authentication property. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param authentication_name: The name of server azure active directory only authentication. + "Default" Required. + :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName + :return: ServerAzureADOnlyAuthentication. The ServerAzureADOnlyAuthentication is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ServerAzureADOnlyAuthentication] = kwargs.pop("cls", None) + + _request = build_server_azure_ad_only_authentications_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + authentication_name=authentication_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ServerAzureADOnlyAuthentication, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + authentication_name: Union[str, _models.AuthenticationName], + parameters: Union[_models.ServerAzureADOnlyAuthentication, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_server_azure_ad_only_authentications_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + authentication_name=authentication_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + authentication_name: Union[str, _models.AuthenticationName], + parameters: _models.ServerAzureADOnlyAuthentication, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerAzureADOnlyAuthentication]: + """Sets Server Active Directory only authentication property or updates an existing server Active + Directory only authentication property. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param authentication_name: The name of server azure active directory only authentication. + "Default" Required. + :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName + :param parameters: The required parameters for creating or updating an Active Directory only + authentication property. Required. + :type parameters: ~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerAzureADOnlyAuthentication. The + ServerAzureADOnlyAuthentication is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + authentication_name: Union[str, _models.AuthenticationName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerAzureADOnlyAuthentication]: + """Sets Server Active Directory only authentication property or updates an existing server Active + Directory only authentication property. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param authentication_name: The name of server azure active directory only authentication. + "Default" Required. + :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName + :param parameters: The required parameters for creating or updating an Active Directory only + authentication property. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerAzureADOnlyAuthentication. The + ServerAzureADOnlyAuthentication is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + authentication_name: Union[str, _models.AuthenticationName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerAzureADOnlyAuthentication]: + """Sets Server Active Directory only authentication property or updates an existing server Active + Directory only authentication property. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param authentication_name: The name of server azure active directory only authentication. + "Default" Required. + :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName + :param parameters: The required parameters for creating or updating an Active Directory only + authentication property. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerAzureADOnlyAuthentication. The + ServerAzureADOnlyAuthentication is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + authentication_name: Union[str, _models.AuthenticationName], + parameters: Union[_models.ServerAzureADOnlyAuthentication, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ServerAzureADOnlyAuthentication]: + """Sets Server Active Directory only authentication property or updates an existing server Active + Directory only authentication property. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param authentication_name: The name of server azure active directory only authentication. + "Default" Required. + :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName + :param parameters: The required parameters for creating or updating an Active Directory only + authentication property. Is one of the following types: ServerAzureADOnlyAuthentication, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication or JSON or IO[bytes] + :return: An instance of LROPoller that returns ServerAzureADOnlyAuthentication. The + ServerAzureADOnlyAuthentication is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + authentication_name=authentication_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ServerAzureADOnlyAuthentication, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ServerAzureADOnlyAuthentication].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ServerAzureADOnlyAuthentication]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, + resource_group_name: str, + server_name: str, + authentication_name: Union[str, _models.AuthenticationName], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_server_azure_ad_only_authentications_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + authentication_name=authentication_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + server_name: str, + authentication_name: Union[str, _models.AuthenticationName], + **kwargs: Any + ) -> LROPoller[None]: + """Deletes an existing server Active Directory only authentication property. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param authentication_name: The name of server azure active directory only authentication. + "Default" Required. + :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + authentication_name=authentication_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.ServerAzureADOnlyAuthentication"]: + """Gets a list of server Azure Active Directory only authentications. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of ServerAzureADOnlyAuthentication + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerAzureADOnlyAuthentication]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_server_azure_ad_only_authentications_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ServerAzureADOnlyAuthentication], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ServerConfigurationOptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`server_configuration_options` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + managed_instance_name: str, + server_configuration_option_name: Union[str, _models.ServerConfigurationOptionName], + **kwargs: Any + ) -> _models.ServerConfigurationOption: + """Gets managed instance server configuration option. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param server_configuration_option_name: The name of the server configuration option. + "allowPolybaseExport" Required. + :type server_configuration_option_name: str or + ~azure.mgmt.sql.models.ServerConfigurationOptionName + :return: ServerConfigurationOption. The ServerConfigurationOption is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerConfigurationOption + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ServerConfigurationOption] = kwargs.pop("cls", None) + + _request = build_server_configuration_options_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + server_configuration_option_name=server_configuration_option_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ServerConfigurationOption, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + server_configuration_option_name: Union[str, _models.ServerConfigurationOptionName], + parameters: Union[_models.ServerConfigurationOption, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_server_configuration_options_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + server_configuration_option_name=server_configuration_option_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + server_configuration_option_name: Union[str, _models.ServerConfigurationOptionName], + parameters: _models.ServerConfigurationOption, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerConfigurationOption]: + """Updates managed instance server configuration option. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param server_configuration_option_name: The name of the server configuration option. + "allowPolybaseExport" Required. + :type server_configuration_option_name: str or + ~azure.mgmt.sql.models.ServerConfigurationOptionName + :param parameters: Server configuration option parameters. Required. + :type parameters: ~azure.mgmt.sql.models.ServerConfigurationOption + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerConfigurationOption. The + ServerConfigurationOption is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerConfigurationOption] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + server_configuration_option_name: Union[str, _models.ServerConfigurationOptionName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerConfigurationOption]: + """Updates managed instance server configuration option. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param server_configuration_option_name: The name of the server configuration option. + "allowPolybaseExport" Required. + :type server_configuration_option_name: str or + ~azure.mgmt.sql.models.ServerConfigurationOptionName + :param parameters: Server configuration option parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerConfigurationOption. The + ServerConfigurationOption is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerConfigurationOption] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + server_configuration_option_name: Union[str, _models.ServerConfigurationOptionName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerConfigurationOption]: + """Updates managed instance server configuration option. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param server_configuration_option_name: The name of the server configuration option. + "allowPolybaseExport" Required. + :type server_configuration_option_name: str or + ~azure.mgmt.sql.models.ServerConfigurationOptionName + :param parameters: Server configuration option parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerConfigurationOption. The + ServerConfigurationOption is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerConfigurationOption] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + server_configuration_option_name: Union[str, _models.ServerConfigurationOptionName], + parameters: Union[_models.ServerConfigurationOption, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ServerConfigurationOption]: + """Updates managed instance server configuration option. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param server_configuration_option_name: The name of the server configuration option. + "allowPolybaseExport" Required. + :type server_configuration_option_name: str or + ~azure.mgmt.sql.models.ServerConfigurationOptionName + :param parameters: Server configuration option parameters. Is one of the following types: + ServerConfigurationOption, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ServerConfigurationOption or JSON or IO[bytes] + :return: An instance of LROPoller that returns ServerConfigurationOption. The + ServerConfigurationOption is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerConfigurationOption] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + server_configuration_option_name=server_configuration_option_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = _deserialize(_models.ServerConfigurationOption, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ServerConfigurationOption].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ServerConfigurationOption]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_managed_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> ItemPaged["_models.ServerConfigurationOption"]: + """Gets a list of managed instance server configuration options. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of ServerConfigurationOption + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerConfigurationOption] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerConfigurationOption]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_server_configuration_options_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ServerConfigurationOption], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ServerConnectionPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`server_connection_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + server_name: str, + connection_policy_name: Union[str, _models.ConnectionPolicyName], + **kwargs: Any + ) -> _models.ServerConnectionPolicy: + """Gets a server connection policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param connection_policy_name: The name of the connection policy. "default" Required. + :type connection_policy_name: str or ~azure.mgmt.sql.models.ConnectionPolicyName + :return: ServerConnectionPolicy. The ServerConnectionPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerConnectionPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ServerConnectionPolicy] = kwargs.pop("cls", None) + + _request = build_server_connection_policies_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + connection_policy_name=connection_policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ServerConnectionPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + connection_policy_name: Union[str, _models.ConnectionPolicyName], + parameters: Union[_models.ServerConnectionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_server_connection_policies_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + connection_policy_name=connection_policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + connection_policy_name: Union[str, _models.ConnectionPolicyName], + parameters: _models.ServerConnectionPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerConnectionPolicy]: + """Updates a server connection policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param connection_policy_name: The name of the connection policy. "default" Required. + :type connection_policy_name: str or ~azure.mgmt.sql.models.ConnectionPolicyName + :param parameters: The required parameters for updating a server connection policy. Required. + :type parameters: ~azure.mgmt.sql.models.ServerConnectionPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerConnectionPolicy. The + ServerConnectionPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerConnectionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + connection_policy_name: Union[str, _models.ConnectionPolicyName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerConnectionPolicy]: + """Updates a server connection policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param connection_policy_name: The name of the connection policy. "default" Required. + :type connection_policy_name: str or ~azure.mgmt.sql.models.ConnectionPolicyName + :param parameters: The required parameters for updating a server connection policy. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerConnectionPolicy. The + ServerConnectionPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerConnectionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + connection_policy_name: Union[str, _models.ConnectionPolicyName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerConnectionPolicy]: + """Updates a server connection policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param connection_policy_name: The name of the connection policy. "default" Required. + :type connection_policy_name: str or ~azure.mgmt.sql.models.ConnectionPolicyName + :param parameters: The required parameters for updating a server connection policy. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerConnectionPolicy. The + ServerConnectionPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerConnectionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + connection_policy_name: Union[str, _models.ConnectionPolicyName], + parameters: Union[_models.ServerConnectionPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ServerConnectionPolicy]: + """Updates a server connection policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param connection_policy_name: The name of the connection policy. "default" Required. + :type connection_policy_name: str or ~azure.mgmt.sql.models.ConnectionPolicyName + :param parameters: The required parameters for updating a server connection policy. Is one of + the following types: ServerConnectionPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ServerConnectionPolicy or JSON or IO[bytes] + :return: An instance of LROPoller that returns ServerConnectionPolicy. The + ServerConnectionPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerConnectionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + connection_policy_name=connection_policy_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ServerConnectionPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ServerConnectionPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ServerConnectionPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.ServerConnectionPolicy"]: + """Lists connection policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of ServerConnectionPolicy + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerConnectionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerConnectionPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_server_connection_policies_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ServerConnectionPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ServerDevOpsAuditSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`server_dev_ops_audit_settings` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + server_name: str, + dev_ops_auditing_settings_name: Union[str, _models.DevOpsAuditingSettingsName], + **kwargs: Any + ) -> _models.ServerDevOpsAuditingSettings: + """Gets a server's DevOps audit settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param dev_ops_auditing_settings_name: "Default" Required. + :type dev_ops_auditing_settings_name: str or ~azure.mgmt.sql.models.DevOpsAuditingSettingsName + :return: ServerDevOpsAuditingSettings. The ServerDevOpsAuditingSettings is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerDevOpsAuditingSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ServerDevOpsAuditingSettings] = kwargs.pop("cls", None) + + _request = build_server_dev_ops_audit_settings_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + dev_ops_auditing_settings_name=dev_ops_auditing_settings_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ServerDevOpsAuditingSettings, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + dev_ops_auditing_settings_name: Union[str, _models.DevOpsAuditingSettingsName], + parameters: Union[_models.ServerDevOpsAuditingSettings, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_server_dev_ops_audit_settings_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + dev_ops_auditing_settings_name=dev_ops_auditing_settings_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + dev_ops_auditing_settings_name: Union[str, _models.DevOpsAuditingSettingsName], + parameters: _models.ServerDevOpsAuditingSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerDevOpsAuditingSettings]: + """Creates or updates a server's DevOps audit settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param dev_ops_auditing_settings_name: "Default" Required. + :type dev_ops_auditing_settings_name: str or ~azure.mgmt.sql.models.DevOpsAuditingSettingsName + :param parameters: Properties of DevOps audit settings. Required. + :type parameters: ~azure.mgmt.sql.models.ServerDevOpsAuditingSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerDevOpsAuditingSettings. The + ServerDevOpsAuditingSettings is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerDevOpsAuditingSettings] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + dev_ops_auditing_settings_name: Union[str, _models.DevOpsAuditingSettingsName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerDevOpsAuditingSettings]: + """Creates or updates a server's DevOps audit settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param dev_ops_auditing_settings_name: "Default" Required. + :type dev_ops_auditing_settings_name: str or ~azure.mgmt.sql.models.DevOpsAuditingSettingsName + :param parameters: Properties of DevOps audit settings. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerDevOpsAuditingSettings. The + ServerDevOpsAuditingSettings is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerDevOpsAuditingSettings] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + dev_ops_auditing_settings_name: Union[str, _models.DevOpsAuditingSettingsName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerDevOpsAuditingSettings]: + """Creates or updates a server's DevOps audit settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param dev_ops_auditing_settings_name: "Default" Required. + :type dev_ops_auditing_settings_name: str or ~azure.mgmt.sql.models.DevOpsAuditingSettingsName + :param parameters: Properties of DevOps audit settings. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerDevOpsAuditingSettings. The + ServerDevOpsAuditingSettings is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerDevOpsAuditingSettings] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + dev_ops_auditing_settings_name: Union[str, _models.DevOpsAuditingSettingsName], + parameters: Union[_models.ServerDevOpsAuditingSettings, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ServerDevOpsAuditingSettings]: + """Creates or updates a server's DevOps audit settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param dev_ops_auditing_settings_name: "Default" Required. + :type dev_ops_auditing_settings_name: str or ~azure.mgmt.sql.models.DevOpsAuditingSettingsName + :param parameters: Properties of DevOps audit settings. Is one of the following types: + ServerDevOpsAuditingSettings, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ServerDevOpsAuditingSettings or JSON or IO[bytes] + :return: An instance of LROPoller that returns ServerDevOpsAuditingSettings. The + ServerDevOpsAuditingSettings is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerDevOpsAuditingSettings] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + dev_ops_auditing_settings_name=dev_ops_auditing_settings_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ServerDevOpsAuditingSettings, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ServerDevOpsAuditingSettings].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ServerDevOpsAuditingSettings]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.ServerDevOpsAuditingSettings"]: + """Lists DevOps audit settings of a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of ServerDevOpsAuditingSettings + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerDevOpsAuditingSettings] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerDevOpsAuditingSettings]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_server_dev_ops_audit_settings_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ServerDevOpsAuditingSettings], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ServerDnsAliasesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`server_dns_aliases` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, server_name: str, dns_alias_name: str, **kwargs: Any + ) -> _models.ServerDnsAlias: + """Gets a server DNS alias. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param dns_alias_name: The name of the server dns alias. Required. + :type dns_alias_name: str + :return: ServerDnsAlias. The ServerDnsAlias is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerDnsAlias + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ServerDnsAlias] = kwargs.pop("cls", None) + + _request = build_server_dns_aliases_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + dns_alias_name=dns_alias_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ServerDnsAlias, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, resource_group_name: str, server_name: str, dns_alias_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_server_dns_aliases_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + dns_alias_name=dns_alias_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, server_name: str, dns_alias_name: str, **kwargs: Any + ) -> LROPoller[_models.ServerDnsAlias]: + """Creates a server DNS alias. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param dns_alias_name: The name of the server dns alias. Required. + :type dns_alias_name: str + :return: An instance of LROPoller that returns ServerDnsAlias. The ServerDnsAlias is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerDnsAlias] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + dns_alias_name=dns_alias_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ServerDnsAlias, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ServerDnsAlias].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ServerDnsAlias]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, server_name: str, dns_alias_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_server_dns_aliases_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + dns_alias_name=dns_alias_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, server_name: str, dns_alias_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the server DNS alias with the given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param dns_alias_name: The name of the server dns alias. Required. + :type dns_alias_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + dns_alias_name=dns_alias_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.ServerDnsAlias"]: + """Gets a list of server DNS aliases for a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of ServerDnsAlias + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerDnsAlias] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerDnsAlias]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_server_dns_aliases_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ServerDnsAlias], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _acquire_initial( + self, + resource_group_name: str, + server_name: str, + dns_alias_name: str, + parameters: Union[_models.ServerDnsAliasAcquisition, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_server_dns_aliases_acquire_request( + resource_group_name=resource_group_name, + server_name=server_name, + dns_alias_name=dns_alias_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_acquire( + self, + resource_group_name: str, + server_name: str, + dns_alias_name: str, + parameters: _models.ServerDnsAliasAcquisition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerDnsAlias]: + """Acquires server DNS alias from another server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param dns_alias_name: The name of the server dns alias. Required. + :type dns_alias_name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.sql.models.ServerDnsAliasAcquisition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerDnsAlias. The ServerDnsAlias is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerDnsAlias] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_acquire( + self, + resource_group_name: str, + server_name: str, + dns_alias_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerDnsAlias]: + """Acquires server DNS alias from another server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param dns_alias_name: The name of the server dns alias. Required. + :type dns_alias_name: str + :param parameters: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerDnsAlias. The ServerDnsAlias is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerDnsAlias] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_acquire( + self, + resource_group_name: str, + server_name: str, + dns_alias_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerDnsAlias]: + """Acquires server DNS alias from another server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param dns_alias_name: The name of the server dns alias. Required. + :type dns_alias_name: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerDnsAlias. The ServerDnsAlias is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerDnsAlias] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_acquire( + self, + resource_group_name: str, + server_name: str, + dns_alias_name: str, + parameters: Union[_models.ServerDnsAliasAcquisition, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ServerDnsAlias]: + """Acquires server DNS alias from another server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param dns_alias_name: The name of the server dns alias. Required. + :type dns_alias_name: str + :param parameters: Is one of the following types: ServerDnsAliasAcquisition, JSON, IO[bytes] + Required. + :type parameters: ~azure.mgmt.sql.models.ServerDnsAliasAcquisition or JSON or IO[bytes] + :return: An instance of LROPoller that returns ServerDnsAlias. The ServerDnsAlias is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerDnsAlias] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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._acquire_initial( + resource_group_name=resource_group_name, + server_name=server_name, + dns_alias_name=dns_alias_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ServerDnsAlias, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ServerDnsAlias].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ServerDnsAlias]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class ServerKeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`server_keys` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, server_name: str, key_name: str, **kwargs: Any) -> _models.ServerKey: + """Gets a server key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param key_name: The name of the server key to be retrieved. Required. + :type key_name: str + :return: ServerKey. The ServerKey is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerKey + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ServerKey] = kwargs.pop("cls", None) + + _request = build_server_keys_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ServerKey, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + key_name: str, + parameters: Union[_models.ServerKey, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_server_keys_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + key_name: str, + parameters: _models.ServerKey, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerKey]: + """Creates or updates a server key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param key_name: The name of the server key to be retrieved. Required. + :type key_name: str + :param parameters: The requested server key resource state. Required. + :type parameters: ~azure.mgmt.sql.models.ServerKey + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerKey. The ServerKey is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerKey] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + key_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerKey]: + """Creates or updates a server key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param key_name: The name of the server key to be retrieved. Required. + :type key_name: str + :param parameters: The requested server key resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerKey. The ServerKey is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerKey] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + key_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerKey]: + """Creates or updates a server key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param key_name: The name of the server key to be retrieved. Required. + :type key_name: str + :param parameters: The requested server key resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerKey. The ServerKey is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerKey] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + key_name: str, + parameters: Union[_models.ServerKey, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ServerKey]: + """Creates or updates a server key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param key_name: The name of the server key to be retrieved. Required. + :type key_name: str + :param parameters: The requested server key resource state. Is one of the following types: + ServerKey, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ServerKey or JSON or IO[bytes] + :return: An instance of LROPoller that returns ServerKey. The ServerKey is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerKey] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + key_name=key_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ServerKey, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ServerKey].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ServerKey]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, server_name: str, key_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_server_keys_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete(self, resource_group_name: str, server_name: str, key_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes the server key with the given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param key_name: The name of the server key to be retrieved. Required. + :type key_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + key_name=key_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.ServerKey"]: + """Gets a list of server keys. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of ServerKey + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerKey] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerKey]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_server_keys_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ServerKey], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ServerSecurityAlertPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`server_security_alert_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + server_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + **kwargs: Any + ) -> _models.ServerSecurityAlertPolicy: + """Get a server's security alert policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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 + :return: ServerSecurityAlertPolicy. The ServerSecurityAlertPolicy is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerSecurityAlertPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ServerSecurityAlertPolicy] = kwargs.pop("cls", None) + + _request = build_server_security_alert_policies_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + security_alert_policy_name=security_alert_policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ServerSecurityAlertPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: Union[_models.ServerSecurityAlertPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_server_security_alert_policies_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + security_alert_policy_name=security_alert_policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: _models.ServerSecurityAlertPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerSecurityAlertPolicy]: + """Creates or updates a threat detection policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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 + :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. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerSecurityAlertPolicy. The + ServerSecurityAlertPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerSecurityAlertPolicy]: + """Creates or updates a threat detection policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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 + :param parameters: The server security alert policy. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerSecurityAlertPolicy. The + ServerSecurityAlertPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerSecurityAlertPolicy]: + """Creates or updates a threat detection policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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 + :param parameters: The server security alert policy. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerSecurityAlertPolicy. The + ServerSecurityAlertPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + parameters: Union[_models.ServerSecurityAlertPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ServerSecurityAlertPolicy]: + """Creates or updates a threat detection policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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 + :param parameters: The server security alert policy. Is one of the following types: + ServerSecurityAlertPolicy, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ServerSecurityAlertPolicy or JSON or IO[bytes] + :return: An instance of LROPoller that returns ServerSecurityAlertPolicy. The + ServerSecurityAlertPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + security_alert_policy_name=security_alert_policy_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ServerSecurityAlertPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ServerSecurityAlertPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ServerSecurityAlertPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.ServerSecurityAlertPolicy"]: + """Get the server's threat detection policies. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of ServerSecurityAlertPolicy + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerSecurityAlertPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_server_security_alert_policies_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ServerSecurityAlertPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ServerTrustCertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`server_trust_certificates` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, managed_instance_name: str, certificate_name: str, **kwargs: Any + ) -> _models.ServerTrustCertificate: + """Gets a server trust certificate that was uploaded from SQL Server to SQL Managed Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param certificate_name: Name of of the certificate to get. Required. + :type certificate_name: str + :return: ServerTrustCertificate. The ServerTrustCertificate is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerTrustCertificate + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ServerTrustCertificate] = kwargs.pop("cls", None) + + _request = build_server_trust_certificates_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ServerTrustCertificate, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + certificate_name: str, + parameters: Union[_models.ServerTrustCertificate, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_server_trust_certificates_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + certificate_name: str, + parameters: _models.ServerTrustCertificate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerTrustCertificate]: + """Uploads a server trust certificate from SQL Server to SQL Managed Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param certificate_name: Name of of the certificate to get. Required. + :type certificate_name: str + :param parameters: The server trust certificate info. Required. + :type parameters: ~azure.mgmt.sql.models.ServerTrustCertificate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerTrustCertificate. The + ServerTrustCertificate is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerTrustCertificate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + certificate_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerTrustCertificate]: + """Uploads a server trust certificate from SQL Server to SQL Managed Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param certificate_name: Name of of the certificate to get. Required. + :type certificate_name: str + :param parameters: The server trust certificate info. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerTrustCertificate. The + ServerTrustCertificate is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerTrustCertificate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + certificate_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerTrustCertificate]: + """Uploads a server trust certificate from SQL Server to SQL Managed Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param certificate_name: Name of of the certificate to get. Required. + :type certificate_name: str + :param parameters: The server trust certificate info. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerTrustCertificate. The + ServerTrustCertificate is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerTrustCertificate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + certificate_name: str, + parameters: Union[_models.ServerTrustCertificate, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ServerTrustCertificate]: + """Uploads a server trust certificate from SQL Server to SQL Managed Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param certificate_name: Name of of the certificate to get. Required. + :type certificate_name: str + :param parameters: The server trust certificate info. Is one of the following types: + ServerTrustCertificate, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ServerTrustCertificate or JSON or IO[bytes] + :return: An instance of LROPoller that returns ServerTrustCertificate. The + ServerTrustCertificate is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerTrustCertificate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + certificate_name=certificate_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ServerTrustCertificate, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ServerTrustCertificate].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ServerTrustCertificate]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, managed_instance_name: str, certificate_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_server_trust_certificates_delete_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, managed_instance_name: str, certificate_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a server trust certificate that was uploaded from SQL Server to SQL Managed Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param certificate_name: Name of of the certificate to get. Required. + :type certificate_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + certificate_name=certificate_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> ItemPaged["_models.ServerTrustCertificate"]: + """Gets a list of the server trust certificates used to secure communication between SQL Server + and the specified SQL Managed Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of ServerTrustCertificate + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerTrustCertificate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerTrustCertificate]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_server_trust_certificates_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ServerTrustCertificate], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ServerVulnerabilityAssessmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`server_vulnerability_assessments` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + **kwargs: Any + ) -> _models.ServerVulnerabilityAssessment: + """Gets the server's vulnerability assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 + :return: ServerVulnerabilityAssessment. The ServerVulnerabilityAssessment is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ServerVulnerabilityAssessment] = kwargs.pop("cls", None) + + _request = build_server_vulnerability_assessments_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ServerVulnerabilityAssessment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: _models.ServerVulnerabilityAssessment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ServerVulnerabilityAssessment: + """Creates or updates the server's vulnerability assessment. Learn more about setting SQL + vulnerability assessment with managed identity - + `https://docs.microsoft.com/azure/azure-sql/database/sql-database-vulnerability-assessment-storage + `_. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 parameters: The requested resource. Required. + :type parameters: ~azure.mgmt.sql.models.ServerVulnerabilityAssessment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ServerVulnerabilityAssessment. The ServerVulnerabilityAssessment is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ServerVulnerabilityAssessment: + """Creates or updates the server's vulnerability assessment. Learn more about setting SQL + vulnerability assessment with managed identity - + `https://docs.microsoft.com/azure/azure-sql/database/sql-database-vulnerability-assessment-storage + `_. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 parameters: The requested resource. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ServerVulnerabilityAssessment. The ServerVulnerabilityAssessment is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ServerVulnerabilityAssessment: + """Creates or updates the server's vulnerability assessment. Learn more about setting SQL + vulnerability assessment with managed identity - + `https://docs.microsoft.com/azure/azure-sql/database/sql-database-vulnerability-assessment-storage + `_. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 parameters: The requested resource. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ServerVulnerabilityAssessment. The ServerVulnerabilityAssessment is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + parameters: Union[_models.ServerVulnerabilityAssessment, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ServerVulnerabilityAssessment: + """Creates or updates the server's vulnerability assessment. Learn more about setting SQL + vulnerability assessment with managed identity - + `https://docs.microsoft.com/azure/azure-sql/database/sql-database-vulnerability-assessment-storage + `_. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 parameters: The requested resource. Is one of the following types: + ServerVulnerabilityAssessment, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ServerVulnerabilityAssessment or JSON or IO[bytes] + :return: ServerVulnerabilityAssessment. The ServerVulnerabilityAssessment is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_server_vulnerability_assessments_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = 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]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ServerVulnerabilityAssessment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + **kwargs: Any + ) -> None: + """Removes the server's vulnerability assessment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_server_vulnerability_assessments_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.ServerVulnerabilityAssessment"]: + """Lists the vulnerability assessment policies associated with a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of ServerVulnerabilityAssessment + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerVulnerabilityAssessment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerVulnerabilityAssessment]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_server_vulnerability_assessments_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ServerVulnerabilityAssessment], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class StartStopManagedInstanceSchedulesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`start_stop_managed_instance_schedules` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + managed_instance_name: str, + start_stop_schedule_name: Union[str, _models.StartStopScheduleName], + **kwargs: Any + ) -> _models.StartStopManagedInstanceSchedule: + """Gets the managed instance's Start/Stop schedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param start_stop_schedule_name: Name of the managed instance Start/Stop schedule. "default" + Required. + :type start_stop_schedule_name: str or ~azure.mgmt.sql.models.StartStopScheduleName + :return: StartStopManagedInstanceSchedule. The StartStopManagedInstanceSchedule is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.StartStopManagedInstanceSchedule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.StartStopManagedInstanceSchedule] = kwargs.pop("cls", None) + + _request = build_start_stop_managed_instance_schedules_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + start_stop_schedule_name=start_stop_schedule_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.StartStopManagedInstanceSchedule, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + start_stop_schedule_name: Union[str, _models.StartStopScheduleName], + parameters: _models.StartStopManagedInstanceSchedule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StartStopManagedInstanceSchedule: + """Creates or updates the managed instance's Start/Stop schedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param start_stop_schedule_name: Name of the managed instance Start/Stop schedule. "default" + Required. + :type start_stop_schedule_name: str or ~azure.mgmt.sql.models.StartStopScheduleName + :param parameters: The requested managed instance Start/Stop schedule. Required. + :type parameters: ~azure.mgmt.sql.models.StartStopManagedInstanceSchedule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: StartStopManagedInstanceSchedule. The StartStopManagedInstanceSchedule is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.StartStopManagedInstanceSchedule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + start_stop_schedule_name: Union[str, _models.StartStopScheduleName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StartStopManagedInstanceSchedule: + """Creates or updates the managed instance's Start/Stop schedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param start_stop_schedule_name: Name of the managed instance Start/Stop schedule. "default" + Required. + :type start_stop_schedule_name: str or ~azure.mgmt.sql.models.StartStopScheduleName + :param parameters: The requested managed instance Start/Stop schedule. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: StartStopManagedInstanceSchedule. The StartStopManagedInstanceSchedule is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.StartStopManagedInstanceSchedule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + start_stop_schedule_name: Union[str, _models.StartStopScheduleName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StartStopManagedInstanceSchedule: + """Creates or updates the managed instance's Start/Stop schedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param start_stop_schedule_name: Name of the managed instance Start/Stop schedule. "default" + Required. + :type start_stop_schedule_name: str or ~azure.mgmt.sql.models.StartStopScheduleName + :param parameters: The requested managed instance Start/Stop schedule. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: StartStopManagedInstanceSchedule. The StartStopManagedInstanceSchedule is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.StartStopManagedInstanceSchedule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + start_stop_schedule_name: Union[str, _models.StartStopScheduleName], + parameters: Union[_models.StartStopManagedInstanceSchedule, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.StartStopManagedInstanceSchedule: + """Creates or updates the managed instance's Start/Stop schedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param start_stop_schedule_name: Name of the managed instance Start/Stop schedule. "default" + Required. + :type start_stop_schedule_name: str or ~azure.mgmt.sql.models.StartStopScheduleName + :param parameters: The requested managed instance Start/Stop schedule. Is one of the following + types: StartStopManagedInstanceSchedule, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.StartStopManagedInstanceSchedule or JSON or IO[bytes] + :return: StartStopManagedInstanceSchedule. The StartStopManagedInstanceSchedule is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.StartStopManagedInstanceSchedule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_start_stop_managed_instance_schedules_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + start_stop_schedule_name=start_stop_schedule_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = 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]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.StartStopManagedInstanceSchedule, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + managed_instance_name: str, + start_stop_schedule_name: Union[str, _models.StartStopScheduleName], + **kwargs: Any + ) -> None: + """Deletes the managed instance's Start/Stop schedule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param start_stop_schedule_name: Name of the managed instance Start/Stop schedule. "default" + Required. + :type start_stop_schedule_name: str or ~azure.mgmt.sql.models.StartStopScheduleName + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_start_stop_managed_instance_schedules_delete_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + start_stop_schedule_name=start_stop_schedule_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = 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) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> ItemPaged["_models.StartStopManagedInstanceSchedule"]: + """Lists the managed instance's Start/Stop schedules. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of StartStopManagedInstanceSchedule + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.StartStopManagedInstanceSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.StartStopManagedInstanceSchedule]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_start_stop_managed_instance_schedules_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.StartStopManagedInstanceSchedule], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class SubscriptionUsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`subscription_usages` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, location_name: str, usage_name: str, **kwargs: Any) -> _models.SubscriptionUsage: + """Gets a subscription usage metric. + + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :param usage_name: Name of usage metric to return. Required. + :type usage_name: str + :return: SubscriptionUsage. The SubscriptionUsage is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SubscriptionUsage + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SubscriptionUsage] = kwargs.pop("cls", None) + + _request = build_subscription_usages_get_request( + location_name=location_name, + usage_name=usage_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SubscriptionUsage, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_location(self, location_name: str, **kwargs: Any) -> ItemPaged["_models.SubscriptionUsage"]: + """Gets all subscription usage metrics in a given location. + + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :return: An iterator like instance of SubscriptionUsage + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SubscriptionUsage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SubscriptionUsage]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_subscription_usages_list_by_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SubscriptionUsage], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class SyncAgentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`sync_agents` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, server_name: str, sync_agent_name: str, **kwargs: Any) -> _models.SyncAgent: + """Gets a sync agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param sync_agent_name: The name of the sync agent. Required. + :type sync_agent_name: str + :return: SyncAgent. The SyncAgent is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SyncAgent + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SyncAgent] = kwargs.pop("cls", None) + + _request = build_sync_agents_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + sync_agent_name=sync_agent_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SyncAgent, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + sync_agent_name: str, + parameters: Union[_models.SyncAgent, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_sync_agents_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + sync_agent_name=sync_agent_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + sync_agent_name: str, + parameters: _models.SyncAgent, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SyncAgent]: + """Creates or updates a sync agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param sync_agent_name: The name of the sync agent. Required. + :type sync_agent_name: str + :param parameters: The requested sync agent resource state. Required. + :type parameters: ~azure.mgmt.sql.models.SyncAgent + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns SyncAgent. The SyncAgent is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + sync_agent_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SyncAgent]: + """Creates or updates a sync agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param sync_agent_name: The name of the sync agent. Required. + :type sync_agent_name: str + :param parameters: The requested sync agent resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns SyncAgent. The SyncAgent is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + sync_agent_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SyncAgent]: + """Creates or updates a sync agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param sync_agent_name: The name of the sync agent. Required. + :type sync_agent_name: str + :param parameters: The requested sync agent resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns SyncAgent. The SyncAgent is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + sync_agent_name: str, + parameters: Union[_models.SyncAgent, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.SyncAgent]: + """Creates or updates a sync agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param sync_agent_name: The name of the sync agent. Required. + :type sync_agent_name: str + :param parameters: The requested sync agent resource state. Is one of the following types: + SyncAgent, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.SyncAgent or JSON or IO[bytes] + :return: An instance of LROPoller that returns SyncAgent. The SyncAgent is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + sync_agent_name=sync_agent_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.SyncAgent, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.SyncAgent].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.SyncAgent]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, server_name: str, sync_agent_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_sync_agents_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + sync_agent_name=sync_agent_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, server_name: str, sync_agent_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a sync agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param sync_agent_name: The name of the sync agent. Required. + :type sync_agent_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + sync_agent_name=sync_agent_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.SyncAgent"]: + """Lists sync agents in a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of SyncAgent + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SyncAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SyncAgent]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_sync_agents_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SyncAgent], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def generate_key( + self, resource_group_name: str, server_name: str, sync_agent_name: str, **kwargs: Any + ) -> _models.SyncAgentKeyProperties: + """Generates a sync agent key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param sync_agent_name: The name of the sync agent. Required. + :type sync_agent_name: str + :return: SyncAgentKeyProperties. The SyncAgentKeyProperties is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SyncAgentKeyProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SyncAgentKeyProperties] = kwargs.pop("cls", None) + + _request = build_sync_agents_generate_key_request( + resource_group_name=resource_group_name, + server_name=server_name, + sync_agent_name=sync_agent_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SyncAgentKeyProperties, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_linked_databases( + self, resource_group_name: str, server_name: str, sync_agent_name: str, **kwargs: Any + ) -> ItemPaged["_models.SyncAgentLinkedDatabase"]: + """Lists databases linked to a sync agent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param sync_agent_name: The name of the sync agent. Required. + :type sync_agent_name: str + :return: An iterator like instance of SyncAgentLinkedDatabase + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SyncAgentLinkedDatabase] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SyncAgentLinkedDatabase]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_sync_agents_list_linked_databases_request( + resource_group_name=resource_group_name, + server_name=server_name, + sync_agent_name=sync_agent_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SyncAgentLinkedDatabase], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class SyncGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`sync_groups` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, sync_group_name: str, **kwargs: Any + ) -> _models.SyncGroup: + """Gets a sync group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :return: SyncGroup. The SyncGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SyncGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SyncGroup] = kwargs.pop("cls", None) + + _request = build_sync_groups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SyncGroup, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + parameters: Union[_models.SyncGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_sync_groups_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + 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 + ) -> LROPoller[_models.SyncGroup]: + """Creates or updates a sync group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 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 + :return: An instance of LROPoller that returns SyncGroup. The SyncGroup is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SyncGroup]: + """Creates or updates a sync group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns SyncGroup. The SyncGroup is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SyncGroup]: + """Creates or updates a sync group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 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[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns SyncGroup. The SyncGroup is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + parameters: Union[_models.SyncGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.SyncGroup]: + """Creates or updates a sync group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :param parameters: The requested sync group resource state. Is one of the following types: + SyncGroup, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.SyncGroup or JSON or IO[bytes] + :return: An instance of LROPoller that returns SyncGroup. The SyncGroup is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.SyncGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.SyncGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.SyncGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + parameters: Union[_models.SyncGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_sync_groups_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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. The name is case insensitive. + Required. + :type resource_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 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 + :return: An instance of LROPoller that returns SyncGroup. The SyncGroup is compatible with + MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SyncGroup]: + """Updates a sync group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns SyncGroup. The SyncGroup is compatible with + MutableMapping + :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[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SyncGroup]: + """Updates a sync group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 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[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns SyncGroup. The SyncGroup is compatible with + MutableMapping + :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, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.SyncGroup]: + """Updates a sync group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :param parameters: The requested sync group resource state. Is one of the following types: + SyncGroup, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.SyncGroup or JSON or IO[bytes] + :return: An instance of LROPoller that returns SyncGroup. The SyncGroup is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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._update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.SyncGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.SyncGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.SyncGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_sync_groups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a sync group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> ItemPaged["_models.SyncGroup"]: + """Lists sync groups under a hub database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of SyncGroup + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SyncGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SyncGroup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_sync_groups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SyncGroup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @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. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_sync_groups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_hub_schemas( + self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any + ) -> ItemPaged["_models.SyncFullSchemaProperties"]: + """Gets a collection of hub database schemas. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :return: An iterator like instance of SyncFullSchemaProperties + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SyncFullSchemaProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SyncFullSchemaProperties]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_sync_groups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SyncFullSchemaProperties], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @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 + ) -> ItemPaged["_models.SyncGroupLogProperties"]: + """Gets a collection of sync group logs. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :keyword start_time: Get logs generated after this time. Required. + :paramtype start_time: str + :keyword end_time: Get logs generated before this time. Required. + :paramtype end_time: str + :keyword type: The types of logs to retrieve. Known values are: "All", "Error", "Warning", and + "Success". Required. + :paramtype type: str or ~azure.mgmt.sql.models.SyncGroupsType + :keyword continuation_token_parameter: The continuation token for this operation. Default value + is None. + :paramtype continuation_token_parameter: str + :return: An iterator like instance of SyncGroupLogProperties + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SyncGroupLogProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SyncGroupLogProperties]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_sync_groups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SyncGroupLogProperties], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _refresh_hub_schema_initial( + self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_sync_groups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + 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. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + 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. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_sync_groups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_sync_database_ids( + self, location_name: str, **kwargs: Any + ) -> ItemPaged["_models.SyncDatabaseIdProperties"]: + """Gets a collection of sync database ids. + + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :return: An iterator like instance of SyncDatabaseIdProperties + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SyncDatabaseIdProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SyncDatabaseIdProperties]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_sync_groups_list_sync_database_ids_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SyncDatabaseIdProperties], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class SyncMembersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`sync_members` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + sync_group_name: str, + sync_member_name: str, + **kwargs: Any + ) -> _models.SyncMember: + """Gets a sync member. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :param sync_member_name: The name of the sync member. Required. + :type sync_member_name: str + :return: SyncMember. The SyncMember is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SyncMember + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SyncMember] = kwargs.pop("cls", None) + + _request = build_sync_members_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + sync_member_name=sync_member_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SyncMember, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + parameters: Union[_models.SyncMember, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_sync_members_create_or_update_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + parameters: _models.SyncMember, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SyncMember]: + """Creates or updates a sync member. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :param sync_member_name: The name of the sync member. Required. + :type sync_member_name: str + :param parameters: The requested sync member resource state. Required. + :type parameters: ~azure.mgmt.sql.models.SyncMember + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns SyncMember. The SyncMember is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncMember] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SyncMember]: + """Creates or updates a sync member. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :param sync_member_name: The name of the sync member. Required. + :type sync_member_name: str + :param parameters: The requested sync member resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns SyncMember. The SyncMember is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncMember] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SyncMember]: + """Creates or updates a sync member. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :param sync_member_name: The name of the sync member. Required. + :type sync_member_name: str + :param parameters: The requested sync member resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns SyncMember. The SyncMember is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncMember] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + parameters: Union[_models.SyncMember, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.SyncMember]: + """Creates or updates a sync member. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :param sync_member_name: The name of the sync member. Required. + :type sync_member_name: str + :param parameters: The requested sync member resource state. Is one of the following types: + SyncMember, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.SyncMember or JSON or IO[bytes] + :return: An instance of LROPoller that returns SyncMember. The SyncMember is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncMember] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + sync_member_name=sync_member_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.SyncMember, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.SyncMember].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.SyncMember]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + parameters: Union[_models.SyncMember, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_sync_members_update_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + parameters: _models.SyncMember, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SyncMember]: + """Updates an existing sync member. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :param sync_member_name: The name of the sync member. Required. + :type sync_member_name: str + :param parameters: The requested sync member resource state. Required. + :type parameters: ~azure.mgmt.sql.models.SyncMember + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns SyncMember. The SyncMember is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncMember] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SyncMember]: + """Updates an existing sync member. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :param sync_member_name: The name of the sync member. Required. + :type sync_member_name: str + :param parameters: The requested sync member resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns SyncMember. The SyncMember is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncMember] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SyncMember]: + """Updates an existing sync member. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :param sync_member_name: The name of the sync member. Required. + :type sync_member_name: str + :param parameters: The requested sync member resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns SyncMember. The SyncMember is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncMember] + :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, + sync_member_name: str, + parameters: Union[_models.SyncMember, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.SyncMember]: + """Updates an existing sync member. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :param sync_member_name: The name of the sync member. Required. + :type sync_member_name: str + :param parameters: The requested sync member resource state. Is one of the following types: + SyncMember, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.SyncMember or JSON or IO[bytes] + :return: An instance of LROPoller that returns SyncMember. The SyncMember is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncMember] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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( + 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, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.SyncMember, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.SyncMember].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.SyncMember]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_sync_members_delete_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes a sync member. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :param sync_member_name: The name of the sync member. Required. + :type sync_member_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_sync_group( + self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any + ) -> ItemPaged["_models.SyncMember"]: + """Lists sync members in the given sync group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :return: An iterator like instance of SyncMember + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SyncMember] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SyncMember]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_sync_members_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SyncMember], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _refresh_member_schema_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_sync_members_refresh_member_schema_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_refresh_member_schema( + self, + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Refreshes a sync member database schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :param sync_member_name: The name of the sync member. Required. + :type sync_member_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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_member_schema_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + sync_member_name=sync_member_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @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 + ) -> ItemPaged["_models.SyncFullSchemaProperties"]: + """Gets a sync member database schema. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :param sync_member_name: The name of the sync member. Required. + :type sync_member_name: str + :return: An iterator like instance of SyncFullSchemaProperties + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SyncFullSchemaProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SyncFullSchemaProperties]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_sync_members_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SyncFullSchemaProperties], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class TimeZonesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`time_zones` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, location_name: str, time_zone_id: str, **kwargs: Any) -> _models.TimeZone: + """Gets a managed instance time zone. + + :param location_name: The location of the database. Required. + :type location_name: str + :param time_zone_id: The time zone ID. Required. + :type time_zone_id: str + :return: TimeZone. The TimeZone is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.TimeZone + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TimeZone] = kwargs.pop("cls", None) + + _request = build_time_zones_get_request( + location_name=location_name, + time_zone_id=time_zone_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TimeZone, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_location(self, location_name: str, **kwargs: Any) -> ItemPaged["_models.TimeZone"]: + """Gets a list of managed instance time zones by location. + + :param location_name: The location of the database. Required. + :type location_name: str + :return: An iterator like instance of TimeZone + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.TimeZone] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TimeZone]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_time_zones_list_by_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TimeZone], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class VirtualClustersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`virtual_clusters` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, virtual_cluster_name: str, **kwargs: Any) -> _models.VirtualCluster: + """Gets a virtual cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param virtual_cluster_name: The name of the virtual cluster. Required. + :type virtual_cluster_name: str + :return: VirtualCluster. The VirtualCluster is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.VirtualCluster + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.VirtualCluster] = kwargs.pop("cls", None) + + _request = build_virtual_clusters_get_request( + resource_group_name=resource_group_name, + virtual_cluster_name=virtual_cluster_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.VirtualCluster, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + virtual_cluster_name: str, + parameters: Union[_models.VirtualCluster, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_virtual_clusters_create_or_update_request( + resource_group_name=resource_group_name, + virtual_cluster_name=virtual_cluster_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + virtual_cluster_name: str, + parameters: _models.VirtualCluster, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualCluster]: + """Creates virtual cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param virtual_cluster_name: The name of the virtual cluster. Required. + :type virtual_cluster_name: str + :param parameters: The requested virtual cluster resource state. Required. + :type parameters: ~azure.mgmt.sql.models.VirtualCluster + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns VirtualCluster. The VirtualCluster is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.VirtualCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + virtual_cluster_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualCluster]: + """Creates virtual cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param virtual_cluster_name: The name of the virtual cluster. Required. + :type virtual_cluster_name: str + :param parameters: The requested virtual cluster resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns VirtualCluster. The VirtualCluster is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.VirtualCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + virtual_cluster_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualCluster]: + """Creates virtual cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param virtual_cluster_name: The name of the virtual cluster. Required. + :type virtual_cluster_name: str + :param parameters: The requested virtual cluster resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns VirtualCluster. The VirtualCluster is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.VirtualCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + virtual_cluster_name: str, + parameters: Union[_models.VirtualCluster, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.VirtualCluster]: + """Creates virtual cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param virtual_cluster_name: The name of the virtual cluster. Required. + :type virtual_cluster_name: str + :param parameters: The requested virtual cluster resource state. Is one of the following types: + VirtualCluster, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.VirtualCluster or JSON or IO[bytes] + :return: An instance of LROPoller that returns VirtualCluster. The VirtualCluster is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.VirtualCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + virtual_cluster_name=virtual_cluster_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.VirtualCluster, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.VirtualCluster].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.VirtualCluster]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + virtual_cluster_name: str, + parameters: Union[_models.VirtualClusterUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_virtual_clusters_update_request( + resource_group_name=resource_group_name, + virtual_cluster_name=virtual_cluster_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + virtual_cluster_name: str, + parameters: _models.VirtualClusterUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualCluster]: + """Updates an existing virtual cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param virtual_cluster_name: The name of the virtual cluster. Required. + :type virtual_cluster_name: str + :param parameters: The requested virtual cluster resource state. Required. + :type parameters: ~azure.mgmt.sql.models.VirtualClusterUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns VirtualCluster. The VirtualCluster is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.VirtualCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + virtual_cluster_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualCluster]: + """Updates an existing virtual cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param virtual_cluster_name: The name of the virtual cluster. Required. + :type virtual_cluster_name: str + :param parameters: The requested virtual cluster resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns VirtualCluster. The VirtualCluster is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.VirtualCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + virtual_cluster_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualCluster]: + """Updates an existing virtual cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param virtual_cluster_name: The name of the virtual cluster. Required. + :type virtual_cluster_name: str + :param parameters: The requested virtual cluster resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns VirtualCluster. The VirtualCluster is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.VirtualCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + virtual_cluster_name: str, + parameters: Union[_models.VirtualClusterUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.VirtualCluster]: + """Updates an existing virtual cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param virtual_cluster_name: The name of the virtual cluster. Required. + :type virtual_cluster_name: str + :param parameters: The requested virtual cluster resource state. Is one of the following types: + VirtualClusterUpdate, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.VirtualClusterUpdate or JSON or IO[bytes] + :return: An instance of LROPoller that returns VirtualCluster. The VirtualCluster is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.VirtualCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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( + resource_group_name=resource_group_name, + virtual_cluster_name=virtual_cluster_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.VirtualCluster, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.VirtualCluster].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.VirtualCluster]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial(self, resource_group_name: str, virtual_cluster_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_virtual_clusters_delete_request( + resource_group_name=resource_group_name, + virtual_cluster_name=virtual_cluster_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete(self, resource_group_name: str, virtual_cluster_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes a virtual cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param virtual_cluster_name: The name of the virtual cluster. Required. + :type virtual_cluster_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + virtual_cluster_name=virtual_cluster_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.VirtualCluster"]: + """Gets a list of virtual clusters in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of VirtualCluster + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.VirtualCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.VirtualCluster]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_virtual_clusters_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.VirtualCluster], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged["_models.VirtualCluster"]: + """Gets a list of all virtualClusters in the subscription. + + :return: An iterator like instance of VirtualCluster + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.VirtualCluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.VirtualCluster]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_virtual_clusters_list_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.VirtualCluster], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _update_dns_servers_initial( + self, resource_group_name: str, virtual_cluster_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_virtual_clusters_update_dns_servers_request( + resource_group_name=resource_group_name, + virtual_cluster_name=virtual_cluster_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_update_dns_servers( + self, resource_group_name: str, virtual_cluster_name: str, **kwargs: Any + ) -> LROPoller[_models.UpdateVirtualClusterDnsServersOperation]: + """Synchronizes the DNS server settings used by the managed instances inside the given virtual + cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param virtual_cluster_name: The name of the virtual cluster. Required. + :type virtual_cluster_name: str + :return: An instance of LROPoller that returns UpdateVirtualClusterDnsServersOperation. The + UpdateVirtualClusterDnsServersOperation is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.UpdateVirtualClusterDnsServersOperation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_dns_servers_initial( + resource_group_name=resource_group_name, + virtual_cluster_name=virtual_cluster_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.UpdateVirtualClusterDnsServersOperation, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.UpdateVirtualClusterDnsServersOperation].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.UpdateVirtualClusterDnsServersOperation]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class VirtualNetworkRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`virtual_network_rules` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, server_name: str, virtual_network_rule_name: str, **kwargs: Any + ) -> _models.VirtualNetworkRule: + """Gets a virtual network rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param virtual_network_rule_name: The name of the virtual network rule. Required. + :type virtual_network_rule_name: str + :return: VirtualNetworkRule. The VirtualNetworkRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.VirtualNetworkRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.VirtualNetworkRule] = kwargs.pop("cls", None) + + _request = build_virtual_network_rules_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + virtual_network_rule_name=virtual_network_rule_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.VirtualNetworkRule, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + virtual_network_rule_name: str, + parameters: Union[_models.VirtualNetworkRule, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_virtual_network_rules_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + virtual_network_rule_name=virtual_network_rule_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + virtual_network_rule_name: str, + parameters: _models.VirtualNetworkRule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualNetworkRule]: + """Creates or updates an existing virtual network rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param virtual_network_rule_name: The name of the virtual network rule. Required. + :type virtual_network_rule_name: str + :param parameters: The requested virtual Network Rule Resource state. Required. + :type parameters: ~azure.mgmt.sql.models.VirtualNetworkRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns VirtualNetworkRule. The VirtualNetworkRule is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.VirtualNetworkRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + virtual_network_rule_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualNetworkRule]: + """Creates or updates an existing virtual network rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param virtual_network_rule_name: The name of the virtual network rule. Required. + :type virtual_network_rule_name: str + :param parameters: The requested virtual Network Rule Resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns VirtualNetworkRule. The VirtualNetworkRule is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.VirtualNetworkRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + virtual_network_rule_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualNetworkRule]: + """Creates or updates an existing virtual network rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param virtual_network_rule_name: The name of the virtual network rule. Required. + :type virtual_network_rule_name: str + :param parameters: The requested virtual Network Rule Resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns VirtualNetworkRule. The VirtualNetworkRule is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.VirtualNetworkRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + virtual_network_rule_name: str, + parameters: Union[_models.VirtualNetworkRule, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.VirtualNetworkRule]: + """Creates or updates an existing virtual network rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param virtual_network_rule_name: The name of the virtual network rule. Required. + :type virtual_network_rule_name: str + :param parameters: The requested virtual Network Rule Resource state. Is one of the following + types: VirtualNetworkRule, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.VirtualNetworkRule or JSON or IO[bytes] + :return: An instance of LROPoller that returns VirtualNetworkRule. The VirtualNetworkRule is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.VirtualNetworkRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + virtual_network_rule_name=virtual_network_rule_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.VirtualNetworkRule, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.VirtualNetworkRule].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.VirtualNetworkRule]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, server_name: str, virtual_network_rule_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_virtual_network_rules_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + virtual_network_rule_name=virtual_network_rule_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, server_name: str, virtual_network_rule_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the virtual network rule with the given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param virtual_network_rule_name: The name of the virtual network rule. Required. + :type virtual_network_rule_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + virtual_network_rule_name=virtual_network_rule_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.VirtualNetworkRule"]: + """Gets a list of virtual network rules in a server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of VirtualNetworkRule + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.VirtualNetworkRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.VirtualNetworkRule]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_virtual_network_rules_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.VirtualNetworkRule], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class WorkloadClassifiersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`workload_classifiers` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + workload_group_name: str, + workload_classifier_name: str, + **kwargs: Any + ) -> _models.WorkloadClassifier: + """Gets a workload classifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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. Required. + :type workload_group_name: str + :param workload_classifier_name: The name of the workload classifier. Required. + :type workload_classifier_name: str + :return: WorkloadClassifier. The WorkloadClassifier is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.WorkloadClassifier + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.WorkloadClassifier] = kwargs.pop("cls", None) + + _request = build_workload_classifiers_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + workload_group_name=workload_group_name, + workload_classifier_name=workload_classifier_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.WorkloadClassifier, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + workload_classifier_name: str, + parameters: Union[_models.WorkloadClassifier, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workload_classifiers_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + workload_group_name=workload_group_name, + workload_classifier_name=workload_classifier_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + workload_classifier_name: str, + parameters: _models.WorkloadClassifier, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadClassifier]: + """Creates or updates a workload classifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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. Required. + :type workload_group_name: str + :param workload_classifier_name: The name of the workload classifier. Required. + :type workload_classifier_name: str + :param parameters: The properties of the workload classifier. Required. + :type parameters: ~azure.mgmt.sql.models.WorkloadClassifier + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns WorkloadClassifier. The WorkloadClassifier is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.WorkloadClassifier] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + workload_classifier_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadClassifier]: + """Creates or updates a workload classifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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. Required. + :type workload_group_name: str + :param workload_classifier_name: The name of the workload classifier. Required. + :type workload_classifier_name: str + :param parameters: The properties of the workload classifier. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns WorkloadClassifier. The WorkloadClassifier is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.WorkloadClassifier] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + workload_classifier_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadClassifier]: + """Creates or updates a workload classifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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. Required. + :type workload_group_name: str + :param workload_classifier_name: The name of the workload classifier. Required. + :type workload_classifier_name: str + :param parameters: The properties of the workload classifier. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns WorkloadClassifier. The WorkloadClassifier is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.WorkloadClassifier] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + workload_classifier_name: str, + parameters: Union[_models.WorkloadClassifier, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.WorkloadClassifier]: + """Creates or updates a workload classifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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. Required. + :type workload_group_name: str + :param workload_classifier_name: The name of the workload classifier. Required. + :type workload_classifier_name: str + :param parameters: The properties of the workload classifier. Is one of the following types: + WorkloadClassifier, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.WorkloadClassifier or JSON or IO[bytes] + :return: An instance of LROPoller that returns WorkloadClassifier. The WorkloadClassifier is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.WorkloadClassifier] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + workload_group_name=workload_group_name, + workload_classifier_name=workload_classifier_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.WorkloadClassifier, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.WorkloadClassifier].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.WorkloadClassifier]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + workload_classifier_name: str, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_workload_classifiers_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + workload_group_name=workload_group_name, + workload_classifier_name=workload_classifier_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + workload_classifier_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes a workload classifier. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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. Required. + :type workload_group_name: str + :param workload_classifier_name: The name of the workload classifier. Required. + :type workload_classifier_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + workload_group_name=workload_group_name, + workload_classifier_name=workload_classifier_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_workload_group( + self, resource_group_name: str, server_name: str, database_name: str, workload_group_name: str, **kwargs: Any + ) -> ItemPaged["_models.WorkloadClassifier"]: + """Gets the list of workload classifiers for a workload group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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. Required. + :type workload_group_name: str + :return: An iterator like instance of WorkloadClassifier + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.WorkloadClassifier] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.WorkloadClassifier]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_workload_classifiers_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.WorkloadClassifier], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class WorkloadGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`workload_groups` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, workload_group_name: str, **kwargs: Any + ) -> _models.WorkloadGroup: + """Gets a workload group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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. Required. + :type workload_group_name: str + :return: WorkloadGroup. The WorkloadGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.WorkloadGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.WorkloadGroup] = kwargs.pop("cls", None) + + _request = build_workload_groups_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + workload_group_name=workload_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.WorkloadGroup, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + parameters: Union[_models.WorkloadGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workload_groups_create_or_update_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + parameters: _models.WorkloadGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadGroup]: + """Creates or updates a workload group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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. Required. + :type workload_group_name: str + :param parameters: The requested workload group state. Required. + :type parameters: ~azure.mgmt.sql.models.WorkloadGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns WorkloadGroup. The WorkloadGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.WorkloadGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadGroup]: + """Creates or updates a workload group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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. Required. + :type workload_group_name: str + :param parameters: The requested workload group state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns WorkloadGroup. The WorkloadGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.WorkloadGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadGroup]: + """Creates or updates a workload group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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. Required. + :type workload_group_name: str + :param parameters: The requested workload group state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns WorkloadGroup. The WorkloadGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.WorkloadGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + parameters: Union[_models.WorkloadGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.WorkloadGroup]: + """Creates or updates a workload group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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. Required. + :type workload_group_name: str + :param parameters: The requested workload group state. Is one of the following types: + WorkloadGroup, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.WorkloadGroup or JSON or IO[bytes] + :return: An instance of LROPoller that returns WorkloadGroup. The WorkloadGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.WorkloadGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + workload_group_name=workload_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.WorkloadGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.WorkloadGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.WorkloadGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, server_name: str, database_name: str, workload_group_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_workload_groups_delete_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, server_name: str, database_name: str, workload_group_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a workload group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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. Required. + :type workload_group_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + workload_group_name=workload_group_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> ItemPaged["_models.WorkloadGroup"]: + """Gets the list of workload groups. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of WorkloadGroup + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.WorkloadGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.WorkloadGroup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_workload_groups_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.WorkloadGroup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ManagedDatabaseSensitivityLabelsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_database_sensitivity_labels` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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. The name is case insensitive. + 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 + :return: SensitivityLabel. The SensitivityLabel is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SensitivityLabel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SensitivityLabel] = kwargs.pop("cls", None) + + _request = build_managed_database_sensitivity_labels_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SensitivityLabel, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + parameters: _models.SensitivityLabel, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SensitivityLabel: + """Creates or updates the sensitivity label of a given column. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 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 + :return: SensitivityLabel. The SensitivityLabel is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SensitivityLabel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SensitivityLabel: + """Creates or updates the sensitivity label of a given column. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 parameters: The column sensitivity label resource. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SensitivityLabel. The SensitivityLabel is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SensitivityLabel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SensitivityLabel: + """Creates or updates the sensitivity label of a given column. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 parameters: The column sensitivity label resource. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SensitivityLabel. The SensitivityLabel is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SensitivityLabel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + parameters: Union[_models.SensitivityLabel, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.SensitivityLabel: + """Creates or updates the sensitivity label of a given column. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 parameters: The column sensitivity label resource. Is one of the following types: + SensitivityLabel, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.SensitivityLabel or JSON or IO[bytes] + :return: SensitivityLabel. The SensitivityLabel is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SensitivityLabel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_database_sensitivity_labels_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + column_name=column_name, + subscription_id=self._config.subscription_id, + sensitivity_label_source=sensitivity_label_source, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = 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]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SensitivityLabel, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + schema_name: str, + table_name: str, + column_name: str, + **kwargs: Any + ) -> None: + """Deletes the sensitivity label of a given column. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_managed_database_sensitivity_labels_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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. The name is case insensitive. + 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 + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_managed_database_sensitivity_labels_disable_recommendation_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + schema_name=schema_name, + table_name=table_name, + column_name=column_name, + subscription_id=self._config.subscription_id, + sensitivity_label_source=sensitivity_label_source, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def enable_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: + """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. The name is case insensitive. + 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 + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_managed_database_sensitivity_labels_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_models.SensitivityLabel"]: + """Gets the sensitivity labels of a given database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 skip_token: Default value is None. + :paramtype skip_token: str + :keyword count: Default value is None. + :paramtype count: bool + :keyword filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of SensitivityLabel + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SensitivityLabel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SensitivityLabel]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_database_sensitivity_labels_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SensitivityLabel], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @overload + def update( + 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. The name is case insensitive. + 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 + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: JSON, + *, + 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. The name is case insensitive. + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: IO[bytes], + *, + 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. The name is case insensitive. + 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[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :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, JSON, IO[bytes]], + **kwargs: Any + ) -> None: + """Update sensitivity labels of a given database using an operations batch. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 one of the following types: SensitivityLabelUpdateList, JSON, IO[bytes] + Required. + :type parameters: ~azure.mgmt.sql.models.SensitivityLabelUpdateList or JSON or IO[bytes] + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_database_sensitivity_labels_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_models.SensitivityLabel"]: + """Gets the sensitivity labels of a given database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 skip_token: Default value is None. + :paramtype skip_token: str + :keyword include_disabled_recommendations: Specifies whether to include disabled + recommendations or not. Default value is None. + :paramtype include_disabled_recommendations: bool + :keyword filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of SensitivityLabel + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SensitivityLabel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SensitivityLabel]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_database_sensitivity_labels_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SensitivityLabel], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_database( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + *, + filter: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.SensitivityLabel"]: + """Gets the sensitivity labels of a given database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of SensitivityLabel + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SensitivityLabel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SensitivityLabel]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_database_sensitivity_labels_list_by_database_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SensitivityLabel], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class DatabaseEncryptionProtectorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`database_encryption_protectors` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _revalidate_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_database_encryption_protectors_revalidate_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + encryption_protector_name=encryption_protector_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_revalidate( + self, + resource_group_name: str, + server_name: str, + database_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + **kwargs: Any + ) -> LROPoller[None]: + """Revalidates an existing encryption protector for a particular database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 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 + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + encryption_protector_name=encryption_protector_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _revert_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_database_encryption_protectors_revert_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + encryption_protector_name=encryption_protector_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_revert( + self, + resource_group_name: str, + server_name: str, + database_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + **kwargs: Any + ) -> LROPoller[None]: + """Reverts an existing encryption protector for a particular database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 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 + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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._revert_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + encryption_protector_name=encryption_protector_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class DatabaseOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`database_operations` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + ) -> ItemPaged["_models.DatabaseOperation"]: + """Gets a list of operations performed on the database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of DatabaseOperation + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseOperation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseOperation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_database_operations_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseOperation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @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. The name is case insensitive. + Required. + :type resource_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 + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_database_operations_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class DatabaseUsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`database_usages` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + ) -> ItemPaged["_models.DatabaseUsage"]: + """Gets database usages. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of DatabaseUsage + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseUsage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseUsage]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_database_usages_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseUsage], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class RecommendedSensitivityLabelsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`recommended_sensitivity_labels` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: _models.RecommendedSensitivityLabelUpdateList, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update recommended sensitivity labels states of a given database using an operations batch. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: Required. + :type parameters: ~azure.mgmt.sql.models.RecommendedSensitivityLabelUpdateList + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update recommended sensitivity labels states of a given database using an operations batch. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update recommended sensitivity labels states of a given database using an operations batch. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.RecommendedSensitivityLabelUpdateList, JSON, IO[bytes]], + **kwargs: Any + ) -> None: + """Update recommended sensitivity labels states of a given database using an operations batch. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: Is one of the following types: RecommendedSensitivityLabelUpdateList, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.RecommendedSensitivityLabelUpdateList or JSON or + IO[bytes] + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_recommended_sensitivity_labels_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class SynapseLinkWorkspacesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`synapse_link_workspaces` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + ) -> ItemPaged["_models.SynapseLinkWorkspace"]: + """Gets all synapselink workspaces for a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of SynapseLinkWorkspace + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SynapseLinkWorkspace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SynapseLinkWorkspace]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_synapse_link_workspaces_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SynapseLinkWorkspace], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ServerOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`server_operations` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + ) -> ItemPaged["_models.ServerOperation"]: + """Gets a list of operations performed on the server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of ServerOperation + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerOperation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerOperation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_server_operations_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ServerOperation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ServerUsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`server_usages` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + ) -> ItemPaged["_models.ServerUsage"]: + """Gets server usages. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of ServerUsage + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerUsage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerUsage]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_server_usages_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ServerUsage], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class TdeCertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`tde_certificates` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _create_initial( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.TdeCertificate, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_tde_certificates_create_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + server_name: str, + parameters: _models.TdeCertificate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Creates a TDE certificate for a given server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The requested TDE certificate to be created or updated. Required. + :type parameters: ~azure.mgmt.sql.models.TdeCertificate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Creates a TDE certificate for a given server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The requested TDE certificate to be created or updated. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Creates a TDE certificate for a given server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The requested TDE certificate to be created or updated. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.TdeCertificate, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[None]: + """Creates a TDE certificate for a given server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The requested TDE certificate to be created or updated. Is one of the + following types: TdeCertificate, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.TdeCertificate or JSON or IO[bytes] + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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( + resource_group_name=resource_group_name, + server_name=server_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class DatabaseAdvancedThreatProtectionSettingsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`database_advanced_threat_protection_settings` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + **kwargs: Any + ) -> _models.DatabaseAdvancedThreatProtection: + """Gets a database's Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :return: DatabaseAdvancedThreatProtection. The DatabaseAdvancedThreatProtection is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseAdvancedThreatProtection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseAdvancedThreatProtection] = kwargs.pop("cls", None) + + _request = build_database_advanced_threat_protection_settings_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + advanced_threat_protection_name=advanced_threat_protection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseAdvancedThreatProtection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: _models.DatabaseAdvancedThreatProtection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseAdvancedThreatProtection: + """Creates or updates a database's Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The database Advanced Threat Protection state. Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseAdvancedThreatProtection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseAdvancedThreatProtection. The DatabaseAdvancedThreatProtection is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseAdvancedThreatProtection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseAdvancedThreatProtection: + """Creates or updates a database's Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The database Advanced Threat Protection state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseAdvancedThreatProtection. The DatabaseAdvancedThreatProtection is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseAdvancedThreatProtection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseAdvancedThreatProtection: + """Creates or updates a database's Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The database Advanced Threat Protection state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseAdvancedThreatProtection. The DatabaseAdvancedThreatProtection is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseAdvancedThreatProtection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: Union[_models.DatabaseAdvancedThreatProtection, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.DatabaseAdvancedThreatProtection: + """Creates or updates a database's Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The database Advanced Threat Protection state. Is one of the following + types: DatabaseAdvancedThreatProtection, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseAdvancedThreatProtection or JSON or IO[bytes] + :return: DatabaseAdvancedThreatProtection. The DatabaseAdvancedThreatProtection is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseAdvancedThreatProtection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_database_advanced_threat_protection_settings_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + advanced_threat_protection_name=advanced_threat_protection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = 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]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseAdvancedThreatProtection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> ItemPaged["_models.DatabaseAdvancedThreatProtection"]: + """Gets a list of database's Advanced Threat Protection states. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of DatabaseAdvancedThreatProtection + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseAdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseAdvancedThreatProtection]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_database_advanced_threat_protection_settings_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseAdvancedThreatProtection], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class DatabaseAdvisorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`database_advisors` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, advisor_name: str, **kwargs: Any + ) -> _models.Advisor: + """Gets a database advisor. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 advisor_name: The name of the Database Advisor. Required. + :type advisor_name: str + :return: Advisor. The Advisor is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Advisor + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Advisor] = kwargs.pop("cls", None) + + _request = build_database_advisors_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + advisor_name=advisor_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Advisor, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + advisor_name: str, + parameters: _models.Advisor, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Advisor: + """Updates a database advisor. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 advisor_name: The name of the Database Advisor. Required. + :type advisor_name: str + :param parameters: The requested advisor resource state. Required. + :type parameters: ~azure.mgmt.sql.models.Advisor + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Advisor. The Advisor is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Advisor + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + advisor_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Advisor: + """Updates a database advisor. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 advisor_name: The name of the Database Advisor. Required. + :type advisor_name: str + :param parameters: The requested advisor resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Advisor. The Advisor is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Advisor + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + advisor_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Advisor: + """Updates a database advisor. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 advisor_name: The name of the Database Advisor. Required. + :type advisor_name: str + :param parameters: The requested advisor resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Advisor. The Advisor is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Advisor + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + advisor_name: str, + parameters: Union[_models.Advisor, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.Advisor: + """Updates a database advisor. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 advisor_name: The name of the Database Advisor. Required. + :type advisor_name: str + :param parameters: The requested advisor resource state. Is one of the following types: + Advisor, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.Advisor or JSON or IO[bytes] + :return: Advisor. The Advisor is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.Advisor + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_database_advisors_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + advisor_name=advisor_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Advisor, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_database( + self, + resource_group_name: str, + server_name: str, + database_name: str, + *, + expand: Optional[str] = None, + **kwargs: Any + ) -> List[_models.Advisor]: + """Gets a list of database advisors. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 expand: The child resources to include in the response. Default value is None. + :paramtype expand: str + :return: list of Advisor + :rtype: list[~azure.mgmt.sql.models.Advisor] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Advisor]] = kwargs.pop("cls", None) + + _request = build_database_advisors_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(List[_models.Advisor], response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class DatabaseAutomaticTuningOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`database_automatic_tuning` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, **kwargs: Any + ) -> _models.DatabaseAutomaticTuning: + """Gets a database's automatic tuning. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: DatabaseAutomaticTuning. The DatabaseAutomaticTuning is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseAutomaticTuning + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseAutomaticTuning] = kwargs.pop("cls", None) + + _request = build_database_automatic_tuning_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseAutomaticTuning, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: _models.DatabaseAutomaticTuning, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseAutomaticTuning: + """Update automatic tuning properties for target database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The requested automatic tuning resource state. Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseAutomaticTuning + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseAutomaticTuning. The DatabaseAutomaticTuning is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseAutomaticTuning + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseAutomaticTuning: + """Update automatic tuning properties for target database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The requested automatic tuning resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseAutomaticTuning. The DatabaseAutomaticTuning is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseAutomaticTuning + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseAutomaticTuning: + """Update automatic tuning properties for target database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The requested automatic tuning resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseAutomaticTuning. The DatabaseAutomaticTuning is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseAutomaticTuning + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.DatabaseAutomaticTuning, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.DatabaseAutomaticTuning: + """Update automatic tuning properties for target database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: The requested automatic tuning resource state. Is one of the following + types: DatabaseAutomaticTuning, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseAutomaticTuning or JSON or IO[bytes] + :return: DatabaseAutomaticTuning. The DatabaseAutomaticTuning is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseAutomaticTuning + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_database_automatic_tuning_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseAutomaticTuning, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class DatabaseExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`database_extensions` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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 + ) -> None: + """Gets a database extension. This will return resource not found as it is not supported. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 extension_name: Required. + :type extension_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_database_extensions_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + extension_name: str, + parameters: Union[_models.DatabaseExtensions, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_database_extensions_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + extension_name: str, + parameters: _models.DatabaseExtensions, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ImportExportExtensionsOperationResult]: + """Perform a database extension operation, like database import, database export, or polybase + import. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 extension_name: Required. + :type extension_name: str + :param parameters: The database import request parameters. Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseExtensions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ImportExportExtensionsOperationResult. The + ImportExportExtensionsOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportExtensionsOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + extension_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ImportExportExtensionsOperationResult]: + """Perform a database extension operation, like database import, database export, or polybase + import. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 extension_name: Required. + :type extension_name: str + :param parameters: The database import request parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ImportExportExtensionsOperationResult. The + ImportExportExtensionsOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportExtensionsOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + extension_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ImportExportExtensionsOperationResult]: + """Perform a database extension operation, like database import, database export, or polybase + import. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 extension_name: Required. + :type extension_name: str + :param parameters: The database import request parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ImportExportExtensionsOperationResult. The + ImportExportExtensionsOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportExtensionsOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + extension_name: str, + parameters: Union[_models.DatabaseExtensions, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ImportExportExtensionsOperationResult]: + """Perform a database extension operation, like database import, database export, or polybase + import. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 extension_name: Required. + :type extension_name: str + :param parameters: The database import request parameters. Is one of the following types: + DatabaseExtensions, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DatabaseExtensions or JSON or IO[bytes] + :return: An instance of LROPoller that returns ImportExportExtensionsOperationResult. The + ImportExportExtensionsOperationResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportExtensionsOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + extension_name=extension_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ImportExportExtensionsOperationResult, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ImportExportExtensionsOperationResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ImportExportExtensionsOperationResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> ItemPaged["_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. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of ImportExportExtensionsOperationResult + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ImportExportExtensionsOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ImportExportExtensionsOperationResult]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_database_extensions_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ImportExportExtensionsOperationResult], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class DatabaseRecommendedActionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`database_recommended_actions` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + advisor_name: str, + recommended_action_name: str, + **kwargs: Any + ) -> _models.RecommendedAction: + """Gets a database recommended action. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 advisor_name: The name of the Database Advisor. Required. + :type advisor_name: str + :param recommended_action_name: The name of Database Recommended Action. Required. + :type recommended_action_name: str + :return: RecommendedAction. The RecommendedAction is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.RecommendedAction + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RecommendedAction] = kwargs.pop("cls", None) + + _request = build_database_recommended_actions_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + advisor_name=advisor_name, + recommended_action_name=recommended_action_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RecommendedAction, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + advisor_name: str, + recommended_action_name: str, + parameters: _models.RecommendedAction, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RecommendedAction: + """Updates a database recommended action. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 advisor_name: The name of the Database Advisor. Required. + :type advisor_name: str + :param recommended_action_name: The name of Database Recommended Action. Required. + :type recommended_action_name: str + :param parameters: The requested recommended action resource state. Required. + :type parameters: ~azure.mgmt.sql.models.RecommendedAction + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RecommendedAction. The RecommendedAction is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.RecommendedAction + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + advisor_name: str, + recommended_action_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RecommendedAction: + """Updates a database recommended action. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 advisor_name: The name of the Database Advisor. Required. + :type advisor_name: str + :param recommended_action_name: The name of Database Recommended Action. Required. + :type recommended_action_name: str + :param parameters: The requested recommended action resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RecommendedAction. The RecommendedAction is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.RecommendedAction + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + advisor_name: str, + recommended_action_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RecommendedAction: + """Updates a database recommended action. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 advisor_name: The name of the Database Advisor. Required. + :type advisor_name: str + :param recommended_action_name: The name of Database Recommended Action. Required. + :type recommended_action_name: str + :param parameters: The requested recommended action resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: RecommendedAction. The RecommendedAction is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.RecommendedAction + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + advisor_name: str, + recommended_action_name: str, + parameters: Union[_models.RecommendedAction, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.RecommendedAction: + """Updates a database recommended action. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 advisor_name: The name of the Database Advisor. Required. + :type advisor_name: str + :param recommended_action_name: The name of Database Recommended Action. Required. + :type recommended_action_name: str + :param parameters: The requested recommended action resource state. Is one of the following + types: RecommendedAction, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.RecommendedAction or JSON or IO[bytes] + :return: RecommendedAction. The RecommendedAction is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.RecommendedAction + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_database_recommended_actions_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + advisor_name=advisor_name, + recommended_action_name=recommended_action_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RecommendedAction, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_database_advisor( + self, resource_group_name: str, server_name: str, database_name: str, advisor_name: str, **kwargs: Any + ) -> List[_models.RecommendedAction]: + """Gets list of Database Recommended Actions. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 advisor_name: The name of the Database Advisor. Required. + :type advisor_name: str + :return: list of RecommendedAction + :rtype: list[~azure.mgmt.sql.models.RecommendedAction] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RecommendedAction]] = kwargs.pop("cls", None) + + _request = build_database_recommended_actions_list_by_database_advisor_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + advisor_name=advisor_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(List[_models.RecommendedAction], response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class DatabaseSqlVulnerabilityAssessmentBaselinesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`database_sql_vulnerability_assessment_baselines` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: + """Gets a list of database's sql vulnerability assessment rule baselines. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :return: DatabaseSqlVulnerabilityAssessmentBaselineSet. The + DatabaseSqlVulnerabilityAssessmentBaselineSet is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentBaselineSet] = kwargs.pop("cls", None) + + _request = build_database_sql_vulnerability_assessment_baselines_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseSqlVulnerabilityAssessmentBaselineSet, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + parameters: _models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: + """Add a database's vulnerability assessment rule baseline list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param parameters: The requested rule baseline resource. Required. + :type parameters: + ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseSqlVulnerabilityAssessmentBaselineSet. The + DatabaseSqlVulnerabilityAssessmentBaselineSet is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: + """Add a database's vulnerability assessment rule baseline list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param parameters: The requested rule baseline resource. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseSqlVulnerabilityAssessmentBaselineSet. The + DatabaseSqlVulnerabilityAssessmentBaselineSet is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: + """Add a database's vulnerability assessment rule baseline list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param parameters: The requested rule baseline resource. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseSqlVulnerabilityAssessmentBaselineSet. The + DatabaseSqlVulnerabilityAssessmentBaselineSet is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + parameters: Union[_models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: + """Add a database's vulnerability assessment rule baseline list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param parameters: The requested rule baseline resource. Is one of the following types: + DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput, JSON, IO[bytes] Required. + :type parameters: + ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput or JSON or + IO[bytes] + :return: DatabaseSqlVulnerabilityAssessmentBaselineSet. The + DatabaseSqlVulnerabilityAssessmentBaselineSet is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_database_sql_vulnerability_assessment_baselines_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseSqlVulnerabilityAssessmentBaselineSet, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_sql_vulnerability_assessment( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + **kwargs: Any + ) -> ItemPaged["_models.DatabaseSqlVulnerabilityAssessmentBaselineSet"]: + """Gets a list of database's sql vulnerability assessment rule baselines. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of DatabaseSqlVulnerabilityAssessmentBaselineSet + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatabaseSqlVulnerabilityAssessmentBaselineSet]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = ( + build_database_sql_vulnerability_assessment_baselines_list_by_sql_vulnerability_assessment_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatabaseSqlVulnerabilityAssessmentBaselineSet], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class SqlVulnerabilityAssessmentBaselinesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`sql_vulnerability_assessment_baselines` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + parameters: _models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput, + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: + """Add a database's vulnerability assessment rule baseline list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param parameters: The requested rule baseline resource. Required. + :type parameters: + ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput + :keyword system_database_name: The vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseSqlVulnerabilityAssessmentBaselineSet. The + DatabaseSqlVulnerabilityAssessmentBaselineSet is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + parameters: JSON, + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: + """Add a database's vulnerability assessment rule baseline list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param parameters: The requested rule baseline resource. Required. + :type parameters: JSON + :keyword system_database_name: The vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseSqlVulnerabilityAssessmentBaselineSet. The + DatabaseSqlVulnerabilityAssessmentBaselineSet is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + parameters: IO[bytes], + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: + """Add a database's vulnerability assessment rule baseline list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param parameters: The requested rule baseline resource. Required. + :type parameters: IO[bytes] + :keyword system_database_name: The vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DatabaseSqlVulnerabilityAssessmentBaselineSet. The + DatabaseSqlVulnerabilityAssessmentBaselineSet is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + parameters: Union[_models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput, JSON, IO[bytes]], + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any + ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: + """Add a database's vulnerability assessment rule baseline list. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param parameters: The requested rule baseline resource. Is one of the following types: + DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput, JSON, IO[bytes] Required. + :type parameters: + ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput or JSON or + IO[bytes] + :keyword system_database_name: The vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :return: DatabaseSqlVulnerabilityAssessmentBaselineSet. The + DatabaseSqlVulnerabilityAssessmentBaselineSet is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_sql_vulnerability_assessment_baselines_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + baseline_name=baseline_name, + subscription_id=self._config.subscription_id, + system_database_name=system_database_name, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseSqlVulnerabilityAssessmentBaselineSet, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class DatabaseSqlVulnerabilityAssessmentsSettingsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`database_sql_vulnerability_assessments_settings` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], + **kwargs: Any + ) -> _models.SqlVulnerabilityAssessment: + """Gets SQL Vulnerability Assessment policy for database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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.SqlVulnerabilityAssessmentName + :return: SqlVulnerabilityAssessment. The SqlVulnerabilityAssessment is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SqlVulnerabilityAssessment] = kwargs.pop("cls", None) + + _request = build_database_sql_vulnerability_assessments_settings_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SqlVulnerabilityAssessment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> ItemPaged["_models.SqlVulnerabilityAssessment"]: + """Lists SQL Vulnerability Assessment policies associated with a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of SqlVulnerabilityAssessment + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SqlVulnerabilityAssessment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SqlVulnerabilityAssessment]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_database_sql_vulnerability_assessments_settings_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SqlVulnerabilityAssessment], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class DatabaseSqlVulnerabilityAssessmentExecuteScanOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`database_sql_vulnerability_assessment_execute_scan` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _execute_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_database_sql_vulnerability_assessment_execute_scan_execute_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_execute( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + **kwargs: Any + ) -> LROPoller[None]: + """Executes a Vulnerability Assessment database scan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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._execute_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class SqlVulnerabilityAssessmentExecuteScanOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`sql_vulnerability_assessment_execute_scan` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _execute_initial( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_sql_vulnerability_assessment_execute_scan_execute_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + system_database_name=system_database_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_execute( + self, + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any + ) -> LROPoller[None]: + """Executes a Vulnerability Assessment database scan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" + Required. + :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName + :keyword system_database_name: The vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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._execute_initial( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + system_database_name=system_database_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class SqlVulnerabilityAssessmentRuleBaselinesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`sql_vulnerability_assessment_rule_baselines` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + baseline_name: Union[str, _models.BaselineName], + rule_id: str, + *, + system_database_name: Union[str, _models.VulnerabilityAssessmentSystemDatabaseName], + **kwargs: Any + ) -> None: + """Removes the database's vulnerability assessment rule baseline. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_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 baseline_name: "default" Required. + :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName + :param rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :keyword system_database_name: The vulnerability assessment system database name. "master" + Required. + :paramtype system_database_name: str or + ~azure.mgmt.sql.models.VulnerabilityAssessmentSystemDatabaseName + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_sql_vulnerability_assessment_rule_baselines_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + vulnerability_assessment_name=vulnerability_assessment_name, + baseline_name=baseline_name, + rule_id=rule_id, + subscription_id=self._config.subscription_id, + system_database_name=system_database_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = 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) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class DatabaseSqlVulnerabilityAssessmentScansOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`database_sql_vulnerability_assessment_scans` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + scan_id: str, + **kwargs: Any + ) -> _models.SqlVulnerabilityAssessmentScanRecord: + """Get a database vulnerability assessment scan result. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: SqlVulnerabilityAssessmentScanRecord. The SqlVulnerabilityAssessmentScanRecord is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanRecord + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SqlVulnerabilityAssessmentScanRecord] = kwargs.pop("cls", None) + + _request = build_database_sql_vulnerability_assessment_scans_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + scan_id=scan_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SqlVulnerabilityAssessmentScanRecord, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_sql_vulnerability_assessments( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + **kwargs: Any + ) -> ItemPaged["_models.SqlVulnerabilityAssessmentScanRecord"]: + """Lists the vulnerability assessment scans of a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of SqlVulnerabilityAssessmentScanRecord + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanRecord] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SqlVulnerabilityAssessmentScanRecord]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = ( + build_database_sql_vulnerability_assessment_scans_list_by_sql_vulnerability_assessments_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SqlVulnerabilityAssessmentScanRecord], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class DatabaseVulnerabilityAssessmentScansOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`database_vulnerability_assessment_scans` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + scan_id: str, + **kwargs: Any + ) -> _models.VulnerabilityAssessmentScanRecord: + """Gets a vulnerability assessment scan record of a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: VulnerabilityAssessmentScanRecord. The VulnerabilityAssessmentScanRecord is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecord + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.VulnerabilityAssessmentScanRecord] = kwargs.pop("cls", None) + + _request = build_database_vulnerability_assessment_scans_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + scan_id=scan_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.VulnerabilityAssessmentScanRecord, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_database( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + **kwargs: Any + ) -> ItemPaged["_models.VulnerabilityAssessmentScanRecord"]: + """Lists the vulnerability assessment scans of a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of VulnerabilityAssessmentScanRecord + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecord] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.VulnerabilityAssessmentScanRecord]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_database_vulnerability_assessment_scans_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.VulnerabilityAssessmentScanRecord], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def export( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + scan_id: str, + **kwargs: Any + ) -> _models.DatabaseVulnerabilityAssessmentScansExport: + """Convert an existing scan result to a human readable format. If already exists nothing happens. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: DatabaseVulnerabilityAssessmentScansExport. The + DatabaseVulnerabilityAssessmentScansExport is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentScansExport + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatabaseVulnerabilityAssessmentScansExport] = kwargs.pop("cls", None) + + _request = build_database_vulnerability_assessment_scans_export_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + scan_id=scan_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = 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]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatabaseVulnerabilityAssessmentScansExport, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _initiate_scan_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + scan_id: str, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_database_vulnerability_assessment_scans_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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. The name is case insensitive. + Required. + :type resource_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 + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + scan_id=scan_id, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class DataMaskingRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`data_masking_rules` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + @api_version_validation( + params_added_on={"2025-02-01-preview": ["skip"]}, + api_versions_list=["2025-01-01", "2025-02-01-preview"], + ) + def list_by_database( + self, + resource_group_name: str, + server_name: str, + database_name: str, + data_masking_policy_name: Union[str, _models.DataMaskingPolicyName], + *, + skip: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_models.DataMaskingRule"]: + """Gets a list of database data masking rules. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 skip: The number of elements in the collection to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of DataMaskingRule + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DataMaskingRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DataMaskingRule]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_data_masking_rules_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, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DataMaskingRule], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataMaskingRule: + """Creates or updates a database data masking rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :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. + Required. + :type parameters: ~azure.mgmt.sql.models.DataMaskingRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DataMaskingRule. The DataMaskingRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DataMaskingRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataMaskingRule: + """Creates or updates a database data masking rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :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. + Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DataMaskingRule. The DataMaskingRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DataMaskingRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataMaskingRule: + """Creates or updates a database data masking rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :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. + Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DataMaskingRule. The DataMaskingRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DataMaskingRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + 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: Union[_models.DataMaskingRule, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.DataMaskingRule: + """Creates or updates a database data masking rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :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 one + of the following types: DataMaskingRule, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.DataMaskingRule or JSON or IO[bytes] + :return: DataMaskingRule. The DataMaskingRule is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.DataMaskingRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_data_masking_rules_create_or_update_request( + 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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = 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]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DataMaskingRule, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class DataWarehouseUserActivitiesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`data_warehouse_user_activities` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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. The name is case insensitive. + Required. + :type resource_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 + :return: DataWarehouseUserActivities. The DataWarehouseUserActivities is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.DataWarehouseUserActivities + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DataWarehouseUserActivities] = kwargs.pop("cls", None) + + _request = build_data_warehouse_user_activities_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DataWarehouseUserActivities, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> ItemPaged["_models.DataWarehouseUserActivities"]: + """List the user activities of a data warehouse which includes running and suspended queries. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of DataWarehouseUserActivities + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DataWarehouseUserActivities] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DataWarehouseUserActivities]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_data_warehouse_user_activities_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DataWarehouseUserActivities], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ManagedDatabaseSecurityEventsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_database_security_events` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + *, + filter: Optional[str] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + skiptoken: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.SecurityEvent"]: + """Gets a list of security events. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :keyword skip: The number of elements in the collection to skip. Default value is None. + :paramtype skip: int + :keyword top: The number of elements to return from the collection. Default value is None. + :paramtype top: int + :keyword skiptoken: An opaque token that identifies a starting point in the collection. Default + value is None. + :paramtype skiptoken: str + :return: An iterator like instance of SecurityEvent + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SecurityEvent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SecurityEvent]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_database_security_events_list_by_database_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + filter=filter, + skip=skip, + top=top, + skiptoken=skiptoken, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SecurityEvent], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ManagedDatabaseRecommendedSensitivityLabelsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_database_recommended_sensitivity_labels` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + def update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: _models.RecommendedSensitivityLabelUpdateList, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update recommended sensitivity labels states of a given database using an operations batch. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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.RecommendedSensitivityLabelUpdateList + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update recommended sensitivity labels states of a given database using an operations batch. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update recommended sensitivity labels states of a given database using an operations batch. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :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.RecommendedSensitivityLabelUpdateList, JSON, IO[bytes]], + **kwargs: Any + ) -> None: + """Update recommended sensitivity labels states of a given database using an operations batch. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 one of the following types: RecommendedSensitivityLabelUpdateList, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.RecommendedSensitivityLabelUpdateList or JSON or + IO[bytes] + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_database_recommended_sensitivity_labels_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class ManagedInstanceTdeCertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_instance_tde_certificates` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _create_initial( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: Union[_models.TdeCertificate, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_instance_tde_certificates_create_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: _models.TdeCertificate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Creates a TDE certificate for a given server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: The requested TDE certificate to be created or updated. Required. + :type parameters: ~azure.mgmt.sql.models.TdeCertificate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Creates a TDE certificate for a given server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: The requested TDE certificate to be created or updated. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Creates a TDE certificate for a given server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: The requested TDE certificate to be created or updated. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: Union[_models.TdeCertificate, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[None]: + """Creates a TDE certificate for a given server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: The requested TDE certificate to be created or updated. Is one of the + following types: TdeCertificate, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.TdeCertificate or JSON or IO[bytes] + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class ElasticPoolOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`elastic_pool_operations` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + ) -> ItemPaged["_models.ElasticPoolOperation"]: + """Gets a list of operations performed on the elastic pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An iterator like instance of ElasticPoolOperation + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ElasticPoolOperation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ElasticPoolOperation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_elastic_pool_operations_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ElasticPoolOperation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @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. The name is case insensitive. + 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 operation_id: The operation identifier. Required. + :type operation_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_elastic_pool_operations_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class UsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`usages` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_instance_pool( + self, + resource_group_name: str, + instance_pool_name: str, + *, + expand_children: Optional[bool] = None, + **kwargs: Any + ) -> ItemPaged["_models.Usage"]: + """Gets all instance pool usage metrics. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param instance_pool_name: The name of the instance pool to be retrieved. Required. + :type instance_pool_name: str + :keyword expand_children: Optional request parameter to include managed instance usages within + the instance pool. Default value is None. + :paramtype expand_children: bool + :return: An iterator like instance of Usage + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Usage]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_usages_list_by_instance_pool_request( + resource_group_name=resource_group_name, + instance_pool_name=instance_pool_name, + subscription_id=self._config.subscription_id, + expand_children=expand_children, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Usage], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class LedgerDigestUploadsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`ledger_digest_uploads` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], + **kwargs: Any + ) -> _models.LedgerDigestUploads: + """Gets the current ledger digest upload configuration for a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 ledger_digest_uploads: "current" Required. + :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName + :return: LedgerDigestUploads. The LedgerDigestUploads is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.LedgerDigestUploads + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LedgerDigestUploads] = kwargs.pop("cls", None) + + _request = build_ledger_digest_uploads_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + ledger_digest_uploads=ledger_digest_uploads, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.LedgerDigestUploads, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], + parameters: Union[_models.LedgerDigestUploads, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_ledger_digest_uploads_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + ledger_digest_uploads=ledger_digest_uploads, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], + parameters: _models.LedgerDigestUploads, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LedgerDigestUploads]: + """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 ledger_digest_uploads: "current" Required. + :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName + :param parameters: Required. + :type parameters: ~azure.mgmt.sql.models.LedgerDigestUploads + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns LedgerDigestUploads. The LedgerDigestUploads is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LedgerDigestUploads] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LedgerDigestUploads]: + """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 ledger_digest_uploads: "current" Required. + :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName + :param parameters: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns LedgerDigestUploads. The LedgerDigestUploads is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LedgerDigestUploads] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LedgerDigestUploads]: + """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 ledger_digest_uploads: "current" Required. + :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns LedgerDigestUploads. The LedgerDigestUploads is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LedgerDigestUploads] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], + parameters: Union[_models.LedgerDigestUploads, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.LedgerDigestUploads]: + """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 ledger_digest_uploads: "current" Required. + :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName + :param parameters: Is one of the following types: LedgerDigestUploads, JSON, IO[bytes] + Required. + :type parameters: ~azure.mgmt.sql.models.LedgerDigestUploads or JSON or IO[bytes] + :return: An instance of LROPoller that returns LedgerDigestUploads. The LedgerDigestUploads is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LedgerDigestUploads] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + ledger_digest_uploads=ledger_digest_uploads, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LedgerDigestUploads, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.LedgerDigestUploads].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.LedgerDigestUploads]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> ItemPaged["_models.LedgerDigestUploads"]: + """Gets all ledger digest upload settings on a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of LedgerDigestUploads + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LedgerDigestUploads] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.LedgerDigestUploads]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_ledger_digest_uploads_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.LedgerDigestUploads], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _disable_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_ledger_digest_uploads_disable_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + ledger_digest_uploads=ledger_digest_uploads, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_disable( + self, + resource_group_name: str, + server_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], + **kwargs: Any + ) -> LROPoller[_models.LedgerDigestUploads]: + """Disables uploading ledger digests to an Azure Storage account or an Azure Confidential Ledger + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 ledger_digest_uploads: "current" Required. + :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.LedgerDigestUploadsName + :return: An instance of LROPoller that returns LedgerDigestUploads. The LedgerDigestUploads is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LedgerDigestUploads] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._disable_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + ledger_digest_uploads=ledger_digest_uploads, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.LedgerDigestUploads, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.LedgerDigestUploads].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.LedgerDigestUploads]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class MaintenanceWindowOptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`maintenance_window_options` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + *, + maintenance_window_options_name: str, + **kwargs: Any + ) -> _models.MaintenanceWindowOptions: + """Gets a list of available maintenance windows. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 maintenance_window_options_name: Maintenance window options name. Required. + :paramtype maintenance_window_options_name: str + :return: MaintenanceWindowOptions. The MaintenanceWindowOptions is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.MaintenanceWindowOptions + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.MaintenanceWindowOptions] = kwargs.pop("cls", None) + + _request = build_maintenance_window_options_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + maintenance_window_options_name=maintenance_window_options_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.MaintenanceWindowOptions, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class MaintenanceWindowsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`maintenance_windows` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + *, + maintenance_window_name: str, + **kwargs: Any + ) -> _models.MaintenanceWindows: + """Gets maintenance windows settings for a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 maintenance_window_name: Maintenance window name. Required. + :paramtype maintenance_window_name: str + :return: MaintenanceWindows. The MaintenanceWindows is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.MaintenanceWindows + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.MaintenanceWindows] = kwargs.pop("cls", None) + + _request = build_maintenance_windows_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + maintenance_window_name=maintenance_window_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.MaintenanceWindows, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: _models.MaintenanceWindows, + *, + maintenance_window_name: str, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Sets maintenance windows settings for a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: Required. + :type parameters: ~azure.mgmt.sql.models.MaintenanceWindows + :keyword maintenance_window_name: Maintenance window name. Required. + :paramtype maintenance_window_name: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: JSON, + *, + maintenance_window_name: str, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Sets maintenance windows settings for a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: Required. + :type parameters: JSON + :keyword maintenance_window_name: Maintenance window name. Required. + :paramtype maintenance_window_name: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: IO[bytes], + *, + maintenance_window_name: str, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Sets maintenance windows settings for a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: Required. + :type parameters: IO[bytes] + :keyword maintenance_window_name: Maintenance window name. Required. + :paramtype maintenance_window_name: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + server_name: str, + database_name: str, + parameters: Union[_models.MaintenanceWindows, JSON, IO[bytes]], + *, + maintenance_window_name: str, + **kwargs: Any + ) -> None: + """Sets maintenance windows settings for a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 parameters: Is one of the following types: MaintenanceWindows, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.MaintenanceWindows or JSON or IO[bytes] + :keyword maintenance_window_name: Maintenance window name. Required. + :paramtype maintenance_window_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_maintenance_windows_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + maintenance_window_name=maintenance_window_name, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class ManagedDatabaseAdvancedThreatProtectionSettingsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_database_advanced_threat_protection_settings` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + **kwargs: Any + ) -> _models.ManagedDatabaseAdvancedThreatProtection: + """Gets a managed database's Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :return: ManagedDatabaseAdvancedThreatProtection. The ManagedDatabaseAdvancedThreatProtection + is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedDatabaseAdvancedThreatProtection] = kwargs.pop("cls", None) + + _request = build_managed_database_advanced_threat_protection_settings_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + advanced_threat_protection_name=advanced_threat_protection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedDatabaseAdvancedThreatProtection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: _models.ManagedDatabaseAdvancedThreatProtection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedDatabaseAdvancedThreatProtection: + """Creates or updates a managed database's Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The managed database Advanced Threat Protection state. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedDatabaseAdvancedThreatProtection. The ManagedDatabaseAdvancedThreatProtection + is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedDatabaseAdvancedThreatProtection: + """Creates or updates a managed database's Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The managed database Advanced Threat Protection state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedDatabaseAdvancedThreatProtection. The ManagedDatabaseAdvancedThreatProtection + is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedDatabaseAdvancedThreatProtection: + """Creates or updates a managed database's Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The managed database Advanced Threat Protection state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedDatabaseAdvancedThreatProtection. The ManagedDatabaseAdvancedThreatProtection + is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: Union[_models.ManagedDatabaseAdvancedThreatProtection, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ManagedDatabaseAdvancedThreatProtection: + """Creates or updates a managed database's Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The managed database Advanced Threat Protection state. Is one of the + following types: ManagedDatabaseAdvancedThreatProtection, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection or JSON or + IO[bytes] + :return: ManagedDatabaseAdvancedThreatProtection. The ManagedDatabaseAdvancedThreatProtection + is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_database_advanced_threat_protection_settings_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + advanced_threat_protection_name=advanced_threat_protection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = 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]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedDatabaseAdvancedThreatProtection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_database( + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> ItemPaged["_models.ManagedDatabaseAdvancedThreatProtection"]: + """Gets a list of managed database's Advanced Threat Protection states. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An iterator like instance of ManagedDatabaseAdvancedThreatProtection + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedDatabaseAdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedDatabaseAdvancedThreatProtection]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_database_advanced_threat_protection_settings_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedDatabaseAdvancedThreatProtection], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ManagedDatabaseMoveOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_database_move_operations` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, location_name: str, operation_id: str, **kwargs: Any + ) -> _models.ManagedDatabaseMoveOperationResult: + """Gets a managed database move operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :type location_name: str + :param operation_id: The ID of the managed database move operation. Required. + :type operation_id: str + :return: ManagedDatabaseMoveOperationResult. The ManagedDatabaseMoveOperationResult is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedDatabaseMoveOperationResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedDatabaseMoveOperationResult] = kwargs.pop("cls", None) + + _request = build_managed_database_move_operations_get_request( + resource_group_name=resource_group_name, + location_name=location_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedDatabaseMoveOperationResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_location( + self, + resource_group_name: str, + location_name: str, + *, + only_latest_per_database: Optional[bool] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.ManagedDatabaseMoveOperationResult"]: + """Lists managed database move operations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 only_latest_per_database: Whether or not to only get the latest operation for each + database. Has higher priority than $filter. Default value is None. + :paramtype only_latest_per_database: bool + :keyword filter: An OData filter expression that filters elements in the collection. Default + value is None. + :paramtype filter: str + :return: An iterator like instance of ManagedDatabaseMoveOperationResult + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedDatabaseMoveOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedDatabaseMoveOperationResult]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_database_move_operations_list_by_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, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedDatabaseMoveOperationResult], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ManagedDatabaseQueriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_database_queries` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, managed_instance_name: str, database_name: str, query_id: str, **kwargs: Any + ) -> _models.ManagedInstanceQuery: + """Get query by query id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 query_id: Required. + :type query_id: str + :return: ManagedInstanceQuery. The ManagedInstanceQuery is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstanceQuery + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedInstanceQuery] = kwargs.pop("cls", None) + + _request = build_managed_database_queries_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + query_id=query_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedInstanceQuery, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_query( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + query_id: str, + *, + start_time: Optional[str] = None, + end_time: Optional[str] = None, + interval: Optional[Union[str, _models.QueryTimeGrainType]] = None, + **kwargs: Any + ) -> ItemPaged["_models.QueryStatistics"]: + """Get query execution statistics by query id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 query_id: Required. + :type query_id: str + :keyword start_time: Start time for observed period. Default value is None. + :paramtype start_time: str + :keyword end_time: End time for observed period. Default value is None. + :paramtype end_time: str + :keyword interval: The time step to be used to summarize the metric values. Known values are: + "PT1H" and "P1D". Default value is None. + :paramtype interval: str or ~azure.mgmt.sql.models.QueryTimeGrainType + :return: An iterator like instance of QueryStatistics + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.QueryStatistics] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.QueryStatistics]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_database_queries_list_by_query_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + query_id=query_id, + subscription_id=self._config.subscription_id, + start_time=start_time, + end_time=end_time, + interval=interval, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.QueryStatistics], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ManagedDatabaseRestoreDetailsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_database_restore_details` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + restore_details_name: Union[str, _models.RestoreDetailsName], + **kwargs: Any + ) -> _models.ManagedDatabaseRestoreDetailsResult: + """Gets managed database restore details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 restore_details_name: The name of the restore details to retrieve. "Default" Required. + :type restore_details_name: str or ~azure.mgmt.sql.models.RestoreDetailsName + :return: ManagedDatabaseRestoreDetailsResult. The ManagedDatabaseRestoreDetailsResult is + compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedDatabaseRestoreDetailsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedDatabaseRestoreDetailsResult] = kwargs.pop("cls", None) + + _request = build_managed_database_restore_details_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + restore_details_name=restore_details_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedDatabaseRestoreDetailsResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class ManagedDatabaseTransparentDataEncryptionOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_database_transparent_data_encryption` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + tde_name: Union[str, _models.TransparentDataEncryptionName], + **kwargs: Any + ) -> _models.ManagedTransparentDataEncryption: + """Gets a managed database's transparent data encryption. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 tde_name: The name of the transparent data encryption configuration. "current" Required. + :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName + :return: ManagedTransparentDataEncryption. The ManagedTransparentDataEncryption is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedTransparentDataEncryption + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedTransparentDataEncryption] = kwargs.pop("cls", None) + + _request = build_managed_database_transparent_data_encryption_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + tde_name=tde_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedTransparentDataEncryption, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + tde_name: Union[str, _models.TransparentDataEncryptionName], + parameters: _models.ManagedTransparentDataEncryption, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedTransparentDataEncryption: + """Updates a database's transparent data encryption configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 tde_name: The name of the transparent data encryption configuration. "current" Required. + :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName + :param parameters: The database transparent data encryption. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedTransparentDataEncryption + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedTransparentDataEncryption. The ManagedTransparentDataEncryption is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedTransparentDataEncryption + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + tde_name: Union[str, _models.TransparentDataEncryptionName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedTransparentDataEncryption: + """Updates a database's transparent data encryption configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 tde_name: The name of the transparent data encryption configuration. "current" Required. + :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName + :param parameters: The database transparent data encryption. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedTransparentDataEncryption. The ManagedTransparentDataEncryption is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedTransparentDataEncryption + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + tde_name: Union[str, _models.TransparentDataEncryptionName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedTransparentDataEncryption: + """Updates a database's transparent data encryption configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 tde_name: The name of the transparent data encryption configuration. "current" Required. + :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName + :param parameters: The database transparent data encryption. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ManagedTransparentDataEncryption. The ManagedTransparentDataEncryption is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedTransparentDataEncryption + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + tde_name: Union[str, _models.TransparentDataEncryptionName], + parameters: Union[_models.ManagedTransparentDataEncryption, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ManagedTransparentDataEncryption: + """Updates a database's transparent data encryption configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 tde_name: The name of the transparent data encryption configuration. "current" Required. + :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName + :param parameters: The database transparent data encryption. Is one of the following types: + ManagedTransparentDataEncryption, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedTransparentDataEncryption or JSON or IO[bytes] + :return: ManagedTransparentDataEncryption. The ManagedTransparentDataEncryption is compatible + with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedTransparentDataEncryption + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_database_transparent_data_encryption_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + tde_name=tde_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = 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]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedTransparentDataEncryption, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_database( + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> ItemPaged["_models.ManagedTransparentDataEncryption"]: + """Gets a list of managed database's transparent data encryptions. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An iterator like instance of ManagedTransparentDataEncryption + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedTransparentDataEncryption] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedTransparentDataEncryption]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_database_transparent_data_encryption_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedTransparentDataEncryption], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ManagedInstanceAdvancedThreatProtectionSettingsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_instance_advanced_threat_protection_settings` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + managed_instance_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + **kwargs: Any + ) -> _models.ManagedInstanceAdvancedThreatProtection: + """Get a managed instance's Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :return: ManagedInstanceAdvancedThreatProtection. The ManagedInstanceAdvancedThreatProtection + is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedInstanceAdvancedThreatProtection] = kwargs.pop("cls", None) + + _request = build_managed_instance_advanced_threat_protection_settings_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + advanced_threat_protection_name=advanced_threat_protection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedInstanceAdvancedThreatProtection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: Union[_models.ManagedInstanceAdvancedThreatProtection, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_instance_advanced_threat_protection_settings_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + advanced_threat_protection_name=advanced_threat_protection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: _models.ManagedInstanceAdvancedThreatProtection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedInstanceAdvancedThreatProtection]: + """Creates or updates Advanced Threat Protection settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The managed instance Advanced Threat Protection state. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedInstanceAdvancedThreatProtection. The + ManagedInstanceAdvancedThreatProtection is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedInstanceAdvancedThreatProtection]: + """Creates or updates Advanced Threat Protection settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The managed instance Advanced Threat Protection state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedInstanceAdvancedThreatProtection. The + ManagedInstanceAdvancedThreatProtection is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedInstanceAdvancedThreatProtection]: + """Creates or updates Advanced Threat Protection settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The managed instance Advanced Threat Protection state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedInstanceAdvancedThreatProtection. The + ManagedInstanceAdvancedThreatProtection is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: Union[_models.ManagedInstanceAdvancedThreatProtection, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ManagedInstanceAdvancedThreatProtection]: + """Creates or updates Advanced Threat Protection settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The managed instance Advanced Threat Protection state. Is one of the + following types: ManagedInstanceAdvancedThreatProtection, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection or JSON or + IO[bytes] + :return: An instance of LROPoller that returns ManagedInstanceAdvancedThreatProtection. The + ManagedInstanceAdvancedThreatProtection is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + advanced_threat_protection_name=advanced_threat_protection_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedInstanceAdvancedThreatProtection, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ManagedInstanceAdvancedThreatProtection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ManagedInstanceAdvancedThreatProtection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> ItemPaged["_models.ManagedInstanceAdvancedThreatProtection"]: + """Get the managed instance's Advanced Threat Protection settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of ManagedInstanceAdvancedThreatProtection + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceAdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstanceAdvancedThreatProtection]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_instance_advanced_threat_protection_settings_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstanceAdvancedThreatProtection], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ManagedInstancePrivateLinkResourcesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_instance_private_link_resources` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, managed_instance_name: str, group_name: str, **kwargs: Any + ) -> _models.ManagedInstancePrivateLink: + """Gets a private link resource for SQL server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param group_name: The name of the private link resource. Required. + :type group_name: str + :return: ManagedInstancePrivateLink. The ManagedInstancePrivateLink is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedInstancePrivateLink + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedInstancePrivateLink] = kwargs.pop("cls", None) + + _request = build_managed_instance_private_link_resources_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + group_name=group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedInstancePrivateLink, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_managed_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> ItemPaged["_models.ManagedInstancePrivateLink"]: + """Gets the private link resources for SQL server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: An iterator like instance of ManagedInstancePrivateLink + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstancePrivateLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedInstancePrivateLink]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_instance_private_link_resources_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedInstancePrivateLink], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ManagedLedgerDigestUploadsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`managed_ledger_digest_uploads` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], + **kwargs: Any + ) -> _models.ManagedLedgerDigestUploads: + """Gets the current ledger digest upload configuration for a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ledger_digest_uploads: "current" Required. + :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.ManagedLedgerDigestUploadsName + :return: ManagedLedgerDigestUploads. The ManagedLedgerDigestUploads is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.ManagedLedgerDigestUploads + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedLedgerDigestUploads] = kwargs.pop("cls", None) + + _request = build_managed_ledger_digest_uploads_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + ledger_digest_uploads=ledger_digest_uploads, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedLedgerDigestUploads, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], + parameters: Union[_models.ManagedLedgerDigestUploads, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_ledger_digest_uploads_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + ledger_digest_uploads=ledger_digest_uploads, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], + parameters: _models.ManagedLedgerDigestUploads, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedLedgerDigestUploads]: + """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ledger_digest_uploads: "current" Required. + :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.ManagedLedgerDigestUploadsName + :param parameters: The Ledger Digest Storage Endpoint. Required. + :type parameters: ~azure.mgmt.sql.models.ManagedLedgerDigestUploads + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedLedgerDigestUploads. The + ManagedLedgerDigestUploads is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedLedgerDigestUploads] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedLedgerDigestUploads]: + """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ledger_digest_uploads: "current" Required. + :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.ManagedLedgerDigestUploadsName + :param parameters: The Ledger Digest Storage Endpoint. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedLedgerDigestUploads. The + ManagedLedgerDigestUploads is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedLedgerDigestUploads] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedLedgerDigestUploads]: + """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ledger_digest_uploads: "current" Required. + :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.ManagedLedgerDigestUploadsName + :param parameters: The Ledger Digest Storage Endpoint. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedLedgerDigestUploads. The + ManagedLedgerDigestUploads is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedLedgerDigestUploads] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], + parameters: Union[_models.ManagedLedgerDigestUploads, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ManagedLedgerDigestUploads]: + """Enables upload ledger digests to an Azure Storage account or an Azure Confidential Ledger + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ledger_digest_uploads: "current" Required. + :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.ManagedLedgerDigestUploadsName + :param parameters: The Ledger Digest Storage Endpoint. Is one of the following types: + ManagedLedgerDigestUploads, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ManagedLedgerDigestUploads or JSON or IO[bytes] + :return: An instance of LROPoller that returns ManagedLedgerDigestUploads. The + ManagedLedgerDigestUploads is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedLedgerDigestUploads] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + managed_instance_name=managed_instance_name, + database_name=database_name, + ledger_digest_uploads=ledger_digest_uploads, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedLedgerDigestUploads, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ManagedLedgerDigestUploads].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ManagedLedgerDigestUploads]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_database( + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> ItemPaged["_models.ManagedLedgerDigestUploads"]: + """Gets all ledger digest upload settings on a database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 + :return: An iterator like instance of ManagedLedgerDigestUploads + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedLedgerDigestUploads] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedLedgerDigestUploads]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_ledger_digest_uploads_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedLedgerDigestUploads], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _disable_initial( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_managed_ledger_digest_uploads_disable_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + ledger_digest_uploads=ledger_digest_uploads, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_disable( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.ManagedLedgerDigestUploadsName], + **kwargs: Any + ) -> LROPoller[_models.ManagedLedgerDigestUploads]: + """Disables uploading ledger digests to an Azure Storage account or an Azure Confidential Ledger + instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 ledger_digest_uploads: "current" Required. + :type ledger_digest_uploads: str or ~azure.mgmt.sql.models.ManagedLedgerDigestUploadsName + :return: An instance of LROPoller that returns ManagedLedgerDigestUploads. The + ManagedLedgerDigestUploads is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedLedgerDigestUploads] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._disable_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + ledger_digest_uploads=ledger_digest_uploads, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ManagedLedgerDigestUploads, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ManagedLedgerDigestUploads].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ManagedLedgerDigestUploads]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class ServerAdvancedThreatProtectionSettingsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`server_advanced_threat_protection_settings` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + server_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + **kwargs: Any + ) -> _models.ServerAdvancedThreatProtection: + """Get a server's Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :return: ServerAdvancedThreatProtection. The ServerAdvancedThreatProtection is compatible with + MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerAdvancedThreatProtection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ServerAdvancedThreatProtection] = kwargs.pop("cls", None) + + _request = build_server_advanced_threat_protection_settings_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + advanced_threat_protection_name=advanced_threat_protection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ServerAdvancedThreatProtection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: Union[_models.ServerAdvancedThreatProtection, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_server_advanced_threat_protection_settings_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + advanced_threat_protection_name=advanced_threat_protection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: _models.ServerAdvancedThreatProtection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerAdvancedThreatProtection]: + """Creates or updates an Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The server Advanced Threat Protection state. Required. + :type parameters: ~azure.mgmt.sql.models.ServerAdvancedThreatProtection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerAdvancedThreatProtection. The + ServerAdvancedThreatProtection is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerAdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerAdvancedThreatProtection]: + """Creates or updates an Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The server Advanced Threat Protection state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerAdvancedThreatProtection. The + ServerAdvancedThreatProtection is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerAdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerAdvancedThreatProtection]: + """Creates or updates an Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The server Advanced Threat Protection state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ServerAdvancedThreatProtection. The + ServerAdvancedThreatProtection is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerAdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], + parameters: Union[_models.ServerAdvancedThreatProtection, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ServerAdvancedThreatProtection]: + """Creates or updates an Advanced Threat Protection state. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. + "Default" Required. + :type advanced_threat_protection_name: str or + ~azure.mgmt.sql.models.AdvancedThreatProtectionName + :param parameters: The server Advanced Threat Protection state. Is one of the following types: + ServerAdvancedThreatProtection, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ServerAdvancedThreatProtection or JSON or IO[bytes] + :return: An instance of LROPoller that returns ServerAdvancedThreatProtection. The + ServerAdvancedThreatProtection is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerAdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + advanced_threat_protection_name=advanced_threat_protection_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ServerAdvancedThreatProtection, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ServerAdvancedThreatProtection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ServerAdvancedThreatProtection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> ItemPaged["_models.ServerAdvancedThreatProtection"]: + """Get a list of the server's Advanced Threat Protection states. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: An iterator like instance of ServerAdvancedThreatProtection + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerAdvancedThreatProtection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ServerAdvancedThreatProtection]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_server_advanced_threat_protection_settings_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ServerAdvancedThreatProtection], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ServerAutomaticTuningOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`server_automatic_tuning` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, server_name: str, **kwargs: Any) -> _models.ServerAutomaticTuning: + """Retrieves server automatic tuning options. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :return: ServerAutomaticTuning. The ServerAutomaticTuning is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerAutomaticTuning + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ServerAutomaticTuning] = kwargs.pop("cls", None) + + _request = build_server_automatic_tuning_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ServerAutomaticTuning, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + server_name: str, + parameters: _models.ServerAutomaticTuning, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ServerAutomaticTuning: + """Update automatic tuning options on server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The requested automatic tuning resource state. Required. + :type parameters: ~azure.mgmt.sql.models.ServerAutomaticTuning + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ServerAutomaticTuning. The ServerAutomaticTuning is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerAutomaticTuning + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + server_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ServerAutomaticTuning: + """Update automatic tuning options on server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The requested automatic tuning resource state. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ServerAutomaticTuning. The ServerAutomaticTuning is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerAutomaticTuning + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + server_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ServerAutomaticTuning: + """Update automatic tuning options on server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The requested automatic tuning resource state. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ServerAutomaticTuning. The ServerAutomaticTuning is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerAutomaticTuning + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerAutomaticTuning, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ServerAutomaticTuning: + """Update automatic tuning options on server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param parameters: The requested automatic tuning resource state. Is one of the following + types: ServerAutomaticTuning, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.ServerAutomaticTuning or JSON or IO[bytes] + :return: ServerAutomaticTuning. The ServerAutomaticTuning is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.ServerAutomaticTuning + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_server_automatic_tuning_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ServerAutomaticTuning, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class SqlAgentOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`sql_agent` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, managed_instance_name: str, **kwargs: Any) -> _models.SqlAgentConfiguration: + """Gets current instance sql agent configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :return: SqlAgentConfiguration. The SqlAgentConfiguration is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SqlAgentConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SqlAgentConfiguration] = kwargs.pop("cls", None) + + _request = build_sql_agent_get_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SqlAgentConfiguration, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: _models.SqlAgentConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SqlAgentConfiguration: + """Puts new sql agent configuration to instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.sql.models.SqlAgentConfiguration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SqlAgentConfiguration. The SqlAgentConfiguration is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SqlAgentConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SqlAgentConfiguration: + """Puts new sql agent configuration to instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SqlAgentConfiguration. The SqlAgentConfiguration is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SqlAgentConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SqlAgentConfiguration: + """Puts new sql agent configuration to instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SqlAgentConfiguration. The SqlAgentConfiguration is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SqlAgentConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + managed_instance_name: str, + parameters: Union[_models.SqlAgentConfiguration, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.SqlAgentConfiguration: + """Puts new sql agent configuration to instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param parameters: Is one of the following types: SqlAgentConfiguration, JSON, IO[bytes] + Required. + :type parameters: ~azure.mgmt.sql.models.SqlAgentConfiguration or JSON or IO[bytes] + :return: SqlAgentConfiguration. The SqlAgentConfiguration is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.SqlAgentConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_sql_agent_create_or_update_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SqlAgentConfiguration, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class TransparentDataEncryptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`transparent_data_encryptions` attribute. """ - models = _models - def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") @@ -75,18 +92842,385 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_models.Operation"]: - """Lists all of the available SQL Rest API operations. + def get( + self, + resource_group_name: str, + server_name: str, + database_name: str, + tde_name: Union[str, _models.TransparentDataEncryptionName], + **kwargs: Any + ) -> _models.LogicalDatabaseTransparentDataEncryption: + """Gets a logical database's transparent data encryption. - :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.Operation] + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 tde_name: The name of the transparent data encryption configuration. "current" Required. + :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName + :return: LogicalDatabaseTransparentDataEncryption. The LogicalDatabaseTransparentDataEncryption + is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LogicalDatabaseTransparentDataEncryption] = kwargs.pop("cls", None) + + _request = build_transparent_data_encryptions_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + tde_name=tde_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.LogicalDatabaseTransparentDataEncryption, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + tde_name: Union[str, _models.TransparentDataEncryptionName], + parameters: Union[_models.LogicalDatabaseTransparentDataEncryption, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_transparent_data_encryptions_create_or_update_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + tde_name=tde_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + tde_name: Union[str, _models.TransparentDataEncryptionName], + parameters: _models.LogicalDatabaseTransparentDataEncryption, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LogicalDatabaseTransparentDataEncryption]: + """Updates a logical database's transparent data encryption configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 tde_name: The name of the transparent data encryption configuration. "current" Required. + :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName + :param parameters: The database transparent data encryption. Required. + :type parameters: ~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns LogicalDatabaseTransparentDataEncryption. The + LogicalDatabaseTransparentDataEncryption is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + tde_name: Union[str, _models.TransparentDataEncryptionName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LogicalDatabaseTransparentDataEncryption]: + """Updates a logical database's transparent data encryption configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 tde_name: The name of the transparent data encryption configuration. "current" Required. + :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName + :param parameters: The database transparent data encryption. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns LogicalDatabaseTransparentDataEncryption. The + LogicalDatabaseTransparentDataEncryption is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + tde_name: Union[str, _models.TransparentDataEncryptionName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LogicalDatabaseTransparentDataEncryption]: + """Updates a logical database's transparent data encryption configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 tde_name: The name of the transparent data encryption configuration. "current" Required. + :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName + :param parameters: The database transparent data encryption. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns LogicalDatabaseTransparentDataEncryption. The + LogicalDatabaseTransparentDataEncryption is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + tde_name: Union[str, _models.TransparentDataEncryptionName], + parameters: Union[_models.LogicalDatabaseTransparentDataEncryption, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.LogicalDatabaseTransparentDataEncryption]: + """Updates a logical database's transparent data encryption configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 tde_name: The name of the transparent data encryption configuration. "current" Required. + :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName + :param parameters: The database transparent data encryption. Is one of the following types: + LogicalDatabaseTransparentDataEncryption, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption or JSON or + IO[bytes] + :return: An instance of LROPoller that returns LogicalDatabaseTransparentDataEncryption. The + LogicalDatabaseTransparentDataEncryption is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + tde_name=tde_name, + parameters=parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.LogicalDatabaseTransparentDataEncryption, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.LogicalDatabaseTransparentDataEncryption].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.LogicalDatabaseTransparentDataEncryption]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> ItemPaged["_models.LogicalDatabaseTransparentDataEncryption"]: + """Gets a list of the logical database's transparent data encryption. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 + :return: An iterator like instance of LogicalDatabaseTransparentDataEncryption + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + cls: ClsType[List[_models.LogicalDatabaseTransparentDataEncryption]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -99,25 +93233,53 @@ def list(self, **kwargs: Any) -> ItemPaged["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - _request = build_list_request( - api_version=api_version, + _request = build_transparent_data_encryptions_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=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request def extract_data(pipeline_response): - deserialized = self._deserialize("OperationListResult", pipeline_response) - list_of_elem = deserialized.value + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.LogicalDatabaseTransparentDataEncryption], + deserialized.get("value", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) + return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -130,8 +93292,402 @@ def get_next(next_link=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) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) + + def _resume_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + tde_name: Union[str, _models.TransparentDataEncryptionName], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_transparent_data_encryptions_resume_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + tde_name=tde_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_resume( + self, + resource_group_name: str, + server_name: str, + database_name: str, + tde_name: Union[str, _models.TransparentDataEncryptionName], + **kwargs: Any + ) -> LROPoller[_models.LogicalDatabaseTransparentDataEncryption]: + """Resume ongoing logical database's Transparent Data Encryption scan configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 tde_name: The name of the transparent data encryption configuration. "current" Required. + :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName + :return: An instance of LROPoller that returns LogicalDatabaseTransparentDataEncryption. The + LogicalDatabaseTransparentDataEncryption is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LogicalDatabaseTransparentDataEncryption] = 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._resume_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + tde_name=tde_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.LogicalDatabaseTransparentDataEncryption, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.LogicalDatabaseTransparentDataEncryption].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.LogicalDatabaseTransparentDataEncryption]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _suspend_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + tde_name: Union[str, _models.TransparentDataEncryptionName], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_transparent_data_encryptions_suspend_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + tde_name=tde_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_suspend( + self, + resource_group_name: str, + server_name: str, + database_name: str, + tde_name: Union[str, _models.TransparentDataEncryptionName], + **kwargs: Any + ) -> LROPoller[_models.LogicalDatabaseTransparentDataEncryption]: + """Suspend ongoing logical database's Transparent Data Encryption scan configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_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 tde_name: The name of the transparent data encryption configuration. "current" Required. + :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName + :return: An instance of LROPoller that returns LogicalDatabaseTransparentDataEncryption. The + LogicalDatabaseTransparentDataEncryption is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LogicalDatabaseTransparentDataEncryption] = 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._suspend_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + tde_name=tde_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.LogicalDatabaseTransparentDataEncryption, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.LogicalDatabaseTransparentDataEncryption].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.LogicalDatabaseTransparentDataEncryption]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class CapabilitiesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`capabilities` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_location( + self, location_name: str, *, include: Optional[Union[str, _models.CapabilityGroup]] = None, **kwargs: Any + ) -> _models.LocationCapabilities: + """Gets the subscription capabilities available for the specified location. + + :param location_name: The location name whose capabilities are retrieved. Required. + :type location_name: str + :keyword include: If specified, restricts the response to only include the selected item. Known + values are: "supportedEditions", "supportedElasticPoolEditions", + "supportedManagedInstanceVersions", "supportedInstancePoolEditions", + "supportedManagedInstanceEditions", and "supportedJobAgentVersions". Default value is None. + :paramtype include: str or ~azure.mgmt.sql.models.CapabilityGroup + :return: LocationCapabilities. The LocationCapabilities is compatible with MutableMapping + :rtype: ~azure.mgmt.sql.models.LocationCapabilities + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LocationCapabilities] = kwargs.pop("cls", None) + + _request = build_capabilities_list_by_location_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + include=include, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.LocationCapabilities, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_outbound_firewall_rules_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_outbound_firewall_rules_operations.py deleted file mode 100644 index 4cd5d2664be7..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_outbound_firewall_rules_operations.py +++ /dev/null @@ -1,631 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, server_name: str, outbound_rule_fqdn: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/outboundFirewallRules/{outboundRuleFqdn}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "outboundRuleFqdn": _SERIALIZER.url("outbound_rule_fqdn", outbound_rule_fqdn, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, server_name: str, outbound_rule_fqdn: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - 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}/outboundFirewallRules/{outboundRuleFqdn}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "outboundRuleFqdn": _SERIALIZER.url("outbound_rule_fqdn", outbound_rule_fqdn, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, server_name: str, outbound_rule_fqdn: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/outboundFirewallRules/{outboundRuleFqdn}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "outboundRuleFqdn": _SERIALIZER.url("outbound_rule_fqdn", outbound_rule_fqdn, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/outboundFirewallRules", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class OutboundFirewallRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`outbound_firewall_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, resource_group_name: str, server_name: str, outbound_rule_fqdn: str, **kwargs: Any - ) -> _models.OutboundFirewallRule: - """Gets an outbound firewall rule. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 - :return: OutboundFirewallRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.OutboundFirewallRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[_models.OutboundFirewallRule] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - outbound_rule_fqdn=outbound_rule_fqdn, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("OutboundFirewallRule", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - outbound_rule_fqdn: str, - parameters: Union[_models.OutboundFirewallRule, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2021-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "OutboundFirewallRule") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - outbound_rule_fqdn=outbound_rule_fqdn, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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: Is either a OutboundFirewallRule type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.OutboundFirewallRule or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - 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) - 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, - 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, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OutboundFirewallRule", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.OutboundFirewallRule].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OutboundFirewallRule]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, server_name: str, outbound_rule_fqdn: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, server_name: str, outbound_rule_fqdn: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes a outbound firewall rule with a given name. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-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( - resource_group_name=resource_group_name, - server_name=server_name, - outbound_rule_fqdn=outbound_rule_fqdn, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either OutboundFirewallRule or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.OutboundFirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[_models.OutboundFirewallRuleListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_patch.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_patch.py index f7dd32510333..87676c65a8f0 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_patch.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_patch.py @@ -1,14 +1,15 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): 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 deleted file mode 100644 index 56667861da73..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,649 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_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", "2022-08-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", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - server_name: str, - private_endpoint_connection_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", private_endpoint_connection_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_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: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-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}/privateEndpointConnections/{privateEndpointConnectionName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", private_endpoint_connection_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - server_name: str, - private_endpoint_connection_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", private_endpoint_connection_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -class PrivateEndpointConnectionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`private_endpoint_connections` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_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 - :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", "2022-08-01-preview")) - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace - def get( - self, resource_group_name: str, server_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Gets a private endpoint connection. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("PrivateEndpointConnection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "PrivateEndpointConnection") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - private_endpoint_connection_name: str, - parameters: _models.PrivateEndpointConnection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param private_endpoint_connection_name: Required. - :type private_endpoint_connection_name: str - :param parameters: Required. - :type parameters: ~azure.mgmt.sql.models.PrivateEndpointConnection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - private_endpoint_connection_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param private_endpoint_connection_name: Required. - :type private_endpoint_connection_name: str - :param parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - """Approve or reject a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param private_endpoint_connection_name: Required. - :type private_endpoint_connection_name: str - :param parameters: Is either a PrivateEndpointConnection type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.PrivateEndpointConnection or IO[bytes] - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - 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) - 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, - private_endpoint_connection_name=private_endpoint_connection_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, server_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, server_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes a private endpoint connection with a given name. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param private_endpoint_connection_name: Required. - :type private_endpoint_connection_name: str - :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", "2022-08-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( - resource_group_name=resource_group_name, - server_name=server_name, - private_endpoint_connection_name=private_endpoint_connection_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index 3485f279557d..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_private_link_resources_operations.py +++ /dev/null @@ -1,252 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_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", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateLinkResources", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, server_name: str, group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateLinkResources/{groupName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "groupName": _SERIALIZER.url("group_name", group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class PrivateLinkResourcesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`private_link_resources` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.PrivateLinkResource"]: - """Gets the private link resources for SQL 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 - :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.PrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, server_name: str, group_name: str, **kwargs: Any - ) -> _models.PrivateLinkResource: - """Gets a private link resource for SQL server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param group_name: The name of the private link resource. Required. - :type group_name: str - :return: PrivateLinkResource or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.PrivateLinkResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - group_name=group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("PrivateLinkResource", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_recommended_sensitivity_labels_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_recommended_sensitivity_labels_operations.py deleted file mode 100644 index ff07136bc5fc..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_recommended_sensitivity_labels_operations.py +++ /dev/null @@ -1,225 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_update_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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/servers/{serverName}/databases/{databaseName}/recommendedSensitivityLabels", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -class RecommendedSensitivityLabelsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`recommended_sensitivity_labels` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: _models.RecommendedSensitivityLabelUpdateList, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Update recommended sensitivity labels states of a given database using an operations batch. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: Required. - :type parameters: ~azure.mgmt.sql.models.RecommendedSensitivityLabelUpdateList - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Update recommended sensitivity labels states of a given database using an operations batch. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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, - server_name: str, - database_name: str, - parameters: Union[_models.RecommendedSensitivityLabelUpdateList, IO[bytes]], - **kwargs: Any - ) -> None: - """Update recommended sensitivity labels states of a given database using an operations batch. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: Is either a RecommendedSensitivityLabelUpdateList type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.sql.models.RecommendedSensitivityLabelUpdateList or IO[bytes] - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, "RecommendedSensitivityLabelUpdateList") - - _request = build_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_recoverable_databases_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_recoverable_databases_operations.py deleted file mode 100644 index 8000fb2fa9ae..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_recoverable_databases_operations.py +++ /dev/null @@ -1,276 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_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", "2022-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/recoverableDatabases", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - server_name: str, - database_name: str, - subscription_id: str, - *, - expand: Optional[str] = None, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/recoverableDatabases/{databaseName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - 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 RecoverableDatabasesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`recoverable_databases` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.RecoverableDatabase"]: - """Gets a list of recoverable databases. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either RecoverableDatabase or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.RecoverableDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.RecoverableDatabaseListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RecoverableDatabaseListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - database_name: str, - expand: Optional[str] = None, - filter: Optional[str] = None, - **kwargs: Any - ) -> _models.RecoverableDatabase: - """Gets a recoverable 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 expand: The child resources to include in the response. Default value is None. - :type expand: str - :param filter: An OData filter expression that filters elements in the collection. Default - value is None. - :type filter: str - :return: RecoverableDatabase or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.RecoverableDatabase - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - cls: ClsType[_models.RecoverableDatabase] = 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, - expand=expand, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("RecoverableDatabase", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index e20c6aa82edf..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_recoverable_managed_databases_operations.py +++ /dev/null @@ -1,257 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_instance_request( - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/recoverableDatabases", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - managed_instance_name: str, - recoverable_database_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/recoverableDatabases/{recoverableDatabaseName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "recoverableDatabaseName": _SERIALIZER.url("recoverable_database_name", recoverable_database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class RecoverableManagedDatabasesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`recoverable_managed_databases` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.RecoverableManagedDatabase"]: - """Gets a list of recoverable managed databases. - - :param resource_group_name: The name of the resource group that 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 - :return: An iterator like instance of either RecoverableManagedDatabase or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.RecoverableManagedDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.RecoverableManagedDatabaseListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RecoverableManagedDatabaseListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, managed_instance_name: str, recoverable_database_name: str, **kwargs: Any - ) -> _models.RecoverableManagedDatabase: - """Gets a recoverable managed database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 recoverable_database_name: Required. - :type recoverable_database_name: str - :return: RecoverableManagedDatabase or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.RecoverableManagedDatabase - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.RecoverableManagedDatabase] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - recoverable_database_name=recoverable_database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("RecoverableManagedDatabase", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_replication_links_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_replication_links_operations.py deleted file mode 100644 index 71bb3228923b..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_replication_links_operations.py +++ /dev/null @@ -1,1314 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_database_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, server_name: str, database_name: str, link_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "linkId": _SERIALIZER.url("link_id", link_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, server_name: str, database_name: str, link_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "linkId": _SERIALIZER.url("link_id", link_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, server_name: str, database_name: str, link_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "linkId": _SERIALIZER.url("link_id", link_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_update_request( - resource_group_name: str, server_name: str, database_name: str, link_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "linkId": _SERIALIZER.url("link_id", link_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_failover_request( - resource_group_name: str, server_name: str, database_name: str, link_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/failover", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "linkId": _SERIALIZER.url("link_id", link_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_failover_allow_data_loss_request( - resource_group_name: str, server_name: str, database_name: str, link_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/forceFailoverAllowDataLoss", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "linkId": _SERIALIZER.url("link_id", link_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/replicationLinks", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ReplicationLinksOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`replication_links` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.ReplicationLink"]: - """Gets a list of replication links on 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 - :return: An iterator like instance of either ReplicationLink or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ReplicationLink] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - cls: ClsType[_models.ReplicationLinkListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ReplicationLinkListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, server_name: str, database_name: str, link_id: str, **kwargs: Any - ) -> _models.ReplicationLink: - """Gets a replication link. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 link_id: The name of the replication link. Required. - :type link_id: str - :return: ReplicationLink or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ReplicationLink - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[_models.ReplicationLink] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - link_id=link_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ReplicationLink", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - link_id: str, - parameters: Union[_models.ReplicationLink, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ReplicationLink") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - link_id=link_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - link_id: str, - parameters: _models.ReplicationLink, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ReplicationLink]: - """Updates the replication link type. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 link_id: Required. - :type link_id: str - :param parameters: Required. - :type parameters: ~azure.mgmt.sql.models.ReplicationLink - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ReplicationLink or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ReplicationLink] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - link_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ReplicationLink]: - """Updates the replication link type. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 link_id: Required. - :type link_id: str - :param parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ReplicationLink or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ReplicationLink] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - link_id: str, - parameters: Union[_models.ReplicationLink, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ReplicationLink]: - """Updates the replication link type. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 link_id: Required. - :type link_id: str - :param parameters: Is either a ReplicationLink type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ReplicationLink or IO[bytes] - :return: An instance of LROPoller that returns either ReplicationLink or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ReplicationLink] - :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", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - 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) - 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, - link_id=link_id, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ReplicationLink", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ReplicationLink].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ReplicationLink]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, server_name: str, database_name: str, link_id: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - link_id=link_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, server_name: str, database_name: str, link_id: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes the replication 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 database_name: The name of the database. Required. - :type database_name: str - :param link_id: Required. - :type link_id: str - :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", "2023-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_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - link_id=link_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - link_id: str, - parameters: Union[_models.ReplicationLinkUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ReplicationLinkUpdate") - - _request = build_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - link_id=link_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - link_id: str, - parameters: _models.ReplicationLinkUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ReplicationLink]: - """Updates the replication link type. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 link_id: Required. - :type link_id: str - :param parameters: Required. - :type parameters: ~azure.mgmt.sql.models.ReplicationLinkUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ReplicationLink or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ReplicationLink] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - link_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ReplicationLink]: - """Updates the replication link type. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 link_id: Required. - :type link_id: str - :param parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ReplicationLink or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ReplicationLink] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - link_id: str, - parameters: Union[_models.ReplicationLinkUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ReplicationLink]: - """Updates the replication link type. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 link_id: Required. - :type link_id: str - :param parameters: Is either a ReplicationLinkUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ReplicationLinkUpdate or IO[bytes] - :return: An instance of LROPoller that returns either ReplicationLink or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ReplicationLink] - :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", "2023-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - 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) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - link_id=link_id, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ReplicationLink", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ReplicationLink].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ReplicationLink]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _failover_initial( - self, resource_group_name: str, server_name: str, database_name: str, link_id: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_failover_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - link_id=link_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_failover( - self, resource_group_name: str, server_name: str, database_name: str, link_id: str, **kwargs: Any - ) -> LROPoller[_models.ReplicationLink]: - """Fails over from the current primary server to this server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 link_id: The name of the replication link. Required. - :type link_id: str - :return: An instance of LROPoller that returns either ReplicationLink or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ReplicationLink] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - 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) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._failover_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - link_id=link_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ReplicationLink", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ReplicationLink].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ReplicationLink]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _failover_allow_data_loss_initial( - self, resource_group_name: str, server_name: str, database_name: str, link_id: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2023-05-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_failover_allow_data_loss_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - link_id=link_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_failover_allow_data_loss( - self, resource_group_name: str, server_name: str, database_name: str, link_id: str, **kwargs: Any - ) -> LROPoller[_models.ReplicationLink]: - """Fails over from the current primary server to this server allowing 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 database_name: The name of the database. Required. - :type database_name: str - :param link_id: The name of the replication link. Required. - :type link_id: str - :return: An instance of LROPoller that returns either ReplicationLink or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ReplicationLink] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - 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) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._failover_allow_data_loss_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - link_id=link_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ReplicationLink", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ReplicationLink].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ReplicationLink]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> ItemPaged["_models.ReplicationLink"]: - """Gets a list of replication 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 - :return: An iterator like instance of either ReplicationLink or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ReplicationLink] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) - cls: ClsType[_models.ReplicationLinkListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ReplicationLinkListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_restorable_dropped_databases_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_restorable_dropped_databases_operations.py deleted file mode 100644 index 4db32238d2ff..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_restorable_dropped_databases_operations.py +++ /dev/null @@ -1,279 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_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", "2022-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/restorableDroppedDatabases", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - server_name: str, - restorable_dropped_database_id: str, - subscription_id: str, - *, - expand: Optional[str] = None, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "restorableDroppedDatabaseId": _SERIALIZER.url( - "restorable_dropped_database_id", restorable_dropped_database_id, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - 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 RestorableDroppedDatabasesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`restorable_dropped_databases` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.RestorableDroppedDatabase"]: - """Gets a list of restorable dropped databases. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either RestorableDroppedDatabase or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.RestorableDroppedDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.RestorableDroppedDatabaseListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RestorableDroppedDatabaseListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - restorable_dropped_database_id: str, - expand: Optional[str] = None, - filter: Optional[str] = None, - **kwargs: Any - ) -> _models.RestorableDroppedDatabase: - """Gets a restorable dropped database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param restorable_dropped_database_id: Required. - :type restorable_dropped_database_id: str - :param expand: The child resources to include in the response. Default value is None. - :type expand: str - :param filter: An OData filter expression that filters elements in the collection. Default - value is None. - :type filter: str - :return: RestorableDroppedDatabase or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.RestorableDroppedDatabase - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - cls: ClsType[_models.RestorableDroppedDatabase] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - restorable_dropped_database_id=restorable_dropped_database_id, - subscription_id=self._config.subscription_id, - expand=expand, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("RestorableDroppedDatabase", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_restorable_dropped_managed_databases_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_restorable_dropped_managed_databases_operations.py deleted file mode 100644 index cd62590c7e27..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_restorable_dropped_managed_databases_operations.py +++ /dev/null @@ -1,259 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_instance_request( - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - managed_instance_name: str, - restorable_dropped_database_id: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "restorableDroppedDatabaseId": _SERIALIZER.url( - "restorable_dropped_database_id", restorable_dropped_database_id, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class RestorableDroppedManagedDatabasesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`restorable_dropped_managed_databases` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.RestorableDroppedManagedDatabase"]: - """Gets a list of restorable dropped managed databases. - - :param resource_group_name: The name of the resource group that 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 - :return: An iterator like instance of either RestorableDroppedManagedDatabase or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.RestorableDroppedManagedDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.RestorableDroppedManagedDatabaseListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RestorableDroppedManagedDatabaseListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, managed_instance_name: str, restorable_dropped_database_id: str, **kwargs: Any - ) -> _models.RestorableDroppedManagedDatabase: - """Gets a restorable dropped managed database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :return: RestorableDroppedManagedDatabase or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.RestorableDroppedManagedDatabase - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.RestorableDroppedManagedDatabase] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - restorable_dropped_database_id=restorable_dropped_database_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("RestorableDroppedManagedDatabase", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_restore_points_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_restore_points_operations.py deleted file mode 100644 index a23e884c3fb8..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_restore_points_operations.py +++ /dev/null @@ -1,600 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_database_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/restorePoints", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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}/restorePoints", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - server_name: str, - database_name: str, - restore_point_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/restorePoints/{restorePointName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "restorePointName": _SERIALIZER.url("restore_point_name", restore_point_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - server_name: str, - database_name: str, - restore_point_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/restorePoints/{restorePointName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "restorePointName": _SERIALIZER.url("restore_point_name", restore_point_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -class RestorePointsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`restore_points` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.RestorePoint"]: - """Gets a list of database restore points. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :return: An iterator like instance of either RestorePoint or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.RestorePoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.RestorePointListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RestorePointListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _create_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.CreateDatabaseRestorePointDefinition, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "CreateDatabaseRestorePointDefinition") - - _request = build_create_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: _models.CreateDatabaseRestorePointDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.RestorePoint]: - """Creates a restore point for a data warehouse. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The definition for creating the restore point of this database. Required. - :type parameters: ~azure.mgmt.sql.models.CreateDatabaseRestorePointDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either RestorePoint or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.RestorePoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.RestorePoint]: - """Creates a restore point for a data warehouse. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The definition for creating the restore point of this database. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either RestorePoint or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.RestorePoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: Union[_models.CreateDatabaseRestorePointDefinition, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.RestorePoint]: - """Creates a restore point for a data warehouse. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 parameters: The definition for creating the restore point of this database. Is either a - CreateDatabaseRestorePointDefinition type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.CreateDatabaseRestorePointDefinition or IO[bytes] - :return: An instance of LROPoller that returns either RestorePoint or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.RestorePoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RestorePoint] = 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( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("RestorePoint", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.RestorePoint].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.RestorePoint]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def get( - self, resource_group_name: str, server_name: str, database_name: str, restore_point_name: str, **kwargs: Any - ) -> _models.RestorePoint: - """Gets a restore point. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 restore_point_name: The name of the restore point. Required. - :type restore_point_name: str - :return: RestorePoint or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.RestorePoint - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.RestorePoint] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - restore_point_name=restore_point_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("RestorePoint", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, server_name: str, database_name: str, restore_point_name: str, **kwargs: Any - ) -> None: - """Deletes a restore point. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 restore_point_name: The name of the restore point. Required. - :type restore_point_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - restore_point_name=restore_point_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sensitivity_labels_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sensitivity_labels_operations.py deleted file mode 100644 index 097d779b1047..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sensitivity_labels_operations.py +++ /dev/null @@ -1,1185 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Literal, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_current_by_database_request( - resource_group_name: str, - server_name: str, - database_name: str, - subscription_id: str, - *, - skip_token: Optional[str] = None, - count: Optional[bool] = None, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/currentSensitivityLabels", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if skip_token is not None: - _params["$skipToken"] = _SERIALIZER.query("skip_token", skip_token, "str") - if count is not None: - _params["$count"] = _SERIALIZER.query("count", count, "bool") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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/servers/{serverName}/databases/{databaseName}/currentSensitivityLabels", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_recommended_by_database_request( # pylint: disable=name-too-long - resource_group_name: str, - server_name: str, - database_name: str, - subscription_id: str, - *, - skip_token: Optional[str] = None, - include_disabled_recommendations: Optional[bool] = None, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/recommendedSensitivityLabels", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if skip_token is not None: - _params["$skipToken"] = _SERIALIZER.query("skip_token", skip_token, "str") - if include_disabled_recommendations is not None: - _params["includeDisabledRecommendations"] = _SERIALIZER.query( - "include_disabled_recommendations", include_disabled_recommendations, "bool" - ) - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_enable_recommendation_request( - resource_group_name: str, - server_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/enable", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), - "tableName": _SERIALIZER.url("table_name", table_name, "str"), - "columnName": _SERIALIZER.url("column_name", column_name, "str"), - "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_disable_recommendation_request( - resource_group_name: str, - server_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/disable", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), - "tableName": _SERIALIZER.url("table_name", table_name, "str"), - "columnName": _SERIALIZER.url("column_name", column_name, "str"), - "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_get_request( - resource_group_name: str, - server_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - sensitivity_label_source: Union[str, _models.SensitivityLabelSource], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), - "tableName": _SERIALIZER.url("table_name", table_name, "str"), - "columnName": _SERIALIZER.url("column_name", column_name, "str"), - "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - server_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), - "tableName": _SERIALIZER.url("table_name", table_name, "str"), - "columnName": _SERIALIZER.url("column_name", column_name, "str"), - "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - server_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), - "tableName": _SERIALIZER.url("table_name", table_name, "str"), - "columnName": _SERIALIZER.url("column_name", column_name, "str"), - "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -class SensitivityLabelsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`sensitivity_labels` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_current_by_database( - self, - resource_group_name: str, - server_name: str, - database_name: str, - skip_token: Optional[str] = None, - count: Optional[bool] = None, - filter: Optional[str] = None, - **kwargs: Any - ) -> ItemPaged["_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 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 - :return: An iterator like instance of either SensitivityLabel or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SensitivityLabel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SensitivityLabelListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - skip_token=skip_token, - count=count, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @overload - def update( - self, - resource_group_name: str, - server_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 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 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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - parameters: IO[bytes], - *, - 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 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 parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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, - server_name: str, - database_name: str, - parameters: Union[_models.SensitivityLabelUpdateList, IO[bytes]], - **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 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 parameters: Is either a SensitivityLabelUpdateList type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.SensitivityLabelUpdateList or IO[bytes] - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @distributed_trace - def list_recommended_by_database( - self, - resource_group_name: str, - server_name: str, - database_name: str, - skip_token: Optional[str] = None, - include_disabled_recommendations: Optional[bool] = None, - filter: Optional[str] = None, - **kwargs: Any - ) -> ItemPaged["_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 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 - :return: An iterator like instance of either SensitivityLabel or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SensitivityLabel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SensitivityLabelListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - skip_token=skip_token, - include_disabled_recommendations=include_disabled_recommendations, - filter=filter, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace - 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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_enable_recommendation_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - schema_name=schema_name, - table_name=table_name, - column_name=column_name, - subscription_id=self._config.subscription_id, - sensitivity_label_source=sensitivity_label_source, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @distributed_trace - 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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_disable_recommendation_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - schema_name=schema_name, - table_name=table_name, - column_name=column_name, - subscription_id=self._config.subscription_id, - sensitivity_label_source=sensitivity_label_source, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - sensitivity_label_source: Union[str, _models.SensitivityLabelSource], - **kwargs: Any - ) -> _models.SensitivityLabel: - """Gets the sensitivity label of a given column. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :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 - :return: SensitivityLabel or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SensitivityLabel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SensitivityLabel] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - schema_name=schema_name, - table_name=table_name, - column_name=column_name, - sensitivity_label_source=sensitivity_label_source, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - parameters: _models.SensitivityLabel, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SensitivityLabel: - """Creates or updates the sensitivity label of a given column. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :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 - :return: SensitivityLabel or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SensitivityLabel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SensitivityLabel: - """Creates or updates the sensitivity label of a given column. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :param parameters: The column sensitivity label resource. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: SensitivityLabel or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SensitivityLabel - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - parameters: Union[_models.SensitivityLabel, IO[bytes]], - **kwargs: Any - ) -> _models.SensitivityLabel: - """Creates or updates the sensitivity label of a given column. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :param parameters: The column sensitivity label resource. Is either a SensitivityLabel type or - a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.SensitivityLabel or IO[bytes] - :return: SensitivityLabel or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SensitivityLabel - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 {}) - - sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SensitivityLabel] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SensitivityLabel") - - _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, - headers=_headers, - params=_params, - ) - _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) - - deserialized = self._deserialize("SensitivityLabel", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # 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: - """Deletes the sensitivity label of a given column. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param 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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - 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, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore 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 deleted file mode 100644 index 1bfece501969..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_advanced_threat_protection_settings_operations.py +++ /dev/null @@ -1,521 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_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", "2021-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advancedThreatProtectionSettings", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - server_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "advancedThreatProtectionName": _SERIALIZER.url( - "advanced_threat_protection_name", advanced_threat_protection_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - server_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-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}/advancedThreatProtectionSettings/{advancedThreatProtectionName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "advancedThreatProtectionName": _SERIALIZER.url( - "advanced_threat_protection_name", advanced_threat_protection_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -class ServerAdvancedThreatProtectionSettingsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`server_advanced_threat_protection_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.ServerAdvancedThreatProtection"]: - """Get a list of the server's Advanced Threat Protection states. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either ServerAdvancedThreatProtection or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerAdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.LogicalServerAdvancedThreatProtectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("LogicalServerAdvancedThreatProtectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - **kwargs: Any - ) -> _models.ServerAdvancedThreatProtection: - """Get a server's Advanced Threat Protection state. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. - "Default" Required. - :type advanced_threat_protection_name: str or - ~azure.mgmt.sql.models.AdvancedThreatProtectionName - :return: ServerAdvancedThreatProtection or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerAdvancedThreatProtection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.ServerAdvancedThreatProtection] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - advanced_threat_protection_name=advanced_threat_protection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ServerAdvancedThreatProtection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: Union[_models.ServerAdvancedThreatProtection, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2021-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ServerAdvancedThreatProtection") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - advanced_threat_protection_name=advanced_threat_protection_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: _models.ServerAdvancedThreatProtection, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ServerAdvancedThreatProtection]: - """Creates or updates an Advanced Threat Protection state. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. - "Default" Required. - :type advanced_threat_protection_name: str or - ~azure.mgmt.sql.models.AdvancedThreatProtectionName - :param parameters: The server Advanced Threat Protection state. Required. - :type parameters: ~azure.mgmt.sql.models.ServerAdvancedThreatProtection - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ServerAdvancedThreatProtection or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerAdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ServerAdvancedThreatProtection]: - """Creates or updates an Advanced Threat Protection state. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. - "Default" Required. - :type advanced_threat_protection_name: str or - ~azure.mgmt.sql.models.AdvancedThreatProtectionName - :param parameters: The server Advanced Threat Protection state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ServerAdvancedThreatProtection or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerAdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - advanced_threat_protection_name: Union[str, _models.AdvancedThreatProtectionName], - parameters: Union[_models.ServerAdvancedThreatProtection, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ServerAdvancedThreatProtection]: - """Creates or updates an Advanced Threat Protection state. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param advanced_threat_protection_name: The name of the Advanced Threat Protection state. - "Default" Required. - :type advanced_threat_protection_name: str or - ~azure.mgmt.sql.models.AdvancedThreatProtectionName - :param parameters: The server Advanced Threat Protection state. Is either a - ServerAdvancedThreatProtection type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ServerAdvancedThreatProtection or IO[bytes] - :return: An instance of LROPoller that returns either ServerAdvancedThreatProtection or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerAdvancedThreatProtection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - 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) - 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, - advanced_threat_protection_name=advanced_threat_protection_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ServerAdvancedThreatProtection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ServerAdvancedThreatProtection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ServerAdvancedThreatProtection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_advisors_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_advisors_operations.py deleted file mode 100644 index e9d064b95198..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_advisors_operations.py +++ /dev/null @@ -1,415 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advisors", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "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_get_request( - resource_group_name: str, server_name: str, advisor_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advisors/{advisorName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "advisorName": _SERIALIZER.url("advisor_name", advisor_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, server_name: str, advisor_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advisors/{advisorName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "advisorName": _SERIALIZER.url("advisor_name", advisor_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -class ServerAdvisorsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`server_advisors` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, expand: Optional[str] = None, **kwargs: Any - ) -> List[_models.Advisor]: - """Gets a list of server advisors. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param expand: The child resources to include in the response. Default value is None. - :type expand: str - :return: list of Advisor or the result of cls(response) - :rtype: list[~azure.mgmt.sql.models.Advisor] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[List[_models.Advisor]] = 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, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("[Advisor]", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get(self, resource_group_name: str, server_name: str, advisor_name: str, **kwargs: Any) -> _models.Advisor: - """Gets a server advisor. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param advisor_name: The name of the Server Advisor. Required. - :type advisor_name: str - :return: Advisor or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.Advisor - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.Advisor] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - advisor_name=advisor_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("Advisor", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, - resource_group_name: str, - server_name: str, - advisor_name: str, - parameters: _models.Advisor, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Advisor: - """Updates a server advisor. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param advisor_name: The name of the Server Advisor. Required. - :type advisor_name: str - :param parameters: The requested advisor resource state. Required. - :type parameters: ~azure.mgmt.sql.models.Advisor - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Advisor or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.Advisor - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - server_name: str, - advisor_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Advisor: - """Updates a server advisor. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param advisor_name: The name of the Server Advisor. Required. - :type advisor_name: str - :param parameters: The requested advisor resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: Advisor or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.Advisor - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - server_name: str, - advisor_name: str, - parameters: Union[_models.Advisor, IO[bytes]], - **kwargs: Any - ) -> _models.Advisor: - """Updates a server advisor. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param advisor_name: The name of the Server Advisor. Required. - :type advisor_name: str - :param parameters: The requested advisor resource state. Is either a Advisor type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.Advisor or IO[bytes] - :return: Advisor or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.Advisor - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "Advisor") - - _request = build_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - advisor_name=advisor_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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("Advisor", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_automatic_tuning_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_automatic_tuning_operations.py deleted file mode 100644 index a75cb75f5412..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_automatic_tuning_operations.py +++ /dev/null @@ -1,305 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/automaticTuning/current", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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}/automaticTuning/current", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -class ServerAutomaticTuningOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`server_automatic_tuning` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get(self, resource_group_name: str, server_name: str, **kwargs: Any) -> _models.ServerAutomaticTuning: - """Retrieves server automatic tuning options. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: ServerAutomaticTuning or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerAutomaticTuning - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerAutomaticTuning] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ServerAutomaticTuning", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, - resource_group_name: str, - server_name: str, - parameters: _models.ServerAutomaticTuning, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ServerAutomaticTuning: - """Update automatic tuning options on server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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: The requested automatic tuning resource state. Required. - :type parameters: ~azure.mgmt.sql.models.ServerAutomaticTuning - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ServerAutomaticTuning or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerAutomaticTuning - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ServerAutomaticTuning: - """Update automatic tuning options on server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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: The requested automatic tuning resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ServerAutomaticTuning or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerAutomaticTuning - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerAutomaticTuning, IO[bytes]], - **kwargs: Any - ) -> _models.ServerAutomaticTuning: - """Update automatic tuning options on server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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: The requested automatic tuning resource state. Is either a - ServerAutomaticTuning type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ServerAutomaticTuning or IO[bytes] - :return: ServerAutomaticTuning or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerAutomaticTuning - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ServerAutomaticTuning") - - _request = build_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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("ServerAutomaticTuning", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_azure_ad_administrators_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_azure_ad_administrators_operations.py deleted file mode 100644 index f1b543e161fa..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_azure_ad_administrators_operations.py +++ /dev/null @@ -1,661 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - server_name: str, - administrator_name: Union[str, _models.AdministratorName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators/{administratorName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "administratorName": _SERIALIZER.url("administrator_name", administrator_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - server_name: str, - administrator_name: Union[str, _models.AdministratorName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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}/administrators/{administratorName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "administratorName": _SERIALIZER.url("administrator_name", administrator_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - server_name: str, - administrator_name: Union[str, _models.AdministratorName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators/{administratorName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "administratorName": _SERIALIZER.url("administrator_name", administrator_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ServerAzureADAdministratorsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`server_azure_ad_administrators` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - administrator_name: Union[str, _models.AdministratorName], - **kwargs: Any - ) -> _models.ServerAzureADAdministrator: - """Gets a Azure Active Directory administrator. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param administrator_name: The name of server active directory administrator. "ActiveDirectory" - Required. - :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName - :return: ServerAzureADAdministrator or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerAzureADAdministrator - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerAzureADAdministrator] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - administrator_name=administrator_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ServerAzureADAdministrator", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - administrator_name: Union[str, _models.AdministratorName], - parameters: Union[_models.ServerAzureADAdministrator, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ServerAzureADAdministrator") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - administrator_name=administrator_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - administrator_name: Union[str, _models.AdministratorName], - parameters: _models.ServerAzureADAdministrator, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ServerAzureADAdministrator]: - """Creates or updates an existing Azure Active Directory administrator. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param administrator_name: The name of server active directory administrator. "ActiveDirectory" - Required. - :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName - :param parameters: The requested Azure Active Directory administrator Resource state. Required. - :type parameters: ~azure.mgmt.sql.models.ServerAzureADAdministrator - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ServerAzureADAdministrator or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerAzureADAdministrator] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - administrator_name: Union[str, _models.AdministratorName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ServerAzureADAdministrator]: - """Creates or updates an existing Azure Active Directory administrator. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param administrator_name: The name of server active directory administrator. "ActiveDirectory" - Required. - :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName - :param parameters: The requested Azure Active Directory administrator Resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ServerAzureADAdministrator or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerAzureADAdministrator] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - administrator_name: Union[str, _models.AdministratorName], - parameters: Union[_models.ServerAzureADAdministrator, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ServerAzureADAdministrator]: - """Creates or updates an existing Azure Active Directory administrator. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param administrator_name: The name of server active directory administrator. "ActiveDirectory" - Required. - :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName - :param parameters: The requested Azure Active Directory administrator Resource state. Is either - a ServerAzureADAdministrator type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ServerAzureADAdministrator or IO[bytes] - :return: An instance of LROPoller that returns either ServerAzureADAdministrator or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerAzureADAdministrator] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ServerAzureADAdministrator] = 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, - administrator_name=administrator_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ServerAzureADAdministrator", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ServerAzureADAdministrator].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ServerAzureADAdministrator]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, - resource_group_name: str, - server_name: str, - administrator_name: Union[str, _models.AdministratorName], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - administrator_name=administrator_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, - resource_group_name: str, - server_name: str, - administrator_name: Union[str, _models.AdministratorName], - **kwargs: Any - ) -> LROPoller[None]: - """Deletes the Azure Active Directory administrator with the given name. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param administrator_name: The name of server active directory administrator. "ActiveDirectory" - Required. - :type administrator_name: str or ~azure.mgmt.sql.models.AdministratorName - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - administrator_name=administrator_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either ServerAzureADAdministrator or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerAzureADAdministrator] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.AdministratorListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index b9e72a7a1b00..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_azure_ad_only_authentications_operations.py +++ /dev/null @@ -1,667 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - server_name: str, - authentication_name: Union[str, _models.AuthenticationName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/azureADOnlyAuthentications/{authenticationName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "authenticationName": _SERIALIZER.url("authentication_name", authentication_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - server_name: str, - authentication_name: Union[str, _models.AuthenticationName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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}/azureADOnlyAuthentications/{authenticationName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "authenticationName": _SERIALIZER.url("authentication_name", authentication_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - server_name: str, - authentication_name: Union[str, _models.AuthenticationName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/azureADOnlyAuthentications/{authenticationName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "authenticationName": _SERIALIZER.url("authentication_name", authentication_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/azureADOnlyAuthentications", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ServerAzureADOnlyAuthenticationsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`server_azure_ad_only_authentications` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - authentication_name: Union[str, _models.AuthenticationName], - **kwargs: Any - ) -> _models.ServerAzureADOnlyAuthentication: - """Gets a specific Azure Active Directory only authentication property. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param authentication_name: The name of server azure active directory only authentication. - "Default" Required. - :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName - :return: ServerAzureADOnlyAuthentication or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerAzureADOnlyAuthentication] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - authentication_name=authentication_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ServerAzureADOnlyAuthentication", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - authentication_name: Union[str, _models.AuthenticationName], - parameters: Union[_models.ServerAzureADOnlyAuthentication, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ServerAzureADOnlyAuthentication") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - authentication_name=authentication_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - authentication_name: Union[str, _models.AuthenticationName], - parameters: _models.ServerAzureADOnlyAuthentication, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ServerAzureADOnlyAuthentication]: - """Sets Server Active Directory only authentication property or updates an existing server Active - Directory only authentication property. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param authentication_name: The name of server azure active directory only authentication. - "Default" Required. - :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName - :param parameters: The required parameters for creating or updating an Active Directory only - authentication property. Required. - :type parameters: ~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ServerAzureADOnlyAuthentication or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - authentication_name: Union[str, _models.AuthenticationName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ServerAzureADOnlyAuthentication]: - """Sets Server Active Directory only authentication property or updates an existing server Active - Directory only authentication property. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param authentication_name: The name of server azure active directory only authentication. - "Default" Required. - :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName - :param parameters: The required parameters for creating or updating an Active Directory only - authentication property. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ServerAzureADOnlyAuthentication or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - authentication_name: Union[str, _models.AuthenticationName], - parameters: Union[_models.ServerAzureADOnlyAuthentication, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ServerAzureADOnlyAuthentication]: - """Sets Server Active Directory only authentication property or updates an existing server Active - Directory only authentication property. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param authentication_name: The name of server azure active directory only authentication. - "Default" Required. - :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName - :param parameters: The required parameters for creating or updating an Active Directory only - authentication property. Is either a ServerAzureADOnlyAuthentication type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication or IO[bytes] - :return: An instance of LROPoller that returns either ServerAzureADOnlyAuthentication or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ServerAzureADOnlyAuthentication] = 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, - authentication_name=authentication_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ServerAzureADOnlyAuthentication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ServerAzureADOnlyAuthentication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ServerAzureADOnlyAuthentication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, - resource_group_name: str, - server_name: str, - authentication_name: Union[str, _models.AuthenticationName], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - authentication_name=authentication_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, - resource_group_name: str, - server_name: str, - authentication_name: Union[str, _models.AuthenticationName], - **kwargs: Any - ) -> LROPoller[None]: - """Deletes an existing server Active Directory only authentication property. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param authentication_name: The name of server azure active directory only authentication. - "Default" Required. - :type authentication_name: str or ~azure.mgmt.sql.models.AuthenticationName - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - authentication_name=authentication_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either ServerAzureADOnlyAuthentication or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.AzureADOnlyAuthListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index b53d7e033f47..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_blob_auditing_policies_operations.py +++ /dev/null @@ -1,486 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Literal, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_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", "2021-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/auditingSettings", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/auditingSettings/{blobAuditingPolicyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_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 {}) - - blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - 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}/auditingSettings/{blobAuditingPolicyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -class ServerBlobAuditingPoliciesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`server_blob_auditing_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.ServerBlobAuditingPolicy"]: - """Lists auditing settings of 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 - :return: An iterator like instance of either ServerBlobAuditingPolicy or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerBlobAuditingPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.ServerBlobAuditingPolicyListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ServerBlobAuditingPolicyListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, resource_group_name: str, server_name: str, **kwargs: Any) -> _models.ServerBlobAuditingPolicy: - """Gets a server's blob auditing policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: ServerBlobAuditingPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerBlobAuditingPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 {}) - - blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.ServerBlobAuditingPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - blob_auditing_policy_name=blob_auditing_policy_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ServerBlobAuditingPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerBlobAuditingPolicy, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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 {}) - - blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ServerBlobAuditingPolicy") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - blob_auditing_policy_name=blob_auditing_policy_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - parameters: _models.ServerBlobAuditingPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ServerBlobAuditingPolicy]: - """Creates or updates a server's blob auditing policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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: Properties of blob auditing policy. Required. - :type parameters: ~azure.mgmt.sql.models.ServerBlobAuditingPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ServerBlobAuditingPolicy or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerBlobAuditingPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ServerBlobAuditingPolicy]: - """Creates or updates a server's blob auditing policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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: Properties of blob auditing policy. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ServerBlobAuditingPolicy or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerBlobAuditingPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerBlobAuditingPolicy, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ServerBlobAuditingPolicy]: - """Creates or updates a server's blob auditing policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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: Properties of blob auditing policy. Is either a ServerBlobAuditingPolicy - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ServerBlobAuditingPolicy or IO[bytes] - :return: An instance of LROPoller that returns either ServerBlobAuditingPolicy or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerBlobAuditingPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - 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) - 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, - parameters=parameters, - blob_auditing_policy_name=blob_auditing_policy_name, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ServerBlobAuditingPolicy", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ServerBlobAuditingPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ServerBlobAuditingPolicy]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 b25c0a1efc1c..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_communication_links_operations.py +++ /dev/null @@ -1,579 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_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: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "communicationLinkName": _SERIALIZER.url("communication_link_name", communication_link_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_get_request( - resource_group_name: str, server_name: str, communication_link_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "communicationLinkName": _SERIALIZER.url("communication_link_name", communication_link_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_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: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "communicationLinkName": _SERIALIZER.url("communication_link_name", communication_link_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="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: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class 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) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - communication_link_name=communication_link_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @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 - :return: ServerCommunicationLink or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerCommunicationLink - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.ServerCommunicationLink] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - communication_link_name=communication_link_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - communication_link_name: str, - parameters: Union[_models.ServerCommunicationLink, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ServerCommunicationLink") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - communication_link_name=communication_link_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ServerCommunicationLink or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ServerCommunicationLink] = kwargs.pop("cls", None) - polling: Union[bool, 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ServerCommunicationLink", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ServerCommunicationLink].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ServerCommunicationLink]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either ServerCommunicationLink or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerCommunicationLink] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.ServerCommunicationLinkListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 3f1851940680..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_configuration_options_operations.py +++ /dev/null @@ -1,521 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_managed_instance_request( - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverConfigurationOptions", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - managed_instance_name: str, - server_configuration_option_name: Union[str, _models.ServerConfigurationOptionName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverConfigurationOptions/{serverConfigurationOptionName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "serverConfigurationOptionName": _SERIALIZER.url( - "server_configuration_option_name", server_configuration_option_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - managed_instance_name: str, - server_configuration_option_name: Union[str, _models.ServerConfigurationOptionName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-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}/serverConfigurationOptions/{serverConfigurationOptionName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "serverConfigurationOptionName": _SERIALIZER.url( - "server_configuration_option_name", server_configuration_option_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -class ServerConfigurationOptionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`server_configuration_options` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.ServerConfigurationOption"]: - """Gets a list of managed instance server configuration options. - - :param resource_group_name: The name of the resource group that 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 - :return: An iterator like instance of either ServerConfigurationOption or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerConfigurationOption] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.ServerConfigurationOptionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ServerConfigurationOptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - managed_instance_name: str, - server_configuration_option_name: Union[str, _models.ServerConfigurationOptionName], - **kwargs: Any - ) -> _models.ServerConfigurationOption: - """Gets managed instance server configuration option. - - :param resource_group_name: The name of the resource group that 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 server_configuration_option_name: The name of the server configuration option. - "allowPolybaseExport" Required. - :type server_configuration_option_name: str or - ~azure.mgmt.sql.models.ServerConfigurationOptionName - :return: ServerConfigurationOption or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerConfigurationOption - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - cls: ClsType[_models.ServerConfigurationOption] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - server_configuration_option_name=server_configuration_option_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ServerConfigurationOption", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - server_configuration_option_name: Union[str, _models.ServerConfigurationOptionName], - parameters: Union[_models.ServerConfigurationOption, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ServerConfigurationOption") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - server_configuration_option_name=server_configuration_option_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - server_configuration_option_name: Union[str, _models.ServerConfigurationOptionName], - parameters: _models.ServerConfigurationOption, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ServerConfigurationOption]: - """Updates managed instance server configuration option. - - :param resource_group_name: The name of the resource group that 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 server_configuration_option_name: The name of the server configuration option. - "allowPolybaseExport" Required. - :type server_configuration_option_name: str or - ~azure.mgmt.sql.models.ServerConfigurationOptionName - :param parameters: Server configuration option parameters. Required. - :type parameters: ~azure.mgmt.sql.models.ServerConfigurationOption - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ServerConfigurationOption or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerConfigurationOption] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - server_configuration_option_name: Union[str, _models.ServerConfigurationOptionName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ServerConfigurationOption]: - """Updates managed instance server configuration option. - - :param resource_group_name: The name of the resource group that 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 server_configuration_option_name: The name of the server configuration option. - "allowPolybaseExport" Required. - :type server_configuration_option_name: str or - ~azure.mgmt.sql.models.ServerConfigurationOptionName - :param parameters: Server configuration option parameters. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ServerConfigurationOption or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerConfigurationOption] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - server_configuration_option_name: Union[str, _models.ServerConfigurationOptionName], - parameters: Union[_models.ServerConfigurationOption, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ServerConfigurationOption]: - """Updates managed instance server configuration option. - - :param resource_group_name: The name of the resource group that 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 server_configuration_option_name: The name of the server configuration option. - "allowPolybaseExport" Required. - :type server_configuration_option_name: str or - ~azure.mgmt.sql.models.ServerConfigurationOptionName - :param parameters: Server configuration option parameters. Is either a - ServerConfigurationOption type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ServerConfigurationOption or IO[bytes] - :return: An instance of LROPoller that returns either ServerConfigurationOption or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerConfigurationOption] - :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", "2022-08-01-preview")) - 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) - 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, - managed_instance_name=managed_instance_name, - server_configuration_option_name=server_configuration_option_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ServerConfigurationOption", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ServerConfigurationOption].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ServerConfigurationOption]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 7d15aeee5738..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_connection_policies_operations.py +++ /dev/null @@ -1,509 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - server_name: str, - connection_policy_name: Union[str, _models.ConnectionPolicyName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "connectionPolicyName": _SERIALIZER.url("connection_policy_name", connection_policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - server_name: str, - connection_policy_name: Union[str, _models.ConnectionPolicyName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - 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/{connectionPolicyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "connectionPolicyName": _SERIALIZER.url("connection_policy_name", connection_policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="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: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ServerConnectionPoliciesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`server_connection_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - connection_policy_name: Union[str, _models.ConnectionPolicyName], - **kwargs: Any - ) -> _models.ServerConnectionPolicy: - """Gets a server connection policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param connection_policy_name: The name of the connection policy. "default" Required. - :type connection_policy_name: str or ~azure.mgmt.sql.models.ConnectionPolicyName - :return: ServerConnectionPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerConnectionPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.ServerConnectionPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - connection_policy_name=connection_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ServerConnectionPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - connection_policy_name: Union[str, _models.ConnectionPolicyName], - parameters: Union[_models.ServerConnectionPolicy, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ServerConnectionPolicy") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - connection_policy_name=connection_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - connection_policy_name: Union[str, _models.ConnectionPolicyName], - parameters: _models.ServerConnectionPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ServerConnectionPolicy]: - """Updates a server connection policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param connection_policy_name: The name of the connection policy. "default" Required. - :type connection_policy_name: str or ~azure.mgmt.sql.models.ConnectionPolicyName - :param parameters: The required parameters for updating a server connection policy. Required. - :type parameters: ~azure.mgmt.sql.models.ServerConnectionPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ServerConnectionPolicy or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerConnectionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - connection_policy_name: Union[str, _models.ConnectionPolicyName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ServerConnectionPolicy]: - """Updates a server connection policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param connection_policy_name: The name of the connection policy. "default" Required. - :type connection_policy_name: str or ~azure.mgmt.sql.models.ConnectionPolicyName - :param parameters: The required parameters for updating a server connection policy. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ServerConnectionPolicy or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerConnectionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - connection_policy_name: Union[str, _models.ConnectionPolicyName], - parameters: Union[_models.ServerConnectionPolicy, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ServerConnectionPolicy]: - """Updates a server connection policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param connection_policy_name: The name of the connection policy. "default" Required. - :type connection_policy_name: str or ~azure.mgmt.sql.models.ConnectionPolicyName - :param parameters: The required parameters for updating a server connection policy. Is either a - ServerConnectionPolicy type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ServerConnectionPolicy or IO[bytes] - :return: An instance of LROPoller that returns either ServerConnectionPolicy or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerConnectionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ServerConnectionPolicy] = 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, - connection_policy_name=connection_policy_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ServerConnectionPolicy", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ServerConnectionPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ServerConnectionPolicy]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either ServerConnectionPolicy or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerConnectionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.ServerConnectionPolicyListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 69d02847ff0a..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_dev_ops_audit_settings_operations.py +++ /dev/null @@ -1,515 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_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", "2022-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}/devOpsAuditingSettings", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - server_name: str, - dev_ops_auditing_settings_name: Union[str, _models.DevOpsAuditingSettingsName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/devOpsAuditingSettings/{devOpsAuditingSettingsName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "devOpsAuditingSettingsName": _SERIALIZER.url( - "dev_ops_auditing_settings_name", dev_ops_auditing_settings_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - server_name: str, - dev_ops_auditing_settings_name: Union[str, _models.DevOpsAuditingSettingsName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) - 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}/devOpsAuditingSettings/{devOpsAuditingSettingsName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "devOpsAuditingSettingsName": _SERIALIZER.url( - "dev_ops_auditing_settings_name", dev_ops_auditing_settings_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -class ServerDevOpsAuditSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`server_dev_ops_audit_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.ServerDevOpsAuditingSettings"]: - """Lists DevOps audit settings of 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 - :return: An iterator like instance of either ServerDevOpsAuditingSettings or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerDevOpsAuditingSettings] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) - cls: ClsType[_models.ServerDevOpsAuditSettingsListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ServerDevOpsAuditSettingsListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - dev_ops_auditing_settings_name: Union[str, _models.DevOpsAuditingSettingsName], - **kwargs: Any - ) -> _models.ServerDevOpsAuditingSettings: - """Gets a server's DevOps audit settings. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param dev_ops_auditing_settings_name: "Default" Required. - :type dev_ops_auditing_settings_name: str or ~azure.mgmt.sql.models.DevOpsAuditingSettingsName - :return: ServerDevOpsAuditingSettings or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerDevOpsAuditingSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-02-01-preview")) - cls: ClsType[_models.ServerDevOpsAuditingSettings] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - dev_ops_auditing_settings_name=dev_ops_auditing_settings_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ServerDevOpsAuditingSettings", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - dev_ops_auditing_settings_name: Union[str, _models.DevOpsAuditingSettingsName], - parameters: Union[_models.ServerDevOpsAuditingSettings, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2022-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ServerDevOpsAuditingSettings") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - dev_ops_auditing_settings_name=dev_ops_auditing_settings_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - dev_ops_auditing_settings_name: Union[str, _models.DevOpsAuditingSettingsName], - parameters: _models.ServerDevOpsAuditingSettings, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ServerDevOpsAuditingSettings]: - """Creates or updates a server's DevOps audit settings. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param dev_ops_auditing_settings_name: "Default" Required. - :type dev_ops_auditing_settings_name: str or ~azure.mgmt.sql.models.DevOpsAuditingSettingsName - :param parameters: Properties of DevOps audit settings. Required. - :type parameters: ~azure.mgmt.sql.models.ServerDevOpsAuditingSettings - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ServerDevOpsAuditingSettings or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerDevOpsAuditingSettings] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - dev_ops_auditing_settings_name: Union[str, _models.DevOpsAuditingSettingsName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ServerDevOpsAuditingSettings]: - """Creates or updates a server's DevOps audit settings. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param dev_ops_auditing_settings_name: "Default" Required. - :type dev_ops_auditing_settings_name: str or ~azure.mgmt.sql.models.DevOpsAuditingSettingsName - :param parameters: Properties of DevOps audit settings. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ServerDevOpsAuditingSettings or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerDevOpsAuditingSettings] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - dev_ops_auditing_settings_name: Union[str, _models.DevOpsAuditingSettingsName], - parameters: Union[_models.ServerDevOpsAuditingSettings, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ServerDevOpsAuditingSettings]: - """Creates or updates a server's DevOps audit settings. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param dev_ops_auditing_settings_name: "Default" Required. - :type dev_ops_auditing_settings_name: str or ~azure.mgmt.sql.models.DevOpsAuditingSettingsName - :param parameters: Properties of DevOps audit settings. Is either a - ServerDevOpsAuditingSettings type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ServerDevOpsAuditingSettings or IO[bytes] - :return: An instance of LROPoller that returns either ServerDevOpsAuditingSettings or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerDevOpsAuditingSettings] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) - 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) - 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, - dev_ops_auditing_settings_name=dev_ops_auditing_settings_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ServerDevOpsAuditingSettings", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.ServerDevOpsAuditingSettings].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ServerDevOpsAuditingSettings]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 79c6323f3b85..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_dns_aliases_operations.py +++ /dev/null @@ -1,776 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, server_name: str, dns_alias_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "dnsAliasName": _SERIALIZER.url("dns_alias_name", dns_alias_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, server_name: str, dns_alias_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "dnsAliasName": _SERIALIZER.url("dns_alias_name", dns_alias_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, server_name: str, dns_alias_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "dnsAliasName": _SERIALIZER.url("dns_alias_name", dns_alias_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_acquire_request( - resource_group_name: str, server_name: str, dns_alias_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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}/dnsAliases/{dnsAliasName}/acquire", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "dnsAliasName": _SERIALIZER.url("dns_alias_name", dns_alias_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class ServerDnsAliasesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`server_dns_aliases` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, resource_group_name: str, server_name: str, dns_alias_name: str, **kwargs: Any - ) -> _models.ServerDnsAlias: - """Gets a server DNS alias. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param dns_alias_name: The name of the server dns alias. Required. - :type dns_alias_name: str - :return: ServerDnsAlias or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerDnsAlias - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerDnsAlias] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - dns_alias_name=dns_alias_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ServerDnsAlias", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, resource_group_name: str, server_name: str, dns_alias_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - dns_alias_name=dns_alias_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_create_or_update( - self, resource_group_name: str, server_name: str, dns_alias_name: str, **kwargs: Any - ) -> LROPoller[_models.ServerDnsAlias]: - """Creates a server DNS alias. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param dns_alias_name: The name of the server dns alias. Required. - :type dns_alias_name: str - :return: An instance of LROPoller that returns either ServerDnsAlias or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerDnsAlias] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerDnsAlias] = 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, - dns_alias_name=dns_alias_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ServerDnsAlias", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ServerDnsAlias].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ServerDnsAlias]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, server_name: str, dns_alias_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - dns_alias_name=dns_alias_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, server_name: str, dns_alias_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes the server DNS alias with the given name. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param dns_alias_name: The name of the server dns alias. Required. - :type dns_alias_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - dns_alias_name=dns_alias_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either ServerDnsAlias or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerDnsAlias] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerDnsAliasListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - def _acquire_initial( - self, - resource_group_name: str, - server_name: str, - dns_alias_name: str, - parameters: Union[_models.ServerDnsAliasAcquisition, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ServerDnsAliasAcquisition") - - _request = build_acquire_request( - resource_group_name=resource_group_name, - server_name=server_name, - dns_alias_name=dns_alias_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_acquire( - self, - resource_group_name: str, - server_name: str, - dns_alias_name: str, - parameters: _models.ServerDnsAliasAcquisition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ServerDnsAlias]: - """Acquires server DNS alias from another server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param dns_alias_name: The name of the server dns alias. Required. - :type dns_alias_name: str - :param parameters: Required. - :type parameters: ~azure.mgmt.sql.models.ServerDnsAliasAcquisition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ServerDnsAlias or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerDnsAlias] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_acquire( - self, - resource_group_name: str, - server_name: str, - dns_alias_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ServerDnsAlias]: - """Acquires server DNS alias from another server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param dns_alias_name: The name of the server dns alias. Required. - :type dns_alias_name: str - :param parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ServerDnsAlias or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerDnsAlias] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_acquire( - self, - resource_group_name: str, - server_name: str, - dns_alias_name: str, - parameters: Union[_models.ServerDnsAliasAcquisition, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ServerDnsAlias]: - """Acquires server DNS alias from another server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param dns_alias_name: The name of the server dns alias. Required. - :type dns_alias_name: str - :param parameters: Is either a ServerDnsAliasAcquisition type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ServerDnsAliasAcquisition or IO[bytes] - :return: An instance of LROPoller that returns either ServerDnsAlias or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerDnsAlias] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ServerDnsAlias] = 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._acquire_initial( - resource_group_name=resource_group_name, - server_name=server_name, - dns_alias_name=dns_alias_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ServerDnsAlias", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ServerDnsAlias].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ServerDnsAlias]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_keys_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_keys_operations.py deleted file mode 100644 index 6de718012092..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_keys_operations.py +++ /dev/null @@ -1,633 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_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", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, server_name: str, key_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys/{keyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "keyName": _SERIALIZER.url("key_name", key_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, server_name: str, key_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys/{keyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "keyName": _SERIALIZER.url("key_name", key_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, server_name: str, key_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys/{keyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "keyName": _SERIALIZER.url("key_name", key_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -class ServerKeysOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`server_keys` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.ServerKey"]: - """Gets a list of server keys. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either ServerKey or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerKey] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerKeyListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ServerKeyListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, resource_group_name: str, server_name: str, key_name: str, **kwargs: Any) -> _models.ServerKey: - """Gets a server key. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param key_name: The name of the server key to be retrieved. Required. - :type key_name: str - :return: ServerKey or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerKey - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerKey] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - key_name=key_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ServerKey", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - key_name: str, - parameters: Union[_models.ServerKey, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ServerKey") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - key_name=key_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - key_name: str, - parameters: _models.ServerKey, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ServerKey]: - """Creates or updates a server key. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param key_name: The name of the server key to be operated on (updated or created). The key - name is required to be in the format of 'vault_key_version'. For example, if the keyId is - https://YourVaultName.vault.azure.net/keys/YourKeyName/YourKeyVersion, then the server key name - should be formatted as: YourVaultName_YourKeyName_YourKeyVersion. Required. - :type key_name: str - :param parameters: The requested server key resource state. Required. - :type parameters: ~azure.mgmt.sql.models.ServerKey - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ServerKey or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerKey] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - key_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ServerKey]: - """Creates or updates a server key. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param key_name: The name of the server key to be operated on (updated or created). The key - name is required to be in the format of 'vault_key_version'. For example, if the keyId is - https://YourVaultName.vault.azure.net/keys/YourKeyName/YourKeyVersion, then the server key name - should be formatted as: YourVaultName_YourKeyName_YourKeyVersion. Required. - :type key_name: str - :param parameters: The requested server key resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ServerKey or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerKey] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - key_name: str, - parameters: Union[_models.ServerKey, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ServerKey]: - """Creates or updates a server key. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param key_name: The name of the server key to be operated on (updated or created). The key - name is required to be in the format of 'vault_key_version'. For example, if the keyId is - https://YourVaultName.vault.azure.net/keys/YourKeyName/YourKeyVersion, then the server key name - should be formatted as: YourVaultName_YourKeyName_YourKeyVersion. Required. - :type key_name: str - :param parameters: The requested server key resource state. Is either a ServerKey type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ServerKey or IO[bytes] - :return: An instance of LROPoller that returns either ServerKey or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerKey] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ServerKey] = 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, - key_name=key_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ServerKey", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ServerKey].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ServerKey]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, server_name: str, key_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - key_name=key_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete(self, resource_group_name: str, server_name: str, key_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes the server key with the given name. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param key_name: The name of the server key to be deleted. Required. - :type key_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - key_name=key_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_operations_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_operations_operations.py deleted file mode 100644 index e1b8a8f5f4d7..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_operations_operations.py +++ /dev/null @@ -1,160 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_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", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/operations", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ServerOperationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`server_operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.ServerOperation"]: - """Gets a list of operations performed on the server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either ServerOperation or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerOperation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerOperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ServerOperationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_security_alert_policies_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_security_alert_policies_operations.py deleted file mode 100644 index 9b4b842579b2..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_security_alert_policies_operations.py +++ /dev/null @@ -1,509 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - server_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/securityAlertPolicies/{securityAlertPolicyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - server_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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/{securityAlertPolicyName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="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: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-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", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ServerSecurityAlertPoliciesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`server_security_alert_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - **kwargs: Any - ) -> _models.ServerSecurityAlertPolicy: - """Get a server's security alert policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :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 - :return: ServerSecurityAlertPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerSecurityAlertPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerSecurityAlertPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - security_alert_policy_name=security_alert_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ServerSecurityAlertPolicy", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - parameters: Union[_models.ServerSecurityAlertPolicy, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ServerSecurityAlertPolicy") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - security_alert_policy_name=security_alert_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - parameters: _models.ServerSecurityAlertPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ServerSecurityAlertPolicy]: - """Creates or updates a threat detection policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :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 - :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. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ServerSecurityAlertPolicy or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerSecurityAlertPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ServerSecurityAlertPolicy]: - """Creates or updates a threat detection policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :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 - :param parameters: The server security alert policy. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ServerSecurityAlertPolicy or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerSecurityAlertPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - parameters: Union[_models.ServerSecurityAlertPolicy, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ServerSecurityAlertPolicy]: - """Creates or updates a threat detection policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :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 - :param parameters: The server security alert policy. Is either a ServerSecurityAlertPolicy type - or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ServerSecurityAlertPolicy or IO[bytes] - :return: An instance of LROPoller that returns either ServerSecurityAlertPolicy or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerSecurityAlertPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ServerSecurityAlertPolicy] = 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, - security_alert_policy_name=security_alert_policy_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ServerSecurityAlertPolicy", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ServerSecurityAlertPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ServerSecurityAlertPolicy]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either ServerSecurityAlertPolicy or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerSecurityAlertPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.LogicalServerSecurityAlertPolicyListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index e5ce5b9fa9a0..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_trust_certificates_operations.py +++ /dev/null @@ -1,633 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_instance_request( - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverTrustCertificates", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, managed_instance_name: str, certificate_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverTrustCertificates/{certificateName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, managed_instance_name: str, certificate_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - 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}/serverTrustCertificates/{certificateName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, managed_instance_name: str, certificate_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverTrustCertificates/{certificateName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -class ServerTrustCertificatesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`server_trust_certificates` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.ServerTrustCertificate"]: - """Gets a list of server trust certificates that were uploaded from box to the given Sql Managed - Instance. - - :param resource_group_name: The name of the resource group that 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 - :return: An iterator like instance of either ServerTrustCertificate or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerTrustCertificate] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.ServerTrustCertificatesListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ServerTrustCertificatesListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, managed_instance_name: str, certificate_name: str, **kwargs: Any - ) -> _models.ServerTrustCertificate: - """Gets a server trust certificate that was uploaded from box to Sql Managed Instance. - - :param resource_group_name: The name of the resource group that 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 certificate_name: Name of of the certificate to get. Required. - :type certificate_name: str - :return: ServerTrustCertificate or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerTrustCertificate - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[_models.ServerTrustCertificate] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - certificate_name=certificate_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ServerTrustCertificate", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - managed_instance_name: str, - certificate_name: str, - parameters: Union[_models.ServerTrustCertificate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2021-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ServerTrustCertificate") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - certificate_name=certificate_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - certificate_name: str, - parameters: _models.ServerTrustCertificate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ServerTrustCertificate]: - """Uploads a server trust certificate from box to Sql Managed Instance. - - :param resource_group_name: The name of the resource group that 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 certificate_name: Name of of the certificate to upload. Required. - :type certificate_name: str - :param parameters: The server trust certificate info. Required. - :type parameters: ~azure.mgmt.sql.models.ServerTrustCertificate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ServerTrustCertificate or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerTrustCertificate] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - certificate_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ServerTrustCertificate]: - """Uploads a server trust certificate from box to Sql Managed Instance. - - :param resource_group_name: The name of the resource group that 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 certificate_name: Name of of the certificate to upload. Required. - :type certificate_name: str - :param parameters: The server trust certificate info. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ServerTrustCertificate or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerTrustCertificate] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - certificate_name: str, - parameters: Union[_models.ServerTrustCertificate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ServerTrustCertificate]: - """Uploads a server trust certificate from box to Sql Managed Instance. - - :param resource_group_name: The name of the resource group that 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 certificate_name: Name of of the certificate to upload. Required. - :type certificate_name: str - :param parameters: The server trust certificate info. Is either a ServerTrustCertificate type - or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ServerTrustCertificate or IO[bytes] - :return: An instance of LROPoller that returns either ServerTrustCertificate or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerTrustCertificate] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - 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) - 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, - managed_instance_name=managed_instance_name, - certificate_name=certificate_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ServerTrustCertificate", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ServerTrustCertificate].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ServerTrustCertificate]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, managed_instance_name: str, certificate_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - certificate_name=certificate_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, managed_instance_name: str, certificate_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes a server trust certificate that was uploaded from box to Sql Managed Instance. - - :param resource_group_name: The name of the resource group that 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 certificate_name: Name of of the certificate to delete. Required. - :type certificate_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-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( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - certificate_name=certificate_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index 4fb2beea92dc..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_trust_groups_operations.py +++ /dev/null @@ -1,734 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, location_name: str, server_trust_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups/{serverTrustGroupName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "serverTrustGroupName": _SERIALIZER.url("server_trust_group_name", server_trust_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, location_name: str, server_trust_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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}/serverTrustGroups/{serverTrustGroupName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "serverTrustGroupName": _SERIALIZER.url("server_trust_group_name", server_trust_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, location_name: str, server_trust_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups/{serverTrustGroupName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "serverTrustGroupName": _SERIALIZER.url("server_trust_group_name", server_trust_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_list_by_location_request( - resource_group_name: str, location_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_instance_request( - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverTrustGroups", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ServerTrustGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`server_trust_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, resource_group_name: str, location_name: str, server_trust_group_name: str, **kwargs: Any - ) -> _models.ServerTrustGroup: - """Gets a server trust group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param server_trust_group_name: The name of the server trust group. Required. - :type server_trust_group_name: str - :return: ServerTrustGroup or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerTrustGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerTrustGroup] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - location_name=location_name, - server_trust_group_name=server_trust_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ServerTrustGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - location_name: str, - server_trust_group_name: str, - parameters: Union[_models.ServerTrustGroup, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ServerTrustGroup") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - location_name=location_name, - server_trust_group_name=server_trust_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - location_name: str, - server_trust_group_name: str, - parameters: _models.ServerTrustGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ServerTrustGroup]: - """Creates or updates a server trust group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param server_trust_group_name: The name of the server trust group. Required. - :type server_trust_group_name: str - :param parameters: The server trust group parameters. Required. - :type parameters: ~azure.mgmt.sql.models.ServerTrustGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ServerTrustGroup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerTrustGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - location_name: str, - server_trust_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ServerTrustGroup]: - """Creates or updates a server trust group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param server_trust_group_name: The name of the server trust group. Required. - :type server_trust_group_name: str - :param parameters: The server trust group parameters. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ServerTrustGroup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerTrustGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - location_name: str, - server_trust_group_name: str, - parameters: Union[_models.ServerTrustGroup, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ServerTrustGroup]: - """Creates or updates a server trust group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param server_trust_group_name: The name of the server trust group. Required. - :type server_trust_group_name: str - :param parameters: The server trust group parameters. Is either a ServerTrustGroup type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ServerTrustGroup or IO[bytes] - :return: An instance of LROPoller that returns either ServerTrustGroup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerTrustGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ServerTrustGroup] = 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, - location_name=location_name, - server_trust_group_name=server_trust_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ServerTrustGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ServerTrustGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ServerTrustGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, location_name: str, server_trust_group_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - location_name=location_name, - server_trust_group_name=server_trust_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, location_name: str, server_trust_group_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes a server trust group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :param server_trust_group_name: The name of the server trust group. Required. - :type server_trust_group_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - location_name=location_name, - server_trust_group_name=server_trust_group_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_by_location( - self, resource_group_name: str, location_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either ServerTrustGroup or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerTrustGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerTrustGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace - def list_by_instance( - self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> ItemPaged["_models.ServerTrustGroup"]: - """Gets a server trust groups by instance 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 managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :return: An iterator like instance of either ServerTrustGroup or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerTrustGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerTrustGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index b71d9957fc52..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_usages_operations.py +++ /dev/null @@ -1,160 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_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", "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}/usages", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ServerUsagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`server_usages` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.ServerUsage"]: - """Returns 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. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :return: An iterator like instance of either ServerUsage or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerUsage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.ServerUsageListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ServerUsageListResult", 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) 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 deleted file mode 100644 index 25c5c215d1bb..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_vulnerability_assessments_operations.py +++ /dev/null @@ -1,553 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/vulnerabilityAssessments", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ServerVulnerabilityAssessmentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`server_vulnerability_assessments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **kwargs: Any - ) -> _models.ServerVulnerabilityAssessment: - """Gets the server's vulnerability assessment. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server for which the vulnerability assessment is defined. - Required. - :type server_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 - :return: ServerVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerVulnerabilityAssessment] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("ServerVulnerabilityAssessment", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: _models.ServerVulnerabilityAssessment, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ServerVulnerabilityAssessment: - """Creates or updates the server's vulnerability assessment. Learn more about setting SQL - vulnerability assessment with managed identity - - https://docs.microsoft.com/azure/azure-sql/database/sql-database-vulnerability-assessment-storage. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server for which the vulnerability assessment is defined. - Required. - :type server_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 parameters: The requested resource. Required. - :type parameters: ~azure.mgmt.sql.models.ServerVulnerabilityAssessment - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ServerVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ServerVulnerabilityAssessment: - """Creates or updates the server's vulnerability assessment. Learn more about setting SQL - vulnerability assessment with managed identity - - https://docs.microsoft.com/azure/azure-sql/database/sql-database-vulnerability-assessment-storage. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server for which the vulnerability assessment is defined. - Required. - :type server_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 parameters: The requested resource. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ServerVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: Union[_models.ServerVulnerabilityAssessment, IO[bytes]], - **kwargs: Any - ) -> _models.ServerVulnerabilityAssessment: - """Creates or updates the server's vulnerability assessment. Learn more about setting SQL - vulnerability assessment with managed identity - - https://docs.microsoft.com/azure/azure-sql/database/sql-database-vulnerability-assessment-storage. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server for which the vulnerability assessment is defined. - Required. - :type server_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 parameters: The requested resource. Is either a ServerVulnerabilityAssessment type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ServerVulnerabilityAssessment or IO[bytes] - :return: ServerVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ServerVulnerabilityAssessment") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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) - - deserialized = self._deserialize("ServerVulnerabilityAssessment", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **kwargs: Any - ) -> None: - """Removes the server's vulnerability assessment. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server for which the vulnerability assessment is defined. - Required. - :type server_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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either ServerVulnerabilityAssessment or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerVulnerabilityAssessment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 42df44bdda70..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_servers_operations.py +++ /dev/null @@ -1,1444 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-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/checkNameAvailability") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(subscription_id: str, *, expand: 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", "2024-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/servers") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "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_resource_group_request( - resource_group_name: str, subscription_id: str, *, expand: 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", "2024-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "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_get_request( - resource_group_name: str, server_name: str, subscription_id: str, *, expand: 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", "2024-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "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_create_or_update_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", "2024-11-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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_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_delete_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", "2024-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_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", "2024-11-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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_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_import_database_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", "2024-11-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}/import", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_refresh_status_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", "2024-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/refreshExternalGovernanceStatus", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class ServersOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`servers` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def check_name_availability( - self, parameters: _models.CheckNameAvailabilityRequest, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CheckNameAvailabilityResponse: - """Determines whether a resource can be created with the specified name. - - :param parameters: The name availability request parameters. Required. - :type parameters: ~azure.mgmt.sql.models.CheckNameAvailabilityRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CheckNameAvailabilityResponse or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.CheckNameAvailabilityResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def check_name_availability( - self, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CheckNameAvailabilityResponse: - """Determines whether a resource can be created with the specified name. - - :param parameters: The name availability request parameters. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: CheckNameAvailabilityResponse or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.CheckNameAvailabilityResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def check_name_availability( - self, parameters: Union[_models.CheckNameAvailabilityRequest, IO[bytes]], **kwargs: Any - ) -> _models.CheckNameAvailabilityResponse: - """Determines whether a resource can be created with the specified name. - - :param parameters: The name availability request parameters. Is either a - CheckNameAvailabilityRequest type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.CheckNameAvailabilityRequest or IO[bytes] - :return: CheckNameAvailabilityResponse or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.CheckNameAvailabilityResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "CheckNameAvailabilityRequest") - - _request = build_check_name_availability_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckNameAvailabilityResponse", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list(self, expand: Optional[str] = None, **kwargs: Any) -> ItemPaged["_models.Server"]: - """Gets a list of all servers in the subscription. - - :param expand: The child resources to include in the response. Default value is None. - :type expand: str - :return: An iterator like instance of either Server or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - cls: ClsType[_models.ServerListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ServerListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group( - self, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_models.Server"]: - """Gets a list of servers in a resource groups. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param expand: The child resources to include in the response. Default value is None. - :type expand: str - :return: An iterator like instance of either Server or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - cls: ClsType[_models.ServerListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ServerListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, server_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> _models.Server: - """Gets a server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param expand: The child resources to include in the response. Default value is None. - :type expand: str - :return: Server or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.Server - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - cls: ClsType[_models.Server] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - expand=expand, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Server", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, resource_group_name: str, server_name: str, parameters: Union[_models.Server, IO[bytes]], **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "Server") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - parameters: _models.Server, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Server]: - """Creates or updates a server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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: The requested server resource state. Required. - :type parameters: ~azure.mgmt.sql.models.Server - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Server or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Server]: - """Creates or updates a server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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: The requested server resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Server or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, resource_group_name: str, server_name: str, parameters: Union[_models.Server, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.Server]: - """Creates or updates a server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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: The requested server resource state. Is either a Server type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.sql.models.Server or IO[bytes] - :return: An instance of LROPoller that returns either Server or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - 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) - 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, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Server", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Server].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Server]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial(self, resource_group_name: str, server_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete(self, resource_group_name: str, server_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes a server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :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", "2024-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( - resource_group_name=resource_group_name, - server_name=server_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ServerUpdate") - - _request = build_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - server_name: str, - parameters: _models.ServerUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Server]: - """Updates a server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: The requested server resource state. Required. - :type parameters: ~azure.mgmt.sql.models.ServerUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Server or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Server]: - """Updates a server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: The requested server resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Server or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ServerUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Server]: - """Updates a server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param parameters: The requested server resource state. Is either a ServerUpdate type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ServerUpdate or IO[bytes] - :return: An instance of LROPoller that returns either Server or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.Server] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - 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) - 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( - resource_group_name=resource_group_name, - server_name=server_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Server", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Server].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Server]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _import_database_initial( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ImportNewDatabaseDefinition, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "ImportNewDatabaseDefinition") - - _request = build_import_database_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_import_database( - self, - resource_group_name: str, - server_name: str, - parameters: _models.ImportNewDatabaseDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ImportExportOperationResult]: - """Imports a bacpac into a new database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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: The database import request parameters. Required. - :type parameters: ~azure.mgmt.sql.models.ImportNewDatabaseDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ImportExportOperationResult or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_import_database( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ImportExportOperationResult]: - """Imports a bacpac into a new database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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: The database import request parameters. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ImportExportOperationResult or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_import_database( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.ImportNewDatabaseDefinition, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ImportExportOperationResult]: - """Imports a bacpac into a new database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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: The database import request parameters. Is either a - ImportNewDatabaseDefinition type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.ImportNewDatabaseDefinition or IO[bytes] - :return: An instance of LROPoller that returns either ImportExportOperationResult or the result - of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ImportExportOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - 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) - 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._import_database_initial( - resource_group_name=resource_group_name, - server_name=server_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ImportExportOperationResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ImportExportOperationResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ImportExportOperationResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _refresh_status_initial(self, resource_group_name: str, server_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2024-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_refresh_status_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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) - - response_headers = {} - if response.status_code == 202: - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_refresh_status( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> LROPoller[_models.RefreshExternalGovernanceStatusOperationResult]: - """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 server_name: The name of the server. Required. - :type server_name: str - :return: An instance of LROPoller that returns either - RefreshExternalGovernanceStatusOperationResult or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.RefreshExternalGovernanceStatusOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-11-01-preview")) - 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) - 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, - server_name=server_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize( - "RefreshExternalGovernanceStatusOperationResult", pipeline_response.http_response - ) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.RefreshExternalGovernanceStatusOperationResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.RefreshExternalGovernanceStatusOperationResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_service_objectives_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_service_objectives_operations.py deleted file mode 100644 index 29a14f8842ba..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_service_objectives_operations.py +++ /dev/null @@ -1,252 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, server_name: str, service_objective_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/serviceObjectives/{serviceObjectiveName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "serviceObjectiveName": _SERIALIZER.url("service_objective_name", service_objective_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/serviceObjectives", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ServiceObjectivesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`service_objectives` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - :return: ServiceObjective or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServiceObjective - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.ServiceObjective] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - service_objective_name=service_objective_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either ServiceObjective or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServiceObjective] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.ServiceObjectiveListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index 58230c4e92bd..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_agent_operations.py +++ /dev/null @@ -1,306 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/sqlAgent/current", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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}/sqlAgent/current", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -class SqlAgentOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`sql_agent` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get(self, resource_group_name: str, managed_instance_name: str, **kwargs: Any) -> _models.SqlAgentConfiguration: - """Gets current instance sql agent configuration. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :return: SqlAgentConfiguration or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SqlAgentConfiguration - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SqlAgentConfiguration] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("SqlAgentConfiguration", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - parameters: _models.SqlAgentConfiguration, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SqlAgentConfiguration: - """Puts new sql agent configuration to instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 parameters: Required. - :type parameters: ~azure.mgmt.sql.models.SqlAgentConfiguration - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SqlAgentConfiguration or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SqlAgentConfiguration - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SqlAgentConfiguration: - """Puts new sql agent configuration to instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 parameters: Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: SqlAgentConfiguration or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SqlAgentConfiguration - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - parameters: Union[_models.SqlAgentConfiguration, IO[bytes]], - **kwargs: Any - ) -> _models.SqlAgentConfiguration: - """Puts new sql agent configuration to instance. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 parameters: Is either a SqlAgentConfiguration type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.SqlAgentConfiguration or IO[bytes] - :return: SqlAgentConfiguration or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SqlAgentConfiguration - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SqlAgentConfiguration") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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("SqlAgentConfiguration", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 56d98bf89821..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_baseline_operations.py +++ /dev/null @@ -1,306 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Literal, Optional, TypeVar, Union - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_sql_vulnerability_assessment_request( # pylint: disable=name-too-long - 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 {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/baselines", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["systemDatabaseName"] = _SERIALIZER.query("system_database_name", system_database_name, "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_get_request( - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/baselines/{baselineName}", - ) - 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" - ), - "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["systemDatabaseName"] = _SERIALIZER.query("system_database_name", system_database_name, "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 SqlVulnerabilityAssessmentBaselineOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`sql_vulnerability_assessment_baseline` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_sql_vulnerability_assessment( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **kwargs: Any - ) -> ItemPaged["_models.DatabaseSqlVulnerabilityAssessmentBaselineSet"]: - """Gets a list of database's sql vulnerability assessment rule baselines. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_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 - :return: An iterator like instance of either DatabaseSqlVulnerabilityAssessmentBaselineSet or - the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentBaselineSetListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_sql_vulnerability_assessment_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - system_database_name=system_database_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize( - "DatabaseSqlVulnerabilityAssessmentBaselineSetListResult", pipeline_response - ) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - **kwargs: Any - ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: - """Gets a list of database's sql vulnerability assessment rule baselines. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :return: DatabaseSqlVulnerabilityAssessmentBaselineSet or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentBaselineSet] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - baseline_name=baseline_name, - subscription_id=self._config.subscription_id, - system_database_name=system_database_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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( - "DatabaseSqlVulnerabilityAssessmentBaselineSet", pipeline_response.http_response - ) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 8bd06092c835..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_baselines_operations.py +++ /dev/null @@ -1,265 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Literal, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_or_update_request( - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - 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}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/baselines/{baselineName}", - ) - 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" - ), - "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["systemDatabaseName"] = _SERIALIZER.query("system_database_name", system_database_name, "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) - - -class SqlVulnerabilityAssessmentBaselinesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`sql_vulnerability_assessment_baselines` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - parameters: _models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: - """Add a database's vulnerability assessment rule baseline 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 server_name: The name of the server. Required. - :type server_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :param parameters: The requested rule baseline resource. Required. - :type parameters: - ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseSqlVulnerabilityAssessmentBaselineSet or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: - """Add a database's vulnerability assessment rule baseline 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 server_name: The name of the server. Required. - :type server_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :param parameters: The requested rule baseline resource. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseSqlVulnerabilityAssessmentBaselineSet or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - parameters: Union[_models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput, IO[bytes]], - **kwargs: Any - ) -> _models.DatabaseSqlVulnerabilityAssessmentBaselineSet: - """Add a database's vulnerability assessment rule baseline 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 server_name: The name of the server. Required. - :type server_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :param parameters: The requested rule baseline resource. Is either a - DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput type or a IO[bytes] type. Required. - :type parameters: - ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput or IO[bytes] - :return: DatabaseSqlVulnerabilityAssessmentBaselineSet or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentBaselineSet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - baseline_name=baseline_name, - subscription_id=self._config.subscription_id, - system_database_name=system_database_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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( - "DatabaseSqlVulnerabilityAssessmentBaselineSet", pipeline_response.http_response - ) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index f9058da7d3d2..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_execute_scan_operations.py +++ /dev/null @@ -1,222 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Iterator, Literal, Optional, TypeVar, Union, cast - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_execute_request( - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/initiateScan", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["systemDatabaseName"] = _SERIALIZER.query("system_database_name", system_database_name, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -class SqlVulnerabilityAssessmentExecuteScanOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`sql_vulnerability_assessment_execute_scan` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - def _execute_initial( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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 {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_execute_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - system_database_name=system_database_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_execute( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **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 vulnerability_assessment_name: The name of the vulnerability assessment. "default" - Required. - :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName - :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 {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - 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._execute_initial( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - system_database_name=system_database_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index 535a7c08f040..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_rule_baseline_operations.py +++ /dev/null @@ -1,538 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Literal, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_baseline_request( - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/baselines/{baselineName}/rules", - ) - 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" - ), - "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["systemDatabaseName"] = _SERIALIZER.query("system_database_name", system_database_name, "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_get_request( - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - rule_id: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/baselines/{baselineName}/rules/{ruleId}", - ) - 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" - ), - "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), - "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["systemDatabaseName"] = _SERIALIZER.query("system_database_name", system_database_name, "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_create_or_update_request( - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - rule_id: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - 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}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/baselines/{baselineName}/rules/{ruleId}", - ) - 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" - ), - "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), - "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["systemDatabaseName"] = _SERIALIZER.query("system_database_name", system_database_name, "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) - - -class SqlVulnerabilityAssessmentRuleBaselineOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`sql_vulnerability_assessment_rule_baseline` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_baseline( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - **kwargs: Any - ) -> ItemPaged["_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline"]: - """Gets a system database's sql vulnerability assessment rule baseline. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :return: An iterator like instance of either DatabaseSqlVulnerabilityAssessmentRuleBaseline or - the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_baseline_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - baseline_name=baseline_name, - subscription_id=self._config.subscription_id, - system_database_name=system_database_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize( - "DatabaseSqlVulnerabilityAssessmentRuleBaselineListResult", pipeline_response - ) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - rule_id: str, - **kwargs: Any - ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: - """Gets a system database's sql vulnerability assessment rule baseline. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :param rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - baseline_name=baseline_name, - rule_id=rule_id, - subscription_id=self._config.subscription_id, - system_database_name=system_database_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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( - "DatabaseSqlVulnerabilityAssessmentRuleBaseline", pipeline_response.http_response - ) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - rule_id: str, - parameters: _models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :param rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :param parameters: The requested rule baseline resource. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - rule_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :param rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :param parameters: The requested rule baseline resource. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - rule_id: str, - parameters: Union[_models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput, IO[bytes]], - **kwargs: Any - ) -> _models.DatabaseSqlVulnerabilityAssessmentRuleBaseline: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :param rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :param parameters: The requested rule baseline resource. Is either a - DatabaseSqlVulnerabilityAssessmentRuleBaselineInput type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaselineInput or - IO[bytes] - :return: DatabaseSqlVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseSqlVulnerabilityAssessmentRuleBaseline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "DatabaseSqlVulnerabilityAssessmentRuleBaselineInput") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - baseline_name=baseline_name, - rule_id=rule_id, - subscription_id=self._config.subscription_id, - system_database_name=system_database_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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( - "DatabaseSqlVulnerabilityAssessmentRuleBaseline", pipeline_response.http_response - ) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 0d4269cad3ea..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_rule_baselines_operations.py +++ /dev/null @@ -1,169 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Literal, Optional, TypeVar, Union - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_delete_request( - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - rule_id: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/baselines/{baselineName}/rules/{ruleId}", - ) - 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" - ), - "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), - "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["systemDatabaseName"] = _SERIALIZER.query("system_database_name", system_database_name, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -class SqlVulnerabilityAssessmentRuleBaselinesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`sql_vulnerability_assessment_rule_baselines` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - baseline_name: Union[str, _models.BaselineName], - rule_id: str, - **kwargs: Any - ) -> None: - """Removes the database's vulnerability assessment rule baseline. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_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 baseline_name: "default" Required. - :type baseline_name: str or ~azure.mgmt.sql.models.BaselineName - :param rule_id: The vulnerability assessment rule ID. Required. - :type rule_id: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - baseline_name=baseline_name, - rule_id=rule_id, - subscription_id=self._config.subscription_id, - system_database_name=system_database_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore 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 deleted file mode 100644 index 76d0d5531bc5..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_scan_result_operations.py +++ /dev/null @@ -1,318 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Literal, Optional, TypeVar, Union - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_scan_request( - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], - 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 {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/scanResults", - ) - 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" - ), - "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["systemDatabaseName"] = _SERIALIZER.query("system_database_name", system_database_name, "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_get_request( - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], - scan_id: str, - scan_result_id: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/scanResults/{scanResultId}", - ) - 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" - ), - "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), - "scanResultId": _SERIALIZER.url("scan_result_id", scan_result_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["systemDatabaseName"] = _SERIALIZER.query("system_database_name", system_database_name, "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 SqlVulnerabilityAssessmentScanResultOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`sql_vulnerability_assessment_scan_result` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_scan( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], - scan_id: str, - **kwargs: Any - ) -> ItemPaged["_models.SqlVulnerabilityAssessmentScanResults"]: - """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. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" - Required. - :type vulnerability_assessment_name: str or - ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentName - :param scan_id: The scan id of the SQL Vulnerability Assessment scan to retrieve result from. - Required. - :type scan_id: str - :return: An iterator like instance of either SqlVulnerabilityAssessmentScanResults or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanResults] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[_models.SQLVulnerabilityAssessmentScanListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_scan_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - scan_id=scan_id, - subscription_id=self._config.subscription_id, - system_database_name=system_database_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SQLVulnerabilityAssessmentScanListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], - scan_id: str, - scan_result_id: str, - **kwargs: Any - ) -> _models.SqlVulnerabilityAssessmentScanResults: - """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. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" - Required. - :type vulnerability_assessment_name: str or - ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentName - :param scan_id: The scan id of the SQL Vulnerability Assessment scan to retrieve result from. - Required. - :type scan_id: str - :param scan_result_id: The scan result id of the specific result to retrieve. Required. - :type scan_result_id: str - :return: SqlVulnerabilityAssessmentScanResults or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanResults - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[_models.SqlVulnerabilityAssessmentScanResults] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - scan_id=scan_id, - scan_result_id=scan_result_id, - subscription_id=self._config.subscription_id, - system_database_name=system_database_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("SqlVulnerabilityAssessmentScanResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index c789a9b1149d..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_scans_operations.py +++ /dev/null @@ -1,302 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Literal, Optional, TypeVar, Union - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_sql_vulnerability_assessments_request( # pylint: disable=name-too-long - 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 {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/scans", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["systemDatabaseName"] = _SERIALIZER.query("system_database_name", system_database_name, "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_get_request( - resource_group_name: str, - server_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 {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}", - ) - 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" - ), - "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["systemDatabaseName"] = _SERIALIZER.query("system_database_name", system_database_name, "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 SqlVulnerabilityAssessmentScansOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`sql_vulnerability_assessment_scans` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_sql_vulnerability_assessments( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **kwargs: Any - ) -> ItemPaged["_models.SqlVulnerabilityAssessmentScanRecord"]: - """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 server_name: The name of the server. Required. - :type server_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 - :return: An iterator like instance of either SqlVulnerabilityAssessmentScanRecord or the result - of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanRecord] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[_models.SqlVulnerabilityAssessmentScanRecordListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_sql_vulnerability_assessments_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - system_database_name=system_database_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SqlVulnerabilityAssessmentScanRecordListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - scan_id: str, - **kwargs: Any - ) -> _models.SqlVulnerabilityAssessmentScanRecord: - """Get a system database vulnerability assessment scan record. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_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: Required. - :type scan_id: str - :return: SqlVulnerabilityAssessmentScanRecord or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentScanRecord - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 {}) - - system_database_name: Literal["master"] = kwargs.pop( - "system_database_name", _params.pop("systemDatabaseName", "master") - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[_models.SqlVulnerabilityAssessmentScanRecord] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - scan_id=scan_id, - subscription_id=self._config.subscription_id, - system_database_name=system_database_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("SqlVulnerabilityAssessmentScanRecord", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index cfac9a835cd6..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessments_operations.py +++ /dev/null @@ -1,149 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar, Union - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_delete_request( - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -class SqlVulnerabilityAssessmentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`sql_vulnerability_assessments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - **kwargs: Any - ) -> None: - """Removes SQL Vulnerability Assessment. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" - Required. - :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore 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 deleted file mode 100644 index 2b12a804400d..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessments_settings_operations.py +++ /dev/null @@ -1,450 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_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", "2022-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/sqlVulnerabilityAssessments", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-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}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -class SqlVulnerabilityAssessmentsSettingsOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`sql_vulnerability_assessments_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.SqlVulnerabilityAssessment"]: - """Lists SQL 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 - :return: An iterator like instance of either SqlVulnerabilityAssessment or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SqlVulnerabilityAssessment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) - cls: ClsType[_models.SqlVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SqlVulnerabilityAssessmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.SqlVulnerabilityAssessmentName], - **kwargs: Any - ) -> _models.SqlVulnerabilityAssessment: - """Gets SQL Vulnerability Assessment 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 vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" - Required. - :type vulnerability_assessment_name: str or - ~azure.mgmt.sql.models.SqlVulnerabilityAssessmentName - :return: SqlVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-11-01-preview")) - cls: ClsType[_models.SqlVulnerabilityAssessment] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("SqlVulnerabilityAssessment", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: _models.SqlVulnerabilityAssessment, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SqlVulnerabilityAssessment: - """Creates or updates SQL Vulnerability Assessment 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 vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" - Required. - :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName - :param parameters: The requested resource. Required. - :type parameters: ~azure.mgmt.sql.models.SqlVulnerabilityAssessment - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: SqlVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.SqlVulnerabilityAssessment: - """Creates or updates SQL Vulnerability Assessment 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 vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" - Required. - :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName - :param parameters: The requested resource. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: SqlVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - server_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: Union[_models.SqlVulnerabilityAssessment, IO[bytes]], - **kwargs: Any - ) -> _models.SqlVulnerabilityAssessment: - """Creates or updates SQL Vulnerability Assessment 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 vulnerability_assessment_name: The name of the SQL Vulnerability Assessment. "default" - Required. - :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName - :param parameters: The requested resource. Is either a SqlVulnerabilityAssessment type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.SqlVulnerabilityAssessment or IO[bytes] - :return: SqlVulnerabilityAssessment or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SqlVulnerabilityAssessment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-11-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SqlVulnerabilityAssessment") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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) - - deserialized = self._deserialize("SqlVulnerabilityAssessment", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 30af31d5364a..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_start_stop_managed_instance_schedules_operations.py +++ /dev/null @@ -1,536 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_instance_request( - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/startStopSchedules", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - managed_instance_name: str, - start_stop_schedule_name: Union[str, _models.StartStopScheduleName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/startStopSchedules/{startStopScheduleName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "startStopScheduleName": _SERIALIZER.url("start_stop_schedule_name", start_stop_schedule_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - managed_instance_name: str, - start_stop_schedule_name: Union[str, _models.StartStopScheduleName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-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}/startStopSchedules/{startStopScheduleName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "startStopScheduleName": _SERIALIZER.url("start_stop_schedule_name", start_stop_schedule_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - managed_instance_name: str, - start_stop_schedule_name: Union[str, _models.StartStopScheduleName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/startStopSchedules/{startStopScheduleName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "startStopScheduleName": _SERIALIZER.url("start_stop_schedule_name", start_stop_schedule_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -class StartStopManagedInstanceSchedulesOperations: # pylint: disable=name-too-long - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`start_stop_managed_instance_schedules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.StartStopManagedInstanceSchedule"]: - """Lists the managed instance's Start/Stop schedules. - - :param resource_group_name: The name of the resource group that 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 - :return: An iterator like instance of either StartStopManagedInstanceSchedule or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.StartStopManagedInstanceSchedule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.StartStopManagedInstanceScheduleListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("StartStopManagedInstanceScheduleListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - managed_instance_name: str, - start_stop_schedule_name: Union[str, _models.StartStopScheduleName], - **kwargs: Any - ) -> _models.StartStopManagedInstanceSchedule: - """Gets the managed instance's Start/Stop schedule. - - :param resource_group_name: The name of the resource group that 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 start_stop_schedule_name: Name of the managed instance Start/Stop schedule. "default" - Required. - :type start_stop_schedule_name: str or ~azure.mgmt.sql.models.StartStopScheduleName - :return: StartStopManagedInstanceSchedule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.StartStopManagedInstanceSchedule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - cls: ClsType[_models.StartStopManagedInstanceSchedule] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - start_stop_schedule_name=start_stop_schedule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("StartStopManagedInstanceSchedule", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - start_stop_schedule_name: Union[str, _models.StartStopScheduleName], - parameters: _models.StartStopManagedInstanceSchedule, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.StartStopManagedInstanceSchedule: - """Creates or updates the managed instance's Start/Stop schedule. - - :param resource_group_name: The name of the resource group that 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 start_stop_schedule_name: Name of the managed instance Start/Stop schedule. "default" - Required. - :type start_stop_schedule_name: str or ~azure.mgmt.sql.models.StartStopScheduleName - :param parameters: The requested managed instance Start/Stop schedule. Required. - :type parameters: ~azure.mgmt.sql.models.StartStopManagedInstanceSchedule - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: StartStopManagedInstanceSchedule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.StartStopManagedInstanceSchedule - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - start_stop_schedule_name: Union[str, _models.StartStopScheduleName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.StartStopManagedInstanceSchedule: - """Creates or updates the managed instance's Start/Stop schedule. - - :param resource_group_name: The name of the resource group that 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 start_stop_schedule_name: Name of the managed instance Start/Stop schedule. "default" - Required. - :type start_stop_schedule_name: str or ~azure.mgmt.sql.models.StartStopScheduleName - :param parameters: The requested managed instance Start/Stop schedule. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: StartStopManagedInstanceSchedule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.StartStopManagedInstanceSchedule - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - managed_instance_name: str, - start_stop_schedule_name: Union[str, _models.StartStopScheduleName], - parameters: Union[_models.StartStopManagedInstanceSchedule, IO[bytes]], - **kwargs: Any - ) -> _models.StartStopManagedInstanceSchedule: - """Creates or updates the managed instance's Start/Stop schedule. - - :param resource_group_name: The name of the resource group that 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 start_stop_schedule_name: Name of the managed instance Start/Stop schedule. "default" - Required. - :type start_stop_schedule_name: str or ~azure.mgmt.sql.models.StartStopScheduleName - :param parameters: The requested managed instance Start/Stop schedule. Is either a - StartStopManagedInstanceSchedule type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.StartStopManagedInstanceSchedule or IO[bytes] - :return: StartStopManagedInstanceSchedule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.StartStopManagedInstanceSchedule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - 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, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "StartStopManagedInstanceSchedule") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - start_stop_schedule_name=start_stop_schedule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _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) - - deserialized = self._deserialize("StartStopManagedInstanceSchedule", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - managed_instance_name: str, - start_stop_schedule_name: Union[str, _models.StartStopScheduleName], - **kwargs: Any - ) -> None: - """Deletes the managed instance's Start/Stop schedule. - - :param resource_group_name: The name of the resource group that 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 start_stop_schedule_name: Name of the managed instance Start/Stop schedule. "default" - Required. - :type start_stop_schedule_name: str or ~azure.mgmt.sql.models.StartStopScheduleName - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-08-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, - start_stop_schedule_name=start_stop_schedule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_subscription_usages_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_subscription_usages_operations.py deleted file mode 100644 index 35f6691501ba..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_subscription_usages_operations.py +++ /dev/null @@ -1,232 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_location_request(location_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/usages" - ) - path_format_arguments = { - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(location_name: str, usage_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/usages/{usageName}", - ) - path_format_arguments = { - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "usageName": _SERIALIZER.url("usage_name", usage_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class SubscriptionUsagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`subscription_usages` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_location(self, location_name: str, **kwargs: Any) -> ItemPaged["_models.SubscriptionUsage"]: - """Gets all subscription usage metrics in a given location. - - :param location_name: The name of the region where the resource is located. Required. - :type location_name: str - :return: An iterator like instance of either SubscriptionUsage or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SubscriptionUsage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SubscriptionUsageListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SubscriptionUsageListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, location_name: str, usage_name: str, **kwargs: Any) -> _models.SubscriptionUsage: - """Gets a subscription usage metric. - - :param location_name: The name of the region where the resource is located. Required. - :type location_name: str - :param usage_name: Name of usage metric to return. Required. - :type usage_name: str - :return: SubscriptionUsage or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SubscriptionUsage - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SubscriptionUsage] = kwargs.pop("cls", None) - - _request = build_get_request( - location_name=location_name, - usage_name=usage_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("SubscriptionUsage", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index d46fc66b539f..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_synapse_link_workspaces_operations.py +++ /dev/null @@ -1,165 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_database_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/linkWorkspaces", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _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 SynapseLinkWorkspacesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`synapse_link_workspaces` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.SynapseLinkWorkspace"]: - """Gets all synapselink workspaces 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 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 - :return: An iterator like instance of either SynapseLinkWorkspace or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SynapseLinkWorkspace] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - cls: ClsType[_models.SynapseLinkWorkspaceListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SynapseLinkWorkspaceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) 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 deleted file mode 100644 index cc1a169ccf49..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sync_agents_operations.py +++ /dev/null @@ -1,826 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, server_name: str, sync_agent_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "syncAgentName": _SERIALIZER.url("sync_agent_name", sync_agent_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, server_name: str, sync_agent_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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}/syncAgents/{syncAgentName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "syncAgentName": _SERIALIZER.url("sync_agent_name", sync_agent_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, server_name: str, sync_agent_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "syncAgentName": _SERIALIZER.url("sync_agent_name", sync_agent_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_generate_key_request( - resource_group_name: str, server_name: str, sync_agent_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}/generateKey", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "syncAgentName": _SERIALIZER.url("sync_agent_name", sync_agent_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_linked_databases_request( - resource_group_name: str, server_name: str, sync_agent_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}/linkedDatabases", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "syncAgentName": _SERIALIZER.url("sync_agent_name", sync_agent_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class SyncAgentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`sync_agents` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get(self, resource_group_name: str, server_name: str, sync_agent_name: str, **kwargs: Any) -> _models.SyncAgent: - """Gets a sync agent. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param sync_agent_name: The name of the sync agent. Required. - :type sync_agent_name: str - :return: SyncAgent or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SyncAgent - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncAgent] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - sync_agent_name=sync_agent_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("SyncAgent", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - sync_agent_name: str, - parameters: Union[_models.SyncAgent, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "SyncAgent") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - sync_agent_name=sync_agent_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - sync_agent_name: str, - parameters: _models.SyncAgent, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.SyncAgent]: - """Creates or updates a sync agent. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param sync_agent_name: The name of the sync agent. Required. - :type sync_agent_name: str - :param parameters: The requested sync agent resource state. Required. - :type parameters: ~azure.mgmt.sql.models.SyncAgent - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either SyncAgent or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncAgent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - sync_agent_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.SyncAgent]: - """Creates or updates a sync agent. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param sync_agent_name: The name of the sync agent. Required. - :type sync_agent_name: str - :param parameters: The requested sync agent resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either SyncAgent or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncAgent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - sync_agent_name: str, - parameters: Union[_models.SyncAgent, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.SyncAgent]: - """Creates or updates a sync agent. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param sync_agent_name: The name of the sync agent. Required. - :type sync_agent_name: str - :param parameters: The requested sync agent resource state. Is either a SyncAgent type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.SyncAgent or IO[bytes] - :return: An instance of LROPoller that returns either SyncAgent or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncAgent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SyncAgent] = 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, - sync_agent_name=sync_agent_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SyncAgent", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.SyncAgent].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.SyncAgent]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, server_name: str, sync_agent_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - sync_agent_name=sync_agent_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, server_name: str, sync_agent_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes a sync agent. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param sync_agent_name: The name of the sync agent. Required. - :type sync_agent_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - sync_agent_name=sync_agent_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either SyncAgent or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SyncAgent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncAgentListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @distributed_trace - def generate_key( - self, resource_group_name: str, server_name: str, sync_agent_name: str, **kwargs: Any - ) -> _models.SyncAgentKeyProperties: - """Generates a sync agent key. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param sync_agent_name: The name of the sync agent. Required. - :type sync_agent_name: str - :return: SyncAgentKeyProperties or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SyncAgentKeyProperties - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncAgentKeyProperties] = kwargs.pop("cls", None) - - _request = build_generate_key_request( - resource_group_name=resource_group_name, - server_name=server_name, - sync_agent_name=sync_agent_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("SyncAgentKeyProperties", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_linked_databases( - self, resource_group_name: str, server_name: str, sync_agent_name: str, **kwargs: Any - ) -> ItemPaged["_models.SyncAgentLinkedDatabase"]: - """Lists databases linked to a sync agent. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this 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 - :param sync_agent_name: The name of the sync agent. Required. - :type sync_agent_name: str - :return: An iterator like instance of either SyncAgentLinkedDatabase or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SyncAgentLinkedDatabase] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncAgentLinkedDatabaseListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_linked_databases_request( - resource_group_name=resource_group_name, - server_name=server_name, - sync_agent_name=sync_agent_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SyncAgentLinkedDatabaseListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sync_groups_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sync_groups_operations.py deleted file mode 100644 index 097d1bdb2a97..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sync_groups_operations.py +++ /dev/null @@ -1,1616 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_sync_database_ids_request(location_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/syncDatabaseIds", - ) - path_format_arguments = { - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_refresh_hub_schema_request( - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/refreshHubSchema", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_list_hub_schemas_request( - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/hubSchemas", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_logs_request( - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - subscription_id: str, - *, - start_time: str, - end_time: str, - type: Union[str, _models.SyncGroupsType], - continuation_token_parameter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["startTime"] = _SERIALIZER.query("start_time", start_time, "str") - _params["endTime"] = _SERIALIZER.query("end_time", end_time, "str") - _params["type"] = _SERIALIZER.query("type", type, "str") - if continuation_token_parameter is not None: - _params["continuationToken"] = _SERIALIZER.query( - "continuation_token_parameter", continuation_token_parameter, "str" - ) - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cancel_sync_request( - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/cancelSync", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_trigger_sync_request( - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/triggerSync", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_get_request( - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_update_request( - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", 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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class SyncGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`sync_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_sync_database_ids( - self, location_name: str, **kwargs: Any - ) -> ItemPaged["_models.SyncDatabaseIdProperties"]: - """Gets a collection of sync database ids. - - :param location_name: The name of the region where the resource is located. Required. - :type location_name: str - :return: An iterator like instance of either SyncDatabaseIdProperties or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SyncDatabaseIdProperties] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncDatabaseIdListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_sync_database_ids_request( - location_name=location_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SyncDatabaseIdListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _refresh_hub_schema_initial( - self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - 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. - :type resource_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 - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._refresh_hub_schema_initial( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_hub_schemas( - self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any - ) -> ItemPaged["_models.SyncFullSchemaProperties"]: - """Gets a collection of hub database schemas. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database on which the sync group is hosted. Required. - :type database_name: str - :param sync_group_name: The name of the sync group. Required. - :type sync_group_name: str - :return: An iterator like instance of either SyncFullSchemaProperties or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SyncFullSchemaProperties] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncFullSchemaPropertiesListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @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 - ) -> ItemPaged["_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 - :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", "2020-11-01-preview")) - cls: ClsType[_models.SyncGroupLogListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_cancel_sync_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - sync_group_name=sync_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @distributed_trace - def trigger_sync( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any - ) -> None: - """Triggers a sync group synchronization. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database on which the sync group is hosted. Required. - :type database_name: str - :param sync_group_name: The name of the sync group. Required. - :type sync_group_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_trigger_sync_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - sync_group_name=sync_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @distributed_trace - def get( - self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any - ) -> _models.SyncGroup: - """Gets a sync group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database on which the sync group is hosted. Required. - :type database_name: str - :param sync_group_name: The name of the sync group. Required. - :type sync_group_name: str - :return: SyncGroup or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SyncGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncGroup] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - sync_group_name=sync_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - 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[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - 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 - ) -> 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. - :type resource_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 - :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_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **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. - :type resource_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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - parameters: Union[_models.SyncGroup, IO[bytes]], - **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. - :type resource_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. Is either a SyncGroup type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.SyncGroup or IO[bytes] - :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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SyncGroup] = kwargs.pop("cls", None) - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SyncGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.SyncGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.SyncGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes a sync group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - parameters: Union[_models.SyncGroup, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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. Is either a SyncGroup type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.SyncGroup or IO[bytes] - :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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SyncGroup] = kwargs.pop("cls", None) - 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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SyncGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.SyncGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.SyncGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :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", "2020-11-01-preview")) - cls: ClsType[_models.SyncGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sync_members_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sync_members_operations.py deleted file mode 100644 index fd62a94be58d..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sync_members_operations.py +++ /dev/null @@ -1,1290 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - sync_member_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, "str"), - "syncMemberName": _SERIALIZER.url("sync_member_name", sync_member_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - sync_member_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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/{syncMemberName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, "str"), - "syncMemberName": _SERIALIZER.url("sync_member_name", sync_member_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, "str"), - "syncMemberName": _SERIALIZER.url("sync_member_name", sync_member_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_update_request( - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - sync_member_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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/{syncMemberName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, "str"), - "syncMemberName": _SERIALIZER.url("sync_member_name", sync_member_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_sync_group_request( - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_member_schemas_request( - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - sync_member_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}/schemas", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, "str"), - "syncMemberName": _SERIALIZER.url("sync_member_name", sync_member_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_refresh_member_schema_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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}/refreshSchema", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "syncGroupName": _SERIALIZER.url("sync_group_name", sync_group_name, "str"), - "syncMemberName": _SERIALIZER.url("sync_member_name", sync_member_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -class SyncMembersOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`sync_members` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - sync_group_name: str, - sync_member_name: str, - **kwargs: Any - ) -> _models.SyncMember: - """Gets a sync member. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :return: SyncMember or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SyncMember - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncMember] = 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, - sync_member_name=sync_member_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("SyncMember", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - sync_member_name: str, - parameters: Union[_models.SyncMember, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "SyncMember") - - _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, - sync_member_name=sync_member_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - sync_member_name: str, - parameters: _models.SyncMember, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.SyncMember]: - """Creates or updates a sync member. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :param parameters: The requested sync member resource state. Required. - :type parameters: ~azure.mgmt.sql.models.SyncMember - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either SyncMember or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncMember] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - sync_member_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.SyncMember]: - """Creates or updates a sync member. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :param parameters: The requested sync member resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either SyncMember or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncMember] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - sync_member_name: str, - parameters: Union[_models.SyncMember, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.SyncMember]: - """Creates or updates a sync member. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :param parameters: The requested sync member resource state. Is either a SyncMember type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.SyncMember or IO[bytes] - :return: An instance of LROPoller that returns either SyncMember or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncMember] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SyncMember] = 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, - sync_member_name=sync_member_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SyncMember", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.SyncMember].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.SyncMember]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - sync_member_name: str, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - sync_member_name: str, - **kwargs: Any - ) -> LROPoller[None]: - """Deletes a sync member. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - sync_group_name=sync_group_name, - sync_member_name=sync_member_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - sync_member_name: str, - parameters: Union[_models.SyncMember, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "SyncMember") - - _request = build_update_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - sync_member_name: str, - parameters: _models.SyncMember, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.SyncMember]: - """Updates an existing sync member. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :param parameters: The requested sync member resource state. Required. - :type parameters: ~azure.mgmt.sql.models.SyncMember - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either SyncMember or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncMember] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - sync_member_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.SyncMember]: - """Updates an existing sync member. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :param parameters: The requested sync member resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either SyncMember or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncMember] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - sync_member_name: str, - parameters: Union[_models.SyncMember, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.SyncMember]: - """Updates an existing sync member. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :param parameters: The requested sync member resource state. Is either a SyncMember type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.SyncMember or IO[bytes] - :return: An instance of LROPoller that returns either SyncMember or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncMember] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SyncMember] = 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( - 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, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SyncMember", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.SyncMember].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.SyncMember]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list_by_sync_group( - self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either SyncMember or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SyncMember] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncMemberListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - @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 - ) -> ItemPaged["_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 - :return: An iterator like instance of either SyncFullSchemaProperties or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SyncFullSchemaProperties] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncFullSchemaPropertiesListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) - - def _refresh_member_schema_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - sync_member_name: str, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_refresh_member_schema_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_refresh_member_schema( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - sync_member_name: str, - **kwargs: Any - ) -> LROPoller[None]: - """Refreshes a sync member database schema. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._refresh_member_schema_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - sync_group_name=sync_group_name, - sync_member_name=sync_member_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_tde_certificates_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_tde_certificates_operations.py deleted file mode 100644 index 892fea524bca..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_tde_certificates_operations.py +++ /dev/null @@ -1,277 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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/servers/{serverName}/tdeCertificates", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class TdeCertificatesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`tde_certificates` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - def _create_initial( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.TdeCertificate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "TdeCertificate") - - _request = build_create_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create( - self, - resource_group_name: str, - server_name: str, - parameters: _models.TdeCertificate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Creates a TDE certificate for a given server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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: The requested TDE certificate to be created or updated. Required. - :type parameters: ~azure.mgmt.sql.models.TdeCertificate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - server_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Creates a TDE certificate for a given server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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: The requested TDE certificate to be created or updated. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @distributed_trace - def begin_create( - self, - resource_group_name: str, - server_name: str, - parameters: Union[_models.TdeCertificate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[None]: - """Creates a TDE certificate for a given server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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: The requested TDE certificate to be created or updated. Is either a - TdeCertificate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.TdeCertificate or IO[bytes] - :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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[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._create_initial( - resource_group_name=resource_group_name, - server_name=server_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_time_zones_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_time_zones_operations.py deleted file mode 100644 index 921d47b6c57c..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_time_zones_operations.py +++ /dev/null @@ -1,232 +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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_location_request(location_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/timeZones" - ) - path_format_arguments = { - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(location_name: str, time_zone_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/timeZones/{timeZoneId}", - ) - path_format_arguments = { - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "timeZoneId": _SERIALIZER.url("time_zone_id", time_zone_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class TimeZonesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`time_zones` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_location(self, location_name: str, **kwargs: Any) -> ItemPaged["_models.TimeZone"]: - """Gets a list of managed instance time zones by location. - - :param location_name: Required. - :type location_name: str - :return: An iterator like instance of either TimeZone or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.TimeZone] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.TimeZoneListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("TimeZoneListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, location_name: str, time_zone_id: str, **kwargs: Any) -> _models.TimeZone: - """Gets a managed instance time zone. - - :param location_name: Required. - :type location_name: str - :param time_zone_id: Required. - :type time_zone_id: str - :return: TimeZone or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.TimeZone - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.TimeZone] = kwargs.pop("cls", None) - - _request = build_get_request( - location_name=location_name, - time_zone_id=time_zone_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("TimeZone", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_transparent_data_encryptions_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_transparent_data_encryptions_operations.py deleted file mode 100644 index 31c6b1a814be..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_transparent_data_encryptions_operations.py +++ /dev/null @@ -1,546 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_database_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-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}/transparentDataEncryption", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - server_name: str, - database_name: str, - tde_name: Union[str, _models.TransparentDataEncryptionName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-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}/transparentDataEncryption/{tdeName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "tdeName": _SERIALIZER.url("tde_name", tde_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - server_name: str, - database_name: str, - tde_name: Union[str, _models.TransparentDataEncryptionName], - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-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}/transparentDataEncryption/{tdeName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "tdeName": _SERIALIZER.url("tde_name", tde_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -class TransparentDataEncryptionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`transparent_data_encryptions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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 - ) -> ItemPaged["_models.LogicalDatabaseTransparentDataEncryption"]: - """Gets a list of the logical database's transparent data encryption. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the logical database for which the transparent data - encryption is defined. Required. - :type database_name: str - :return: An iterator like instance of either LogicalDatabaseTransparentDataEncryption or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[_models.LogicalDatabaseTransparentDataEncryptionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("LogicalDatabaseTransparentDataEncryptionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, - resource_group_name: str, - server_name: str, - database_name: str, - tde_name: Union[str, _models.TransparentDataEncryptionName], - **kwargs: Any - ) -> _models.LogicalDatabaseTransparentDataEncryption: - """Gets a logical database's transparent data encryption. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the logical database for which the transparent data - encryption is defined. Required. - :type database_name: str - :param tde_name: The name of the transparent data encryption configuration. "current" Required. - :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName - :return: LogicalDatabaseTransparentDataEncryption or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - cls: ClsType[_models.LogicalDatabaseTransparentDataEncryption] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - tde_name=tde_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("LogicalDatabaseTransparentDataEncryption", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - tde_name: Union[str, _models.TransparentDataEncryptionName], - parameters: Union[_models.LogicalDatabaseTransparentDataEncryption, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2022-08-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "LogicalDatabaseTransparentDataEncryption") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - tde_name=tde_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - tde_name: Union[str, _models.TransparentDataEncryptionName], - parameters: _models.LogicalDatabaseTransparentDataEncryption, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.LogicalDatabaseTransparentDataEncryption]: - """Updates a logical database's transparent data encryption configuration. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the logical database for which the security alert policy is - defined. Required. - :type database_name: str - :param tde_name: The name of the transparent data encryption configuration. "current" Required. - :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName - :param parameters: The database transparent data encryption. Required. - :type parameters: ~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either LogicalDatabaseTransparentDataEncryption - or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - tde_name: Union[str, _models.TransparentDataEncryptionName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.LogicalDatabaseTransparentDataEncryption]: - """Updates a logical database's transparent data encryption configuration. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the logical database for which the security alert policy is - defined. Required. - :type database_name: str - :param tde_name: The name of the transparent data encryption configuration. "current" Required. - :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName - :param parameters: The database transparent data encryption. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either LogicalDatabaseTransparentDataEncryption - or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - tde_name: Union[str, _models.TransparentDataEncryptionName], - parameters: Union[_models.LogicalDatabaseTransparentDataEncryption, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.LogicalDatabaseTransparentDataEncryption]: - """Updates a logical database's transparent data encryption configuration. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the logical database for which the security alert policy is - defined. Required. - :type database_name: str - :param tde_name: The name of the transparent data encryption configuration. "current" Required. - :type tde_name: str or ~azure.mgmt.sql.models.TransparentDataEncryptionName - :param parameters: The database transparent data encryption. Is either a - LogicalDatabaseTransparentDataEncryption type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption or IO[bytes] - :return: An instance of LROPoller that returns either LogicalDatabaseTransparentDataEncryption - or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LogicalDatabaseTransparentDataEncryption] - :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", "2022-08-01-preview")) - 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) - 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, - tde_name=tde_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize( - "LogicalDatabaseTransparentDataEncryption", pipeline_response.http_response - ) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.LogicalDatabaseTransparentDataEncryption].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.LogicalDatabaseTransparentDataEncryption]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 021eb409e038..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_usages_operations.py +++ /dev/null @@ -1,171 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -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.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_instance_pool_request( - resource_group_name: str, - instance_pool_name: str, - subscription_id: str, - *, - expand_children: Optional[bool] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}/usages", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "instancePoolName": _SERIALIZER.url("instance_pool_name", instance_pool_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if expand_children is not None: - _params["expandChildren"] = _SERIALIZER.query("expand_children", expand_children, "bool") - _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 UsagesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`usages` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_instance_pool( - self, resource_group_name: str, instance_pool_name: str, expand_children: Optional[bool] = None, **kwargs: Any - ) -> ItemPaged["_models.Usage"]: - """Gets all instance pool usage 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 instance_pool_name: The name of the instance pool to be retrieved. Required. - :type instance_pool_name: str - :param expand_children: Optional request parameter to include managed instance usages within - the instance pool. Default value is None. - :type expand_children: bool - :return: An iterator like instance of either Usage or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.Usage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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_pool_request( - resource_group_name=resource_group_name, - instance_pool_name=instance_pool_name, - subscription_id=self._config.subscription_id, - expand_children=expand_children, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("UsageListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_virtual_clusters_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_virtual_clusters_operations.py deleted file mode 100644 index cfc95394305e..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_virtual_clusters_operations.py +++ /dev/null @@ -1,825 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/virtualClusters") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, virtual_cluster_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters/{virtualClusterName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "virtualClusterName": _SERIALIZER.url("virtual_cluster_name", virtual_cluster_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, virtual_cluster_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters/{virtualClusterName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "virtualClusterName": _SERIALIZER.url("virtual_cluster_name", virtual_cluster_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_update_request( - resource_group_name: str, virtual_cluster_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - 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/virtualClusters/{virtualClusterName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "virtualClusterName": _SERIALIZER.url("virtual_cluster_name", virtual_cluster_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_dns_servers_request( - resource_group_name: str, virtual_cluster_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/virtualClusters/{virtualClusterName}/updateManagedInstanceDnsServers", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "virtualClusterName": _SERIALIZER.url("virtual_cluster_name", virtual_cluster_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class VirtualClustersOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`virtual_clusters` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_models.VirtualCluster"]: - """Gets a list of all virtualClusters in the subscription. - - :return: An iterator like instance of either VirtualCluster or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.VirtualCluster] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - cls: ClsType[_models.VirtualClusterListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualClusterListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.VirtualCluster"]: - """Gets a list of virtual clusters in a resource group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :return: An iterator like instance of either VirtualCluster or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.VirtualCluster] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - cls: ClsType[_models.VirtualClusterListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualClusterListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, resource_group_name: str, virtual_cluster_name: str, **kwargs: Any) -> _models.VirtualCluster: - """Gets a virtual cluster. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param virtual_cluster_name: The name of the virtual cluster. Required. - :type virtual_cluster_name: str - :return: VirtualCluster or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.VirtualCluster - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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", "2022-05-01-preview")) - cls: ClsType[_models.VirtualCluster] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - virtual_cluster_name=virtual_cluster_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("VirtualCluster", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _delete_initial(self, resource_group_name: str, virtual_cluster_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2022-05-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - virtual_cluster_name=virtual_cluster_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete(self, resource_group_name: str, virtual_cluster_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes a virtual cluster. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param virtual_cluster_name: The name of the virtual cluster. Required. - :type virtual_cluster_name: str - :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", "2022-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_initial( - resource_group_name=resource_group_name, - virtual_cluster_name=virtual_cluster_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - virtual_cluster_name: str, - parameters: Union[_models.VirtualClusterUpdate, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2022-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "VirtualClusterUpdate") - - _request = build_update_request( - resource_group_name=resource_group_name, - virtual_cluster_name=virtual_cluster_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - virtual_cluster_name: str, - parameters: _models.VirtualClusterUpdate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualCluster]: - """Updates an existing virtual cluster. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param virtual_cluster_name: The name of the virtual cluster. Required. - :type virtual_cluster_name: str - :param parameters: The requested virtual cluster resource state. Required. - :type parameters: ~azure.mgmt.sql.models.VirtualClusterUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualCluster or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.VirtualCluster] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - virtual_cluster_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualCluster]: - """Updates an existing virtual cluster. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param virtual_cluster_name: The name of the virtual cluster. Required. - :type virtual_cluster_name: str - :param parameters: The requested virtual cluster resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualCluster or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.VirtualCluster] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - virtual_cluster_name: str, - parameters: Union[_models.VirtualClusterUpdate, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualCluster]: - """Updates an existing virtual cluster. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param virtual_cluster_name: The name of the virtual cluster. Required. - :type virtual_cluster_name: str - :param parameters: The requested virtual cluster resource state. Is either a - VirtualClusterUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.VirtualClusterUpdate or IO[bytes] - :return: An instance of LROPoller that returns either VirtualCluster or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.VirtualCluster] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - 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) - 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( - resource_group_name=resource_group_name, - virtual_cluster_name=virtual_cluster_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualCluster", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.VirtualCluster].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualCluster]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_dns_servers_initial( - self, resource_group_name: str, virtual_cluster_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2022-05-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_update_dns_servers_request( - resource_group_name=resource_group_name, - virtual_cluster_name=virtual_cluster_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_update_dns_servers( - self, resource_group_name: str, virtual_cluster_name: str, **kwargs: Any - ) -> LROPoller[_models.UpdateVirtualClusterDnsServersOperation]: - """Synchronizes the DNS server settings used by the managed instances inside the given virtual - cluster. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param virtual_cluster_name: The name of the virtual cluster. Required. - :type virtual_cluster_name: str - :return: An instance of LROPoller that returns either UpdateVirtualClusterDnsServersOperation - or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.UpdateVirtualClusterDnsServersOperation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - 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) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_dns_servers_initial( - resource_group_name=resource_group_name, - virtual_cluster_name=virtual_cluster_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("UpdateVirtualClusterDnsServersOperation", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.UpdateVirtualClusterDnsServersOperation].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.UpdateVirtualClusterDnsServersOperation]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_virtual_network_rules_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_virtual_network_rules_operations.py deleted file mode 100644 index 5c4e528d4421..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_virtual_network_rules_operations.py +++ /dev/null @@ -1,631 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, server_name: str, virtual_network_rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "virtualNetworkRuleName": _SERIALIZER.url("virtual_network_rule_name", virtual_network_rule_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, server_name: str, virtual_network_rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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}/virtualNetworkRules/{virtualNetworkRuleName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "virtualNetworkRuleName": _SERIALIZER.url("virtual_network_rule_name", virtual_network_rule_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, server_name: str, virtual_network_rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "virtualNetworkRuleName": _SERIALIZER.url("virtual_network_rule_name", virtual_network_rule_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class VirtualNetworkRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`virtual_network_rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, resource_group_name: str, server_name: str, virtual_network_rule_name: str, **kwargs: Any - ) -> _models.VirtualNetworkRule: - """Gets a virtual network rule. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param virtual_network_rule_name: The name of the virtual network rule. Required. - :type virtual_network_rule_name: str - :return: VirtualNetworkRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.VirtualNetworkRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.VirtualNetworkRule] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - virtual_network_rule_name=virtual_network_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("VirtualNetworkRule", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - virtual_network_rule_name: str, - parameters: Union[_models.VirtualNetworkRule, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "VirtualNetworkRule") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - virtual_network_rule_name=virtual_network_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - virtual_network_rule_name: str, - parameters: _models.VirtualNetworkRule, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualNetworkRule]: - """Creates or updates an existing virtual network rule. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param virtual_network_rule_name: The name of the virtual network rule. Required. - :type virtual_network_rule_name: str - :param parameters: The requested virtual Network Rule Resource state. Required. - :type parameters: ~azure.mgmt.sql.models.VirtualNetworkRule - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualNetworkRule or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.VirtualNetworkRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - virtual_network_rule_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.VirtualNetworkRule]: - """Creates or updates an existing virtual network rule. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param virtual_network_rule_name: The name of the virtual network rule. Required. - :type virtual_network_rule_name: str - :param parameters: The requested virtual Network Rule Resource state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either VirtualNetworkRule or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.VirtualNetworkRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - virtual_network_rule_name: str, - parameters: Union[_models.VirtualNetworkRule, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.VirtualNetworkRule]: - """Creates or updates an existing virtual network rule. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param virtual_network_rule_name: The name of the virtual network rule. Required. - :type virtual_network_rule_name: str - :param parameters: The requested virtual Network Rule Resource state. Is either a - VirtualNetworkRule type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.VirtualNetworkRule or IO[bytes] - :return: An instance of LROPoller that returns either VirtualNetworkRule or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.VirtualNetworkRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualNetworkRule] = 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, - virtual_network_rule_name=virtual_network_rule_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualNetworkRule", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.VirtualNetworkRule].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.VirtualNetworkRule]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, server_name: str, virtual_network_rule_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - virtual_network_rule_name=virtual_network_rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, server_name: str, virtual_network_rule_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes the virtual network rule with the given name. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param virtual_network_rule_name: The name of the virtual network rule. Required. - :type virtual_network_rule_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - virtual_network_rule_name=virtual_network_rule_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either VirtualNetworkRule or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.VirtualNetworkRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.VirtualNetworkRuleListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index fa7db3db3cc0..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_workload_classifiers_operations.py +++ /dev/null @@ -1,733 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - server_name: str, - database_name: str, - workload_group_name: str, - workload_classifier_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, "str"), - "workloadClassifierName": _SERIALIZER.url("workload_classifier_name", workload_classifier_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - server_name: str, - database_name: str, - workload_group_name: str, - workload_classifier_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, "str"), - "workloadClassifierName": _SERIALIZER.url("workload_classifier_name", workload_classifier_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, "str"), - "workloadClassifierName": _SERIALIZER.url("workload_classifier_name", workload_classifier_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_list_by_workload_group_request( - resource_group_name: str, - server_name: str, - database_name: str, - workload_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class WorkloadClassifiersOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`workload_classifiers` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, - workload_group_name: str, - workload_classifier_name: str, - **kwargs: Any - ) -> _models.WorkloadClassifier: - """Gets a workload classifier. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 classifier - from. Required. - :type workload_group_name: str - :param workload_classifier_name: The name of the workload classifier. Required. - :type workload_classifier_name: str - :return: WorkloadClassifier or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.WorkloadClassifier - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.WorkloadClassifier] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - workload_group_name=workload_group_name, - workload_classifier_name=workload_classifier_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("WorkloadClassifier", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - workload_group_name: str, - workload_classifier_name: str, - parameters: Union[_models.WorkloadClassifier, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "WorkloadClassifier") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - workload_group_name=workload_group_name, - workload_classifier_name=workload_classifier_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - workload_group_name: str, - workload_classifier_name: str, - parameters: _models.WorkloadClassifier, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.WorkloadClassifier]: - """Creates or updates a workload classifier. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 classifier - from. Required. - :type workload_group_name: str - :param workload_classifier_name: The name of the workload classifier to create/update. - Required. - :type workload_classifier_name: str - :param parameters: The properties of the workload classifier. Required. - :type parameters: ~azure.mgmt.sql.models.WorkloadClassifier - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either WorkloadClassifier or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.WorkloadClassifier] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - workload_group_name: str, - workload_classifier_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.WorkloadClassifier]: - """Creates or updates a workload classifier. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 classifier - from. Required. - :type workload_group_name: str - :param workload_classifier_name: The name of the workload classifier to create/update. - Required. - :type workload_classifier_name: str - :param parameters: The properties of the workload classifier. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either WorkloadClassifier or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.WorkloadClassifier] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - workload_group_name: str, - workload_classifier_name: str, - parameters: Union[_models.WorkloadClassifier, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.WorkloadClassifier]: - """Creates or updates a workload classifier. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 classifier - from. Required. - :type workload_group_name: str - :param workload_classifier_name: The name of the workload classifier to create/update. - Required. - :type workload_classifier_name: str - :param parameters: The properties of the workload classifier. Is either a WorkloadClassifier - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.WorkloadClassifier or IO[bytes] - :return: An instance of LROPoller that returns either WorkloadClassifier or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.WorkloadClassifier] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.WorkloadClassifier] = 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, - workload_group_name=workload_group_name, - workload_classifier_name=workload_classifier_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("WorkloadClassifier", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.WorkloadClassifier].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.WorkloadClassifier]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - workload_group_name: str, - workload_classifier_name: str, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - workload_group_name=workload_group_name, - workload_classifier_name=workload_classifier_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, - resource_group_name: str, - server_name: str, - database_name: str, - workload_group_name: str, - workload_classifier_name: str, - **kwargs: Any - ) -> LROPoller[None]: - """Deletes a workload classifier. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 classifier - from. Required. - :type workload_group_name: str - :param workload_classifier_name: The name of the workload classifier to delete. Required. - :type workload_classifier_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - workload_group_name=workload_group_name, - workload_classifier_name=workload_classifier_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_by_workload_group( - self, resource_group_name: str, server_name: str, database_name: str, workload_group_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either WorkloadClassifier or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.WorkloadClassifier] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.WorkloadClassifierListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 deleted file mode 100644 index e8871be6d31f..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_workload_groups_operations.py +++ /dev/null @@ -1,672 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 .._configuration import SqlManagementClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request( - resource_group_name: str, - server_name: str, - database_name: str, - workload_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - server_name: str, - database_name: str, - workload_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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}/workloadGroups/{workloadGroupName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - server_name: str, - database_name: str, - workload_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_list_by_database_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - 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", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "serverName": _SERIALIZER.url("server_name", server_name, "str"), - "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _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 WorkloadGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`workload_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: SqlManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = 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, workload_group_name: str, **kwargs: Any - ) -> _models.WorkloadGroup: - """Gets a workload group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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. Required. - :type workload_group_name: str - :return: WorkloadGroup or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.WorkloadGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.WorkloadGroup] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - workload_group_name=workload_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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("WorkloadGroup", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - database_name: str, - workload_group_name: str, - parameters: Union[_models.WorkloadGroup, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, "WorkloadGroup") - - _request = build_create_or_update_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, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - workload_group_name: str, - parameters: _models.WorkloadGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.WorkloadGroup]: - """Creates or updates a workload group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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. Required. - :type workload_group_name: str - :param parameters: The requested workload group state. Required. - :type parameters: ~azure.mgmt.sql.models.WorkloadGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either WorkloadGroup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.WorkloadGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - workload_group_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.WorkloadGroup]: - """Creates or updates a workload group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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. Required. - :type workload_group_name: str - :param parameters: The requested workload group state. Required. - :type parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either WorkloadGroup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.WorkloadGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - workload_group_name: str, - parameters: Union[_models.WorkloadGroup, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.WorkloadGroup]: - """Creates or updates a workload group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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. Required. - :type workload_group_name: str - :param parameters: The requested workload group state. Is either a WorkloadGroup type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.sql.models.WorkloadGroup or IO[bytes] - :return: An instance of LROPoller that returns either WorkloadGroup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.WorkloadGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.WorkloadGroup] = 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, - workload_group_name=workload_group_name, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("WorkloadGroup", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.WorkloadGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.WorkloadGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, server_name: str, database_name: str, workload_group_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, server_name: str, database_name: str, workload_group_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes a workload group. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_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 to delete. Required. - :type workload_group_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - workload_group_name=workload_group_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> ItemPaged["_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 - :return: An iterator like instance of either WorkloadGroup or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.WorkloadGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.WorkloadGroupListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _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) 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 791adee8ea39..dadec3bbeed3 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_azure_ad_administrators.begin_create_or_update( @@ -47,6 +46,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: 2025-02-01-preview/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 d0ba60ce7eb1..cde83c0499f6 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/administrator_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/administrator_delete.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.server_azure_ad_administrators.begin_delete( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AdministratorDelete.json +# x-ms-original-file: 2025-02-01-preview/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 b0ef4ad6a635..335a0cd41eb7 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/administrator_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/administrator_get.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_azure_ad_administrators.get( @@ -39,6 +38,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: 2025-02-01-preview/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 1a0117389d91..ad0261cb2ccb 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/administrator_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/administrator_list.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_azure_ad_administrators.list_by_server( @@ -39,6 +38,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: 2025-02-01-preview/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 41ab912e67f6..29674bbdff8f 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_azure_ad_only_authentications.begin_create_or_update( @@ -40,6 +39,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: 2025-02-01-preview/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 a2ae8c43f5b4..9b2809bdf36b 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.server_azure_ad_only_authentications.begin_delete( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AzureADOnlyAuthDelete.json +# x-ms-original-file: 2025-02-01-preview/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 26fb5e5bcff4..68b4e049bfd7 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_azure_ad_only_authentications.get( @@ -39,6 +38,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: 2025-02-01-preview/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 04cb08f8e76e..f67aed9e84ef 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_azure_ad_only_authentications.list_by_server( @@ -39,6 +38,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: 2025-02-01-preview/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 5594595098c2..7f55f4ba5095 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.database_operations.cancel( @@ -39,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/CancelDatabaseOperation.json +# x-ms-original-file: 2025-02-01-preview/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 6aa0732410d6..667f3a035e41 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.elastic_pool_operations.cancel( @@ -39,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CancelElasticPoolOperation.json +# x-ms-original-file: 2025-02-01-preview/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 8ad9c350eadb..73943a705610 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.job_executions.cancel( @@ -40,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CancelJobExecution.json +# x-ms-original-file: 2025-02-01-preview/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 19a392bb13e7..680e4c85efa2 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.managed_instance_operations.cancel( @@ -38,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CancelManagedInstanceOperation.json +# x-ms-original-file: 2025-02-01-preview/CancelManagedInstanceOperation.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/change_long_term_retention_backup_access_tier.py b/sdk/sql/azure-mgmt-sql/generated_samples/change_long_term_retention_backup_access_tier.py index 72167567fd8c..eec5cb86d8aa 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/change_long_term_retention_backup_access_tier.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/change_long_term_retention_backup_access_tier.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_term_retention_backups.begin_change_access_tier( @@ -41,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/ChangeLongTermRetentionBackupAccessTier.json +# x-ms-original-file: 2025-02-01-preview/ChangeLongTermRetentionBackupAccessTier.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/check_name_availability_server_already_exists.py b/sdk/sql/azure-mgmt-sql/generated_samples/check_name_availability_server_already_exists.py index 864dc7aa1207..342086062455 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.check_name_availability( @@ -37,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/CheckNameAvailabilityServerAlreadyExists.json +# x-ms-original-file: 2025-02-01-preview/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 70da6917a40d..67e2adb477e7 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.check_name_availability( @@ -37,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/CheckNameAvailabilityServerAvailable.json +# x-ms-original-file: 2025-02-01-preview/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 2859e100d078..44ca3cb0dd06 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.check_name_availability( @@ -37,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/CheckNameAvailabilityServerInvalid.json +# x-ms-original-file: 2025-02-01-preview/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 e1ac702eaf19..da2d4d651ce7 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sensitivity_labels.create_or_update( @@ -40,6 +39,7 @@ def main(): column_name="myColumn", parameters={ "properties": { + "clientClassificationSource": "Native", "informationType": "PhoneNumber", "informationTypeId": "d22fa6e9-5ee4-3bde-4c2b-a409604c4646", "labelId": "bf91e08c-f4f0-478a-b016-25164b2a65ff", @@ -51,6 +51,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: 2025-02-01-preview/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 e2b7125df46a..90d0e8096ee1 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.sensitivity_labels.delete( @@ -41,6 +40,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ColumnSensitivityLabelDelete.json +# x-ms-original-file: 2025-02-01-preview/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 60c4a72b93ef..573404db8757 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sensitivity_labels.get( @@ -43,6 +42,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: 2025-02-01-preview/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 d2699ecfe62e..ea64d6e8aa47 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_columns.list_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 7cc748a21a4c..3ea9b9def606 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_columns.list_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 5614b6719370..d73fe528c83f 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_create_or_update( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseConfiguredBackupStorageRedundancy.json +# x-ms-original-file: 2025-02-01-preview/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 a360ef91c475..faceb8de7bf0 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_create_or_update( @@ -47,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseCopyMode.json +# x-ms-original-file: 2025-02-01-preview/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 e95bf02f5a6e..2e88a8eba43e 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_create_or_update( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseDefaultEnclave.json +# x-ms-original-file: 2025-02-01-preview/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 2278321c6f79..84da2aa892ab 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_create_or_update( @@ -48,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseDefaultMode.json +# x-ms-original-file: 2025-02-01-preview/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 9f6f7220ef6b..10574b7125f7 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_create_or_update( @@ -59,6 +59,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseDefaultModeWithKeysAndEncryptionProtector.json +# x-ms-original-file: 2025-02-01-preview/CreateDatabaseDefaultModeWithKeysAndEncryptionProtector.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_default_mode_with_versionless_keys_and_versionless_encryption_protector.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_default_mode_with_versionless_keys_and_versionless_encryption_protector.py new file mode 100644 index 000000000000..f3e9d4e84043 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_default_mode_with_versionless_keys_and_versionless_encryption_protector.py @@ -0,0 +1,64 @@ +# pylint: disable=line-too-long,useless-suppression +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python create_database_default_mode_with_versionless_keys_and_versionless_encryption_protector.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.databases.begin_create_or_update( + resource_group_name="Default-SQL-SouthEastAsia", + server_name="testsvr", + database_name="testdb", + parameters={ + "identity": { + "type": "UserAssigned", + "userAssignedIdentities": { + "/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.ManagedIdentity/userAssignedIdentities/umi": {} + }, + }, + "location": "southeastasia", + "properties": { + "collation": "SQL_Latin1_General_CP1_CI_AS", + "createMode": "Default", + "encryptionProtector": "https://your-key-vault-name.vault.azure.net/yourKey", + "keys": { + "https://your-key-vault-name.vault.azure.net/yourKey": {}, + "https://your-key-vault-name.vault.azure.net/yourKey2": {}, + }, + "maxSizeBytes": 1073741824, + }, + "sku": {"name": "S0", "tier": "Standard"}, + }, + ).result() + print(response) + + +# x-ms-original-file: 2025-02-01-preview/CreateDatabaseDefaultModeWithVersionlessKeysAndVersionlessEncryptionProtector.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 d4407f9c2ce1..3ee586d8dc3c 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_create_or_update( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseLedger.json +# x-ms-original-file: 2025-02-01-preview/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 1739a761cdb9..f532fb2d1f67 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_create_or_update( @@ -49,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseMaintenanceConfiguration.json +# x-ms-original-file: 2025-02-01-preview/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 5fec663c86a9..36ceda72e5af 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_create_or_update( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseMin.json +# x-ms-original-file: 2025-02-01-preview/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 7de9c4feb2ed..47ee52606120 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_create_or_update( @@ -48,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseNamedReplica.json +# x-ms-original-file: 2025-02-01-preview/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 730ba06e0516..e7004aed53a0 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_create_or_update( @@ -47,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabasePITRMode.json +# x-ms-original-file: 2025-02-01-preview/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 b28a160c75e7..e91f349510c6 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_create_or_update( @@ -48,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseSecondaryMode.json +# x-ms-original-file: 2025-02-01-preview/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 ed7b806890cc..abe86db34608 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_create_or_update( @@ -48,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseStandbyMode.json +# x-ms-original-file: 2025-02-01-preview/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 7fa358ea67a1..a5fa5fccdb5f 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_create_or_update( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseVBSEnclave.json +# x-ms-original-file: 2025-02-01-preview/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 ee1ac2f2e006..1e8baeb702c0 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_create_or_update( @@ -49,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseWithAvailabilityZone.json +# x-ms-original-file: 2025-02-01-preview/CreateDatabaseWithAvailabilityZone.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_with_encryption_protector_auto_rotation.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_with_encryption_protector_auto_rotation.py new file mode 100644 index 000000000000..a1f7968d39a6 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_with_encryption_protector_auto_rotation.py @@ -0,0 +1,61 @@ +# pylint: disable=line-too-long,useless-suppression +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python create_database_with_encryption_protector_auto_rotation.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.databases.begin_create_or_update( + resource_group_name="Default-SQL-SouthEastAsia", + server_name="testsvr", + database_name="testdb", + parameters={ + "identity": { + "type": "UserAssigned", + "userAssignedIdentities": { + "/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.ManagedIdentity/userAssignedIdentities/umi": {} + }, + }, + "location": "southeastasia", + "properties": { + "collation": "SQL_Latin1_General_CP1_CI_AS", + "createMode": "Default", + "encryptionProtector": "https://your-key-vault-name.vault.azure.net/yourKey/yourKeyVersion", + "encryptionProtectorAutoRotation": True, + "maxSizeBytes": 1073741824, + }, + "sku": {"name": "S0", "tier": "Standard"}, + }, + ).result() + print(response) + + +# x-ms-original-file: 2025-02-01-preview/CreateDatabaseWithEncryptionProtectorAutoRotation.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 b10c2e643d65..0769a08a0e66 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_create_or_update( @@ -47,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDwDatabaseCrossSubscriptionPITR.json +# x-ms-original-file: 2025-02-01-preview/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 e1a97e872416..0cbb65a8d162 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_create_or_update( @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDwDatabaseCrossSubscriptionRecovery.json +# x-ms-original-file: 2025-02-01-preview/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 d19571e8b205..a4ceba450dc9 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_create_or_update( @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDwDatabaseCrossSubscriptionRestore.json +# x-ms-original-file: 2025-02-01-preview/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 2952ffe7b57e..4f3ff5baa386 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.elastic_pools.begin_create_or_update( @@ -48,6 +47,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: 2025-02-01-preview/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 75d227e6b2c0..eefd7da9b1b7 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.job_executions.begin_create( @@ -40,6 +39,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: 2025-02-01-preview/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 0ad797435e38..2fa8add7cfbe 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_databases.begin_create_or_update( @@ -40,6 +39,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: 2025-02-01-preview/CreateManagedDatabaseLedger.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_managed_short_term_retention_policy.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_managed_short_term_retention_policy.py new file mode 100644 index 000000000000..e9015b382cb2 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_managed_short_term_retention_policy.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python create_managed_short_term_retention_policy.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.managed_backup_short_term_retention_policies.begin_create_or_update( + resource_group_name="resourceGroup", + managed_instance_name="testsvr", + database_name="testdb", + policy_name="default", + parameters={"properties": {"retentionDays": 14}}, + ).result() + print(response) + + +# x-ms-original-file: 2025-02-01-preview/CreateManagedShortTermRetentionPolicy.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/create_managed_short_term_retention_policy_restorable_dropped.py similarity index 62% rename from sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_activity_list.py rename to sdk/sql/azure-mgmt-sql/generated_samples/create_managed_short_term_retention_policy_restorable_dropped.py index 7aa1b4bd5110..ba041b3dc8a0 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_activity_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_managed_short_term_retention_policy_restorable_dropped.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -16,7 +15,7 @@ pip install azure-identity pip install azure-mgmt-sql # USAGE - python elastic_pool_activity_list.py + python create_managed_short_term_retention_policy_restorable_dropped.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, @@ -28,18 +27,19 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) - 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) + response = client.managed_restorable_dropped_database_backup_short_term_retention_policies.begin_create_or_update( + resource_group_name="resourceGroup", + managed_instance_name="testsvr", + restorable_dropped_database_id="testdb,131403269876900000", + policy_name="default", + parameters={"properties": {"retentionDays": 14}}, + ).result() + print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01-legacy/examples/ElasticPoolActivityList.json +# x-ms-original-file: 2025-02-01-preview/CreateManagedShortTermRetentionPolicyRestorableDropped.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 f43eceddbd0a..aa8ab2f43e76 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="a1c0814d-3c18-4e1e-a247-c128c12b1677", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_extensions.begin_create_or_update( @@ -48,6 +48,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: 2025-02-01-preview/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 98cffd87a431..5e61f27f82b8 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.instance_pools.begin_create_or_update( @@ -49,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateOrUpdateInstancePoolMax.json +# x-ms-original-file: 2025-02-01-preview/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 072ee5bed2ec..19d9e2f90f52 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.instance_pools.begin_create_or_update( @@ -47,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateOrUpdateInstancePoolMin.json +# x-ms-original-file: 2025-02-01-preview/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 37f37ba277ca..bdc02833a524 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.job_agents.begin_create_or_update( @@ -45,6 +45,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: 2025-02-01-preview/CreateOrUpdateJobAgent.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_agent_with_identity.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_agent_with_identity.py new file mode 100644 index 000000000000..6fef46271f75 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_agent_with_identity.py @@ -0,0 +1,56 @@ +# pylint: disable=line-too-long,useless-suppression +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python create_or_update_job_agent_with_identity.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.job_agents.begin_create_or_update( + resource_group_name="group1", + server_name="server1", + job_agent_name="agent1", + parameters={ + "identity": { + "type": "UserAssigned", + "userAssignedIdentities": { + "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-umi": {} + }, + }, + "location": "southeastasia", + "properties": { + "databaseId": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/databases/db1" + }, + }, + ).result() + print(response) + + +# x-ms-original-file: 2025-02-01-preview/CreateOrUpdateJobAgentWithIdentity.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_agent_with_sku.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_agent_with_sku.py new file mode 100644 index 000000000000..f0eb863be151 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_agent_with_sku.py @@ -0,0 +1,51 @@ +# pylint: disable=line-too-long,useless-suppression +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python create_or_update_job_agent_with_sku.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.job_agents.begin_create_or_update( + resource_group_name="group1", + server_name="server1", + job_agent_name="agent1", + parameters={ + "location": "southeastasia", + "properties": { + "databaseId": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/databases/db1" + }, + "sku": {"name": "JA400"}, + }, + ).result() + print(response) + + +# x-ms-original-file: 2025-02-01-preview/CreateOrUpdateJobAgentWithSku.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 c2824c8ad589..840863eb5c34 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.job_credentials.create_or_update( @@ -41,6 +40,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: 2025-02-01-preview/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 42ff8b44119a..b5edd03323ed 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.job_executions.begin_create_or_update( @@ -41,6 +40,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: 2025-02-01-preview/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 473e5a694583..ba3a3f5f7aee 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.jobs.create_or_update( @@ -52,6 +51,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: 2025-02-01-preview/CreateOrUpdateJobMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_min.py new file mode 100644 index 000000000000..c00e20b11ce9 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_min.py @@ -0,0 +1,68 @@ +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python create_or_update_job_min.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.jobs.create_or_update( + resource_group_name="group1", + server_name="server1", + job_agent_name="agent1", + job_name="job1", + parameters={ + "id": "str", + "name": "str", + "properties": { + "description": "str", + "schedule": { + "enabled": bool, + "endTime": "2020-02-20 00:00:00", + "interval": "str", + "startTime": "2020-02-20 00:00:00", + "type": "str", + }, + "version": 0, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ) + print(response) + + +# x-ms-original-file: 2025-02-01-preview/CreateOrUpdateJobMin.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_private_endpoint.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_private_endpoint.py index 44a1d290bb3a..35f351aefb3a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_private_endpoint.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_private_endpoint.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.job_private_endpoints.begin_create_or_update( @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateOrUpdateJobPrivateEndpoint.json +# x-ms-original-file: 2025-02-01-preview/CreateOrUpdateJobPrivateEndpoint.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_step_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_step_max.py index a67def32a025..fd8b78a8694a 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.job_steps.create_or_update( @@ -66,6 +66,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: 2025-02-01-preview/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 3399bd8ee67c..1ffcded2b140 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.job_steps.create_or_update( @@ -40,7 +40,6 @@ def main(): parameters={ "properties": { "action": {"value": "select 1"}, - "credential": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/credentials/cred0", "targetGroup": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/targetGroups/targetGroup0", } }, @@ -48,6 +47,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: 2025-02-01-preview/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 456d9a6cf259..a12297b242ba 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.job_target_groups.create_or_update( @@ -72,6 +72,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: 2025-02-01-preview/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 07e13637acfd..157120565228 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.job_target_groups.create_or_update( @@ -41,6 +40,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: 2025-02-01-preview/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 83c8ee379ad4..56096412fbe2 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,20 +27,20 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.maintenance_windows.create_or_update( resource_group_name="Default-SQL-SouthEastAsia", server_name="testsvr", database_name="testdwdb", - maintenance_window_name="current", parameters={ "properties": {"timeRanges": [{"dayOfWeek": "Saturday", "duration": "PT60M", "startTime": "00:00:00"}]} }, + maintenance_window_name="current", ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateMaintenanceWindows.json +# x-ms-original-file: 2025-02-01-preview/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 2468c56546a7..20ea5030aaea 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.workload_classifiers.begin_create_or_update( @@ -51,6 +50,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: 2025-02-01-preview/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 8646e029ad49..bedf5555ad25 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.workload_classifiers.begin_create_or_update( @@ -42,6 +41,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: 2025-02-01-preview/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 c3252f220c5b..e142e7bdcd84 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.workload_groups.begin_create_or_update( @@ -50,6 +49,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: 2025-02-01-preview/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 a980a2d11865..865306b50e72 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.workload_groups.begin_create_or_update( @@ -43,6 +42,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: 2025-02-01-preview/CreateOrUpdateWorkloadGroupMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_short_term_retention_policy.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_short_term_retention_policy.py new file mode 100644 index 000000000000..02af0837769b --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_short_term_retention_policy.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python create_short_term_retention_policy.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.backup_short_term_retention_policies.begin_create_or_update( + resource_group_name="resourceGroup", + server_name="testsvr", + database_name="testdb", + policy_name="default", + parameters={"properties": {"diffBackupIntervalInHours": 24, "retentionDays": 7}}, + ).result() + print(response) + + +# x-ms-original-file: 2025-02-01-preview/CreateShortTermRetentionPolicy.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 5b202589adce..1a294593b3f0 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_create_or_update( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateVCoreDatabaseByServiceObjective.json +# x-ms-original-file: 2025-02-01-preview/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 887681b22680..7d519dc29ddb 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_create_or_update( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateVCoreDatabaseBySkuNameCapacity.json +# x-ms-original-file: 2025-02-01-preview/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 0cabf573bae6..7ea93a027624 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,18 +27,19 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.data_masking_policies.create_or_update( 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: 2025-02-01-preview/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 4a6d76ba9388..397b23e43920 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,18 +27,19 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.data_masking_policies.create_or_update( 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: 2025-02-01-preview/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 8f68212383e6..c02118512380 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,17 +27,18 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.data_masking_policies.get( 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: 2025-02-01-preview/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 a4c82c46c0a7..10455da59905 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,13 +27,14 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.data_masking_rules.create_or_update( 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": { @@ -50,6 +50,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: 2025-02-01-preview/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 ed1b4f3a9f6e..93e01e165069 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,13 +27,14 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.data_masking_rules.create_or_update( 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 +48,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: 2025-02-01-preview/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 a467ab625d23..970c0501bd84 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,13 +27,14 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.data_masking_rules.create_or_update( 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": { @@ -50,6 +50,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: 2025-02-01-preview/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 2e7305aa24a9..41393023216d 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,13 +27,14 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.data_masking_rules.create_or_update( 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": { @@ -51,6 +51,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: 2025-02-01-preview/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 80% 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 7aba3aef2948..09164b7b5ffe 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -16,7 +15,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, @@ -28,18 +27,19 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.data_masking_rules.list_by_database( 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: 2025-02-01-preview/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 461efb4b1f80..5972098f2560 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.restore_points.get( @@ -40,6 +39,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: 2025-02-01-preview/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 1a3a9ece5b4e..5c30cb4b97a6 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.restore_points.list_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 ee55a2bf8be5..ea9c27987613 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_advanced_threat_protection_settings.create_or_update( @@ -41,6 +40,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: 2025-02-01-preview/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 01586043ce03..d5c43bb0765d 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_advanced_threat_protection_settings.create_or_update( @@ -41,6 +40,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: 2025-02-01-preview/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 bb1cfc0c311b..495da9feac04 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_advanced_threat_protection_settings.get( @@ -40,6 +39,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: 2025-02-01-preview/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 6ac5b8bfb4d6..7c1a6b5ea6f7 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_advanced_threat_protection_settings.list_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 22de1121b07c..da636f901af2 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_advisors.get( @@ -40,6 +39,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: 2025-02-01-preview/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 7c9e5c365f96..3ecf6576236a 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_advisors.list_by_database( @@ -39,6 +38,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: 2025-02-01-preview/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 887abf079231..b49315d4258b 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_advisors.update( @@ -41,6 +40,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: 2025-02-01-preview/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 1e890a1fdcbd..34ed692a84b9 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_blob_auditing_policies.list_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 23735b90287e..82d4ca2a5359 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="c3aa9078-0000-0000-0000-e36f151182d7", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_automatic_tuning.get( @@ -39,6 +38,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: 2025-02-01-preview/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 da5d4d53fd15..916f62e3f789 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="c3aa9078-0000-0000-0000-e36f151182d7", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_automatic_tuning.update( @@ -49,6 +48,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: 2025-02-01-preview/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 3a5231272025..607fe7eab9ab 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="c3aa9078-0000-0000-0000-e36f151182d7", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_automatic_tuning.update( @@ -40,6 +39,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: 2025-02-01-preview/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 96de5e4bdb73..d34f47cfc78c 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_blob_auditing_policies.create_or_update( @@ -40,6 +39,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: 2025-02-01-preview/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 3d695ff928bf..54b6fdf2d8e3 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_blob_auditing_policies.create_or_update( @@ -56,6 +56,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: 2025-02-01-preview/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 e8b7d51a8ac7..5b9f1f92b4dc 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_blob_auditing_policies.create_or_update( @@ -46,6 +46,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: 2025-02-01-preview/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 e7dcb84e2445..61e3d82f5605 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_blob_auditing_policies.get( @@ -39,6 +38,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: 2025-02-01-preview/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 9cfb513efd91..50370a8888d7 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_columns.get( @@ -42,6 +41,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: 2025-02-01-preview/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 630a5db0f311..ef69044be163 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_columns.list_by_table( @@ -42,6 +41,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: 2025-02-01-preview/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 4fc7690e0d3a..6f9541ae1ec0 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.database_encryption_protectors.begin_revalidate( @@ -39,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/DatabaseEncryptionProtectorRevalidate.json +# x-ms-original-file: 2025-02-01-preview/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 a94ca33330ec..64ed3023e086 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.database_encryption_protectors.begin_revert( @@ -39,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/DatabaseEncryptionProtectorRevert.json +# x-ms-original-file: 2025-02-01-preview/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 bbcb4462292a..f8d4c2e500dd 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.extended_database_blob_auditing_policies.list_by_database( @@ -40,6 +39,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: 2025-02-01-preview/DatabaseExtendedAuditingSettingsList.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/database_metrics_definitions_list.py deleted file mode 100644 index b90eecf5235c..000000000000 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_metrics_definitions_list.py +++ /dev/null @@ -1,45 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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_definitions_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.databases.list_metric_definitions( - resource_group_name="sqlcrudtest-6730", - server_name="sqlcrudtest-9007", - database_name="3481", - ) - for item in response: - print(item) - - -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/DatabaseMetricsDefinitionsList.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 71672c41d213..000000000000 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_metrics_list_with_filter.py +++ /dev/null @@ -1,46 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 1fd0d22aba35..821cb56ab79d 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_recommended_actions.get( @@ -41,6 +40,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: 2025-02-01-preview/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 099ea54a5009..38858e0bf50c 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_recommended_actions.list_by_database_advisor( @@ -40,6 +39,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: 2025-02-01-preview/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 cc21269ce128..913ea987d929 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_advisors.list_by_database( @@ -39,6 +38,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: 2025-02-01-preview/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 56f591bffff6..99036c98333f 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_recommended_actions.update( @@ -42,6 +41,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: 2025-02-01-preview/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 a60a52bce31b..928f3e8e36d2 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.restore_points.delete( @@ -39,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseRestorePointsDelete.json +# x-ms-original-file: 2025-02-01-preview/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 9aea0ff80a8e..1bf75bcf43b8 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.restore_points.get( @@ -40,6 +39,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: 2025-02-01-preview/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 58b1a91ff767..800968154d49 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.restore_points.list_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 a9a7ca46ea99..e3eb0a2c4df2 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.restore_points.begin_create( @@ -40,6 +39,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: 2025-02-01-preview/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 ca72a06cf2da..dcc7902d0519 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_schemas.get( @@ -40,6 +39,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: 2025-02-01-preview/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 63884f7e6f1d..6f84f8265447 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_schemas.list_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 18ac5535099f..683d79713afd 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_security_alert_policies.create_or_update( @@ -51,6 +51,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: 2025-02-01-preview/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 5001395a51ba..7141e79add5b 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_security_alert_policies.create_or_update( @@ -41,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseSecurityAlertCreateMin.json +# x-ms-original-file: 2025-02-01-preview/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 9772ce9e1b60..170641855023 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_security_alert_policies.get( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseSecurityAlertGet.json +# x-ms-original-file: 2025-02-01-preview/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 c45d70e50e33..46fcdd4ac399 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_security_alert_policies.list_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 843897e5e088..9cdcbb0d99eb 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_sql_vulnerability_assessment_baselines.create_or_update( @@ -50,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentBaselineAdd.json +# x-ms-original-file: 2025-02-01-preview/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 f2436f1c6fba..9d54d8534951 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_sql_vulnerability_assessment_baselines.create_or_update( @@ -42,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentBaselineAddLatest.json +# x-ms-original-file: 2025-02-01-preview/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 b75c899f53a4..c1ae1cb8c9ce 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_sql_vulnerability_assessment_baselines.get( @@ -41,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentBaselineGet.json +# x-ms-original-file: 2025-02-01-preview/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 0eb8e8538cd2..5455cfc6a684 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_sql_vulnerability_assessment_baselines.list_by_sql_vulnerability_assessment( @@ -41,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentBaselineListBySqlVulnerabilityAssessment.json +# x-ms-original-file: 2025-02-01-preview/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 ea1f2f047ec9..b2e1a6616272 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_sql_vulnerability_assessments_settings.get( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentGet.json +# x-ms-original-file: 2025-02-01-preview/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 b557eb124c27..07e0c8ca385b 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_sql_vulnerability_assessments_settings.list_by_database( @@ -40,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentListByDatabase.json +# x-ms-original-file: 2025-02-01-preview/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 76df9b8871f6..6d65ee1a64f1 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_sql_vulnerability_assessment_scan_result.list_by_scan( @@ -42,6 +41,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentListScansResults.json +# x-ms-original-file: 2025-02-01-preview/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 cec78fcb2cff..633315ad1a7e 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_sql_vulnerability_assessment_rule_baselines.create_or_update( @@ -48,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentRuleBaselineCreate.json +# x-ms-original-file: 2025-02-01-preview/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 0068cba22f8e..229601fabd0a 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.database_sql_vulnerability_assessment_rule_baselines.delete( @@ -41,6 +40,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentRuleBaselineDelete.json +# x-ms-original-file: 2025-02-01-preview/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 af04cfaec03e..614fdb8c4045 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_sql_vulnerability_assessment_rule_baselines.get( @@ -42,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentRuleBaselineGet.json +# x-ms-original-file: 2025-02-01-preview/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 e84a3f19e2d7..ed12759bfca3 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_sql_vulnerability_assessment_rule_baselines.list_by_baseline( @@ -42,6 +41,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentRuleBaselineListByBaseline.json +# x-ms-original-file: 2025-02-01-preview/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 ac8b31a9e71b..f9c0a71dfcee 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_sql_vulnerability_assessment_scans.get( @@ -41,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentScan.json +# x-ms-original-file: 2025-02-01-preview/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 9d140945cc29..295bf3aa8fed 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_sql_vulnerability_assessment_scans.list_by_sql_vulnerability_assessments( @@ -41,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentScanRecordsListByDatabase.json +# x-ms-original-file: 2025-02-01-preview/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 ac8b2d313553..23f822c4b085 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.database_sql_vulnerability_assessment_execute_scan.begin_execute( @@ -39,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentScansExecute.json +# x-ms-original-file: 2025-02-01-preview/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 a9112d3a7f64..d69b61730297 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_sql_vulnerability_assessment_scan_result.get( @@ -42,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentScansResults.json +# x-ms-original-file: 2025-02-01-preview/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 50ccd54fe107..e9e3cca2e79c 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_tables.get( @@ -41,6 +40,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: 2025-02-01-preview/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 51b0c5a57a2e..d11d00ff3afc 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_tables.list_by_schema( @@ -41,6 +40,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: 2025-02-01-preview/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 0319dcbfd973..85428ed438e1 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_vulnerability_assessments.create_or_update( @@ -46,6 +45,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: 2025-02-01-preview/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 0f6996730f5e..a3c7c41033d5 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_vulnerability_assessments.create_or_update( @@ -52,6 +51,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: 2025-02-01-preview/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 13db446ede02..25e527685d9e 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_vulnerability_assessments.create_or_update( @@ -46,6 +45,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: 2025-02-01-preview/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 73b9834b4f2b..7efdc743fa7c 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.database_vulnerability_assessments.delete( @@ -39,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentDelete.json +# x-ms-original-file: 2025-02-01-preview/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 6fa801dea4ad..c6d668c32516 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_vulnerability_assessments.get( @@ -40,6 +39,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: 2025-02-01-preview/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 81f8a75652fb..c90a349f8452 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_vulnerability_assessments.list_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 0196a1deb50a..7250d45d57de 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_vulnerability_assessment_rule_baselines.create_or_update( @@ -51,6 +50,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: 2025-02-01-preview/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 7ccdc9328bbd..4c2e1185fc04 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.database_vulnerability_assessment_rule_baselines.delete( @@ -41,6 +40,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentRuleBaselineDelete.json +# x-ms-original-file: 2025-02-01-preview/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 2e85a08094b4..87fa7149b9e6 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_vulnerability_assessment_rule_baselines.get( @@ -42,6 +41,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: 2025-02-01-preview/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 d99f67b7867b..3dd8ab4634a6 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_vulnerability_assessment_scans.export( @@ -41,6 +40,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: 2025-02-01-preview/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 5c2d0f2ca829..1dbbc2cef3e3 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_vulnerability_assessment_scans.get( @@ -41,6 +40,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: 2025-02-01-preview/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 95f36145fc27..e9da8b279e83 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_vulnerability_assessment_scans.list_by_database( @@ -41,6 +40,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: 2025-02-01-preview/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 09bdbcce03f1..9da0833caaf9 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.database_vulnerability_assessment_scans.begin_initiate_scan( @@ -40,6 +39,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentScansExecute.json +# x-ms-original-file: 2025-02-01-preview/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 b3c024eb6510..52f3c9eee100 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/delete_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/delete_database.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.databases.begin_delete( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/DeleteDatabase.json +# x-ms-original-file: 2025-02-01-preview/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 bd94a689a6d8..66bf996b3cb3 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.instance_pools.begin_delete( @@ -37,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DeleteInstancePool.json +# x-ms-original-file: 2025-02-01-preview/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 6a250abaa0bc..ff0253ec5548 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/delete_job.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/delete_job.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.jobs.delete( @@ -39,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeleteJob.json +# x-ms-original-file: 2025-02-01-preview/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 164644de7cca..b4ca4de9707c 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.job_agents.begin_delete( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeleteJobAgent.json +# x-ms-original-file: 2025-02-01-preview/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 576f9887e8c6..3f2afab75ef4 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.job_credentials.delete( @@ -39,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeleteJobCredential.json +# x-ms-original-file: 2025-02-01-preview/DeleteJobCredential.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/delete_job_private_endpoint.py b/sdk/sql/azure-mgmt-sql/generated_samples/delete_job_private_endpoint.py index f116ac28be01..25d0c5f8db78 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/delete_job_private_endpoint.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/delete_job_private_endpoint.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.job_private_endpoints.begin_delete( @@ -39,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DeleteJobPrivateEndpoint.json +# x-ms-original-file: 2025-02-01-preview/DeleteJobPrivateEndpoint.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/delete_job_step.py b/sdk/sql/azure-mgmt-sql/generated_samples/delete_job_step.py index 4ba4f008ba58..0c71a9399ba1 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.job_steps.delete( @@ -40,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeleteJobStep.json +# x-ms-original-file: 2025-02-01-preview/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 e240ea12fd81..a035a93c2512 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.job_target_groups.delete( @@ -39,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeleteJobTargetGroup.json +# x-ms-original-file: 2025-02-01-preview/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 fdc8e86b0474..0acf7bd41df3 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.workload_classifiers.begin_delete( @@ -40,6 +39,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeleteWorkloadClassifier.json +# x-ms-original-file: 2025-02-01-preview/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 2c8f3635f984..8f6d3faa4da6 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.workload_groups.begin_delete( @@ -39,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeleteWorkloadGroup.json +# x-ms-original-file: 2025-02-01-preview/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 b996f92d7e9e..26d28f3799b7 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.deleted_servers.get( @@ -38,6 +37,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: 2025-02-01-preview/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 d87028a82fbf..ce0a3daf3073 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.deleted_servers.list_by_location( @@ -38,6 +37,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: 2025-02-01-preview/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 4c1c967049d7..76613722d5cf 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.deleted_servers.list() @@ -36,6 +35,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: 2025-02-01-preview/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 cdc3b4c1def4..1fafe568e3c5 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.deleted_servers.begin_recover( @@ -38,6 +37,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: 2025-02-01-preview/DeletedServerRecover.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_create_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_create_max.py index afd72b5f1554..a6c679636041 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_create_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_create_max.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.distributed_availability_groups.begin_create_or_update( @@ -50,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-08-01-preview/examples/DistributedAvailabilityGroupsCreateMax.json +# x-ms-original-file: 2025-02-01-preview/DistributedAvailabilityGroupsCreateMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_create_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_create_min.py index b7c67eed1ce3..48722a5d17a8 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_create_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_create_min.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.distributed_availability_groups.begin_create_or_update( @@ -47,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-08-01-preview/examples/DistributedAvailabilityGroupsCreateMin.json +# x-ms-original-file: 2025-02-01-preview/DistributedAvailabilityGroupsCreateMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_delete.py index 91c4f2e8e57e..bc029a0c0796 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.distributed_availability_groups.begin_delete( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-08-01-preview/examples/DistributedAvailabilityGroupsDelete.json +# x-ms-original-file: 2025-02-01-preview/DistributedAvailabilityGroupsDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_failover.py b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_failover.py index 7a3c9cbf1e2a..efe164d8912d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_failover.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_failover.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.distributed_availability_groups.begin_failover( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-08-01-preview/examples/DistributedAvailabilityGroupsFailover.json +# x-ms-original-file: 2025-02-01-preview/DistributedAvailabilityGroupsFailover.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 4e3e617e4863..2488f26ab952 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.distributed_availability_groups.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-08-01-preview/examples/DistributedAvailabilityGroupsGet.json +# x-ms-original-file: 2025-02-01-preview/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 adf01b5bbec7..6c3e0e2bc01b 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.distributed_availability_groups.list_by_instance( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-08-01-preview/examples/DistributedAvailabilityGroupsListByInstance.json +# x-ms-original-file: 2025-02-01-preview/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 index afb0eb28dff3..80fa175d9814 100644 --- 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.distributed_availability_groups.begin_set_role( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-08-01-preview/examples/DistributedAvailabilityGroupsSetRole.json +# x-ms-original-file: 2025-02-01-preview/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 d5f3dfc3d622..e3ce4b0fa67f 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.distributed_availability_groups.begin_update( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-08-01-preview/examples/DistributedAvailabilityGroupsUpdate.json +# x-ms-original-file: 2025-02-01-preview/DistributedAvailabilityGroupsUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_create_or_update_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_create_or_update_max.py index 9c57ac9084e1..abae30513636 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.elastic_pools.begin_create_or_update( @@ -44,6 +43,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: 2025-02-01-preview/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 4b60c88dd804..57a0b658f1ba 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.elastic_pools.begin_create_or_update( @@ -40,6 +39,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: 2025-02-01-preview/ElasticPoolCreateOrUpdateMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_create_or_update_serverless_properties.py b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_create_or_update_serverless_properties.py new file mode 100644 index 000000000000..6be501d0a25e --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_create_or_update_serverless_properties.py @@ -0,0 +1,52 @@ +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python elastic_pool_create_or_update_serverless_properties.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.elastic_pools.begin_create_or_update( + resource_group_name="sqlcrudtest-2369", + server_name="sqlcrudtest-8069", + elastic_pool_name="sqlcrudtest-8102", + parameters={ + "location": "Japan East", + "properties": { + "autoPauseDelay": 60, + "minCapacity": 0.5, + "perDatabaseSettings": {"autoPauseDelay": 80, "maxCapacity": 2, "minCapacity": 0}, + }, + "sku": {"capacity": 2, "name": "GP_S_Gen5_2", "tier": "GeneralPurpose"}, + }, + ).result() + print(response) + + +# x-ms-original-file: 2025-02-01-preview/ElasticPoolCreateOrUpdateServerlessProperties.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_create_or_update_set_maintenance_configuration.py b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_create_or_update_set_maintenance_configuration.py index 08f45b3bf272..3318616da7d6 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.elastic_pools.begin_create_or_update( @@ -45,6 +45,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: 2025-02-01-preview/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 8844ee102083..5ab925686d43 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.elastic_pools.begin_create_or_update( @@ -44,6 +43,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: 2025-02-01-preview/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 ecd174701476..90f519348d28 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.elastic_pools.begin_create_or_update( @@ -44,6 +43,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: 2025-02-01-preview/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 a40b712eee23..000000000000 --- a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_database_activity_list.py +++ /dev/null @@ -1,45 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 d1efb3e59dd3..ecfbb98410ac 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.elastic_pools.begin_delete( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolDelete.json +# x-ms-original-file: 2025-02-01-preview/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 f49584586019..5ce81aab427b 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.elastic_pools.get( @@ -39,6 +38,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: 2025-02-01-preview/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 715e7f746035..df8ff1e24e28 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.elastic_pools.get( @@ -39,6 +38,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: 2025-02-01-preview/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 c9c01a12df23..fb29b44d0c5a 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.elastic_pools.list_by_server( @@ -39,6 +38,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: 2025-02-01-preview/ElasticPoolListByServer.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/elastic_pool_metrics_definitions_list.py deleted file mode 100644 index a285260d5882..000000000000 --- a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_metrics_definitions_list.py +++ /dev/null @@ -1,45 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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_definitions_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_pools.list_metric_definitions( - resource_group_name="sqlcrudtest-6730", - server_name="sqlcrudtest-9007", - elastic_pool_name="3481", - ) - for item in response: - print(item) - - -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ElasticPoolMetricsDefinitionsList.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 644b4901eff5..000000000000 --- a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_metrics_list_with_filter.py +++ /dev/null @@ -1,46 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 a16ba9635630..42eef3888f9a 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.elastic_pools.begin_update( @@ -44,6 +44,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: 2025-02-01-preview/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 e6c6aa418c73..b5b337fa1048 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.elastic_pools.begin_update( @@ -47,6 +46,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: 2025-02-01-preview/ElasticPoolUpdateMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_update_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_update_min.py new file mode 100644 index 000000000000..de13d856ca4d --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_update_min.py @@ -0,0 +1,60 @@ +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python elastic_pool_update_min.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.elastic_pools.begin_update( + resource_group_name="sqlcrudtest-2369", + server_name="sqlcrudtest-8069", + elastic_pool_name="sqlcrudtest-8102", + parameters={ + "properties": { + "autoPauseDelay": 0, + "availabilityZone": "str", + "currentSku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, + "highAvailabilityReplicaCount": 0, + "licenseType": "str", + "maintenanceConfigurationId": "str", + "maxSizeBytes": 0, + "minCapacity": 0.0, + "perDatabaseSettings": {"autoPauseDelay": 0, "maxCapacity": 0.0, "minCapacity": 0.0}, + "preferredEnclaveType": "str", + "zoneRedundant": bool, + }, + "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, + "tags": {"str": "str"}, + }, + ).result() + print(response) + + +# x-ms-original-file: 2025-02-01-preview/ElasticPoolUpdateMin.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 0f48c9b8761f..b71a37390608 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.elastic_pools.begin_update( @@ -44,6 +44,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: 2025-02-01-preview/ElasticPoolUpdateResetMaintenanceConfiguration.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_update_serverless_properties.py b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_update_serverless_properties.py new file mode 100644 index 000000000000..36b55208592e --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_update_serverless_properties.py @@ -0,0 +1,51 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python elastic_pool_update_serverless_properties.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.elastic_pools.begin_update( + resource_group_name="sqlcrudtest-2369", + server_name="sqlcrudtest-8069", + elastic_pool_name="sqlcrudtest-8102", + parameters={ + "properties": { + "autoPauseDelay": 60, + "minCapacity": 0.5, + "perDatabaseSettings": {"autoPauseDelay": 80, "maxCapacity": 2, "minCapacity": 0}, + }, + "sku": {"capacity": 2, "name": "GP_S_Gen5_2", "tier": "GeneralPurpose"}, + }, + ).result() + print(response) + + +# x-ms-original-file: 2025-02-01-preview/ElasticPoolUpdateServerlessProperties.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_update_with_default_preferred_enclave_type.py b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_update_with_default_preferred_enclave_type.py index e61f1e2c7792..e1ad48d82c8e 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.elastic_pools.begin_update( @@ -40,6 +39,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: 2025-02-01-preview/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 2c0f83c1053f..6ba9027da7d0 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.elastic_pools.begin_update( @@ -40,6 +39,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: 2025-02-01-preview/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 8f98206bb5ff..36aeb1c5c1ba 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.encryption_protectors.begin_create_or_update( @@ -46,6 +45,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: 2025-02-01-preview/EncryptionProtectorCreateOrUpdateKeyVault.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/encryption_protector_create_or_update_key_vault_with_versionless_key.py b/sdk/sql/azure-mgmt-sql/generated_samples/encryption_protector_create_or_update_key_vault_with_versionless_key.py new file mode 100644 index 000000000000..751fcfb58e25 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/encryption_protector_create_or_update_key_vault_with_versionless_key.py @@ -0,0 +1,50 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python 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 encryption_protector_create_or_update_key_vault_with_versionless_key.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.encryption_protectors.begin_create_or_update( + resource_group_name="sqlcrudtest-7398", + server_name="sqlcrudtest-4645", + encryption_protector_name="current", + parameters={ + "properties": { + "autoRotationEnabled": False, + "serverKeyName": "someVault_someKey", + "serverKeyType": "AzureKeyVault", + } + }, + ).result() + print(response) + + +# x-ms-original-file: 2025-02-01-preview/EncryptionProtectorCreateOrUpdateKeyVaultWithVersionlessKey.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 ce3739784e9e..67b6f7141e2a 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.encryption_protectors.begin_create_or_update( @@ -40,6 +39,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: 2025-02-01-preview/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 02fa901f566d..a9233a483e46 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.encryption_protectors.get( @@ -39,6 +38,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: 2025-02-01-preview/EncryptionProtectorGet.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/encryption_protector_get_with_versionless_key.py similarity index 73% rename from sdk/sql/azure-mgmt-sql/generated_samples/server_communication_link_get.py rename to sdk/sql/azure-mgmt-sql/generated_samples/encryption_protector_get_with_versionless_key.py index a50d1ac72ba7..c80ce77d5016 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_communication_link_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/encryption_protector_get_with_versionless_key.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -16,7 +15,7 @@ pip install azure-identity pip install azure-mgmt-sql # USAGE - python server_communication_link_get.py + python encryption_protector_get_with_versionless_key.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, @@ -28,17 +27,17 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) - response = client.server_communication_links.get( + response = client.encryption_protectors.get( resource_group_name="sqlcrudtest-7398", server_name="sqlcrudtest-4645", - communication_link_name="link1", + encryption_protector_name="current", ) print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ServerCommunicationLinkGet.json +# x-ms-original-file: 2025-02-01-preview/EncryptionProtectorGetWithVersionlessKey.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 c6ad629e33ae..00d3345def82 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.encryption_protectors.list_by_server( @@ -39,6 +38,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: 2025-02-01-preview/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 cbba73a58a39..0c265f85a555 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.encryption_protectors.begin_revalidate( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/EncryptionProtectorRevalidate.json +# x-ms-original-file: 2025-02-01-preview/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 fd45e42f20b6..a30ca5f873b3 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="38e0dc56-907f-45ba-a97c-74233baad471", + subscription_id="SUBSCRIPTION_ID", ) response = client.endpoint_certificates.get( @@ -39,6 +38,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: 2025-02-01-preview/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 025e04363765..88353c8a6d76 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="38e0dc56-907f-45ba-a97c-74233baad471", + subscription_id="SUBSCRIPTION_ID", ) response = client.endpoint_certificates.list_by_instance( @@ -39,6 +38,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: 2025-02-01-preview/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 361d470ba1f9..4f3784c45e2f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/export_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/export_database.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_export( @@ -47,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ExportDatabase.json +# x-ms-original-file: 2025-02-01-preview/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..7b509cefe009 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/export_database_using_database_extensions.py @@ -0,0 +1,56 @@ +# pylint: disable=line-too-long,useless-suppression +# 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) Python 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="SUBSCRIPTION_ID", + ) + + 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: 2025-02-01-preview/ExportDatabaseUsingDatabaseExtensions.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/export_database_using_database_extensions_with_managed_identity.py b/sdk/sql/azure-mgmt-sql/generated_samples/export_database_using_database_extensions_with_managed_identity.py new file mode 100644 index 000000000000..39c150efa947 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/export_database_using_database_extensions_with_managed_identity.py @@ -0,0 +1,55 @@ +# pylint: disable=line-too-long,useless-suppression +# 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) Python 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_with_managed_identity.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + 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": "/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/rgName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityName", + "authenticationType": "ManagedIdentity", + "operationMode": "Export", + "storageKey": "/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/rgName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityName", + "storageKeyType": "ManagedIdentity", + "storageUri": "https://teststorage.blob.core.windows.net/testcontainer/Manifest.xml", + } + }, + ).result() + print(response) + + +# x-ms-original-file: 2025-02-01-preview/ExportDatabaseUsingDatabaseExtensionsWithManagedIdentity.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/export_database_with_managed_identity.py b/sdk/sql/azure-mgmt-sql/generated_samples/export_database_with_managed_identity.py new file mode 100644 index 000000000000..e61804b32a92 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/export_database_with_managed_identity.py @@ -0,0 +1,51 @@ +# pylint: disable=line-too-long,useless-suppression +# 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) Python 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_with_managed_identity.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.databases.begin_export( + resource_group_name="Default-SQL-SouthEastAsia", + server_name="testsvr", + database_name="testdb", + parameters={ + "administratorLogin": "/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/rgName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityName", + "authenticationType": "ManagedIdentity", + "storageKey": "/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/rgName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityName", + "storageKeyType": "ManagedIdentity", + "storageUri": "https://test.blob.core.windows.net/test.bacpac", + }, + ).result() + print(response) + + +# x-ms-original-file: 2025-02-01-preview/ExportDatabaseWithManagedIdentity.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 3e03220a6d14..3df8bcdd2f2b 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_export( @@ -51,6 +51,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ExportDatabaseWithNetworkIsolation.json +# x-ms-original-file: 2025-02-01-preview/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 5c6cfe7b2328..b5e5f29d3d53 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.extended_database_blob_auditing_policies.create_or_update( @@ -40,6 +39,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: 2025-02-01-preview/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 929baecbb6ed..8a64d665c789 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.extended_database_blob_auditing_policies.create_or_update( @@ -57,6 +57,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: 2025-02-01-preview/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 c07e51bb85e2..1c024745b77a 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.extended_database_blob_auditing_policies.create_or_update( @@ -46,6 +46,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: 2025-02-01-preview/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 063b87c30288..fb868cdebcf2 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.extended_database_blob_auditing_policies.get( @@ -39,6 +38,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: 2025-02-01-preview/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 3b74c2984d0f..04a2515a2132 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.extended_server_blob_auditing_policies.begin_create_or_update( @@ -56,6 +56,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: 2025-02-01-preview/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 4844e8a0c59a..40f62fa69f0e 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.extended_server_blob_auditing_policies.begin_create_or_update( @@ -45,6 +45,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: 2025-02-01-preview/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 db776bf03847..92f10c125631 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.extended_server_blob_auditing_policies.get( @@ -38,6 +37,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: 2025-02-01-preview/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 3577b926a3e4..93bfb8059a30 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/failover_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/failover_database.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.databases.begin_failover( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/FailoverDatabase.json +# x-ms-original-file: 2025-02-01-preview/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 857bf8704ad1..f484756c4284 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.elastic_pools.begin_failover( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/FailoverElasticPool.json +# x-ms-original-file: 2025-02-01-preview/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 54db9ca1974f..52b5d88809a9 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.failover_groups.begin_create_or_update( @@ -54,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FailoverGroupCreateOrUpdate.json +# x-ms-original-file: 2025-02-01-preview/FailoverGroupCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_create_or_update_standby_secondary.py b/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_create_or_update_standby_secondary.py index df16232df257..51eef1dfff21 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_create_or_update_standby_secondary.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_create_or_update_standby_secondary.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.failover_groups.begin_create_or_update( @@ -55,6 +55,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FailoverGroupCreateOrUpdateStandbySecondary.json +# x-ms-original-file: 2025-02-01-preview/FailoverGroupCreateOrUpdateStandbySecondary.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 10577ce97461..f710b08ee1a5 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.failover_groups.begin_delete( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FailoverGroupDelete.json +# x-ms-original-file: 2025-02-01-preview/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 a02190009002..0d38e4fdb089 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.failover_groups.begin_failover( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FailoverGroupFailover.json +# x-ms-original-file: 2025-02-01-preview/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 baee3caed2c5..197c60120086 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.failover_groups.begin_force_failover_allow_data_loss( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FailoverGroupForceFailoverAllowDataLoss.json +# x-ms-original-file: 2025-02-01-preview/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 8c896e433859..7af75f1a2bf2 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.failover_groups.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FailoverGroupGet.json +# x-ms-original-file: 2025-02-01-preview/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 72751e1ca51b..932264406e5d 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.failover_groups.list_by_server( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FailoverGroupList.json +# x-ms-original-file: 2025-02-01-preview/FailoverGroupList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_try_planned_before_forced_failover.py b/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_try_planned_before_forced_failover.py index 0d036f7b87d5..4d9d6d5fe670 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_try_planned_before_forced_failover.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_try_planned_before_forced_failover.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.failover_groups.begin_try_planned_before_forced_failover( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FailoverGroupTryPlannedBeforeForcedFailover.json +# x-ms-original-file: 2025-02-01-preview/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 154d44230a6c..145cc21c7b0e 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.failover_groups.begin_update( @@ -47,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FailoverGroupUpdate.json +# x-ms-original-file: 2025-02-01-preview/FailoverGroupUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_update_standby_secondary.py b/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_update_standby_secondary.py index 7ebeca17278f..f96c0c735c37 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_update_standby_secondary.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_update_standby_secondary.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.failover_groups.begin_update( @@ -48,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FailoverGroupUpdateStandbySecondary.json +# x-ms-original-file: 2025-02-01-preview/FailoverGroupUpdateStandbySecondary.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 be7c84583ea3..b9bbd5a6bf7e 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.managed_instances.begin_failover( @@ -37,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FailoverManagedInstance.json +# x-ms-original-file: 2025-02-01-preview/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 4542dd1b222f..02c917e5eef2 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.firewall_rules.create_or_update( @@ -40,6 +39,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: 2025-02-01-preview/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 471d3d68d896..ef6285a5de0a 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.firewall_rules.delete( @@ -38,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/FirewallRuleDelete.json +# x-ms-original-file: 2025-02-01-preview/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 af0dc0606980..b11e78594dd6 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.firewall_rules.get( @@ -39,6 +38,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: 2025-02-01-preview/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 bca63a1a4485..8814a0c7aa34 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.firewall_rules.list_by_server( @@ -39,6 +38,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: 2025-02-01-preview/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 a28847a147c7..0da7d370c232 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.firewall_rules.replace( @@ -46,6 +45,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: 2025-02-01-preview/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 508009d16b9a..7aa5017a1bac 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.firewall_rules.create_or_update( @@ -40,6 +39,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: 2025-02-01-preview/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 c08ad34e381a..31d9be5dbdca 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.geo_backup_policies.create_or_update( @@ -41,6 +40,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: 2025-02-01-preview/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 547debb1c16d..721316e16bbc 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.geo_backup_policies.get( @@ -40,6 +39,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: 2025-02-01-preview/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 1767d6b8dbc7..49209cd790ef 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,10 +27,10 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) - 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", @@ -40,6 +39,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: 2025-02-01-preview/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 c432c86cf328..ede4fec6c58e 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.data_warehouse_user_activities.get( @@ -40,6 +39,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: 2025-02-01-preview/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 a79d5832e6be..57df9ddb7634 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="a3473687-7581-41e1-ac24-6bcca5843f07", + subscription_id="SUBSCRIPTION_ID", ) client.database_extensions.get( @@ -39,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/GetDatabaseExtensions.json +# x-ms-original-file: 2025-02-01-preview/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 8a5f2909df25..5ea8b78fa6d3 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_usages.list_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 1bfbbbefe7ab..fad8c71e0721 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetDatabaseWithAvailabilityZone.json +# x-ms-original-file: 2025-02-01-preview/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 6dd2608a487c..bba3435f74ce 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.elastic_pools.get( @@ -39,6 +38,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: 2025-02-01-preview/GetElasticPoolWithAvailabilityZone.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_elastic_pool_with_serverless_properties.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_elastic_pool_with_serverless_properties.py new file mode 100644 index 000000000000..ef1908b0f69b --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_elastic_pool_with_serverless_properties.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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python get_elastic_pool_with_serverless_properties.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.elastic_pools.get( + resource_group_name="sqlcrudtest-2369", + server_name="sqlcrudtest-8069", + elastic_pool_name="sqlcrudtest-8102", + ) + print(response) + + +# x-ms-original-file: 2025-02-01-preview/GetElasticPoolWithServerlessProperties.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_instance_pool.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_instance_pool.py index c85a9e4d128a..7c0a99517d7f 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.instance_pools.get( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetInstancePool.json +# x-ms-original-file: 2025-02-01-preview/GetInstancePool.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_instance_pool_operation.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_instance_pool_operation.py new file mode 100644 index 000000000000..7e5d39c17e00 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_instance_pool_operation.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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python get_instance_pool_operation.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.instance_pool_operations.get( + resource_group_name="resource-group", + instance_pool_name="test-instance-pool", + operation_id="c218773b-203f-4c7a-b174-6bd71fe20f72", + ) + print(response) + + +# x-ms-original-file: 2025-02-01-preview/GetInstancePoolOperation.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 f488e5284114..6072b35eb90d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_job.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_job.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.jobs.get( @@ -39,6 +39,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: 2025-02-01-preview/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 98f05593eaee..c5c45a3de46d 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.job_agents.get( @@ -39,6 +38,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: 2025-02-01-preview/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 2047cd06a548..622f6f51e8a2 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.job_credentials.get( @@ -40,6 +39,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: 2025-02-01-preview/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 15d53776ee0d..42ab52719237 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.job_executions.get( @@ -41,6 +40,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: 2025-02-01-preview/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 0beeea101c48..e9484a9af3d0 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.job_step_executions.get( @@ -42,6 +41,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: 2025-02-01-preview/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 3887418d1329..25515eb2d9bd 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.job_target_executions.get( @@ -43,6 +42,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: 2025-02-01-preview/GetJobExecutionTarget.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_job_private_endpoint.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_job_private_endpoint.py index 3d1c97d322b5..4c39eb035e31 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_job_private_endpoint.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_job_private_endpoint.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.job_private_endpoints.get( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetJobPrivateEndpoint.json +# x-ms-original-file: 2025-02-01-preview/GetJobPrivateEndpoint.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_job_step_by_job.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_job_step_by_job.py index adad6725650d..7b6e2e06e56b 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.job_steps.get( @@ -41,6 +40,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: 2025-02-01-preview/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 56fdf4d8fcb5..71c8a229cf21 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.job_steps.get_by_version( @@ -42,6 +41,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: 2025-02-01-preview/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 5f3ce119b4e4..0e1418b5b3c0 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.job_target_groups.get( @@ -40,6 +39,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: 2025-02-01-preview/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 0e3c718a736c..80961c698420 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.job_versions.get( @@ -41,6 +40,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: 2025-02-01-preview/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 8534da39a20d..81d22e401d21 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_backup_short_term_retention_policies.list_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 3799afc9a677..cbe1d01f759d 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_restorable_dropped_database_backup_short_term_retention_policies.list_by_restorable_dropped_database( @@ -40,6 +40,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: 2025-02-01-preview/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 87a0fe307146..b1baf50a0baf 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.maintenance_window_options.get( @@ -40,6 +39,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: 2025-02-01-preview/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 dc3072cfd2b3..c5e2c84a39e0 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.maintenance_windows.get( @@ -40,6 +39,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: 2025-02-01-preview/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 c2212c116de7..a3d11fbeb4fd 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_operations.get( @@ -39,6 +38,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: 2025-02-01-preview/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 16d3c8e0525b..eff06b51e6df 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_backup_short_term_retention_policies.get( @@ -40,6 +39,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: 2025-02-01-preview/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 f8b87ba9d5a9..172bb40e57a2 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_restorable_dropped_database_backup_short_term_retention_policies.get( @@ -40,6 +39,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: 2025-02-01-preview/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 c67aefd63248..8c5ea058ce2d 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.recoverable_managed_databases.get( @@ -39,6 +38,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: 2025-02-01-preview/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 5a35f36fd021..ba2afcf8db50 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.restorable_dropped_databases.get( @@ -39,6 +38,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: 2025-02-01-preview/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 2484cd2b03dd..a7a93ede9d36 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.restorable_dropped_databases.get( @@ -39,6 +38,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: 2025-02-01-preview/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 661c3b257304..d731e913c84e 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.restorable_dropped_managed_databases.get( @@ -39,6 +38,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: 2025-02-01-preview/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 97effda95bbe..95f4c1c96f25 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.backup_short_term_retention_policies.get( @@ -40,6 +39,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: 2025-02-01-preview/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 e11c2cd13430..11d3e87be9d9 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabase.json +# x-ms-original-file: 2025-02-01-preview/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 ed3e9bb646f6..ff9061a9c6cd 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabaseDefaultEnclave.json +# x-ms-original-file: 2025-02-01-preview/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 9ded92f389b2..a5a081d2eb92 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabaseVBSEnclave.json +# x-ms-original-file: 2025-02-01-preview/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 627dd5f578c4..14ca8818dbbe 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabaseWithExpandEqualsKeys.json +# x-ms-original-file: 2025-02-01-preview/GetVCoreDatabaseWithExpandEqualsKeys.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database_with_expand_equals_keys_with_versionless_keys.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database_with_expand_equals_keys_with_versionless_keys.py new file mode 100644 index 000000000000..ea62421f048d --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database_with_expand_equals_keys_with_versionless_keys.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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python get_vcore_database_with_expand_equals_keys_with_versionless_keys.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.databases.get( + resource_group_name="Default-SQL-SouthEastAsia", + server_name="testsvr", + database_name="testdb", + ) + print(response) + + +# x-ms-original-file: 2025-02-01-preview/GetVCoreDatabaseWithExpandEqualsKeysWithVersionlessKeys.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 ccd7d7ff56f5..216ea30e0c49 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.workload_classifiers.get( @@ -41,6 +40,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: 2025-02-01-preview/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 1a32f1b30c3d..23ae60e90a34 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.workload_classifiers.list_by_workload_group( @@ -41,6 +40,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: 2025-02-01-preview/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 44f84c19dd6a..f5ce42f8bfad 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.workload_groups.get( @@ -40,6 +39,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: 2025-02-01-preview/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 f6fcdd53ce65..738c4fad69d1 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.workload_groups.list_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 82f1bbc11c08..901459d96a8c 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.elastic_pools.begin_create_or_update( @@ -44,6 +43,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: 2025-02-01-preview/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 7f577a2d333f..506f625cee54 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.elastic_pools.get( @@ -39,6 +38,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: 2025-02-01-preview/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 29785bfaa01d..fd01a39f079a 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.elastic_pools.begin_update( @@ -40,6 +39,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: 2025-02-01-preview/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 2af80c1bed93..22c5bdb551a8 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/import_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/import_database.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_import_method( @@ -47,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ImportDatabase.json +# x-ms-original-file: 2025-02-01-preview/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..007c68048833 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/import_database_using_database_extensions.py @@ -0,0 +1,56 @@ +# pylint: disable=line-too-long,useless-suppression +# 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) Python 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="SUBSCRIPTION_ID", + ) + + 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: 2025-02-01-preview/ImportDatabaseUsingDatabaseExtensions.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/import_database_with_managed_identity.py b/sdk/sql/azure-mgmt-sql/generated_samples/import_database_with_managed_identity.py new file mode 100644 index 000000000000..9ea141973169 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/import_database_with_managed_identity.py @@ -0,0 +1,51 @@ +# pylint: disable=line-too-long,useless-suppression +# 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) Python 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_with_managed_identity.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.databases.begin_import_method( + resource_group_name="Default-SQL-SouthEastAsia", + server_name="testsvr", + database_name="testdb", + parameters={ + "administratorLogin": "/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/rgName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityName", + "authenticationType": "ManagedIdentity", + "storageKey": "/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/rgName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityName", + "storageKeyType": "ManagedIdentity", + "storageUri": "https://test.blob.core.windows.net/test.bacpac", + }, + ).result() + print(response) + + +# x-ms-original-file: 2025-02-01-preview/ImportDatabaseWithManagedIdentity.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 a4719f0e5466..cb6e53607919 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_import_method( @@ -51,6 +51,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ImportDatabaseWithNetworkIsolation.json +# x-ms-original-file: 2025-02-01-preview/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 076aefe40493..88e77158b878 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_import_database( @@ -47,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/ImportNewDatabase.json +# x-ms-original-file: 2025-02-01-preview/ImportNewDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/import_new_database_with_managed_identity.py b/sdk/sql/azure-mgmt-sql/generated_samples/import_new_database_with_managed_identity.py index bdb7d5e4d8e4..e05ef2d5b6bb 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/import_new_database_with_managed_identity.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/import_new_database_with_managed_identity.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_import_database( @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/ImportNewDatabaseWithManagedIdentity.json +# x-ms-original-file: 2025-02-01-preview/ImportNewDatabaseWithManagedIdentity.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 5f7906b80f51..aa625511dc60 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_import_database( @@ -51,6 +51,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/ImportNewDatabaseWithNetworkIsolation.json +# x-ms-original-file: 2025-02-01-preview/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 c97e416b889b..070b8c304bbf 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_databases.list_inaccessible_by_instance( @@ -39,6 +38,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: 2025-02-01-preview/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 bbf8c88550e6..6a643bfb8e2f 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.instance_failover_groups.begin_create_or_update( @@ -53,6 +53,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: 2025-02-01-preview/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 4cf1cc7fe784..a30c97e08404 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.instance_failover_groups.begin_delete( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/InstanceFailoverGroupDelete.json +# x-ms-original-file: 2025-02-01-preview/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 b19706cacb02..a618c10cca1c 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.instance_failover_groups.begin_failover( @@ -39,6 +38,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: 2025-02-01-preview/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 7f98463ad510..9acc3aeaf2a7 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.instance_failover_groups.begin_force_failover_allow_data_loss( @@ -39,6 +38,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: 2025-02-01-preview/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 4250fef21f13..3e957f8f8e1c 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.instance_failover_groups.get( @@ -39,6 +38,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: 2025-02-01-preview/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 d13015e81508..6b5408af5bc9 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.instance_failover_groups.list_by_location( @@ -39,6 +38,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: 2025-02-01-preview/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 484f297756ce..12d96b79ede8 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.ipv6_firewall_rules.create_or_update( @@ -45,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/IPv6FirewallRuleCreate.json +# x-ms-original-file: 2025-02-01-preview/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 104efb97ea6e..cfef9a659c23 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.ipv6_firewall_rules.delete( @@ -38,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/IPv6FirewallRuleDelete.json +# x-ms-original-file: 2025-02-01-preview/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 a5d7063c5402..3bdd51bf5fe7 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.ipv6_firewall_rules.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/IPv6FirewallRuleGet.json +# x-ms-original-file: 2025-02-01-preview/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 ac97fce384cb..46592c2f0779 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.ipv6_firewall_rules.list_by_server( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/IPv6FirewallRuleList.json +# x-ms-original-file: 2025-02-01-preview/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 9cfa46cfdf12..95698c0253c9 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.ipv6_firewall_rules.create_or_update( @@ -45,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/IPv6FirewallRuleUpdate.json +# x-ms-original-file: 2025-02-01-preview/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 199b305ff4e6..82de33007a2d 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.ledger_digest_uploads.begin_disable( @@ -40,6 +39,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: 2025-02-01-preview/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 93cc125ca515..568b5615e1ca 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.ledger_digest_uploads.begin_create_or_update( @@ -41,6 +40,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: 2025-02-01-preview/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 c0bdc9097245..42e048181486 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.ledger_digest_uploads.get( @@ -40,6 +39,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: 2025-02-01-preview/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 755d67111002..257566be826d 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.ledger_digest_uploads.list_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 375090374186..fd7b64f07ae4 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.data_warehouse_user_activities.list_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 a2897141006e..750c503749e6 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="7b2515fe-f230-4017-8cf0-695163acab85", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_extensions.list_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 cbc750639421..296d7b98a993 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.database_operations.list_by_database( @@ -40,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/ListDatabaseOperations.json +# x-ms-original-file: 2025-02-01-preview/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 1ee043f82ce6..0162c6c61edc 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.list_by_elastic_pool( @@ -40,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ListDatabasesByElasticPool.json +# x-ms-original-file: 2025-02-01-preview/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 3c7af0062ecb..29a77e6351c6 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.elastic_pool_operations.list_by_elastic_pool( @@ -40,6 +39,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: 2025-02-01-preview/ListElasticPoolOperations.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_instance_pool_operations.py similarity index 71% rename from sdk/sql/azure-mgmt-sql/generated_samples/service_objective_list.py rename to sdk/sql/azure-mgmt-sql/generated_samples/list_instance_pool_operations.py index 7188cf23a304..10ab55e0e50a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/service_objective_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_instance_pool_operations.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -16,7 +15,7 @@ pip install azure-identity pip install azure-mgmt-sql # USAGE - python service_objective_list.py + python list_instance_pool_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, @@ -28,17 +27,17 @@ 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.instance_pool_operations.list_by_instance_pool( + resource_group_name="resource-group", + instance_pool_name="test-instance-pool", ) 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: 2025-02-01-preview/ListInstancePoolOperations.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_instance_pool_operations_empty.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_instance_pool_operations_empty.py new file mode 100644 index 000000000000..35c93cd607d2 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_instance_pool_operations_empty.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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python list_instance_pool_operations_empty.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.instance_pool_operations.list_by_instance_pool( + resource_group_name="resource-group", + instance_pool_name="test-instance-pool", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2025-02-01-preview/ListInstancePoolOperationsEmpty.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 91b8e8f71756..2b398f721500 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.usages.list_by_instance_pool( @@ -39,6 +38,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: 2025-02-01-preview/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 13c28ac488dc..6d7a4809a365 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.usages.list_by_instance_pool( @@ -39,6 +38,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: 2025-02-01-preview/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 f9a2aff8d70a..ae72b321cca1 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.instance_pools.list_by_resource_group( @@ -38,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListInstancePoolsByResourceGroup.json +# x-ms-original-file: 2025-02-01-preview/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 bab058f3352e..0e581be7b3e1 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.instance_pools.list() @@ -36,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListInstancePoolsBySubscriptionId.json +# x-ms-original-file: 2025-02-01-preview/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 808a40456003..6f49f71dd063 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.job_agents.list_by_server( @@ -39,6 +38,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: 2025-02-01-preview/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 29739a91f50d..1b7634e54cee 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.job_credentials.list_by_agent( @@ -40,6 +39,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: 2025-02-01-preview/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 254d6dd79ccc..0081e2ba37ad 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.job_step_executions.list_by_job_execution( @@ -42,6 +41,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: 2025-02-01-preview/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 5aacb01fdb2e..161fa07454fe 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.job_target_executions.list_by_job_execution( @@ -42,6 +41,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: 2025-02-01-preview/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 3232ea32143f..e8e0703115dc 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.job_target_executions.list_by_step( @@ -43,6 +42,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: 2025-02-01-preview/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 e4dff8b0c502..7496c3e37b80 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.job_executions.list_by_agent( @@ -40,6 +39,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: 2025-02-01-preview/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 98bc94520758..db0262af8900 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.job_executions.list_by_agent( @@ -40,6 +39,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: 2025-02-01-preview/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 3662600c0cdb..1aae894ab660 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.job_executions.list_by_job( @@ -41,6 +40,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: 2025-02-01-preview/ListJobExecutionsByJob.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_job_private_endpoints_by_agent.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_job_private_endpoints_by_agent.py index d96a71033c67..87703d8c567d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_job_private_endpoints_by_agent.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_job_private_endpoints_by_agent.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.job_private_endpoints.list_by_agent( @@ -40,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListJobPrivateEndpointsByAgent.json +# x-ms-original-file: 2025-02-01-preview/ListJobPrivateEndpointsByAgent.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_job_steps_by_job.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_job_steps_by_job.py index 20ff382cc411..53f7ad480449 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.job_steps.list_by_job( @@ -41,6 +40,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: 2025-02-01-preview/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 03c44d3acc04..c2590f51cf4e 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.job_steps.list_by_version( @@ -42,6 +41,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: 2025-02-01-preview/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 4c72dad751b4..151226ffcfcd 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.job_target_groups.list_by_agent( @@ -40,6 +39,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: 2025-02-01-preview/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 fe2d5048acfa..0eef619be0ea 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.job_versions.list_by_job( @@ -41,6 +40,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: 2025-02-01-preview/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 1b8a491769ef..d4b006e7a00a 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.jobs.list_by_agent( @@ -40,6 +39,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: 2025-02-01-preview/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 686cc8c2ce9e..72307f3fdc9c 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_operations.list_by_managed_instance( @@ -39,6 +38,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: 2025-02-01-preview/ListManagedInstanceOperations.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_operations.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_operations.py new file mode 100644 index 000000000000..e64056ca3d4f --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_operations.py @@ -0,0 +1,40 @@ +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python list_operations.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.operations.list() + for item in response: + print(item) + + +# x-ms-original-file: 2025-02-01-preview/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 c770cee183e3..f0886a2ef32d 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="20d7082a-0fc7-4468-82bd-542694d5042b", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instances.list_outbound_network_dependencies_by_managed_instance( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListOutboundNetworkDependenciesByManagedInstance.json +# x-ms-original-file: 2025-02-01-preview/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 b5dde3942442..138d9f486f57 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.recoverable_managed_databases.list_by_instance( @@ -39,6 +38,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: 2025-02-01-preview/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 28c216a13cec..6139dab24e8e 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.restorable_dropped_databases.list_by_server( @@ -39,6 +38,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: 2025-02-01-preview/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 58a5310e7c85..9e940b303b1c 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_operations.list_by_server( @@ -39,6 +38,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: 2025-02-01-preview/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 1d1f49e5a40a..f7daff22c94c 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.backup_short_term_retention_policies.list_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 ba51eae32583..dc7035a46cf8 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.list_by_server( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ListVCoreDatabasesByServer.json +# x-ms-original-file: 2025-02-01-preview/ListVCoreDatabasesByServer.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_vcore_databases_by_server_with_odata.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_vcore_databases_by_server_with_odata.py new file mode 100644 index 000000000000..c5ddebd8c468 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_vcore_databases_by_server_with_odata.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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python list_vcore_databases_by_server_with_odata.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.databases.list_by_server( + resource_group_name="Default-SQL-SouthEastAsia", + server_name="testsvr", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2025-02-01-preview/ListVCoreDatabasesByServerWithOdata.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 818a17715e20..f4385ad9c0e6 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.list_by_server( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ListVCoreDatabasesEnclaveTypeByServer.json +# x-ms-original-file: 2025-02-01-preview/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 4fe507f460c9..f0497f3a901b 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.list_inaccessible_by_server( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ListVCoreInaccessibleDatabasesByServer.json +# x-ms-original-file: 2025-02-01-preview/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 ba88682bd935..bd64ec3f5094 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.capabilities.list_by_location( @@ -37,6 +36,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: 2025-02-01-preview/LocationCapabilityListByLocation.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/lock_time_based_immutability_long_term_retention_backup.py b/sdk/sql/azure-mgmt-sql/generated_samples/lock_time_based_immutability_long_term_retention_backup.py index 229d09d8977a..d1cea1f8fb9a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/lock_time_based_immutability_long_term_retention_backup.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/lock_time_based_immutability_long_term_retention_backup.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_term_retention_backups.begin_lock_time_based_immutability( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/LockTimeBasedImmutabilityLongTermRetentionBackup.json +# x-ms-original-file: 2025-02-01-preview/LockTimeBasedImmutabilityLongTermRetentionBackup.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 4ce55a3b4031..7a82488629f3 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_term_retention_backups.begin_copy( @@ -47,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/LongTermRetentionBackupCopy.json +# x-ms-original-file: 2025-02-01-preview/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 d7bfd7f6581e..18946868381c 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.long_term_retention_backups.begin_delete( @@ -39,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/LongTermRetentionBackupDelete.json +# x-ms-original-file: 2025-02-01-preview/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 2ae282a6d90b..4817abf5d0dc 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_term_retention_backups.get( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/LongTermRetentionBackupGet.json +# x-ms-original-file: 2025-02-01-preview/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 946dcb1429e9..6ad0192807c3 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_term_retention_backups.list_by_database( @@ -40,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/LongTermRetentionBackupListByDatabase.json +# x-ms-original-file: 2025-02-01-preview/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 621308087284..7d95f4d1df96 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_term_retention_backups.list_by_location( @@ -38,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/LongTermRetentionBackupListByLocation.json +# x-ms-original-file: 2025-02-01-preview/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 8566ee33fc40..a2176b222d1a 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_term_retention_backups.list_by_server( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/LongTermRetentionBackupListByServer.json +# x-ms-original-file: 2025-02-01-preview/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 a1c724a0ba7d..fca3c5793fbf 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_term_retention_backups.begin_update( @@ -41,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/LongTermRetentionBackupUpdate.json +# x-ms-original-file: 2025-02-01-preview/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 faf48a5771cf..8f3721eaa0d4 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_term_retention_policies.begin_create_or_update( @@ -50,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/LongTermRetentionPolicyCreateOrUpdate.json +# x-ms-original-file: 2025-02-01-preview/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 f3e0b091a227..d2d5a8cf398b 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_term_retention_policies.get( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/LongTermRetentionPolicyGet.json +# x-ms-original-file: 2025-02-01-preview/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 cc76b1253a7a..4d38e8173cef 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_term_retention_policies.list_by_database( @@ -40,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/LongTermRetentionPolicyListByDatabase.json +# x-ms-original-file: 2025-02-01-preview/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 5ab0e4039ea3..2b1c2619598e 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_columns.list_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 66eb541a40a7..b90610de1f4e 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_columns.list_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 954e826dc5a5..fef11ebf52b2 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_advanced_threat_protection_settings.create_or_update( @@ -41,6 +40,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: 2025-02-01-preview/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 4dfe8b344dc7..acc0b211e320 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_advanced_threat_protection_settings.create_or_update( @@ -41,6 +40,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: 2025-02-01-preview/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 30df2ef367a7..8d6f3cf3777f 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_advanced_threat_protection_settings.get( @@ -40,6 +39,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: 2025-02-01-preview/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 cd368c22ec90..9a790b7c51fe 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_advanced_threat_protection_settings.list_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 f03e01162c02..199ebde423c5 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.managed_databases.begin_cancel_move( @@ -41,6 +41,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseCancelMove.json +# x-ms-original-file: 2025-02-01-preview/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 3cb120cc90af..2d867aa22167 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_columns.get( @@ -42,6 +41,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: 2025-02-01-preview/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 4eb3bb234e9e..e43ca7b43188 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_columns.list_by_table( @@ -42,6 +41,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: 2025-02-01-preview/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 644186152a32..b864f2aa3a68 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_sensitivity_labels.create_or_update( @@ -40,6 +39,7 @@ def main(): column_name="myColumn", parameters={ "properties": { + "clientClassificationSource": "Native", "informationType": "PhoneNumber", "informationTypeId": "d22fa6e9-5ee4-3bde-4c2b-a409604c4646", "labelId": "bf91e08c-f4f0-478a-b016-25164b2a65ff", @@ -51,6 +51,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: 2025-02-01-preview/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 d05e2362f992..e590f3c4eb81 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.managed_database_sensitivity_labels.delete( @@ -41,6 +40,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseColumnSensitivityLabelDelete.json +# x-ms-original-file: 2025-02-01-preview/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 fe76c7cc88c2..8ed4e62a9cb0 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_sensitivity_labels.get( @@ -43,6 +42,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: 2025-02-01-preview/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 158dd985a2ad..1fdec3c3d46f 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.managed_databases.begin_complete_restore( @@ -39,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseCompleteExternalRestore.json +# x-ms-original-file: 2025-02-01-preview/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 a5b7ecefe6a8..ec03142812a9 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.managed_databases.begin_complete_move( @@ -41,6 +41,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseCompleteMove.json +# x-ms-original-file: 2025-02-01-preview/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 4978af86154b..d0c8a8eae6a6 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_databases.begin_create_or_update( @@ -48,6 +48,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: 2025-02-01-preview/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 391e0a10d0b1..c9635551b7e7 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_databases.begin_create_or_update( @@ -40,6 +39,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: 2025-02-01-preview/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 8ba446ee9b32..9440c620d38c 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_databases.begin_create_or_update( @@ -40,6 +39,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: 2025-02-01-preview/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 ddcfbe5c5f2d..b6f477f25156 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_databases.begin_create_or_update( @@ -47,6 +47,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: 2025-02-01-preview/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 608245363417..b34e5f012f0b 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_databases.begin_create_or_update( @@ -46,6 +46,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: 2025-02-01-preview/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 883ca3e47bca..c89e842e21d6 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_databases.begin_create_or_update( @@ -50,6 +49,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: 2025-02-01-preview/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 21d2feafd019..8ec1a89bbce1 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_databases.begin_create_or_update( @@ -50,6 +49,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: 2025-02-01-preview/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 96d61f0268f7..24a49ee7953c 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_databases.begin_create_or_update( @@ -48,6 +47,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: 2025-02-01-preview/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 4d1c7b64cb56..dba1d07cbcbb 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.managed_databases.begin_delete( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseDelete.json +# x-ms-original-file: 2025-02-01-preview/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 6114bf045578..7a6850b6e988 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_databases.get( @@ -39,6 +38,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: 2025-02-01-preview/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 c6f0e79963ba..981c34be4e0c 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_databases.list_by_instance( @@ -39,6 +38,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: 2025-02-01-preview/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 5f85ac3399f0..c807293d77bd 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_move_operations.get( @@ -39,6 +38,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: 2025-02-01-preview/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 8798b84e88ed..2508b8d91c12 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_move_operations.list_by_location( @@ -39,6 +38,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: 2025-02-01-preview/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 458cd5db5225..035231fa31da 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_move_operations.list_by_location( @@ -39,6 +38,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: 2025-02-01-preview/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 716a7ae2dad5..151b858606f2 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_move_operations.list_by_location( @@ -39,6 +38,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: 2025-02-01-preview/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 f6f8f981b065..4fb4160c1e2a 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.managed_database_sensitivity_labels.disable_recommendation( @@ -41,6 +40,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseRecommendedColumnSensitivityLabelDisable.json +# x-ms-original-file: 2025-02-01-preview/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 07e8e77854e8..98c784128b2d 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.managed_database_sensitivity_labels.enable_recommendation( @@ -41,6 +40,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseRecommendedColumnSensitivityLabelEnable.json +# x-ms-original-file: 2025-02-01-preview/ManagedDatabaseRecommendedColumnSensitivityLabelEnable.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_reevaluate_inaccessible_database_state.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_reevaluate_inaccessible_database_state.py new file mode 100644 index 000000000000..abe07be51304 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_reevaluate_inaccessible_database_state.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) Python 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_database_reevaluate_inaccessible_database_state.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.managed_databases.begin_reevaluate_inaccessible_database_state( + resource_group_name="Test1", + managed_instance_name="managedInstance", + database_name="managedDatabase", + ).result() + print(response) + + +# x-ms-original-file: 2025-02-01-preview/ManagedDatabaseReevaluateInaccessibleDatabaseState.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 1a426155c29e..78b4c4096ec7 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_restore_details.get( @@ -40,6 +39,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: 2025-02-01-preview/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 7053b4db7175..981084e652ee 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_schemas.get( @@ -40,6 +39,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: 2025-02-01-preview/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 29e1c54f7bc0..a92972f7525e 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_schemas.list_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 279fd5976d65..d386db04a13b 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_security_alert_policies.create_or_update( @@ -51,6 +51,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: 2025-02-01-preview/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 c9f9cf806564..3f5034f21896 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_security_alert_policies.create_or_update( @@ -41,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseSecurityAlertCreateMin.json +# x-ms-original-file: 2025-02-01-preview/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 7d912db218d1..d50b9ad71b72 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_security_alert_policies.get( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseSecurityAlertGet.json +# x-ms-original-file: 2025-02-01-preview/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 e0ca8da5bd48..96463d077426 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_security_alert_policies.list_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 645defb7df76..86fd8ebf83fa 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_security_events.list_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 3da7ff513de8..a34237d70333 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_security_events.list_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 469bdcbf3bdf..3df600d6020d 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.managed_database_sensitivity_labels.update( @@ -75,6 +74,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseSensitivityLabelsCurrentUpdate.json +# x-ms-original-file: 2025-02-01-preview/ManagedDatabaseSensitivityLabelsCurrentUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_sensitivity_labels_list_by_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_sensitivity_labels_list_by_database.py new file mode 100644 index 000000000000..8b7bfaedc3b3 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_sensitivity_labels_list_by_database.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python 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_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, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.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: 2025-02-01-preview/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 85493f7c5a0f..725a395bf973 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_sensitivity_labels.list_current_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 dadd0d08c62b..3375ae9fae72 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_sensitivity_labels.list_recommended_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 de7084e18371..68b2d1af0c71 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.managed_database_recommended_sensitivity_labels.update( @@ -45,6 +44,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseSensitivityLabelsRecommendedUpdate.json +# x-ms-original-file: 2025-02-01-preview/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 3cb893ef0f6f..35aa39606d3c 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.managed_databases.begin_start_move( @@ -42,6 +42,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseStartMoveMax.json +# x-ms-original-file: 2025-02-01-preview/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 eb98741bc7b2..6eafc745ed27 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.managed_databases.begin_start_move( @@ -41,6 +41,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseStartMoveMin.json +# x-ms-original-file: 2025-02-01-preview/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 00ec94420dfa..ce739ad69ae6 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_tables.get( @@ -41,6 +40,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: 2025-02-01-preview/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 4f777e57d589..ba500306b182 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_tables.list_by_schema( @@ -41,6 +40,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: 2025-02-01-preview/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 cc93ae56ac60..05c9dd20f053 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_databases.begin_update( @@ -40,6 +39,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: 2025-02-01-preview/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 9ccbf3e93136..5dde5a459ecc 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_databases.begin_update( @@ -40,6 +39,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: 2025-02-01-preview/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 8b872a7846c2..534581afcaf0 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_vulnerability_assessments.create_or_update( @@ -51,6 +50,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: 2025-02-01-preview/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 57c961dbd8de..72958b00653c 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_vulnerability_assessments.create_or_update( @@ -46,6 +45,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: 2025-02-01-preview/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 90223e5fe93f..e1ee8c970b64 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.managed_database_vulnerability_assessments.delete( @@ -39,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentDelete.json +# x-ms-original-file: 2025-02-01-preview/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 f7e859fd5058..8d422fd71479 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_vulnerability_assessments.get( @@ -40,6 +39,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: 2025-02-01-preview/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 fd8b06ca2683..82a1fcdd1b05 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_vulnerability_assessments.list_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 496adf5b2d8b..5b9ae244610d 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_vulnerability_assessment_rule_baselines.create_or_update( @@ -51,6 +50,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: 2025-02-01-preview/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 f5903db08590..7c0050ad69a7 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.managed_database_vulnerability_assessment_rule_baselines.delete( @@ -41,6 +40,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentRuleBaselineDelete.json +# x-ms-original-file: 2025-02-01-preview/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 8b39a97fb085..1bc8887c3b47 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_vulnerability_assessment_rule_baselines.get( @@ -42,6 +41,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: 2025-02-01-preview/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 5030894326f7..e1d985ac5c4b 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_vulnerability_assessment_scans.export( @@ -41,6 +40,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: 2025-02-01-preview/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 e281b7aa276b..f355ea85386e 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_vulnerability_assessment_scans.get( @@ -41,6 +40,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: 2025-02-01-preview/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 768894c75cce..d867c30a7d71 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_vulnerability_assessment_scans.list_by_database( @@ -41,6 +40,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: 2025-02-01-preview/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 32c1a008d8ad..f73fcdcaa950 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.managed_database_vulnerability_assessment_scans.begin_initiate_scan( @@ -40,6 +39,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentScansExecute.json +# x-ms-original-file: 2025-02-01-preview/ManagedDatabaseVulnerabilityAssessmentScansExecute.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instanc_validate_azure_key_vault_encryption_key.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instanc_validate_azure_key_vault_encryption_key.py new file mode 100644 index 000000000000..6422bfe7446f --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instanc_validate_azure_key_vault_encryption_key.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) Python 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_instanc_validate_azure_key_vault_encryption_key.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.managed_instances.begin_validate_azure_key_vault_encryption_key( + resource_group_name="testrg", + managed_instance_name="testinstance", + parameters={"tdeKeyUri": "https://someVault.vault.azure.net/keys/someKey/01234567890123456789012345678901"}, + ).result() + + +# x-ms-original-file: 2025-02-01-preview/ManagedInstancValidateAzureKeyVaultEncryptionKey.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 e1b759595f8e..a9ac8e699f7a 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_administrators.begin_create_or_update( @@ -47,6 +46,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: 2025-02-01-preview/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 e5b32e3b7575..02c6109b289b 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.managed_instance_administrators.begin_delete( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAdministratorDelete.json +# x-ms-original-file: 2025-02-01-preview/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 605eb192dced..6ecaee0e797c 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_administrators.get( @@ -39,6 +38,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: 2025-02-01-preview/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 a5f92249c08a..28940a1b392c 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_administrators.list_by_instance( @@ -39,6 +38,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: 2025-02-01-preview/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 26ffcfb57efa..991dfe080344 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_administrators.begin_create_or_update( @@ -47,6 +46,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: 2025-02-01-preview/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 cd584af95a5a..7a4577b9313e 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_advanced_threat_protection_settings.begin_create_or_update( @@ -40,6 +39,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: 2025-02-01-preview/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 369deb823efc..dbbabbfd812c 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_advanced_threat_protection_settings.begin_create_or_update( @@ -40,6 +39,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: 2025-02-01-preview/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 eaea7ee85adb..41fa994e1b79 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_advanced_threat_protection_settings.get( @@ -39,6 +38,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: 2025-02-01-preview/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 001a99d2cc8c..6a95bfdf5f82 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_advanced_threat_protection_settings.list_by_instance( @@ -39,6 +38,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: 2025-02-01-preview/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 ec56b20bde22..97be099eb9a3 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_azure_ad_only_authentications.begin_create_or_update( @@ -40,6 +39,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: 2025-02-01-preview/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 9ae5e033c081..47ec001cb930 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.managed_instance_azure_ad_only_authentications.begin_delete( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAzureADOnlyAuthDelete.json +# x-ms-original-file: 2025-02-01-preview/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 1e444a6a5616..f30f11bcf4d4 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_azure_ad_only_authentications.get( @@ -39,6 +38,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: 2025-02-01-preview/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 a4ef75fd6099..4dab727826bf 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_azure_ad_only_authentications.list_by_instance( @@ -39,6 +38,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: 2025-02-01-preview/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 712129b1310a..1938e5487fa5 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="20D7082A-0FC7-4468-82BD-542694D5042B", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instances.begin_create_or_update( @@ -46,6 +46,7 @@ def main(): "sid": "00000011-1111-2222-2222-123456789111", "tenantId": "00000011-1111-2222-2222-123456789111", }, + "authenticationMetadata": "AzureAD", "collation": "SQL_Latin1_General_CP1_CI_AS", "databaseFormat": "AlwaysUpToDate", "dnsZonePartner": "/subscriptions/20D7082A-0FC7-4468-82BD-542694D5042B/resourceGroups/testrg/providers/Microsoft.Sql/managedInstances/testinstance", @@ -57,6 +58,7 @@ def main(): "proxyOverride": "Redirect", "publicDataEndpointEnabled": False, "requestedBackupStorageRedundancy": "Geo", + "requestedLogicalAvailabilityZone": "1", "servicePrincipal": {"type": "SystemAssigned"}, "storageSizeInGB": 1024, "subnetId": "/subscriptions/20D7082A-0FC7-4468-82BD-542694D5042B/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/subnet1", @@ -70,6 +72,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceCreateMax.json +# x-ms-original-file: 2025-02-01-preview/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 f991f27a7622..04e4f24492dd 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="20D7082A-0FC7-4468-82BD-542694D5042B", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instances.begin_create_or_update( @@ -50,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceCreateMin.json +# x-ms-original-file: 2025-02-01-preview/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 12e5efbc3410..0a38f9308b01 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.managed_instances.begin_delete( @@ -37,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceDelete.json +# x-ms-original-file: 2025-02-01-preview/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 8027409deced..58015d438985 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_dtcs.get( @@ -39,6 +38,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: 2025-02-01-preview/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 fa3341d57292..482a6e4e155c 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_dtcs.list_by_managed_instance( @@ -39,6 +38,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: 2025-02-01-preview/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 1361d537e6ce..628db0a7af9e 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_dtcs.begin_create_or_update( @@ -40,6 +39,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: 2025-02-01-preview/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 d47c69875dfa..9707193804d7 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_dtcs.begin_create_or_update( @@ -56,6 +55,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: 2025-02-01-preview/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 81e7a1bf8235..722f0a93dfec 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_encryption_protectors.begin_create_or_update( @@ -46,6 +45,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: 2025-02-01-preview/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 0387a68d82c3..d9d89e9c6783 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_encryption_protectors.begin_create_or_update( @@ -40,6 +39,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: 2025-02-01-preview/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 4c49f267e4b0..1af003c07fb2 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_encryption_protectors.get( @@ -39,6 +38,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: 2025-02-01-preview/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 00c9f76f1c50..bf0eab0766da 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_encryption_protectors.list_by_instance( @@ -39,6 +38,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: 2025-02-01-preview/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 1c2e287ed2f7..303cba2d3b03 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.managed_instance_encryption_protectors.begin_revalidate( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceEncryptionProtectorRevalidate.json +# x-ms-original-file: 2025-02-01-preview/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 e7e522eb7796..26a6270338de 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instances.get( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceGet.json +# x-ms-original-file: 2025-02-01-preview/ManagedInstanceGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_get_while_updating.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_get_while_updating.py index fa187f26ac06..1e9e3d86f8e0 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_get_while_updating.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_get_while_updating.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instances.get( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceGetWhileUpdating.json +# x-ms-original-file: 2025-02-01-preview/ManagedInstanceGetWhileUpdating.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_get_with_expand_equals_administrators.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_get_with_expand_equals_administrators.py index 0dbbca011961..85229afb68fa 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instances.get( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceGetWithExpandEqualsAdministrators.json +# x-ms-original-file: 2025-02-01-preview/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 6bcab42c8ec4..abadb62025e7 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_keys.begin_create_or_update( @@ -45,6 +44,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: 2025-02-01-preview/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 522d510a988e..c1ef33c4b83f 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.managed_instance_keys.begin_delete( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceKeyDelete.json +# x-ms-original-file: 2025-02-01-preview/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 d1fab5e4058c..c31a7da3a23f 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_keys.get( @@ -39,6 +38,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: 2025-02-01-preview/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 11bf61d166bd..d2a801adb05e 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_keys.list_by_instance( @@ -39,6 +38,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: 2025-02-01-preview/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 86d4f0a55a61..afe2ed9731bc 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instances.list() @@ -36,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceList.json +# x-ms-original-file: 2025-02-01-preview/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 ef5c862fcd74..a46621c62d8e 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instances.list_by_instance_pool( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceListByInstancePool.json +# x-ms-original-file: 2025-02-01-preview/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 8a122415d93a..841462933353 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instances.list_by_instance_pool( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceListByInstancePoolWithExpandEqualsAdministrators.json +# x-ms-original-file: 2025-02-01-preview/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 9455050d1000..484f35696c98 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instances.list_by_resource_group( @@ -38,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceListByResourceGroup.json +# x-ms-original-file: 2025-02-01-preview/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 2645f596ffe4..4b4e34b1f2d2 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instances.list_by_resource_group( @@ -38,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceListByResourceGroupWithExpandEqualsAdministrators.json +# x-ms-original-file: 2025-02-01-preview/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 79762a547595..bd7b04bf7641 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instances.list() @@ -36,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceListWithExpandEqualsAdministrators.json +# x-ms-original-file: 2025-02-01-preview/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 db63ebd088ff..760400451bc4 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,17 +27,17 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) 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", + backup_name="55555555-6666-7777-8888-999999999999;131637960820000000;Hot", ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ManagedInstanceLongTermRetentionBackupDelete.json +# x-ms-original-file: 2025-02-01-preview/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 2b8288fd30a0..b9acc21130af 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,18 +27,18 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_term_retention_managed_instance_backups.get( location_name="japaneast", managed_instance_name="testInstance", database_name="testDatabase", - backup_name="55555555-6666-7777-8888-999999999999;131637960820000000", + backup_name="55555555-6666-7777-8888-999999999999;131637960820000000;Archive", ) print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ManagedInstanceLongTermRetentionBackupGet.json +# x-ms-original-file: 2025-02-01-preview/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 4764bc825aa7..30730256f220 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_term_retention_managed_instance_backups.list_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 78cb545388f8..bcf02d39667b 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_term_retention_managed_instance_backups.list_by_instance( @@ -39,6 +38,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: 2025-02-01-preview/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 dc1d35ae180f..e5657f7644fa 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_term_retention_managed_instance_backups.list_by_location( @@ -38,6 +37,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: 2025-02-01-preview/ManagedInstanceLongTermRetentionBackupListByLocation.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_backup_list_by_location_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_backup_list_by_location_max.py new file mode 100644 index 000000000000..bbc7ecba868e --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_backup_list_by_location_max.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python 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_backup_list_by_location_max.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.long_term_retention_managed_instance_backups.list_by_location( + location_name="japaneast", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2025-02-01-preview/ManagedInstanceLongTermRetentionBackupListByLocationMax.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_policy_create_or_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_policy_create_or_update.py index 28710b4480db..256f46769735 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_long_term_retention_policies.begin_create_or_update( @@ -38,6 +37,7 @@ def main(): policy_name="default", parameters={ "properties": { + "backupStorageAccessTier": "Hot", "monthlyRetention": "P1Y", "weekOfYear": 5, "weeklyRetention": "P1M", @@ -48,6 +48,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: 2025-02-01-preview/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..1a8b9f3d55ab --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_policy_delete.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python 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="SUBSCRIPTION_ID", + ) + + 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: 2025-02-01-preview/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 b5d6325ab984..a05f4b070261 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_long_term_retention_policies.get( @@ -40,6 +39,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: 2025-02-01-preview/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 eb93103bee01..fd7468103f6b 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_long_term_retention_policies.list_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 0df3c50c0767..969620681ec1 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.managed_instance_private_endpoint_connections.begin_delete( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstancePrivateEndpointConnectionDelete.json +# x-ms-original-file: 2025-02-01-preview/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 ae29e204df6f..6ba1bd88caa1 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_private_endpoint_connections.get( @@ -39,6 +38,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: 2025-02-01-preview/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 06d1f9405c22..1dc834a886a5 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_private_endpoint_connections.list_by_managed_instance( @@ -39,6 +38,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: 2025-02-01-preview/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 e65363f37d00..10bab8ff9f5a 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_private_endpoint_connections.begin_create_or_update( @@ -38,7 +37,7 @@ def main(): parameters={ "properties": { "privateLinkServiceConnectionState": { - "description": "Approved by johndoe@contoso.com", + "description": "Approved by `johndoe@contoso.com `_", "status": "Approved", } } @@ -47,6 +46,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: 2025-02-01-preview/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 605031ad7f25..14081f932a1b 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_private_link_resources.get( @@ -39,6 +38,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: 2025-02-01-preview/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 71976dcd7604..a24d2c43de31 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_private_link_resources.list_by_managed_instance( @@ -39,6 +38,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: 2025-02-01-preview/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 04935ad2e2e9..2e7f2b55f49d 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_queries.get( @@ -40,6 +39,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: 2025-02-01-preview/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 2397f502d9c1..e5af0cc86953 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_queries.list_by_query( @@ -41,6 +40,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: 2025-02-01-preview/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 18b9c2ff16e1..427fd6de6aef 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_queries.list_by_query( @@ -41,6 +40,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: 2025-02-01-preview/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 8219c6f9c101..b40d9767159a 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_queries.list_by_query( @@ -41,6 +40,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: 2025-02-01-preview/ManagedInstanceQueryStatisticsListMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_reevaluate_inaccessible_database_state.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_reevaluate_inaccessible_database_state.py new file mode 100644 index 000000000000..ebc9372a000b --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_reevaluate_inaccessible_database_state.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python 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_reevaluate_inaccessible_database_state.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.managed_instances.begin_reevaluate_inaccessible_database_state( + resource_group_name="testrg", + managed_instance_name="testinstance", + ).result() + + +# x-ms-original-file: 2025-02-01-preview/ManagedInstanceReevaluateInaccessibleDatabaseState.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_refresh_external_governance_status.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_refresh_external_governance_status.py index 956c4be19714..4ea720476087 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_refresh_external_governance_status.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_refresh_external_governance_status.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instances.begin_refresh_status( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceRefreshExternalGovernanceStatus.json +# x-ms-original-file: 2025-02-01-preview/ManagedInstanceRefreshExternalGovernanceStatus.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_remove_maintenance_configuration.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_remove_maintenance_configuration.py index e0eafd95fb4f..ae75c76a8440 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instances.begin_update( @@ -43,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceRemoveMaintenanceConfiguration.json +# x-ms-original-file: 2025-02-01-preview/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 1658f06dc6ab..526dff38132b 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000001", + subscription_id="SUBSCRIPTION_ID", ) client.managed_instance_tde_certificates.begin_create( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceTdeCertificate.json +# x-ms-original-file: 2025-02-01-preview/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 6cac37e53e67..5a30d15ced72 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="37d5e605-6142-4d79-b564-28b6dbfeec0f", + subscription_id="SUBSCRIPTION_ID", ) response = client.time_zones.get( @@ -38,6 +37,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: 2025-02-01-preview/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 89e81b3367a3..4a748ed22971 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="37d5e605-6142-4d79-b564-28b6dbfeec0f", + subscription_id="SUBSCRIPTION_ID", ) response = client.time_zones.list_by_location( @@ -38,6 +37,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: 2025-02-01-preview/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 25073abc64b2..08a5bad7c714 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instances.list_by_managed_instance( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceTopQueriesList.json +# x-ms-original-file: 2025-02-01-preview/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 d7679e15e05b..2fa78946077e 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instances.list_by_managed_instance( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceTopQueriesListMax.json +# x-ms-original-file: 2025-02-01-preview/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 550cb7a303f6..08a075b86901 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instances.list_by_managed_instance( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceTopQueriesListMin.json +# x-ms-original-file: 2025-02-01-preview/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 bbe59b545c84..dd62be998c7c 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instances.begin_update( @@ -48,6 +48,7 @@ def main(): "proxyOverride": "Redirect", "publicDataEndpointEnabled": False, "requestedBackupStorageRedundancy": "Geo", + "requestedLogicalAvailabilityZone": "1", "storageSizeInGB": 448, "vCores": 8, }, @@ -58,6 +59,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceUpdateMax.json +# x-ms-original-file: 2025-02-01-preview/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 f6cd0563681c..60762e99d7f0 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instances.begin_update( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceUpdateMin.json +# x-ms-original-file: 2025-02-01-preview/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 0d4fd56c6fa8..51a91f18dacb 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_vulnerability_assessments.create_or_update( @@ -45,6 +44,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: 2025-02-01-preview/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 89d9b42a043b..ad02628c7845 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_vulnerability_assessments.create_or_update( @@ -51,6 +50,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: 2025-02-01-preview/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 974c2270e8a2..7fcf3c95c3e1 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_vulnerability_assessments.create_or_update( @@ -45,6 +44,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: 2025-02-01-preview/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 ebc895a24ffc..5c830e781ac7 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.managed_instance_vulnerability_assessments.delete( @@ -38,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceVulnerabilityAssessmentDelete.json +# x-ms-original-file: 2025-02-01-preview/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 df7724b49614..0821c3e16cbe 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_vulnerability_assessments.get( @@ -39,6 +38,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: 2025-02-01-preview/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 dc5ff6cd320e..00c2c16c49a6 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instance_vulnerability_assessments.list_by_instance( @@ -39,6 +38,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: 2025-02-01-preview/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 2ccd188acee4..7b908013d372 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_ledger_digest_uploads.begin_disable( @@ -40,6 +39,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: 2025-02-01-preview/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 904691ae041e..2731c17204f9 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_ledger_digest_uploads.begin_create_or_update( @@ -41,6 +40,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: 2025-02-01-preview/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 099b114f21fa..1da38cc9239c 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_ledger_digest_uploads.get( @@ -40,6 +39,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: 2025-02-01-preview/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 48365a7f6e53..60b31c369fe7 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_ledger_digest_uploads.list_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 30341c9197b1..62b9a3dc202f 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_server_dns_aliases.begin_acquire( @@ -42,6 +42,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: 2025-02-01-preview/ManagedServerDnsAliasAcquire.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_dns_alias_create_or_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_dns_alias_create_or_update.py new file mode 100644 index 000000000000..5cdd316fbf65 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_dns_alias_create_or_update.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python 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_server_dns_alias_create_or_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.managed_server_dns_aliases.begin_create_or_update( + resource_group_name="Default", + managed_instance_name="dns-mi", + dns_alias_name="dns-alias-mi", + parameters={"createDnsRecord": bool}, + ).result() + print(response) + + +# x-ms-original-file: 2025-02-01-preview/ManagedServerDnsAliasCreateOrUpdate.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 2560cf08a721..7e52517dd636 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.managed_server_dns_aliases.begin_delete( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ManagedServerDnsAliasDelete.json +# x-ms-original-file: 2025-02-01-preview/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 6587a52e7dea..d293a0438e99 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_server_dns_aliases.get( @@ -39,6 +38,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: 2025-02-01-preview/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 ab7eaa5b4527..56d6e5d00f39 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_server_dns_aliases.list_by_managed_instance( @@ -39,6 +38,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: 2025-02-01-preview/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 309be7e9bb63..042ea6aaa512 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_server_security_alert_policies.begin_create_or_update( @@ -50,6 +50,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: 2025-02-01-preview/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 aa0e0a4cea85..921af54fb950 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_server_security_alert_policies.begin_create_or_update( @@ -40,6 +39,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: 2025-02-01-preview/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 e9005141849d..edcf06c87460 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_server_security_alert_policies.get( @@ -39,6 +38,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: 2025-02-01-preview/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 7d826d6ec9bb..c56bce57270f 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_server_security_alert_policies.list_by_instance( @@ -39,6 +38,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: 2025-02-01-preview/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 6fb80e8ae590..22f9da23e589 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_transparent_data_encryption.get( @@ -40,6 +39,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: 2025-02-01-preview/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 332a408993a1..5334d7eee207 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_transparent_data_encryption.list_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 977413f9c1a3..600e661899c2 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_database_transparent_data_encryption.create_or_update( @@ -41,6 +40,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: 2025-02-01-preview/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..b021a3c2f050 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/network_security_perimeter_configurations_get.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) Python 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="SUBSCRIPTION_ID", + ) + + 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: 2025-02-01-preview/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 72% 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 147725e669ab..0fc4eb4fc47a 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -16,7 +15,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, @@ -28,17 +27,17 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) - 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: 2025-02-01-preview/NetworkSecurityPerimeterConfigurationsListByServer.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/network_security_perimeter_configurations_reconcile.py b/sdk/sql/azure-mgmt-sql/generated_samples/network_security_perimeter_configurations_reconcile.py new file mode 100644 index 000000000000..92badd19641c --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/network_security_perimeter_configurations_reconcile.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) Python 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_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, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.network_security_perimeter_configurations.begin_reconcile( + resource_group_name="sqlcrudtest-7398", + server_name="sqlcrudtest-7398", + nsp_config_name="00000001-2222-3333-4444-111144444444.assoc1", + ).result() + print(response) + + +# x-ms-original-file: 2025-02-01-preview/NetworkSecurityPerimeterConfigurationsReconcile.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/outbound_firewall_rule_create.py similarity index 68% 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/outbound_firewall_rule_create.py index 608a6aad2b25..4f923736d7f1 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_communication_link_create_or_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/outbound_firewall_rule_create.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -16,7 +15,7 @@ pip install azure-identity pip install azure-mgmt-sql # USAGE - python server_communication_link_create_or_update.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, @@ -28,18 +27,17 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) - response = client.server_communication_links.begin_create_or_update( + response = client.outbound_firewall_rules.begin_create_or_update( resource_group_name="sqlcrudtest-7398", server_name="sqlcrudtest-4645", - communication_link_name="link1", - parameters={"properties": {"partnerServer": "sqldcrudtest-test"}}, + 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/ServerCommunicationLinkCreateOrUpdate.json +# x-ms-original-file: 2025-02-01-preview/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 bcfb83ee5e08..3b1a48e3efb5 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.outbound_firewall_rules.begin_delete( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/OutboundFirewallRuleDelete.json +# x-ms-original-file: 2025-02-01-preview/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 4b38b5ec3fa3..b954b154c7bc 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.outbound_firewall_rules.get( @@ -39,6 +38,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: 2025-02-01-preview/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 69c69c94b8a6..ea06e24df2cf 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.outbound_firewall_rules.list_by_server( @@ -39,6 +38,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: 2025-02-01-preview/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 689058242d77..5aefbfe5437b 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_update( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/PatchDatabaseDefaultEnclave.json +# x-ms-original-file: 2025-02-01-preview/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 71e5fbad0a19..20d3a7f03411 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_update( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/PatchDatabaseVBSEnclave.json +# x-ms-original-file: 2025-02-01-preview/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 c6fcb23619aa..bd22df8d8aa4 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.instance_pools.begin_update( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/PatchInstancePool.json +# x-ms-original-file: 2025-02-01-preview/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 3a97cdfc4ce5..c8dca9e3aabc 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_update( @@ -43,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/PatchVCoreDatabase.json +# x-ms-original-file: 2025-02-01-preview/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 570ff1d49a64..a5acb704d62e 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_update( @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/PatchVCoreDatabaseAssignMaintenanceConfiguration.json +# x-ms-original-file: 2025-02-01-preview/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 69ed59856a1e..c57774a8f72e 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_update( @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/PatchVCoreDatabaseResetMaintenanceConfiguration.json +# x-ms-original-file: 2025-02-01-preview/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 39443333fd61..7bb9ba50a515 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_update( @@ -56,6 +56,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/PatchVCoreDatabaseWithKeysAndEncryptionProtector.json +# x-ms-original-file: 2025-02-01-preview/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 1cda04b7b17b..e143f0eec124 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/pause_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/pause_database.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_pause( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/PauseDatabase.json +# x-ms-original-file: 2025-02-01-preview/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 6d20e9a43e8d..ee1280f43f65 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.private_endpoint_connections.begin_delete( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/PrivateEndpointConnectionDelete.json +# x-ms-original-file: 2025-02-01-preview/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 1837fde62b26..1c61243d6dcd 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.private_endpoint_connections.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/PrivateEndpointConnectionGet.json +# x-ms-original-file: 2025-02-01-preview/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 507ebf609872..53c1b1922aad 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.private_endpoint_connections.list_by_server( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/PrivateEndpointConnectionList.json +# x-ms-original-file: 2025-02-01-preview/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 3179618e59c7..b713bba4511a 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.private_endpoint_connections.begin_create_or_update( @@ -38,7 +37,7 @@ def main(): parameters={ "properties": { "privateLinkServiceConnectionState": { - "description": "Approved by johndoe@contoso.com", + "description": "Approved by `johndoe@contoso.com `_", "status": "Approved", } } @@ -47,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/PrivateEndpointConnectionUpdate.json +# x-ms-original-file: 2025-02-01-preview/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 0c2a4fb459e3..fa903f234291 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.private_link_resources.get( @@ -39,6 +38,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: 2025-02-01-preview/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 fb05b20ea2d4..0e83c723a066 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.private_link_resources.list_by_server( @@ -39,6 +38,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: 2025-02-01-preview/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 2c0750c2126a..159a167ffd7c 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.sensitivity_labels.disable_recommendation( @@ -41,6 +40,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/RecommendedColumnSensitivityLabelDisable.json +# x-ms-original-file: 2025-02-01-preview/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 be8742477051..b7d8ab0cd76c 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.sensitivity_labels.enable_recommendation( @@ -41,6 +40,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/RecommendedColumnSensitivityLabelEnable.json +# x-ms-original-file: 2025-02-01-preview/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 6143d2f349e0..8af06a5fd801 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.recoverable_databases.get( @@ -39,6 +38,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: 2025-02-01-preview/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 8cf44e9ca8f9..d9b65124cbb3 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.recoverable_databases.get( @@ -39,6 +38,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: 2025-02-01-preview/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 6be7dfe7e2ad..49744695f149 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.recoverable_databases.list_by_server( @@ -39,6 +38,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: 2025-02-01-preview/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 21a6a8e0f015..6c5f4b3e297f 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_refresh_status( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/RefreshExternalGovernanceStatus.json +# x-ms-original-file: 2025-02-01-preview/RefreshExternalGovernanceStatus.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/remove_legal_hold_immutability_long_term_retention_backup.py b/sdk/sql/azure-mgmt-sql/generated_samples/remove_legal_hold_immutability_long_term_retention_backup.py index 485349d78266..0dc74d4e66dd 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/remove_legal_hold_immutability_long_term_retention_backup.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/remove_legal_hold_immutability_long_term_retention_backup.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_term_retention_backups.begin_remove_legal_hold_immutability( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/RemoveLegalHoldImmutabilityLongTermRetentionBackup.json +# x-ms-original-file: 2025-02-01-preview/RemoveLegalHoldImmutabilityLongTermRetentionBackup.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/remove_time_based_immutability_long_term_retention_backup.py b/sdk/sql/azure-mgmt-sql/generated_samples/remove_time_based_immutability_long_term_retention_backup.py index 6315e30ff213..a915f0571a04 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/remove_time_based_immutability_long_term_retention_backup.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/remove_time_based_immutability_long_term_retention_backup.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_term_retention_backups.begin_remove_time_based_immutability( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/RemoveTimeBasedImmutabilityLongTermRetentionBackup.json +# x-ms-original-file: 2025-02-01-preview/RemoveTimeBasedImmutabilityLongTermRetentionBackup.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 f2d0e97a18a9..97732bf1270a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/rename_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/rename_database.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.databases.rename( @@ -41,6 +41,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/RenameDatabase.json +# x-ms-original-file: 2025-02-01-preview/RenameDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_create_or_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_create_or_update.py index 302687c97e8e..50f52ece3986 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_create_or_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_create_or_update.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.replication_links.begin_create_or_update( @@ -41,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ReplicationLinkCreateOrUpdate.json +# x-ms-original-file: 2025-02-01-preview/ReplicationLinkCreateOrUpdate.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 f80115b46d6e..33460596a8cc 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.replication_links.begin_delete( @@ -39,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ReplicationLinkDelete.json +# x-ms-original-file: 2025-02-01-preview/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 9ed800d1b3fa..1df49d3d8a84 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.replication_links.begin_failover( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ReplicationLinkFailover.json +# x-ms-original-file: 2025-02-01-preview/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 9e1b89781e53..40b71fe8c74e 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.replication_links.begin_failover_allow_data_loss( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ReplicationLinkFailoverAllowDataLoss.json +# x-ms-original-file: 2025-02-01-preview/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 f5f20c3020d5..c5c208d2ddbd 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.replication_links.get( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ReplicationLinkGet.json +# x-ms-original-file: 2025-02-01-preview/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 ef91ddff7741..1ee52441be38 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.replication_links.list_by_database( @@ -40,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ReplicationLinkListByDatabase.json +# x-ms-original-file: 2025-02-01-preview/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 94b57649017e..63fa6de31c66 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.replication_links.list_by_server( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ReplicationLinkListByServer.json +# x-ms-original-file: 2025-02-01-preview/ReplicationLinkListByServer.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_update.py index 4d07b8161eb4..2b37b2b30d16 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_update.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.replication_links.begin_update( @@ -41,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ReplicationLinkUpdate.json +# x-ms-original-file: 2025-02-01-preview/ReplicationLinkUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_change_long_term_retention_backup_access_tier.py b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_change_long_term_retention_backup_access_tier.py index b142e5ee433c..71b6a4170ed9 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_change_long_term_retention_backup_access_tier.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_change_long_term_retention_backup_access_tier.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_term_retention_backups.begin_change_access_tier_by_resource_group( @@ -42,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/ResourceGroupBasedChangeLongTermRetentionBackupAccessTier.json +# x-ms-original-file: 2025-02-01-preview/ResourceGroupBasedChangeLongTermRetentionBackupAccessTier.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_lock_time_based_immutability_long_term_retention_backup.py b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_lock_time_based_immutability_long_term_retention_backup.py index 8508b10c5a2b..eebbd615c2ec 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_lock_time_based_immutability_long_term_retention_backup.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_lock_time_based_immutability_long_term_retention_backup.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_term_retention_backups.begin_lock_time_based_immutability_by_resource_group( @@ -41,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/ResourceGroupBasedLockTimeBasedImmutabilityLongTermRetentionBackup.json +# x-ms-original-file: 2025-02-01-preview/ResourceGroupBasedLockTimeBasedImmutabilityLongTermRetentionBackup.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 7378eca9b04c..225e99d1ef7e 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_term_retention_backups.begin_copy_by_resource_group( @@ -48,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/ResourceGroupBasedLongTermRetentionBackupCopy.json +# x-ms-original-file: 2025-02-01-preview/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 d9eb4e7f91c8..eceba0792f44 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.long_term_retention_backups.begin_delete_by_resource_group( @@ -40,6 +39,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/ResourceGroupBasedLongTermRetentionBackupDelete.json +# x-ms-original-file: 2025-02-01-preview/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 cebf8c260720..89e3d925d154 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_term_retention_backups.get_by_resource_group( @@ -41,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/ResourceGroupBasedLongTermRetentionBackupGet.json +# x-ms-original-file: 2025-02-01-preview/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 1f02c72e5568..d52eff4f40fc 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_term_retention_backups.list_by_resource_group_database( @@ -41,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/ResourceGroupBasedLongTermRetentionBackupListByDatabase.json +# x-ms-original-file: 2025-02-01-preview/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 eeaf35311ca0..d76475a7057a 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_term_retention_backups.list_by_resource_group_location( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/ResourceGroupBasedLongTermRetentionBackupListByLocation.json +# x-ms-original-file: 2025-02-01-preview/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 4a8e4059e86e..3efccda97f6b 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_term_retention_backups.list_by_resource_group_server( @@ -40,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/ResourceGroupBasedLongTermRetentionBackupListByServer.json +# x-ms-original-file: 2025-02-01-preview/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 1187df030115..f68518146dda 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_term_retention_backups.begin_update_by_resource_group( @@ -42,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/ResourceGroupBasedLongTermRetentionBackupUpdate.json +# x-ms-original-file: 2025-02-01-preview/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 385b30e3dc19..30733e139d3a 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.long_term_retention_managed_instance_backups.begin_delete_by_resource_group( @@ -36,10 +35,10 @@ def main(): location_name="japaneast", managed_instance_name="testInstance", database_name="testDatabase", - backup_name="55555555-6666-7777-8888-999999999999;131637960820000000", + backup_name="55555555-6666-7777-8888-999999999999;131637960820000000;Archive", ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ResourceGroupBasedManagedInstanceLongTermRetentionBackupDelete.json +# x-ms-original-file: 2025-02-01-preview/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 8fd4dae8f049..9b2c85319ab8 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_term_retention_managed_instance_backups.get_by_resource_group( @@ -36,11 +35,11 @@ def main(): location_name="japaneast", managed_instance_name="testInstance", database_name="testDatabase", - backup_name="55555555-6666-7777-8888-999999999999;131637960820000000", + backup_name="55555555-6666-7777-8888-999999999999;131637960820000000;Archive", ) print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ResourceGroupBasedManagedInstanceLongTermRetentionBackupGet.json +# x-ms-original-file: 2025-02-01-preview/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 ebb6fba6a51d..c0a5fc0a822d 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_term_retention_managed_instance_backups.list_by_resource_group_database( @@ -41,6 +40,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: 2025-02-01-preview/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 3fc108a8b7e1..9a6dea24800e 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_term_retention_managed_instance_backups.list_by_resource_group_instance( @@ -40,6 +39,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: 2025-02-01-preview/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 d23278349508..4fe4e04226f7 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_term_retention_managed_instance_backups.list_by_resource_group_location( @@ -39,6 +38,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: 2025-02-01-preview/ResourceGroupBasedManagedInstanceLongTermRetentionBackupListByLocation.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_managed_instance_long_term_retention_backup_list_by_location_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_managed_instance_long_term_retention_backup_list_by_location_max.py new file mode 100644 index 000000000000..504e08a85c60 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_managed_instance_long_term_retention_backup_list_by_location_max.py @@ -0,0 +1,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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python resource_group_based_managed_instance_long_term_retention_backup_list_by_location_max.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.long_term_retention_managed_instance_backups.list_by_resource_group_location( + resource_group_name="testResourceGroup", + location_name="japaneast", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2025-02-01-preview/ResourceGroupBasedManagedInstanceLongTermRetentionBackupListByLocationMax.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_remove_legal_hold_immutability_long_term_retention_backup.py b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_remove_legal_hold_immutability_long_term_retention_backup.py index 4d3bfb985ef7..9fdb9eccb1a5 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_remove_legal_hold_immutability_long_term_retention_backup.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_remove_legal_hold_immutability_long_term_retention_backup.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_term_retention_backups.begin_remove_legal_hold_immutability_by_resource_group( @@ -41,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/ResourceGroupBasedRemoveLegalHoldImmutabilityLongTermRetentionBackup.json +# x-ms-original-file: 2025-02-01-preview/ResourceGroupBasedRemoveLegalHoldImmutabilityLongTermRetentionBackup.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_remove_time_based_immutability_long_term_retention_backup.py b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_remove_time_based_immutability_long_term_retention_backup.py index a67791d665a2..e83b1b0f8c3d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_remove_time_based_immutability_long_term_retention_backup.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_remove_time_based_immutability_long_term_retention_backup.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_term_retention_backups.begin_remove_time_based_immutability_by_resource_group( @@ -41,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/ResourceGroupBasedRemoveTimeBasedImmutabilityLongTermRetentionBackup.json +# x-ms-original-file: 2025-02-01-preview/ResourceGroupBasedRemoveTimeBasedImmutabilityLongTermRetentionBackup.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_set_legal_hold_immutability_long_term_retention_backup.py b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_set_legal_hold_immutability_long_term_retention_backup.py index 3feca581c909..07798b572ae0 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_set_legal_hold_immutability_long_term_retention_backup.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_set_legal_hold_immutability_long_term_retention_backup.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_term_retention_backups.begin_set_legal_hold_immutability_by_resource_group( @@ -41,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/ResourceGroupBasedSetLegalHoldImmutabilityLongTermRetentionBackup.json +# x-ms-original-file: 2025-02-01-preview/ResourceGroupBasedSetLegalHoldImmutabilityLongTermRetentionBackup.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 2e22af35bb96..f235352ad6ca 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.restorable_dropped_managed_databases.list_by_instance( @@ -39,6 +38,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: 2025-02-01-preview/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 739830dd4ab9..0fff78b840d3 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/resume_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/resume_database.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_resume( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ResumeDatabase.json +# x-ms-original-file: 2025-02-01-preview/ResumeDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/resume_transparent_data_encryption_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/resume_transparent_data_encryption_update.py new file mode 100644 index 000000000000..bb9e56f19055 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/resume_transparent_data_encryption_update.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python 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 resume_transparent_data_encryption_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.transparent_data_encryptions.begin_resume( + resource_group_name="securitytde-42-rg", + server_name="securitytde-42", + database_name="testdb", + tde_name="current", + ).result() + print(response) + + +# x-ms-original-file: 2025-02-01-preview/ResumeTransparentDataEncryptionUpdate.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 401e078e3bea..592a031f60f2 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.sensitivity_labels.update( @@ -77,6 +76,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SensitivityLabelsCurrentUpdate.json +# x-ms-original-file: 2025-02-01-preview/SensitivityLabelsCurrentUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sensitivity_labels_list_by_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/sensitivity_labels_list_by_database.py new file mode 100644 index 000000000000..bb8672368fe6 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sensitivity_labels_list_by_database.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python 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 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, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.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: 2025-02-01-preview/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 53d35aed040a..16e6c5a9be20 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sensitivity_labels.list_current_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 7e6f07363522..6e0740aae501 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sensitivity_labels.list_recommended_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 449963e79c62..d5b9722e00e5 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.recommended_sensitivity_labels.update( @@ -45,6 +44,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SensitivityLabelsRecommendedUpdate.json +# x-ms-original-file: 2025-02-01-preview/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 b2a34d592b79..a7b56f3fcda2 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_advanced_threat_protection_settings.begin_create_or_update( @@ -40,6 +39,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: 2025-02-01-preview/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 12c7e8121718..832055e745d8 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_advanced_threat_protection_settings.begin_create_or_update( @@ -40,6 +39,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: 2025-02-01-preview/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 bdfb1e4afcc8..ac74d57126e6 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_advanced_threat_protection_settings.get( @@ -39,6 +38,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: 2025-02-01-preview/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 5ba7b3d24d82..9b0b9cab7dd7 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_advanced_threat_protection_settings.list_by_server( @@ -39,6 +38,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: 2025-02-01-preview/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 b08375ad081f..dc3bfd0fb05a 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_advisors.get( @@ -39,6 +38,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: 2025-02-01-preview/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 bc7f0f348e48..43cea8d6e238 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_advisors.list_by_server( @@ -38,6 +37,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: 2025-02-01-preview/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 b778addaa39b..7f1156ec7d55 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_advisors.update( @@ -40,6 +39,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: 2025-02-01-preview/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 dad6ca4c8552..73ffced9a025 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_blob_auditing_policies.list_by_server( @@ -39,6 +38,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: 2025-02-01-preview/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 f6d687777b9c..c62c5a6d9a7b 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="c3aa9078-0000-0000-0000-e36f151182d7", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_automatic_tuning.get( @@ -38,6 +37,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: 2025-02-01-preview/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 b535eebad2a0..8a7d3647bb68 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="c3aa9078-0000-0000-0000-e36f151182d7", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_automatic_tuning.update( @@ -48,6 +47,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: 2025-02-01-preview/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 55d0e3a14d48..15ebd95065dd 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="c3aa9078-0000-0000-0000-e36f151182d7", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_automatic_tuning.update( @@ -39,6 +38,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: 2025-02-01-preview/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 aa7f906f20bf..cbcec39257fb 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_blob_auditing_policies.begin_create_or_update( @@ -55,6 +55,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: 2025-02-01-preview/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 b7bfc37d0dea..ff303df864a6 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_blob_auditing_policies.begin_create_or_update( @@ -45,6 +45,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: 2025-02-01-preview/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 43e3e0e96e9a..ad24a7516c52 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_blob_auditing_policies.get( @@ -38,6 +37,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: 2025-02-01-preview/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 5035e580ade1..270b088907ba 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_configuration_options.get( @@ -39,6 +38,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: 2025-02-01-preview/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 df4be4a2073d..9900ec5f02f3 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_configuration_options.list_by_managed_instance( @@ -39,6 +38,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: 2025-02-01-preview/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 84683da826f1..73dd6e79f9b4 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_configuration_options.begin_create_or_update( @@ -40,6 +39,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: 2025-02-01-preview/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 9b698143e685..94537534ddd4 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_connection_policies.get( @@ -39,6 +38,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: 2025-02-01-preview/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 382c2c087db4..d0730f535b8d 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_connection_policies.list_by_server( @@ -39,6 +38,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: 2025-02-01-preview/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 717001f69e78..cf4da7f684e4 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_connection_policies.begin_create_or_update( @@ -40,6 +39,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: 2025-02-01-preview/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 ba630bd34589..550a75e6e62e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_create.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_create.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_create_or_update( @@ -57,6 +56,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/ServerCreate.json +# x-ms-original-file: 2025-02-01-preview/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 2d65553b5c9f..a78e3f576184 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_delete.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.servers.begin_delete( @@ -37,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/ServerDelete.json +# x-ms-original-file: 2025-02-01-preview/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 cf5019dd64c3..cedacc3c715b 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_dev_ops_audit_settings.begin_create_or_update( @@ -48,6 +47,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: 2025-02-01-preview/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 a26ccc8a7667..a8f7686a8277 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_dev_ops_audit_settings.begin_create_or_update( @@ -46,6 +45,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: 2025-02-01-preview/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 8b90e1faad87..a0204c70dd09 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_dev_ops_audit_settings.get( @@ -39,6 +38,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: 2025-02-01-preview/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 c6e974cf18f1..35bd280c3c04 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_dev_ops_audit_settings.list_by_server( @@ -39,6 +38,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: 2025-02-01-preview/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 e4017bc1546d..dcf710c1b0e7 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_dns_aliases.begin_acquire( @@ -42,6 +42,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: 2025-02-01-preview/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 3470e4070290..a06ff77a660a 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_dns_aliases.begin_create_or_update( @@ -39,6 +38,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: 2025-02-01-preview/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 c15492ca7da8..3bee9a591743 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.server_dns_aliases.begin_delete( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerDnsAliasDelete.json +# x-ms-original-file: 2025-02-01-preview/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 a56ebc40ffb6..5de5307c56be 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_dns_aliases.get( @@ -39,6 +38,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: 2025-02-01-preview/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 fc08cca3bd89..55f74f888295 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_dns_aliases.list_by_server( @@ -39,6 +38,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: 2025-02-01-preview/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 59e425e9a958..b570d302f28e 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.extended_server_blob_auditing_policies.list_by_server( @@ -39,6 +38,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: 2025-02-01-preview/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 2f9016e93ff2..c89d694037b6 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_get.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.get( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/ServerGet.json +# x-ms-original-file: 2025-02-01-preview/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 68807ca5258c..0d79f66464dc 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.get( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/ServerGetWithExpandEqualsAdministrators.json +# x-ms-original-file: 2025-02-01-preview/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 e18ae5088f41..0d2ea0c4778f 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_keys.begin_create_or_update( @@ -45,6 +44,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: 2025-02-01-preview/ServerKeyCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_key_create_or_update_with_versionless_key.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_key_create_or_update_with_versionless_key.py new file mode 100644 index 000000000000..5d4e8f3d19df --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_key_create_or_update_with_versionless_key.py @@ -0,0 +1,46 @@ +# 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) Python 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 server_key_create_or_update_with_versionless_key.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.server_keys.begin_create_or_update( + resource_group_name="sqlcrudtest-7398", + server_name="sqlcrudtest-4645", + key_name="someVault_someKey", + parameters={ + "properties": {"serverKeyType": "AzureKeyVault", "uri": "https://someVault.vault.azure.net/keys/someKey"} + }, + ).result() + print(response) + + +# x-ms-original-file: 2025-02-01-preview/ServerKeyCreateOrUpdateWithVersionlessKey.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 dfd6709d69e1..06764087a694 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.server_keys.begin_delete( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerKeyDelete.json +# x-ms-original-file: 2025-02-01-preview/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 27a1706095e1..d97e35e22d08 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_keys.get( @@ -39,6 +38,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: 2025-02-01-preview/ServerKeyGet.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/server_key_get_with_versionless_key.py similarity index 73% rename from sdk/sql/azure-mgmt-sql/generated_samples/server_communication_link_delete.py rename to sdk/sql/azure-mgmt-sql/generated_samples/server_key_get_with_versionless_key.py index 3f7ae29165f2..4e33ef35ba9f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_communication_link_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_key_get_with_versionless_key.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -16,7 +15,7 @@ pip install azure-identity pip install azure-mgmt-sql # USAGE - python server_communication_link_delete.py + python server_key_get_with_versionless_key.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, @@ -28,16 +27,17 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) - client.server_communication_links.delete( + response = client.server_keys.get( resource_group_name="sqlcrudtest-7398", server_name="sqlcrudtest-4645", - communication_link_name="link1", + key_name="someVault_someKey", ) + print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ServerCommunicationLinkDelete.json +# x-ms-original-file: 2025-02-01-preview/ServerKeyGetWithVersionlessKey.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 ec15d350da6e..ab5d1864009c 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_keys.list_by_server( @@ -39,6 +38,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: 2025-02-01-preview/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 fb8948711bb9..8b3e661f0f2f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_list.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.list() @@ -36,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/ServerList.json +# x-ms-original-file: 2025-02-01-preview/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 161c3fc936eb..576496df9503 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.list_by_resource_group( @@ -38,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/ServerListByResourceGroup.json +# x-ms-original-file: 2025-02-01-preview/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 8630a8dd9bf7..9785a46dcfbb 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.list_by_resource_group( @@ -38,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/ServerListByResourceGroupWithExpandEqualsAdministrators.json +# x-ms-original-file: 2025-02-01-preview/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 3b9cca85c7f5..66b7bca6e399 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.list() @@ -36,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/ServerListWithExpandEqualsAdministrators.json +# x-ms-original-file: 2025-02-01-preview/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 598d893e4b6b..87cbdb9b0fcb 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_advisors.list_by_server( @@ -38,6 +37,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: 2025-02-01-preview/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 a3dd9e30e0cb..cbafddcffad7 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_security_alert_policies.begin_create_or_update( @@ -50,6 +50,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: 2025-02-01-preview/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 d2ae5f33ae87..f2740f5885e9 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_security_alert_policies.begin_create_or_update( @@ -40,6 +39,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: 2025-02-01-preview/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 cb3fa3c9979a..78a77a57b5a1 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_security_alert_policies.get( @@ -39,6 +38,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: 2025-02-01-preview/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 26b6490f58c2..857b72ede8c7 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_security_alert_policies.list_by_server( @@ -39,6 +38,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: 2025-02-01-preview/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 32410bed87d4..790ed534f278 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="0574222d-5c7f-489c-a172-b3013eafab53", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_trust_certificates.begin_create_or_update( @@ -40,6 +39,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: 2025-02-01-preview/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 bf7d6113edc8..586006578b87 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="38e0dc56-907f-45ba-a97c-74233baad471", + subscription_id="SUBSCRIPTION_ID", ) client.server_trust_certificates.begin_delete( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerTrustCertificatesDelete.json +# x-ms-original-file: 2025-02-01-preview/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 c593dd2f64e5..d611f2f5de67 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="38e0dc56-907f-45ba-a97c-74233baad471", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_trust_certificates.get( @@ -39,6 +38,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: 2025-02-01-preview/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 d5d43da485e3..b45fb528ac82 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="38e0dc56-907f-45ba-a97c-74233baad471", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_trust_certificates.list_by_instance( @@ -39,6 +38,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: 2025-02-01-preview/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 8846a44f1feb..4e4ee25ef174 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_trust_groups.begin_create_or_update( @@ -52,6 +52,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: 2025-02-01-preview/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 5d71ed79eb42..fa6e22042be0 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.server_trust_groups.begin_delete( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerTrustGroupDelete.json +# x-ms-original-file: 2025-02-01-preview/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 83a24522d42c..a589adbf4980 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_trust_groups.get( @@ -39,6 +38,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: 2025-02-01-preview/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 7dafa8da2fdb..9c16f8e431e1 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_trust_groups.list_by_location( @@ -39,6 +38,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: 2025-02-01-preview/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 7f140d70e268..182edee6c597 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_trust_groups.list_by_instance( @@ -39,6 +38,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: 2025-02-01-preview/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 8d3431a639d8..0f1605ffda87 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_update.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.servers.begin_update( @@ -48,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/ServerUpdate.json +# x-ms-original-file: 2025-02-01-preview/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 78% 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 ba08dc783411..e94c5e474e4d 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -16,7 +15,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, @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_usages.list_by_server( @@ -39,6 +38,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: 2025-02-01-preview/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 08d439d994aa..a046c1e95ded 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_vulnerability_assessments.create_or_update( @@ -45,6 +44,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: 2025-02-01-preview/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 021ca20aff29..4104f8d469a1 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_vulnerability_assessments.create_or_update( @@ -51,6 +50,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: 2025-02-01-preview/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 fdd11a45fb82..035b6a36b0e8 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_vulnerability_assessments.create_or_update( @@ -45,6 +44,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: 2025-02-01-preview/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 257c697d5405..e3072120051b 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.server_vulnerability_assessments.delete( @@ -38,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerVulnerabilityAssessmentDelete.json +# x-ms-original-file: 2025-02-01-preview/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 06cb8d920e5b..d026c81e87c4 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_vulnerability_assessments.get( @@ -39,6 +38,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: 2025-02-01-preview/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 35180060caa5..43a9b8ea6342 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.server_vulnerability_assessments.list_by_server( @@ -39,6 +38,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: 2025-02-01-preview/ServerVulnerabilityAssessmentListByServer.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/set_legal_hold_immutability_long_term_retention_backup.py b/sdk/sql/azure-mgmt-sql/generated_samples/set_legal_hold_immutability_long_term_retention_backup.py index d710c47e3d1a..7f7021462a13 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/set_legal_hold_immutability_long_term_retention_backup.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/set_legal_hold_immutability_long_term_retention_backup.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.long_term_retention_backups.begin_set_legal_hold_immutability( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2024-11-01-preview/examples/SetLegalHoldImmutabilityLongTermRetentionBackup.json +# x-ms-original-file: 2025-02-01-preview/SetLegalHoldImmutabilityLongTermRetentionBackup.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 df6afcf72911..cadf60a55e38 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sql_agent.get( @@ -38,6 +37,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: 2025-02-01-preview/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 d0b7e530ade6..b1eeb5a44ea9 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sql_agent.create_or_update( @@ -39,6 +38,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: 2025-02-01-preview/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 bbc977c79f23..19ec12c6b600 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000001", + subscription_id="SUBSCRIPTION_ID", ) client.tde_certificates.begin_create( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SqlTdeCertificateCreate.json +# x-ms-original-file: 2025-02-01-preview/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 ac7708bc7c44..395cb20dd450 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sql_vulnerability_assessment_baselines.create_or_update( @@ -45,10 +44,11 @@ def main(): }, } }, + system_database_name="master", ) print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentBaselineAdd.json +# x-ms-original-file: 2025-02-01-preview/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 349c05c0a53f..9375b685dc82 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sql_vulnerability_assessment_baselines.create_or_update( @@ -37,10 +36,11 @@ def main(): vulnerability_assessment_name="default", baseline_name="default", parameters={"properties": {"latestScan": True, "results": {}}}, + system_database_name="master", ) print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentBaselineAddLatest.json +# x-ms-original-file: 2025-02-01-preview/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 9aa6b79a1d83..68f99d4c412c 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sql_vulnerability_assessment_baseline.get( @@ -36,10 +35,11 @@ def main(): server_name="vulnerabilityaseessmenttest-6411", vulnerability_assessment_name="default", baseline_name="default", + system_database_name="master", ) print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentBaselineGet.json +# x-ms-original-file: 2025-02-01-preview/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 9e6e5ffa12ef..a4b453f31af6 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,18 +27,19 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sql_vulnerability_assessment_baseline.list_by_sql_vulnerability_assessment( resource_group_name="vulnerabilityaseessmenttest-4711", server_name="vulnerabilityaseessmenttest-6411", vulnerability_assessment_name="default", + system_database_name="master", ) for item in response: print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentBaselineListBySqlVulnerabilityAssessment.json +# x-ms-original-file: 2025-02-01-preview/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 1e4ce0d36a42..97885180a4bb 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sql_vulnerability_assessments_settings.create_or_update( @@ -40,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentCreate.json +# x-ms-original-file: 2025-02-01-preview/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 c169959c6b2e..8e532aab6798 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.sql_vulnerability_assessments.delete( @@ -38,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentDelete.json +# x-ms-original-file: 2025-02-01-preview/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 64d6f029acc6..d88ddb5ff4b3 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sql_vulnerability_assessments_settings.get( @@ -39,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentGet.json +# x-ms-original-file: 2025-02-01-preview/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 c6590b3a3c28..cfb52580a4eb 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sql_vulnerability_assessments_settings.list_by_server( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentListByServer.json +# x-ms-original-file: 2025-02-01-preview/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 cca08c7e9310..e094fd9d142d 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sql_vulnerability_assessment_scan_result.list_by_scan( @@ -36,11 +35,12 @@ def main(): server_name="testsvr", vulnerability_assessment_name="default", scan_id="scanId1", + system_database_name="master", ) for item in response: print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentListScansResults.json +# x-ms-original-file: 2025-02-01-preview/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 65339950d35d..69c222bb3233 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sql_vulnerability_assessment_rule_baseline.create_or_update( @@ -43,10 +42,11 @@ def main(): "results": [["userA", "SELECT"], ["userB", "SELECT"], ["userC", "SELECT"]], } }, + system_database_name="master", ) print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentRuleBaselineCreate.json +# x-ms-original-file: 2025-02-01-preview/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 e0b318aec5f1..16af284c56c9 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.sql_vulnerability_assessment_rule_baselines.delete( @@ -37,9 +36,10 @@ def main(): vulnerability_assessment_name="default", baseline_name="default", rule_id="VA1001", + system_database_name="master", ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentRuleBaselineDelete.json +# x-ms-original-file: 2025-02-01-preview/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 6d62cba52224..eec2283f670f 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sql_vulnerability_assessment_rule_baseline.get( @@ -37,10 +36,11 @@ def main(): vulnerability_assessment_name="default", baseline_name="default", rule_id="VA1001", + system_database_name="master", ) print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentRuleBaselineGet.json +# x-ms-original-file: 2025-02-01-preview/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 eda5f2a7f4eb..fdaf08ae4df5 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sql_vulnerability_assessment_rule_baseline.list_by_baseline( @@ -36,11 +35,12 @@ def main(): server_name="vulnerabilityaseessmenttest-6411", vulnerability_assessment_name="default", baseline_name="default", + system_database_name="master", ) for item in response: print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentRuleBaselineListByBaseline.json +# x-ms-original-file: 2025-02-01-preview/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 2013c1e0490f..198968e2e80c 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sql_vulnerability_assessment_scans.get( @@ -36,10 +35,11 @@ def main(): server_name="vulnerabilityassessmenttest-6411", vulnerability_assessment_name="default", scan_id="scan001", + system_database_name="master", ) print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentScan.json +# x-ms-original-file: 2025-02-01-preview/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 0fbf7b94bd19..683019d4ae0d 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,18 +27,19 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sql_vulnerability_assessment_scans.list_by_sql_vulnerability_assessments( resource_group_name="vulnerabilityassessmenttest-4711", server_name="vulnerabilityassessmenttest-6411", vulnerability_assessment_name="default", + system_database_name="master", ) for item in response: print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentScanRecordsListByDatabase.json +# x-ms-original-file: 2025-02-01-preview/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 f49ac6c97de6..0ded2feb0f4b 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,16 +27,17 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.sql_vulnerability_assessment_execute_scan.begin_execute( resource_group_name="vulnerabilityassessmenttest-4711", server_name="vulnerabilityassessmenttest-6411", vulnerability_assessment_name="default", + system_database_name="master", ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentScansExecute.json +# x-ms-original-file: 2025-02-01-preview/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 b353528824dc..b69b85d42e5d 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sql_vulnerability_assessment_scan_result.get( @@ -37,10 +36,11 @@ def main(): vulnerability_assessment_name="default", scan_id="scanId1", scan_result_id="VA1234", + system_database_name="master", ) print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentScansResults.json +# x-ms-original-file: 2025-02-01-preview/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 b2a4138b872d..913377d8b996 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instances.begin_start( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/StartManagedInstance.json +# x-ms-original-file: 2025-02-01-preview/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 6ffda84b01eb..1445b51c040d 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.start_stop_managed_instance_schedules.create_or_update( @@ -49,6 +48,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: 2025-02-01-preview/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 409aef2d3886..ee5b9098a888 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.start_stop_managed_instance_schedules.create_or_update( @@ -47,6 +46,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: 2025-02-01-preview/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 0caeed29673d..a94a70e963b3 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.start_stop_managed_instance_schedules.delete( @@ -38,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/StartStopManagedInstanceScheduleDelete.json +# x-ms-original-file: 2025-02-01-preview/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 27b9d0e0e240..6b6a288e6a1c 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.start_stop_managed_instance_schedules.get( @@ -39,6 +38,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: 2025-02-01-preview/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 e681656c1e6a..1614034c19c7 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.start_stop_managed_instance_schedules.list_by_instance( @@ -39,6 +38,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: 2025-02-01-preview/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 a1f6704a5fcb..312e29713daa 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_instances.begin_stop( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/StopManagedInstance.json +# x-ms-original-file: 2025-02-01-preview/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 7f6ae9bc39dd..6c00aff3e58c 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.subscription_usages.get( @@ -38,6 +37,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: 2025-02-01-preview/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 e9cb093c354f..c58ef00695e7 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.subscription_usages.list_by_location( @@ -38,6 +37,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: 2025-02-01-preview/SubscriptionUsageListByLocation.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/suspend_transparent_data_encryption_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/suspend_transparent_data_encryption_update.py new file mode 100644 index 000000000000..b6836ac30d4f --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/suspend_transparent_data_encryption_update.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python 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 suspend_transparent_data_encryption_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.transparent_data_encryptions.begin_suspend( + resource_group_name="securitytde-42-rg", + server_name="securitytde-42", + database_name="testdb", + tde_name="current", + ).result() + print(response) + + +# x-ms-original-file: 2025-02-01-preview/SuspendTransparentDataEncryptionUpdate.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 ff818ca53e33..88db47b22ca2 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.synapse_link_workspaces.list_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 dc6e6202d6ff..c797fb52528f 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sync_agents.begin_create_or_update( @@ -44,6 +44,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: 2025-02-01-preview/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 72833de2ff89..08b73503383d 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.sync_agents.begin_delete( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncAgentDelete.json +# x-ms-original-file: 2025-02-01-preview/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 261ac60ccc34..6ff5fc0d8280 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sync_agents.generate_key( @@ -39,6 +38,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: 2025-02-01-preview/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 8e7b3ba86f3a..ed7a6488486d 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sync_agents.get( @@ -39,6 +38,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: 2025-02-01-preview/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 d030bbda983f..82ffdb3cbacc 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sync_agents.list_linked_databases( @@ -40,6 +39,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: 2025-02-01-preview/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 248432dedef7..8922ad4a5989 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sync_agents.list_by_server( @@ -39,6 +38,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: 2025-02-01-preview/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 7fe22c3fff5c..a9f9db363753 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sync_agents.begin_create_or_update( @@ -44,6 +44,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: 2025-02-01-preview/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 f310b79da3ac..038bcc69154c 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.sync_groups.cancel_sync( @@ -39,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupCancelSync.json +# x-ms-original-file: 2025-02-01-preview/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 87d6d9b343ac..b60f26e089c7 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sync_groups.begin_create_or_update( @@ -49,6 +49,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: 2025-02-01-preview/SyncGroupCreate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_create_with_identity.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_create_with_identity.py new file mode 100644 index 000000000000..c72a0bbb8f69 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_create_with_identity.py @@ -0,0 +1,59 @@ +# pylint: disable=line-too-long,useless-suppression +# 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) Python 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 sync_group_create_with_identity.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.sync_groups.begin_create_or_update( + resource_group_name="syncgroupcrud-65440", + server_name="syncgroupcrud-8475", + database_name="syncgroupcrud-4328", + sync_group_name="syncgroupcrud-3187", + parameters={ + "identity": { + "type": "UserAssigned", + "userAssignedIdentities": { + "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-umi": {} + }, + }, + "properties": { + "conflictResolutionPolicy": "HubWin", + "interval": -1, + "syncDatabaseId": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/syncgroupcrud-3521/providers/Microsoft.Sql/servers/syncgroupcrud-8475/databases/syncgroupcrud-4328", + "usePrivateLinkConnection": False, + }, + }, + ).result() + print(response) + + +# x-ms-original-file: 2025-02-01-preview/SyncGroupCreateWithIdentity.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 e42baee5ffa7..29a25d3a0685 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.sync_groups.begin_delete( @@ -39,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupDelete.json +# x-ms-original-file: 2025-02-01-preview/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 8739c08064ba..a0a5961169cb 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sync_groups.get( @@ -40,6 +39,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: 2025-02-01-preview/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 b7b5318adccd..d3be703b6a25 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sync_groups.list_hub_schemas( @@ -41,6 +40,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: 2025-02-01-preview/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 1d4be7791030..81175b7860ff 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sync_groups.list_logs( @@ -44,6 +43,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: 2025-02-01-preview/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 adba896d2f18..037179b4f0d7 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sync_groups.list_sync_database_ids( @@ -38,6 +37,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: 2025-02-01-preview/SyncGroupGetSyncDatabaseId.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_get_with_identity.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_get_with_identity.py new file mode 100644 index 000000000000..767a0cc4682d --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_get_with_identity.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python 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 sync_group_get_with_identity.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.sync_groups.get( + resource_group_name="syncgroupcrud-65440", + server_name="syncgroupcrud-8475", + database_name="syncgroupcrud-4328", + sync_group_name="syncgroupcrud-3187", + ) + print(response) + + +# x-ms-original-file: 2025-02-01-preview/SyncGroupGetWithIdentity.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 5fd0b55249c0..cfd1528af5f4 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sync_groups.list_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 8610bdc3b5e8..720b33092d2d 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sync_groups.begin_update( @@ -50,6 +50,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: 2025-02-01-preview/SyncGroupPatch.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_patch_add_and_remove_identity.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_patch_add_and_remove_identity.py new file mode 100644 index 000000000000..b00054809c97 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_patch_add_and_remove_identity.py @@ -0,0 +1,60 @@ +# pylint: disable=line-too-long,useless-suppression +# 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) Python 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 sync_group_patch_add_and_remove_identity.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.sync_groups.begin_update( + resource_group_name="syncgroupcrud-65440", + server_name="syncgroupcrud-8475", + database_name="syncgroupcrud-4328", + sync_group_name="syncgroupcrud-3187", + parameters={ + "identity": { + "type": "UserAssigned", + "userAssignedIdentities": { + "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-umi": None, + "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-umi-2": {}, + }, + }, + "properties": { + "conflictResolutionPolicy": "HubWin", + "interval": -1, + "syncDatabaseId": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/syncgroupcrud-3521/providers/Microsoft.Sql/servers/syncgroupcrud-8475/databases/syncgroupcrud-4328", + "usePrivateLinkConnection": False, + }, + }, + ).result() + print(response) + + +# x-ms-original-file: 2025-02-01-preview/SyncGroupPatchAddAndRemoveIdentity.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_patch_with_identity.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_patch_with_identity.py new file mode 100644 index 000000000000..9180b2bd70eb --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_patch_with_identity.py @@ -0,0 +1,59 @@ +# pylint: disable=line-too-long,useless-suppression +# 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) Python 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 sync_group_patch_with_identity.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.sync_groups.begin_update( + resource_group_name="syncgroupcrud-65440", + server_name="syncgroupcrud-8475", + database_name="syncgroupcrud-4328", + sync_group_name="syncgroupcrud-3187", + parameters={ + "identity": { + "type": "UserAssigned", + "userAssignedIdentities": { + "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-umi": {} + }, + }, + "properties": { + "conflictResolutionPolicy": "HubWin", + "interval": -1, + "syncDatabaseId": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/syncgroupcrud-3521/providers/Microsoft.Sql/servers/syncgroupcrud-8475/databases/syncgroupcrud-4328", + "usePrivateLinkConnection": True, + }, + }, + ).result() + print(response) + + +# x-ms-original-file: 2025-02-01-preview/SyncGroupPatchWithIdentity.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 5c09f1896f88..8dabf5ca3ac6 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.sync_groups.begin_refresh_hub_schema( @@ -39,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupRefreshHubSchema.json +# x-ms-original-file: 2025-02-01-preview/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 c9670fbcf004..f9aa4c4624bd 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.sync_groups.trigger_sync( @@ -39,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupTriggerSync.json +# x-ms-original-file: 2025-02-01-preview/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 ca05f375c381..c41696c6918e 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sync_groups.begin_create_or_update( @@ -49,6 +49,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: 2025-02-01-preview/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 d7b46798a800..da67d4ae3770 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sync_members.begin_create_or_update( @@ -52,6 +52,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: 2025-02-01-preview/SyncMemberCreate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_create_with_identity.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_create_with_identity.py new file mode 100644 index 000000000000..0eb2c71d4134 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_create_with_identity.py @@ -0,0 +1,62 @@ +# pylint: disable=line-too-long,useless-suppression +# 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) Python 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 sync_member_create_with_identity.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.sync_members.begin_create_or_update( + resource_group_name="syncgroupcrud-65440", + server_name="syncgroupcrud-8475", + database_name="syncgroupcrud-4328", + sync_group_name="syncgroupcrud-3187", + sync_member_name="syncmembercrud-4879", + parameters={ + "identity": { + "type": "UserAssigned", + "userAssignedIdentities": { + "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-umi": {} + }, + }, + "properties": { + "databaseName": "syncgroupcrud-7421", + "databaseType": "AzureSqlDatabase", + "serverName": "syncgroupcrud-3379.database.windows.net", + "syncDirection": "Bidirectional", + "syncMemberAzureDatabaseResourceId": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/syncgroupcrud-65440/providers/Microsoft.Sql/servers/syncgroupcrud-8475/databases/syncgroupcrud-4328", + "usePrivateLinkConnection": True, + }, + }, + ).result() + print(response) + + +# x-ms-original-file: 2025-02-01-preview/SyncMemberCreateWithIdentity.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 4ba770e721db..41561f3cfc05 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.sync_members.begin_delete( @@ -40,6 +39,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncMemberDelete.json +# x-ms-original-file: 2025-02-01-preview/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 dc91e71e9e5a..5956c01efd63 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sync_members.get( @@ -41,6 +40,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: 2025-02-01-preview/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 42b270342b3c..cd4f948cdc79 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sync_members.list_member_schemas( @@ -42,6 +41,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: 2025-02-01-preview/SyncMemberGetSchema.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_get_with_identity.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_get_with_identity.py new file mode 100644 index 000000000000..82e0fd8e58ad --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_get_with_identity.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python 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 sync_member_get_with_identity.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.sync_members.get( + resource_group_name="syncgroupcrud-65440", + server_name="syncgroupcrud-8475", + database_name="syncgroupcrud-4328", + sync_group_name="syncgroupcrud-3187", + sync_member_name="syncmembercrud-4879", + ) + print(response) + + +# x-ms-original-file: 2025-02-01-preview/SyncMemberGetWithIdentity.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 5045b6be6ea0..a8b2f22284ff 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sync_members.list_by_sync_group( @@ -41,6 +40,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: 2025-02-01-preview/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 7c91763bb219..4caf3c99ef88 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sync_members.begin_update( @@ -52,6 +52,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: 2025-02-01-preview/SyncMemberPatch.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_patch_add_and_remove_identity.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_patch_add_and_remove_identity.py new file mode 100644 index 000000000000..b0d058a9ce36 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_patch_add_and_remove_identity.py @@ -0,0 +1,63 @@ +# pylint: disable=line-too-long,useless-suppression +# 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) Python 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 sync_member_patch_add_and_remove_identity.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.sync_members.begin_update( + resource_group_name="syncgroupcrud-65440", + server_name="syncgroupcrud-8475", + database_name="syncgroupcrud-4328", + sync_group_name="syncgroupcrud-3187", + sync_member_name="syncmembercrud-4879", + parameters={ + "identity": { + "type": "UserAssigned", + "userAssignedIdentities": { + "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-umi": None, + "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-umi-2": {}, + }, + }, + "properties": { + "databaseName": "syncgroupcrud-7421", + "databaseType": "AzureSqlDatabase", + "serverName": "syncgroupcrud-3379.database.windows.net", + "syncDirection": "Bidirectional", + "syncMemberAzureDatabaseResourceId": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/syncgroupcrud-65440/providers/Microsoft.Sql/servers/syncgroupcrud-8475/databases/syncgroupcrud-4328", + "usePrivateLinkConnection": True, + }, + }, + ).result() + print(response) + + +# x-ms-original-file: 2025-02-01-preview/SyncMemberPatchAddAndRemoveIdentity.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_patch_with_identity.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_patch_with_identity.py new file mode 100644 index 000000000000..6ed5bdda121c --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_patch_with_identity.py @@ -0,0 +1,62 @@ +# pylint: disable=line-too-long,useless-suppression +# 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) Python 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 sync_member_patch_with_identity.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.sync_members.begin_update( + resource_group_name="syncgroupcrud-65440", + server_name="syncgroupcrud-8475", + database_name="syncgroupcrud-4328", + sync_group_name="syncgroupcrud-3187", + sync_member_name="syncmembercrud-4879", + parameters={ + "identity": { + "type": "UserAssigned", + "userAssignedIdentities": { + "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-umi": {} + }, + }, + "properties": { + "databaseName": "syncgroupcrud-7421", + "databaseType": "AzureSqlDatabase", + "serverName": "syncgroupcrud-3379.database.windows.net", + "syncDirection": "Bidirectional", + "syncMemberAzureDatabaseResourceId": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/syncgroupcrud-65440/providers/Microsoft.Sql/servers/syncgroupcrud-8475/databases/syncgroupcrud-4328", + "usePrivateLinkConnection": True, + }, + }, + ).result() + print(response) + + +# x-ms-original-file: 2025-02-01-preview/SyncMemberPatchWithIdentity.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 3087e4b6cc25..b68fe3358fa9 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.sync_members.begin_refresh_member_schema( @@ -40,6 +39,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncMemberRefreshSchema.json +# x-ms-original-file: 2025-02-01-preview/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 1ff26e1ea328..86ca0eda3728 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.sync_members.begin_create_or_update( @@ -52,6 +52,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: 2025-02-01-preview/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 5acf2f228c4b..8c0e3066cd8b 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.transparent_data_encryptions.get( @@ -40,6 +39,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: 2025-02-01-preview/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 0368deea0614..cbd1d613f924 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.transparent_data_encryptions.list_by_database( @@ -40,6 +39,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: 2025-02-01-preview/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 87b856e49e68..f60a379383b1 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.transparent_data_encryptions.begin_create_or_update( @@ -36,11 +35,11 @@ def main(): server_name="securitytde-42", database_name="testdb", tde_name="current", - parameters={"properties": {"state": "Enabled"}}, + parameters={"properties": {"scanState": "Suspend", "state": "Enabled"}}, ).result() print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/TransparentDataEncryptionUpdate.json +# x-ms-original-file: 2025-02-01-preview/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 5d8b545a7b4a..0d54a300cdb8 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_create_or_update( @@ -50,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/UpdateDatabaseHyperscaleMigrationPerformCutover.json +# x-ms-original-file: 2025-02-01-preview/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 d99ff214ba8d..98aa18b90137 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.databases.begin_create_or_update( @@ -51,6 +51,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/UpdateDatabaseHyperscaleMigrationWithManualCutover.json +# x-ms-original-file: 2025-02-01-preview/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 a6897b3167ce..471a38494be8 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.job_agents.begin_update( @@ -40,6 +39,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: 2025-02-01-preview/UpdateJobAgent.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/update_job_agent_with_identity.py b/sdk/sql/azure-mgmt-sql/generated_samples/update_job_agent_with_identity.py new file mode 100644 index 000000000000..5efb0cdce71b --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/update_job_agent_with_identity.py @@ -0,0 +1,52 @@ +# pylint: disable=line-too-long,useless-suppression +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python update_job_agent_with_identity.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.job_agents.begin_update( + resource_group_name="group1", + server_name="server1", + job_agent_name="agent1", + parameters={ + "identity": { + "type": "UserAssigned", + "userAssignedIdentities": { + "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-umi": {} + }, + } + }, + ).result() + print(response) + + +# x-ms-original-file: 2025-02-01-preview/UpdateJobAgentWithIdentity.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/update_job_agent_with_sku.py similarity index 70% rename from sdk/sql/azure-mgmt-sql/generated_samples/service_objective_get.py rename to sdk/sql/azure-mgmt-sql/generated_samples/update_job_agent_with_sku.py index 498feb1ed805..b5ea74c6aad1 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/service_objective_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/update_job_agent_with_sku.py @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -16,7 +15,7 @@ pip install azure-identity pip install azure-mgmt-sql # USAGE - python service_objective_get.py + python update_job_agent_with_sku.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, @@ -28,17 +27,18 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) - response = client.service_objectives.get( + response = client.job_agents.begin_update( resource_group_name="group1", - server_name="sqlcrudtest", - service_objective_name="29dd7459-4a7c-4e56-be22-f0adda49440d", - ) + server_name="server1", + job_agent_name="agent1", + parameters={"sku": {"name": "JA200"}}, + ).result() print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ServiceObjectiveGet.json +# x-ms-original-file: 2025-02-01-preview/UpdateJobAgentWithSku.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 f71cb3bfb4fd..71509d5b4515 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,10 +27,10 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) - response = client.managed_backup_short_term_retention_policies.begin_create_or_update( + response = client.managed_backup_short_term_retention_policies.begin_update( resource_group_name="resourceGroup", managed_instance_name="testsvr", database_name="testdb", @@ -41,6 +40,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: 2025-02-01-preview/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 f619452a846f..1d9e0bcd7488 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,10 +27,10 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) - response = client.managed_restorable_dropped_database_backup_short_term_retention_policies.begin_create_or_update( + response = client.managed_restorable_dropped_database_backup_short_term_retention_policies.begin_update( resource_group_name="resourceGroup", managed_instance_name="testsvr", restorable_dropped_database_id="testdb,131403269876900000", @@ -41,6 +40,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: 2025-02-01-preview/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 c21419c17e99..79421e7bf528 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,10 +27,10 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) - response = client.backup_short_term_retention_policies.begin_create_or_update( + response = client.backup_short_term_retention_policies.begin_update( resource_group_name="resourceGroup", server_name="testsvr", database_name="testdb", @@ -41,6 +40,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: 2025-02-01-preview/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 912370bd2768..3bade9655203 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.virtual_clusters.begin_update_dns_servers( @@ -38,6 +37,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: 2025-02-01-preview/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 3bab6877c6a5..570c36fc5681 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.databases.begin_upgrade_data_warehouse( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/UpgradeDataWarehouse.json +# x-ms-original-file: 2025-02-01-preview/UpgradeDataWarehouse.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/virtual_cluster_create.py b/sdk/sql/azure-mgmt-sql/generated_samples/virtual_cluster_create.py new file mode 100644 index 000000000000..38bc16f79eb2 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/virtual_cluster_create.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) Python 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 virtual_cluster_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, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.virtual_clusters.begin_create_or_update( + resource_group_name="testrg", + virtual_cluster_name="vc-subnet1-f769ed71-b3ad-491a-a9d5-26eeceaa6be2", + parameters={"location": "japaneast", "tags": {"key": "value"}}, + ).result() + print(response) + + +# x-ms-original-file: 2025-02-01-preview/VirtualClusterCreate.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 63e91bd9fd15..8d29676a58e0 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="20d7082a-0fc7-4468-82bd-542694d5042b", + subscription_id="SUBSCRIPTION_ID", ) client.virtual_clusters.begin_delete( @@ -37,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/VirtualClusterDelete.json +# x-ms-original-file: 2025-02-01-preview/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 fe44d5ce3563..5323883c5de0 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="20d7082a-0fc7-4468-82bd-542694d5042b", + subscription_id="SUBSCRIPTION_ID", ) response = client.virtual_clusters.get( @@ -38,6 +37,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: 2025-02-01-preview/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 df05c3e5cd2d..a07c36354b9a 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="20d7082a-0fc7-4468-82bd-542694d5042b", + subscription_id="SUBSCRIPTION_ID", ) response = client.virtual_clusters.list() @@ -36,6 +35,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: 2025-02-01-preview/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 aa8fae31b906..5d6ef600eef6 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="20d7082a-0fc7-4468-82bd-542694d5042b", + subscription_id="SUBSCRIPTION_ID", ) response = client.virtual_clusters.list_by_resource_group( @@ -38,6 +37,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: 2025-02-01-preview/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 b2836604b1c7..c8d80d574c4c 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="20d7082a-0fc7-4468-82bd-542694d5042b", + subscription_id="SUBSCRIPTION_ID", ) response = client.virtual_clusters.begin_update( @@ -39,6 +38,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: 2025-02-01-preview/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 e8050533a084..1378764c1575 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 @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.virtual_network_rules.begin_create_or_update( @@ -45,6 +45,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: 2025-02-01-preview/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 b57f7e299ac7..651236fead29 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) client.virtual_network_rules.begin_delete( @@ -38,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/VirtualNetworkRulesDelete.json +# x-ms-original-file: 2025-02-01-preview/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 eceabad0e356..ce626f0edd0c 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.virtual_network_rules.get( @@ -39,6 +38,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: 2025-02-01-preview/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 5c519a46d1d7..65ab38b5b149 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 @@ -1,9 +1,8 @@ -# pylint: disable=line-too-long,useless-suppression # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) response = client.virtual_network_rules.list_by_server( @@ -39,6 +38,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: 2025-02-01-preview/VirtualNetworkRulesList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/conftest.py b/sdk/sql/azure-mgmt-sql/generated_tests/conftest.py index bb1c3e7c121f..d7239bc79f51 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/conftest.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/conftest.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import os diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_backup_short_term_retention_policies_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_backup_short_term_retention_policies_operations.py index ae214b8915f1..3f087d75fe91 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_backup_short_term_retention_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_backup_short_term_retention_policies_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ def test_backup_short_term_retention_policies_get(self, resource_group): server_name="str", database_name="str", policy_name="str", - api_version="2021-02-01-preview", ) # please add some check logic here by yourself @@ -40,8 +39,20 @@ def test_backup_short_term_retention_policies_begin_create_or_update(self, resou server_name="str", database_name="str", policy_name="str", - parameters={"diffBackupIntervalInHours": 0, "id": "str", "name": "str", "retentionDays": 0, "type": "str"}, - api_version="2021-02-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"diffBackupIntervalInHours": 0, "retentionDays": 0}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -55,8 +66,20 @@ def test_backup_short_term_retention_policies_begin_update(self, resource_group) server_name="str", database_name="str", policy_name="str", - parameters={"diffBackupIntervalInHours": 0, "id": "str", "name": "str", "retentionDays": 0, "type": "str"}, - api_version="2021-02-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"diffBackupIntervalInHours": 0, "retentionDays": 0}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -69,7 +92,6 @@ def test_backup_short_term_retention_policies_list_by_database(self, resource_gr resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2021-02-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_backup_short_term_retention_policies_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_backup_short_term_retention_policies_operations_async.py index 879946fb18f6..d0cd26d8feaf 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_backup_short_term_retention_policies_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_backup_short_term_retention_policies_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -27,7 +27,6 @@ async def test_backup_short_term_retention_policies_get(self, resource_group): server_name="str", database_name="str", policy_name="str", - api_version="2021-02-01-preview", ) # please add some check logic here by yourself @@ -43,13 +42,19 @@ async def test_backup_short_term_retention_policies_begin_create_or_update(self, database_name="str", policy_name="str", parameters={ - "diffBackupIntervalInHours": 0, "id": "str", "name": "str", - "retentionDays": 0, + "properties": {"diffBackupIntervalInHours": 0, "retentionDays": 0}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2021-02-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -66,13 +71,19 @@ async def test_backup_short_term_retention_policies_begin_update(self, resource_ database_name="str", policy_name="str", parameters={ - "diffBackupIntervalInHours": 0, "id": "str", "name": "str", - "retentionDays": 0, + "properties": {"diffBackupIntervalInHours": 0, "retentionDays": 0}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2021-02-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -86,7 +97,6 @@ async def test_backup_short_term_retention_policies_list_by_database(self, resou resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2021-02-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_capabilities_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_capabilities_operations.py index de068969cf9a..4ed16ca67b77 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_capabilities_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_capabilities_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -23,7 +23,6 @@ def setup_method(self, method): def test_capabilities_list_by_location(self, resource_group): response = self.client.capabilities.list_by_location( location_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_capabilities_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_capabilities_operations_async.py index 1198e207b8a3..b7db7f336d54 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_capabilities_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_capabilities_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,7 +24,6 @@ def setup_method(self, method): async def test_capabilities_list_by_location(self, resource_group): response = await self.client.capabilities.list_by_location( location_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_data_masking_policies_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_data_masking_policies_operations.py index 7e2dced7299e..1956f5e555f6 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_data_masking_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_data_masking_policies_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,24 +20,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_data_masking_policies_create_or_update(self, resource_group): - response = self.client.data_masking_policies.create_or_update( + def test_data_masking_policies_get(self, resource_group): + response = self.client.data_masking_policies.get( resource_group_name=resource_group.name, server_name="str", database_name="str", - parameters={ - "applicationPrincipals": "str", - "dataMaskingState": "str", - "exemptPrincipals": "str", - "id": "str", - "kind": "str", - "location": "str", - "maskingLevel": "str", - "name": "str", - "type": "str", - }, - api_version="2014-04-01", - data_masking_policy_name="Default", + data_masking_policy_name="str", ) # please add some check logic here by yourself @@ -45,13 +33,33 @@ def test_data_masking_policies_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_data_masking_policies_get(self, resource_group): - response = self.client.data_masking_policies.get( + def test_data_masking_policies_create_or_update(self, resource_group): + response = self.client.data_masking_policies.create_or_update( resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2014-04-01", - data_masking_policy_name="Default", + data_masking_policy_name="str", + parameters={ + "id": "str", + "kind": "str", + "location": "str", + "name": "str", + "properties": { + "dataMaskingState": "str", + "applicationPrincipals": "str", + "exemptPrincipals": "str", + "maskingLevel": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_data_masking_policies_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_data_masking_policies_operations_async.py index a8d903618927..0229609282ff 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_data_masking_policies_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_data_masking_policies_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,24 +21,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_data_masking_policies_create_or_update(self, resource_group): - response = await self.client.data_masking_policies.create_or_update( + async def test_data_masking_policies_get(self, resource_group): + response = await self.client.data_masking_policies.get( resource_group_name=resource_group.name, server_name="str", database_name="str", - parameters={ - "applicationPrincipals": "str", - "dataMaskingState": "str", - "exemptPrincipals": "str", - "id": "str", - "kind": "str", - "location": "str", - "maskingLevel": "str", - "name": "str", - "type": "str", - }, - api_version="2014-04-01", - data_masking_policy_name="Default", + data_masking_policy_name="str", ) # please add some check logic here by yourself @@ -46,13 +34,33 @@ async def test_data_masking_policies_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_data_masking_policies_get(self, resource_group): - response = await self.client.data_masking_policies.get( + async def test_data_masking_policies_create_or_update(self, resource_group): + response = await self.client.data_masking_policies.create_or_update( resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2014-04-01", - data_masking_policy_name="Default", + data_masking_policy_name="str", + parameters={ + "id": "str", + "kind": "str", + "location": "str", + "name": "str", + "properties": { + "dataMaskingState": "str", + "applicationPrincipals": "str", + "exemptPrincipals": "str", + "maskingLevel": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_data_masking_rules_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_data_masking_rules_operations.py index cdf058792a95..c9d66a7cdcd6 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_data_masking_rules_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_data_masking_rules_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,6 +18,19 @@ class TestSqlManagementDataMaskingRulesOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_data_masking_rules_list_by_database(self, resource_group): + response = self.client.data_masking_rules.list_by_database( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + data_masking_policy_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_data_masking_rules_create_or_update(self, resource_group): @@ -25,42 +38,38 @@ def test_data_masking_rules_create_or_update(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", + data_masking_policy_name="str", data_masking_rule_name="str", parameters={ - "aliasName": "str", - "columnName": "str", "id": "str", "kind": "str", "location": "str", - "maskingFunction": "str", "name": "str", - "numberFrom": "str", - "numberTo": "str", - "prefixSize": "str", - "replacementString": "str", - "ruleState": "str", - "schemaName": "str", - "suffixSize": "str", - "tableName": "str", + "properties": { + "columnName": "str", + "maskingFunction": "str", + "schemaName": "str", + "tableName": "str", + "aliasName": "str", + "id": "str", + "numberFrom": "str", + "numberTo": "str", + "prefixSize": "str", + "replacementString": "str", + "ruleState": "str", + "suffixSize": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2014-04-01", - data_masking_policy_name="Default", ) # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_data_masking_rules_list_by_database(self, resource_group): - response = self.client.data_masking_rules.list_by_database( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - api_version="2014-04-01", - data_masking_policy_name="Default", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_data_masking_rules_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_data_masking_rules_operations_async.py index 273d1ff9265e..6839f8d8eb9e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_data_masking_rules_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_data_masking_rules_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,6 +19,19 @@ class TestSqlManagementDataMaskingRulesOperationsAsync(AzureMgmtRecordedTestCase def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_data_masking_rules_list_by_database(self, resource_group): + response = self.client.data_masking_rules.list_by_database( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + data_masking_policy_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_data_masking_rules_create_or_update(self, resource_group): @@ -26,42 +39,38 @@ async def test_data_masking_rules_create_or_update(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", + data_masking_policy_name="str", data_masking_rule_name="str", parameters={ - "aliasName": "str", - "columnName": "str", "id": "str", "kind": "str", "location": "str", - "maskingFunction": "str", "name": "str", - "numberFrom": "str", - "numberTo": "str", - "prefixSize": "str", - "replacementString": "str", - "ruleState": "str", - "schemaName": "str", - "suffixSize": "str", - "tableName": "str", + "properties": { + "columnName": "str", + "maskingFunction": "str", + "schemaName": "str", + "tableName": "str", + "aliasName": "str", + "id": "str", + "numberFrom": "str", + "numberTo": "str", + "prefixSize": "str", + "replacementString": "str", + "ruleState": "str", + "suffixSize": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2014-04-01", - data_masking_policy_name="Default", ) # please add some check logic here by yourself # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_data_masking_rules_list_by_database(self, resource_group): - response = self.client.data_masking_rules.list_by_database( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - api_version="2014-04-01", - data_masking_policy_name="Default", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_data_warehouse_user_activities_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_data_warehouse_user_activities_operations.py index 8a61523a09f5..f5098ae3e074 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_data_warehouse_user_activities_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_data_warehouse_user_activities_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ def test_data_warehouse_user_activities_get(self, resource_group): server_name="str", database_name="str", data_warehouse_user_activity_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -39,7 +38,6 @@ def test_data_warehouse_user_activities_list_by_database(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_data_warehouse_user_activities_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_data_warehouse_user_activities_operations_async.py index 009fcbf39780..227b6920101c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_data_warehouse_user_activities_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_data_warehouse_user_activities_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -27,7 +27,6 @@ async def test_data_warehouse_user_activities_get(self, resource_group): server_name="str", database_name="str", data_warehouse_user_activity_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -40,7 +39,6 @@ async def test_data_warehouse_user_activities_list_by_database(self, resource_gr resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_advanced_threat_protection_settings_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_advanced_threat_protection_settings_operations.py index 2e556e82353f..1868796bd041 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_advanced_threat_protection_settings_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_advanced_threat_protection_settings_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,19 +18,6 @@ class TestSqlManagementDatabaseAdvancedThreatProtectionSettingsOperations(AzureM def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_database_advanced_threat_protection_settings_list_by_database(self, resource_group): - response = self.client.database_advanced_threat_protection_settings.list_by_database( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - api_version="2021-11-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_database_advanced_threat_protection_settings_get(self, resource_group): @@ -39,7 +26,6 @@ def test_database_advanced_threat_protection_settings_get(self, resource_group): server_name="str", database_name="str", advanced_threat_protection_name="str", - api_version="2021-11-01-preview", ) # please add some check logic here by yourself @@ -54,10 +40,9 @@ def test_database_advanced_threat_protection_settings_create_or_update(self, res database_name="str", advanced_threat_protection_name="str", parameters={ - "creationTime": "2020-02-20 00:00:00", "id": "str", "name": "str", - "state": "str", + "properties": {"state": "str", "creationTime": "2020-02-20 00:00:00"}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -68,8 +53,19 @@ def test_database_advanced_threat_protection_settings_create_or_update(self, res }, "type": "str", }, - api_version="2021-11-01-preview", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_database_advanced_threat_protection_settings_list_by_database(self, resource_group): + response = self.client.database_advanced_threat_protection_settings.list_by_database( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_advanced_threat_protection_settings_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_advanced_threat_protection_settings_operations_async.py index 59bb4a0e1f6e..7c6da71958bb 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_advanced_threat_protection_settings_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_advanced_threat_protection_settings_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,19 +19,6 @@ class TestSqlManagementDatabaseAdvancedThreatProtectionSettingsOperationsAsync(A def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_database_advanced_threat_protection_settings_list_by_database(self, resource_group): - response = self.client.database_advanced_threat_protection_settings.list_by_database( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - api_version="2021-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_database_advanced_threat_protection_settings_get(self, resource_group): @@ -40,7 +27,6 @@ async def test_database_advanced_threat_protection_settings_get(self, resource_g server_name="str", database_name="str", advanced_threat_protection_name="str", - api_version="2021-11-01-preview", ) # please add some check logic here by yourself @@ -55,10 +41,9 @@ async def test_database_advanced_threat_protection_settings_create_or_update(sel database_name="str", advanced_threat_protection_name="str", parameters={ - "creationTime": "2020-02-20 00:00:00", "id": "str", "name": "str", - "state": "str", + "properties": {"state": "str", "creationTime": "2020-02-20 00:00:00"}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -69,8 +54,19 @@ async def test_database_advanced_threat_protection_settings_create_or_update(sel }, "type": "str", }, - api_version="2021-11-01-preview", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_database_advanced_threat_protection_settings_list_by_database(self, resource_group): + response = self.client.database_advanced_threat_protection_settings.list_by_database( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_advisors_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_advisors_operations.py index a5daefc268a9..2f19c946da10 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_advisors_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_advisors_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,19 +18,6 @@ class TestSqlManagementDatabaseAdvisorsOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_database_advisors_list_by_database(self, resource_group): - response = self.client.database_advisors.list_by_database( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - api_version="2020-11-01-preview", - ) - - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_database_advisors_get(self, resource_group): @@ -39,7 +26,6 @@ def test_database_advisors_get(self, resource_group): server_name="str", database_name="str", advisor_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -54,78 +40,109 @@ def test_database_advisors_update(self, resource_group): database_name="str", advisor_name="str", parameters={ - "advisorStatus": "str", - "autoExecuteStatus": "str", - "autoExecuteStatusInheritedFrom": "str", "id": "str", "kind": "str", - "lastChecked": "2020-02-20 00:00:00", "location": "str", "name": "str", - "recommendationsStatus": "str", - "recommendedActions": [ - { - "details": {"str": {}}, - "errorDetails": {"errorCode": "str", "isRetryable": "str"}, - "estimatedImpact": [ - { - "absoluteValue": 0.0, - "changeValueAbsolute": 0.0, - "changeValueRelative": 0.0, - "dimensionName": "str", - "unit": "str", - } - ], - "executeActionDuration": "str", - "executeActionInitiatedBy": "str", - "executeActionInitiatedTime": "2020-02-20 00:00:00", - "executeActionStartTime": "2020-02-20 00:00:00", - "id": "str", - "implementationDetails": {"method": "str", "script": "str"}, - "isArchivedAction": bool, - "isExecutableAction": bool, - "isRevertableAction": bool, - "kind": "str", - "lastRefresh": "2020-02-20 00:00:00", - "linkedObjects": ["str"], - "location": "str", - "name": "str", - "observedImpact": [ - { - "absoluteValue": 0.0, - "changeValueAbsolute": 0.0, - "changeValueRelative": 0.0, - "dimensionName": "str", - "unit": "str", - } - ], - "recommendationReason": "str", - "revertActionDuration": "str", - "revertActionInitiatedBy": "str", - "revertActionInitiatedTime": "2020-02-20 00:00:00", - "revertActionStartTime": "2020-02-20 00:00:00", - "score": 0, - "state": { - "currentValue": "str", - "actionInitiatedBy": "str", - "lastModified": "2020-02-20 00:00:00", - }, - "timeSeries": [ - { - "metricName": "str", - "startTime": "2020-02-20 00:00:00", - "timeGrain": "str", - "unit": "str", - "value": 0.0, - } - ], - "type": "str", - "validSince": "2020-02-20 00:00:00", - } - ], + "properties": { + "autoExecuteStatus": "str", + "advisorStatus": "str", + "autoExecuteStatusInheritedFrom": "str", + "lastChecked": "2020-02-20 00:00:00", + "recommendationsStatus": "str", + "recommendedActions": [ + { + "id": "str", + "kind": "str", + "location": "str", + "name": "str", + "properties": { + "state": { + "currentValue": "str", + "actionInitiatedBy": "str", + "lastModified": "2020-02-20 00:00:00", + }, + "details": {"str": "str"}, + "errorDetails": {"errorCode": "str", "isRetryable": "str"}, + "estimatedImpact": [ + { + "absoluteValue": 0.0, + "changeValueAbsolute": 0.0, + "changeValueRelative": 0.0, + "dimensionName": "str", + "unit": "str", + } + ], + "executeActionDuration": "1 day, 0:00:00", + "executeActionInitiatedBy": "str", + "executeActionInitiatedTime": "2020-02-20 00:00:00", + "executeActionStartTime": "2020-02-20 00:00:00", + "implementationDetails": {"method": "str", "script": "str"}, + "isArchivedAction": bool, + "isExecutableAction": bool, + "isRevertableAction": bool, + "lastRefresh": "2020-02-20 00:00:00", + "linkedObjects": ["str"], + "observedImpact": [ + { + "absoluteValue": 0.0, + "changeValueAbsolute": 0.0, + "changeValueRelative": 0.0, + "dimensionName": "str", + "unit": "str", + } + ], + "recommendationReason": "str", + "revertActionDuration": "1 day, 0:00:00", + "revertActionInitiatedBy": "str", + "revertActionInitiatedTime": "2020-02-20 00:00:00", + "revertActionStartTime": "2020-02-20 00:00:00", + "score": 0, + "timeSeries": [ + { + "metricName": "str", + "startTime": "2020-02-20 00:00:00", + "timeGrain": "str", + "unit": "str", + "value": 0.0, + } + ], + "validSince": "2020-02-20 00:00:00", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + } + ], + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2020-11-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_database_advisors_list_by_database(self, resource_group): + response = self.client.database_advisors.list_by_database( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_advisors_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_advisors_operations_async.py index 72eeb0da9caf..b6135841fadb 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_advisors_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_advisors_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,19 +19,6 @@ class TestSqlManagementDatabaseAdvisorsOperationsAsync(AzureMgmtRecordedTestCase def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_database_advisors_list_by_database(self, resource_group): - response = await self.client.database_advisors.list_by_database( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - api_version="2020-11-01-preview", - ) - - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_database_advisors_get(self, resource_group): @@ -40,7 +27,6 @@ async def test_database_advisors_get(self, resource_group): server_name="str", database_name="str", advisor_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -55,78 +41,109 @@ async def test_database_advisors_update(self, resource_group): database_name="str", advisor_name="str", parameters={ - "advisorStatus": "str", - "autoExecuteStatus": "str", - "autoExecuteStatusInheritedFrom": "str", "id": "str", "kind": "str", - "lastChecked": "2020-02-20 00:00:00", "location": "str", "name": "str", - "recommendationsStatus": "str", - "recommendedActions": [ - { - "details": {"str": {}}, - "errorDetails": {"errorCode": "str", "isRetryable": "str"}, - "estimatedImpact": [ - { - "absoluteValue": 0.0, - "changeValueAbsolute": 0.0, - "changeValueRelative": 0.0, - "dimensionName": "str", - "unit": "str", - } - ], - "executeActionDuration": "str", - "executeActionInitiatedBy": "str", - "executeActionInitiatedTime": "2020-02-20 00:00:00", - "executeActionStartTime": "2020-02-20 00:00:00", - "id": "str", - "implementationDetails": {"method": "str", "script": "str"}, - "isArchivedAction": bool, - "isExecutableAction": bool, - "isRevertableAction": bool, - "kind": "str", - "lastRefresh": "2020-02-20 00:00:00", - "linkedObjects": ["str"], - "location": "str", - "name": "str", - "observedImpact": [ - { - "absoluteValue": 0.0, - "changeValueAbsolute": 0.0, - "changeValueRelative": 0.0, - "dimensionName": "str", - "unit": "str", - } - ], - "recommendationReason": "str", - "revertActionDuration": "str", - "revertActionInitiatedBy": "str", - "revertActionInitiatedTime": "2020-02-20 00:00:00", - "revertActionStartTime": "2020-02-20 00:00:00", - "score": 0, - "state": { - "currentValue": "str", - "actionInitiatedBy": "str", - "lastModified": "2020-02-20 00:00:00", - }, - "timeSeries": [ - { - "metricName": "str", - "startTime": "2020-02-20 00:00:00", - "timeGrain": "str", - "unit": "str", - "value": 0.0, - } - ], - "type": "str", - "validSince": "2020-02-20 00:00:00", - } - ], + "properties": { + "autoExecuteStatus": "str", + "advisorStatus": "str", + "autoExecuteStatusInheritedFrom": "str", + "lastChecked": "2020-02-20 00:00:00", + "recommendationsStatus": "str", + "recommendedActions": [ + { + "id": "str", + "kind": "str", + "location": "str", + "name": "str", + "properties": { + "state": { + "currentValue": "str", + "actionInitiatedBy": "str", + "lastModified": "2020-02-20 00:00:00", + }, + "details": {"str": "str"}, + "errorDetails": {"errorCode": "str", "isRetryable": "str"}, + "estimatedImpact": [ + { + "absoluteValue": 0.0, + "changeValueAbsolute": 0.0, + "changeValueRelative": 0.0, + "dimensionName": "str", + "unit": "str", + } + ], + "executeActionDuration": "1 day, 0:00:00", + "executeActionInitiatedBy": "str", + "executeActionInitiatedTime": "2020-02-20 00:00:00", + "executeActionStartTime": "2020-02-20 00:00:00", + "implementationDetails": {"method": "str", "script": "str"}, + "isArchivedAction": bool, + "isExecutableAction": bool, + "isRevertableAction": bool, + "lastRefresh": "2020-02-20 00:00:00", + "linkedObjects": ["str"], + "observedImpact": [ + { + "absoluteValue": 0.0, + "changeValueAbsolute": 0.0, + "changeValueRelative": 0.0, + "dimensionName": "str", + "unit": "str", + } + ], + "recommendationReason": "str", + "revertActionDuration": "1 day, 0:00:00", + "revertActionInitiatedBy": "str", + "revertActionInitiatedTime": "2020-02-20 00:00:00", + "revertActionStartTime": "2020-02-20 00:00:00", + "score": 0, + "timeSeries": [ + { + "metricName": "str", + "startTime": "2020-02-20 00:00:00", + "timeGrain": "str", + "unit": "str", + "value": 0.0, + } + ], + "validSince": "2020-02-20 00:00:00", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + } + ], + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2020-11-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_database_advisors_list_by_database(self, resource_group): + response = await self.client.database_advisors.list_by_database( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_automatic_tuning_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_automatic_tuning_operations.py index d9f75487ec23..2f32b7ec728f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_automatic_tuning_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_automatic_tuning_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_database_automatic_tuning_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -39,14 +38,25 @@ def test_database_automatic_tuning_update(self, resource_group): server_name="str", database_name="str", parameters={ - "actualState": "str", - "desiredState": "str", "id": "str", "name": "str", - "options": {"str": {"actualState": "str", "desiredState": "str", "reasonCode": 0, "reasonDesc": "str"}}, + "properties": { + "actualState": "str", + "desiredState": "str", + "options": { + "str": {"actualState": "str", "desiredState": "str", "reasonCode": 0, "reasonDesc": "str"} + }, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_automatic_tuning_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_automatic_tuning_operations_async.py index a7c9b089f803..50261550c04a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_automatic_tuning_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_automatic_tuning_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_database_automatic_tuning_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -40,14 +39,25 @@ async def test_database_automatic_tuning_update(self, resource_group): server_name="str", database_name="str", parameters={ - "actualState": "str", - "desiredState": "str", "id": "str", "name": "str", - "options": {"str": {"actualState": "str", "desiredState": "str", "reasonCode": 0, "reasonDesc": "str"}}, + "properties": { + "actualState": "str", + "desiredState": "str", + "options": { + "str": {"actualState": "str", "desiredState": "str", "reasonCode": 0, "reasonDesc": "str"} + }, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_blob_auditing_policies_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_blob_auditing_policies_operations.py index 23a14c2bd701..fb2b4a1110fd 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_blob_auditing_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_blob_auditing_policies_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,19 +18,6 @@ class TestSqlManagementDatabaseBlobAuditingPoliciesOperations(AzureMgmtRecordedT def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_database_blob_auditing_policies_list_by_database(self, resource_group): - response = self.client.database_blob_auditing_policies.list_by_database( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - api_version="2021-11-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_database_blob_auditing_policies_get(self, resource_group): @@ -39,7 +26,6 @@ def test_database_blob_auditing_policies_get(self, resource_group): server_name="str", database_name="str", blob_auditing_policy_name="default", - api_version="2021-11-01-preview", ) # please add some check logic here by yourself @@ -53,24 +39,45 @@ def test_database_blob_auditing_policies_create_or_update(self, resource_group): server_name="str", database_name="str", parameters={ - "auditActionsAndGroups": ["str"], "id": "str", - "isAzureMonitorTargetEnabled": bool, - "isManagedIdentityInUse": bool, - "isStorageSecondaryKeyInUse": bool, "kind": "str", "name": "str", - "queueDelayMs": 0, - "retentionDays": 0, - "state": "str", - "storageAccountAccessKey": "str", - "storageAccountSubscriptionId": "str", - "storageEndpoint": "str", + "properties": { + "state": "str", + "auditActionsAndGroups": ["str"], + "isAzureMonitorTargetEnabled": bool, + "isManagedIdentityInUse": bool, + "isStorageSecondaryKeyInUse": bool, + "queueDelayMs": 0, + "retentionDays": 0, + "storageAccountAccessKey": "str", + "storageAccountSubscriptionId": "str", + "storageEndpoint": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, blob_auditing_policy_name="default", - api_version="2021-11-01-preview", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_database_blob_auditing_policies_list_by_database(self, resource_group): + response = self.client.database_blob_auditing_policies.list_by_database( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_blob_auditing_policies_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_blob_auditing_policies_operations_async.py index 5b3936e093bf..a7d6e132d452 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_blob_auditing_policies_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_blob_auditing_policies_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,19 +19,6 @@ class TestSqlManagementDatabaseBlobAuditingPoliciesOperationsAsync(AzureMgmtReco def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_database_blob_auditing_policies_list_by_database(self, resource_group): - response = self.client.database_blob_auditing_policies.list_by_database( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - api_version="2021-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_database_blob_auditing_policies_get(self, resource_group): @@ -40,7 +27,6 @@ async def test_database_blob_auditing_policies_get(self, resource_group): server_name="str", database_name="str", blob_auditing_policy_name="default", - api_version="2021-11-01-preview", ) # please add some check logic here by yourself @@ -54,24 +40,45 @@ async def test_database_blob_auditing_policies_create_or_update(self, resource_g server_name="str", database_name="str", parameters={ - "auditActionsAndGroups": ["str"], "id": "str", - "isAzureMonitorTargetEnabled": bool, - "isManagedIdentityInUse": bool, - "isStorageSecondaryKeyInUse": bool, "kind": "str", "name": "str", - "queueDelayMs": 0, - "retentionDays": 0, - "state": "str", - "storageAccountAccessKey": "str", - "storageAccountSubscriptionId": "str", - "storageEndpoint": "str", + "properties": { + "state": "str", + "auditActionsAndGroups": ["str"], + "isAzureMonitorTargetEnabled": bool, + "isManagedIdentityInUse": bool, + "isStorageSecondaryKeyInUse": bool, + "queueDelayMs": 0, + "retentionDays": 0, + "storageAccountAccessKey": "str", + "storageAccountSubscriptionId": "str", + "storageEndpoint": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, blob_auditing_policy_name="default", - api_version="2021-11-01-preview", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_database_blob_auditing_policies_list_by_database(self, resource_group): + response = self.client.database_blob_auditing_policies.list_by_database( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_columns_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_columns_operations.py index ca5b5c1eb465..ee86bec8ab4d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_columns_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_columns_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,14 +20,16 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_database_columns_list_by_database(self, resource_group): - response = self.client.database_columns.list_by_database( + def test_database_columns_get(self, resource_group): + response = self.client.database_columns.get( resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2020-11-01-preview", + schema_name="str", + table_name="str", + column_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @@ -40,7 +42,6 @@ def test_database_columns_list_by_table(self, resource_group): database_name="str", schema_name="str", table_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself @@ -48,16 +49,12 @@ def test_database_columns_list_by_table(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_database_columns_get(self, resource_group): - response = self.client.database_columns.get( + def test_database_columns_list_by_database(self, resource_group): + response = self.client.database_columns.list_by_database( resource_group_name=resource_group.name, server_name="str", database_name="str", - schema_name="str", - table_name="str", - column_name="str", - api_version="2020-11-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_columns_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_columns_operations_async.py index 399cf54217cd..f373d8be5840 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_columns_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_columns_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,14 +21,16 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_database_columns_list_by_database(self, resource_group): - response = self.client.database_columns.list_by_database( + async def test_database_columns_get(self, resource_group): + response = await self.client.database_columns.get( resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2020-11-01-preview", + schema_name="str", + table_name="str", + column_name="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @@ -41,7 +43,6 @@ async def test_database_columns_list_by_table(self, resource_group): database_name="str", schema_name="str", table_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself @@ -49,16 +50,12 @@ async def test_database_columns_list_by_table(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_database_columns_get(self, resource_group): - response = await self.client.database_columns.get( + async def test_database_columns_list_by_database(self, resource_group): + response = self.client.database_columns.list_by_database( resource_group_name=resource_group.name, server_name="str", database_name="str", - schema_name="str", - table_name="str", - column_name="str", - api_version="2020-11-01-preview", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_encryption_protectors_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_encryption_protectors_operations.py index efbadff67d1e..87a764662472 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_encryption_protectors_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_encryption_protectors_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ def test_database_encryption_protectors_begin_revalidate(self, resource_group): server_name="str", database_name="str", encryption_protector_name="str", - api_version="2022-08-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -40,7 +39,6 @@ def test_database_encryption_protectors_begin_revert(self, resource_group): server_name="str", database_name="str", encryption_protector_name="str", - api_version="2022-08-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_encryption_protectors_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_encryption_protectors_operations_async.py index f8cce8ea0e76..426053f1c5fb 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_encryption_protectors_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_encryption_protectors_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -28,7 +28,6 @@ async def test_database_encryption_protectors_begin_revalidate(self, resource_gr server_name="str", database_name="str", encryption_protector_name="str", - api_version="2022-08-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -44,7 +43,6 @@ async def test_database_encryption_protectors_begin_revert(self, resource_group) server_name="str", database_name="str", encryption_protector_name="str", - api_version="2022-08-01-preview", ) ).result() # call '.result()' to poll until service return final result diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_extensions_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_extensions_operations.py index 52da9774f0e4..aea2f688b954 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_extensions_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_extensions_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ def test_database_extensions_get(self, resource_group): server_name="str", database_name="str", extension_name="str", - api_version="2021-02-01-preview", ) # please add some check logic here by yourself @@ -43,13 +42,29 @@ def test_database_extensions_begin_create_or_update(self, resource_group): parameters={ "id": "str", "name": "str", - "operationMode": "str", - "storageKey": "str", - "storageKeyType": "str", - "storageUri": "str", + "properties": { + "operationMode": "str", + "storageKey": "str", + "storageKeyType": "str", + "storageUri": "str", + "administratorLogin": "str", + "administratorLoginPassword": "str", + "authenticationType": "str", + "databaseEdition": "str", + "maxSizeBytes": "str", + "networkIsolation": {"sqlServerResourceId": "str", "storageAccountResourceId": "str"}, + "serviceObjectiveName": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2021-02-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -62,7 +77,6 @@ def test_database_extensions_list_by_database(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2021-02-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_extensions_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_extensions_operations_async.py index 5f26bdc65d8d..f4a053ebd94b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_extensions_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_extensions_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -27,7 +27,6 @@ async def test_database_extensions_get(self, resource_group): server_name="str", database_name="str", extension_name="str", - api_version="2021-02-01-preview", ) # please add some check logic here by yourself @@ -45,13 +44,29 @@ async def test_database_extensions_begin_create_or_update(self, resource_group): parameters={ "id": "str", "name": "str", - "operationMode": "str", - "storageKey": "str", - "storageKeyType": "str", - "storageUri": "str", + "properties": { + "operationMode": "str", + "storageKey": "str", + "storageKeyType": "str", + "storageUri": "str", + "administratorLogin": "str", + "administratorLoginPassword": "str", + "authenticationType": "str", + "databaseEdition": "str", + "maxSizeBytes": "str", + "networkIsolation": {"sqlServerResourceId": "str", "storageAccountResourceId": "str"}, + "serviceObjectiveName": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2021-02-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -65,7 +80,6 @@ async def test_database_extensions_list_by_database(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2021-02-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_operations_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_operations_operations.py index 3641b50e5e2a..ed5c937f5b7c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_operations_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_operations_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_database_operations_list_by_database(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2024-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself @@ -39,7 +38,6 @@ def test_database_operations_cancel(self, resource_group): server_name="str", database_name="str", operation_id="str", - api_version="2024-11-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_operations_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_operations_operations_async.py index 224389b2aba3..f1a124cab4ec 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_operations_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_operations_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_database_operations_list_by_database(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2024-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself @@ -40,7 +39,6 @@ async def test_database_operations_cancel(self, resource_group): server_name="str", database_name="str", operation_id="str", - api_version="2024-11-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_recommended_actions_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_recommended_actions_operations.py index bb09d6c877d6..74998dcd070a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_recommended_actions_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_recommended_actions_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,20 +18,6 @@ class TestSqlManagementDatabaseRecommendedActionsOperations(AzureMgmtRecordedTes def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_database_recommended_actions_list_by_database_advisor(self, resource_group): - response = self.client.database_recommended_actions.list_by_database_advisor( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - advisor_name="str", - api_version="2020-11-01-preview", - ) - - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_database_recommended_actions_get(self, resource_group): @@ -41,7 +27,6 @@ def test_database_recommended_actions_get(self, resource_group): database_name="str", advisor_name="str", recommended_action_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -57,60 +42,82 @@ def test_database_recommended_actions_update(self, resource_group): advisor_name="str", recommended_action_name="str", parameters={ - "details": {"str": {}}, - "errorDetails": {"errorCode": "str", "isRetryable": "str"}, - "estimatedImpact": [ - { - "absoluteValue": 0.0, - "changeValueAbsolute": 0.0, - "changeValueRelative": 0.0, - "dimensionName": "str", - "unit": "str", - } - ], - "executeActionDuration": "str", - "executeActionInitiatedBy": "str", - "executeActionInitiatedTime": "2020-02-20 00:00:00", - "executeActionStartTime": "2020-02-20 00:00:00", "id": "str", - "implementationDetails": {"method": "str", "script": "str"}, - "isArchivedAction": bool, - "isExecutableAction": bool, - "isRevertableAction": bool, "kind": "str", - "lastRefresh": "2020-02-20 00:00:00", - "linkedObjects": ["str"], "location": "str", "name": "str", - "observedImpact": [ - { - "absoluteValue": 0.0, - "changeValueAbsolute": 0.0, - "changeValueRelative": 0.0, - "dimensionName": "str", - "unit": "str", - } - ], - "recommendationReason": "str", - "revertActionDuration": "str", - "revertActionInitiatedBy": "str", - "revertActionInitiatedTime": "2020-02-20 00:00:00", - "revertActionStartTime": "2020-02-20 00:00:00", - "score": 0, - "state": {"currentValue": "str", "actionInitiatedBy": "str", "lastModified": "2020-02-20 00:00:00"}, - "timeSeries": [ - { - "metricName": "str", - "startTime": "2020-02-20 00:00:00", - "timeGrain": "str", - "unit": "str", - "value": 0.0, - } - ], + "properties": { + "state": {"currentValue": "str", "actionInitiatedBy": "str", "lastModified": "2020-02-20 00:00:00"}, + "details": {"str": "str"}, + "errorDetails": {"errorCode": "str", "isRetryable": "str"}, + "estimatedImpact": [ + { + "absoluteValue": 0.0, + "changeValueAbsolute": 0.0, + "changeValueRelative": 0.0, + "dimensionName": "str", + "unit": "str", + } + ], + "executeActionDuration": "1 day, 0:00:00", + "executeActionInitiatedBy": "str", + "executeActionInitiatedTime": "2020-02-20 00:00:00", + "executeActionStartTime": "2020-02-20 00:00:00", + "implementationDetails": {"method": "str", "script": "str"}, + "isArchivedAction": bool, + "isExecutableAction": bool, + "isRevertableAction": bool, + "lastRefresh": "2020-02-20 00:00:00", + "linkedObjects": ["str"], + "observedImpact": [ + { + "absoluteValue": 0.0, + "changeValueAbsolute": 0.0, + "changeValueRelative": 0.0, + "dimensionName": "str", + "unit": "str", + } + ], + "recommendationReason": "str", + "revertActionDuration": "1 day, 0:00:00", + "revertActionInitiatedBy": "str", + "revertActionInitiatedTime": "2020-02-20 00:00:00", + "revertActionStartTime": "2020-02-20 00:00:00", + "score": 0, + "timeSeries": [ + { + "metricName": "str", + "startTime": "2020-02-20 00:00:00", + "timeGrain": "str", + "unit": "str", + "value": 0.0, + } + ], + "validSince": "2020-02-20 00:00:00", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "validSince": "2020-02-20 00:00:00", }, - api_version="2020-11-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_database_recommended_actions_list_by_database_advisor(self, resource_group): + response = self.client.database_recommended_actions.list_by_database_advisor( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + advisor_name="str", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_recommended_actions_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_recommended_actions_operations_async.py index 434572d8d510..03cc9f85973f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_recommended_actions_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_recommended_actions_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,20 +19,6 @@ class TestSqlManagementDatabaseRecommendedActionsOperationsAsync(AzureMgmtRecord def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_database_recommended_actions_list_by_database_advisor(self, resource_group): - response = await self.client.database_recommended_actions.list_by_database_advisor( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - advisor_name="str", - api_version="2020-11-01-preview", - ) - - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_database_recommended_actions_get(self, resource_group): @@ -42,7 +28,6 @@ async def test_database_recommended_actions_get(self, resource_group): database_name="str", advisor_name="str", recommended_action_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -58,60 +43,82 @@ async def test_database_recommended_actions_update(self, resource_group): advisor_name="str", recommended_action_name="str", parameters={ - "details": {"str": {}}, - "errorDetails": {"errorCode": "str", "isRetryable": "str"}, - "estimatedImpact": [ - { - "absoluteValue": 0.0, - "changeValueAbsolute": 0.0, - "changeValueRelative": 0.0, - "dimensionName": "str", - "unit": "str", - } - ], - "executeActionDuration": "str", - "executeActionInitiatedBy": "str", - "executeActionInitiatedTime": "2020-02-20 00:00:00", - "executeActionStartTime": "2020-02-20 00:00:00", "id": "str", - "implementationDetails": {"method": "str", "script": "str"}, - "isArchivedAction": bool, - "isExecutableAction": bool, - "isRevertableAction": bool, "kind": "str", - "lastRefresh": "2020-02-20 00:00:00", - "linkedObjects": ["str"], "location": "str", "name": "str", - "observedImpact": [ - { - "absoluteValue": 0.0, - "changeValueAbsolute": 0.0, - "changeValueRelative": 0.0, - "dimensionName": "str", - "unit": "str", - } - ], - "recommendationReason": "str", - "revertActionDuration": "str", - "revertActionInitiatedBy": "str", - "revertActionInitiatedTime": "2020-02-20 00:00:00", - "revertActionStartTime": "2020-02-20 00:00:00", - "score": 0, - "state": {"currentValue": "str", "actionInitiatedBy": "str", "lastModified": "2020-02-20 00:00:00"}, - "timeSeries": [ - { - "metricName": "str", - "startTime": "2020-02-20 00:00:00", - "timeGrain": "str", - "unit": "str", - "value": 0.0, - } - ], + "properties": { + "state": {"currentValue": "str", "actionInitiatedBy": "str", "lastModified": "2020-02-20 00:00:00"}, + "details": {"str": "str"}, + "errorDetails": {"errorCode": "str", "isRetryable": "str"}, + "estimatedImpact": [ + { + "absoluteValue": 0.0, + "changeValueAbsolute": 0.0, + "changeValueRelative": 0.0, + "dimensionName": "str", + "unit": "str", + } + ], + "executeActionDuration": "1 day, 0:00:00", + "executeActionInitiatedBy": "str", + "executeActionInitiatedTime": "2020-02-20 00:00:00", + "executeActionStartTime": "2020-02-20 00:00:00", + "implementationDetails": {"method": "str", "script": "str"}, + "isArchivedAction": bool, + "isExecutableAction": bool, + "isRevertableAction": bool, + "lastRefresh": "2020-02-20 00:00:00", + "linkedObjects": ["str"], + "observedImpact": [ + { + "absoluteValue": 0.0, + "changeValueAbsolute": 0.0, + "changeValueRelative": 0.0, + "dimensionName": "str", + "unit": "str", + } + ], + "recommendationReason": "str", + "revertActionDuration": "1 day, 0:00:00", + "revertActionInitiatedBy": "str", + "revertActionInitiatedTime": "2020-02-20 00:00:00", + "revertActionStartTime": "2020-02-20 00:00:00", + "score": 0, + "timeSeries": [ + { + "metricName": "str", + "startTime": "2020-02-20 00:00:00", + "timeGrain": "str", + "unit": "str", + "value": 0.0, + } + ], + "validSince": "2020-02-20 00:00:00", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "validSince": "2020-02-20 00:00:00", }, - api_version="2020-11-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_database_recommended_actions_list_by_database_advisor(self, resource_group): + response = await self.client.database_recommended_actions.list_by_database_advisor( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + advisor_name="str", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_schemas_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_schemas_operations.py index 39f8a49fe72f..530595f02931 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_schemas_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_schemas_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,27 +20,25 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_database_schemas_list_by_database(self, resource_group): - response = self.client.database_schemas.list_by_database( + def test_database_schemas_get(self, resource_group): + response = self.client.database_schemas.get( resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2020-11-01-preview", + schema_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_database_schemas_get(self, resource_group): - response = self.client.database_schemas.get( + def test_database_schemas_list_by_database(self, resource_group): + response = self.client.database_schemas.list_by_database( resource_group_name=resource_group.name, server_name="str", database_name="str", - schema_name="str", - api_version="2020-11-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_schemas_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_schemas_operations_async.py index ac410ac53b58..a4fb6fd86894 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_schemas_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_schemas_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,27 +21,25 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_database_schemas_list_by_database(self, resource_group): - response = self.client.database_schemas.list_by_database( + async def test_database_schemas_get(self, resource_group): + response = await self.client.database_schemas.get( resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2020-11-01-preview", + schema_name="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_database_schemas_get(self, resource_group): - response = await self.client.database_schemas.get( + async def test_database_schemas_list_by_database(self, resource_group): + response = self.client.database_schemas.list_by_database( resource_group_name=resource_group.name, server_name="str", database_name="str", - schema_name="str", - api_version="2020-11-01-preview", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_security_alert_policies_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_security_alert_policies_operations.py index fd68d6743397..897d2a3b1cf7 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_security_alert_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_security_alert_policies_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ def test_database_security_alert_policies_get(self, resource_group): server_name="str", database_name="str", security_alert_policy_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -41,16 +40,18 @@ def test_database_security_alert_policies_create_or_update(self, resource_group) database_name="str", security_alert_policy_name="str", parameters={ - "creationTime": "2020-02-20 00:00:00", - "disabledAlerts": ["str"], - "emailAccountAdmins": bool, - "emailAddresses": ["str"], "id": "str", "name": "str", - "retentionDays": 0, - "state": "str", - "storageAccountAccessKey": "str", - "storageEndpoint": "str", + "properties": { + "state": "str", + "creationTime": "2020-02-20 00:00:00", + "disabledAlerts": ["str"], + "emailAccountAdmins": bool, + "emailAddresses": ["str"], + "retentionDays": 0, + "storageAccountAccessKey": "str", + "storageEndpoint": "str", + }, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -61,7 +62,6 @@ def test_database_security_alert_policies_create_or_update(self, resource_group) }, "type": "str", }, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -74,7 +74,6 @@ def test_database_security_alert_policies_list_by_database(self, resource_group) resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_security_alert_policies_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_security_alert_policies_operations_async.py index c8efa1a22508..9ed8ba432bb0 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_security_alert_policies_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_security_alert_policies_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -27,7 +27,6 @@ async def test_database_security_alert_policies_get(self, resource_group): server_name="str", database_name="str", security_alert_policy_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -42,16 +41,18 @@ async def test_database_security_alert_policies_create_or_update(self, resource_ database_name="str", security_alert_policy_name="str", parameters={ - "creationTime": "2020-02-20 00:00:00", - "disabledAlerts": ["str"], - "emailAccountAdmins": bool, - "emailAddresses": ["str"], "id": "str", "name": "str", - "retentionDays": 0, - "state": "str", - "storageAccountAccessKey": "str", - "storageEndpoint": "str", + "properties": { + "state": "str", + "creationTime": "2020-02-20 00:00:00", + "disabledAlerts": ["str"], + "emailAccountAdmins": bool, + "emailAddresses": ["str"], + "retentionDays": 0, + "storageAccountAccessKey": "str", + "storageEndpoint": "str", + }, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -62,7 +63,6 @@ async def test_database_security_alert_policies_create_or_update(self, resource_ }, "type": "str", }, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -75,7 +75,6 @@ async def test_database_security_alert_policies_list_by_database(self, resource_ resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_baselines_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_baselines_operations.py index 5ad43da961c1..b8dccf429c70 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_baselines_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_baselines_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,20 +18,6 @@ class TestSqlManagementDatabaseSqlVulnerabilityAssessmentBaselinesOperations(Azu def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_database_sql_vulnerability_assessment_baselines_list_by_sql_vulnerability_assessment(self, resource_group): - response = self.client.database_sql_vulnerability_assessment_baselines.list_by_sql_vulnerability_assessment( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - vulnerability_assessment_name="str", - api_version="2022-11-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_database_sql_vulnerability_assessment_baselines_get(self, resource_group): @@ -41,7 +27,6 @@ def test_database_sql_vulnerability_assessment_baselines_get(self, resource_grou database_name="str", vulnerability_assessment_name="str", baseline_name="str", - api_version="2022-11-01-preview", ) # please add some check logic here by yourself @@ -58,9 +43,8 @@ def test_database_sql_vulnerability_assessment_baselines_create_or_update(self, baseline_name="str", parameters={ "id": "str", - "latestScan": bool, "name": "str", - "results": {"str": [["str"]]}, + "properties": {"latestScan": bool, "results": {"str": [["str"]]}}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -71,8 +55,20 @@ def test_database_sql_vulnerability_assessment_baselines_create_or_update(self, }, "type": "str", }, - api_version="2022-11-01-preview", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_database_sql_vulnerability_assessment_baselines_list_by_sql_vulnerability_assessment(self, resource_group): + response = self.client.database_sql_vulnerability_assessment_baselines.list_by_sql_vulnerability_assessment( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + vulnerability_assessment_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_baselines_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_baselines_operations_async.py index 11cf3082f0a3..f425c5b87625 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_baselines_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_baselines_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,22 +19,6 @@ class TestSqlManagementDatabaseSqlVulnerabilityAssessmentBaselinesOperationsAsyn def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_database_sql_vulnerability_assessment_baselines_list_by_sql_vulnerability_assessment( - self, resource_group - ): - response = self.client.database_sql_vulnerability_assessment_baselines.list_by_sql_vulnerability_assessment( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - vulnerability_assessment_name="str", - api_version="2022-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_database_sql_vulnerability_assessment_baselines_get(self, resource_group): @@ -44,7 +28,6 @@ async def test_database_sql_vulnerability_assessment_baselines_get(self, resourc database_name="str", vulnerability_assessment_name="str", baseline_name="str", - api_version="2022-11-01-preview", ) # please add some check logic here by yourself @@ -61,9 +44,8 @@ async def test_database_sql_vulnerability_assessment_baselines_create_or_update( baseline_name="str", parameters={ "id": "str", - "latestScan": bool, "name": "str", - "results": {"str": [["str"]]}, + "properties": {"latestScan": bool, "results": {"str": [["str"]]}}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -74,8 +56,22 @@ async def test_database_sql_vulnerability_assessment_baselines_create_or_update( }, "type": "str", }, - api_version="2022-11-01-preview", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_database_sql_vulnerability_assessment_baselines_list_by_sql_vulnerability_assessment( + self, resource_group + ): + response = self.client.database_sql_vulnerability_assessment_baselines.list_by_sql_vulnerability_assessment( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + vulnerability_assessment_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_execute_scan_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_execute_scan_operations.py index 3b0224fc7068..148c62e8c471 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_execute_scan_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_execute_scan_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ def test_database_sql_vulnerability_assessment_execute_scan_begin_execute(self, server_name="str", database_name="str", vulnerability_assessment_name="str", - api_version="2022-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_execute_scan_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_execute_scan_operations_async.py index f6c7dc9de6a6..a18a1ba5f0d6 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_execute_scan_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_execute_scan_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -28,7 +28,6 @@ async def test_database_sql_vulnerability_assessment_execute_scan_begin_execute( server_name="str", database_name="str", vulnerability_assessment_name="str", - api_version="2022-11-01-preview", ) ).result() # call '.result()' to poll until service return final result diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_rule_baselines_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_rule_baselines_operations.py index 9b52e9ff152d..6a72c5ee178a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_rule_baselines_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_rule_baselines_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,21 +18,6 @@ class TestSqlManagementDatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_database_sql_vulnerability_assessment_rule_baselines_list_by_baseline(self, resource_group): - response = self.client.database_sql_vulnerability_assessment_rule_baselines.list_by_baseline( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - vulnerability_assessment_name="str", - baseline_name="str", - api_version="2022-11-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_database_sql_vulnerability_assessment_rule_baselines_get(self, resource_group): @@ -43,7 +28,6 @@ def test_database_sql_vulnerability_assessment_rule_baselines_get(self, resource vulnerability_assessment_name="str", baseline_name="str", rule_id="str", - api_version="2022-11-01-preview", ) # please add some check logic here by yourself @@ -61,9 +45,8 @@ def test_database_sql_vulnerability_assessment_rule_baselines_create_or_update(s rule_id="str", parameters={ "id": "str", - "latestScan": bool, "name": "str", - "results": [["str"]], + "properties": {"latestScan": bool, "results": [["str"]]}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -74,7 +57,6 @@ def test_database_sql_vulnerability_assessment_rule_baselines_create_or_update(s }, "type": "str", }, - api_version="2022-11-01-preview", ) # please add some check logic here by yourself @@ -90,8 +72,21 @@ def test_database_sql_vulnerability_assessment_rule_baselines_delete(self, resou vulnerability_assessment_name="str", baseline_name="str", rule_id="str", - api_version="2022-11-01-preview", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_database_sql_vulnerability_assessment_rule_baselines_list_by_baseline(self, resource_group): + response = self.client.database_sql_vulnerability_assessment_rule_baselines.list_by_baseline( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + vulnerability_assessment_name="str", + baseline_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_rule_baselines_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_rule_baselines_operations_async.py index 3260f56f7877..348951b98e0e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_rule_baselines_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_rule_baselines_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,21 +19,6 @@ class TestSqlManagementDatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_database_sql_vulnerability_assessment_rule_baselines_list_by_baseline(self, resource_group): - response = self.client.database_sql_vulnerability_assessment_rule_baselines.list_by_baseline( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - vulnerability_assessment_name="str", - baseline_name="str", - api_version="2022-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_database_sql_vulnerability_assessment_rule_baselines_get(self, resource_group): @@ -44,7 +29,6 @@ async def test_database_sql_vulnerability_assessment_rule_baselines_get(self, re vulnerability_assessment_name="str", baseline_name="str", rule_id="str", - api_version="2022-11-01-preview", ) # please add some check logic here by yourself @@ -62,9 +46,8 @@ async def test_database_sql_vulnerability_assessment_rule_baselines_create_or_up rule_id="str", parameters={ "id": "str", - "latestScan": bool, "name": "str", - "results": [["str"]], + "properties": {"latestScan": bool, "results": [["str"]]}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -75,7 +58,6 @@ async def test_database_sql_vulnerability_assessment_rule_baselines_create_or_up }, "type": "str", }, - api_version="2022-11-01-preview", ) # please add some check logic here by yourself @@ -91,8 +73,21 @@ async def test_database_sql_vulnerability_assessment_rule_baselines_delete(self, vulnerability_assessment_name="str", baseline_name="str", rule_id="str", - api_version="2022-11-01-preview", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_database_sql_vulnerability_assessment_rule_baselines_list_by_baseline(self, resource_group): + response = self.client.database_sql_vulnerability_assessment_rule_baselines.list_by_baseline( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + vulnerability_assessment_name="str", + baseline_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_scan_result_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_scan_result_operations.py index de0e24f2280a..02a3fa51048b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_scan_result_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_scan_result_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,31 +20,29 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_database_sql_vulnerability_assessment_scan_result_list_by_scan(self, resource_group): - response = self.client.database_sql_vulnerability_assessment_scan_result.list_by_scan( + def test_database_sql_vulnerability_assessment_scan_result_get(self, resource_group): + response = self.client.database_sql_vulnerability_assessment_scan_result.get( resource_group_name=resource_group.name, server_name="str", database_name="str", vulnerability_assessment_name="str", scan_id="str", - api_version="2022-11-01-preview", + scan_result_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_database_sql_vulnerability_assessment_scan_result_get(self, resource_group): - response = self.client.database_sql_vulnerability_assessment_scan_result.get( + def test_database_sql_vulnerability_assessment_scan_result_list_by_scan(self, resource_group): + response = self.client.database_sql_vulnerability_assessment_scan_result.list_by_scan( resource_group_name=resource_group.name, server_name="str", database_name="str", vulnerability_assessment_name="str", scan_id="str", - scan_result_id="str", - api_version="2022-11-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_scan_result_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_scan_result_operations_async.py index f90b875408a9..3bea635153f0 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_scan_result_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_scan_result_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,31 +21,29 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_database_sql_vulnerability_assessment_scan_result_list_by_scan(self, resource_group): - response = self.client.database_sql_vulnerability_assessment_scan_result.list_by_scan( + async def test_database_sql_vulnerability_assessment_scan_result_get(self, resource_group): + response = await self.client.database_sql_vulnerability_assessment_scan_result.get( resource_group_name=resource_group.name, server_name="str", database_name="str", vulnerability_assessment_name="str", scan_id="str", - api_version="2022-11-01-preview", + scan_result_id="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_database_sql_vulnerability_assessment_scan_result_get(self, resource_group): - response = await self.client.database_sql_vulnerability_assessment_scan_result.get( + async def test_database_sql_vulnerability_assessment_scan_result_list_by_scan(self, resource_group): + response = self.client.database_sql_vulnerability_assessment_scan_result.list_by_scan( resource_group_name=resource_group.name, server_name="str", database_name="str", vulnerability_assessment_name="str", scan_id="str", - scan_result_id="str", - api_version="2022-11-01-preview", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_scans_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_scans_operations.py index d601956edb45..ff2aec24575c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_scans_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_scans_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,29 +20,27 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_database_sql_vulnerability_assessment_scans_list_by_sql_vulnerability_assessments(self, resource_group): - response = self.client.database_sql_vulnerability_assessment_scans.list_by_sql_vulnerability_assessments( + def test_database_sql_vulnerability_assessment_scans_get(self, resource_group): + response = self.client.database_sql_vulnerability_assessment_scans.get( resource_group_name=resource_group.name, server_name="str", database_name="str", vulnerability_assessment_name="str", - api_version="2022-11-01-preview", + scan_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_database_sql_vulnerability_assessment_scans_get(self, resource_group): - response = self.client.database_sql_vulnerability_assessment_scans.get( + def test_database_sql_vulnerability_assessment_scans_list_by_sql_vulnerability_assessments(self, resource_group): + response = self.client.database_sql_vulnerability_assessment_scans.list_by_sql_vulnerability_assessments( resource_group_name=resource_group.name, server_name="str", database_name="str", vulnerability_assessment_name="str", - scan_id="str", - api_version="2022-11-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_scans_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_scans_operations_async.py index 89df33ee0946..070b92abfbb4 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_scans_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessment_scans_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,31 +21,29 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_database_sql_vulnerability_assessment_scans_list_by_sql_vulnerability_assessments( - self, resource_group - ): - response = self.client.database_sql_vulnerability_assessment_scans.list_by_sql_vulnerability_assessments( + async def test_database_sql_vulnerability_assessment_scans_get(self, resource_group): + response = await self.client.database_sql_vulnerability_assessment_scans.get( resource_group_name=resource_group.name, server_name="str", database_name="str", vulnerability_assessment_name="str", - api_version="2022-11-01-preview", + scan_id="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_database_sql_vulnerability_assessment_scans_get(self, resource_group): - response = await self.client.database_sql_vulnerability_assessment_scans.get( + async def test_database_sql_vulnerability_assessment_scans_list_by_sql_vulnerability_assessments( + self, resource_group + ): + response = self.client.database_sql_vulnerability_assessment_scans.list_by_sql_vulnerability_assessments( resource_group_name=resource_group.name, server_name="str", database_name="str", vulnerability_assessment_name="str", - scan_id="str", - api_version="2022-11-01-preview", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessments_settings_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessments_settings_operations.py index 871f257cb02e..53f4462c2a7c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessments_settings_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessments_settings_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,27 +20,25 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_database_sql_vulnerability_assessments_settings_list_by_database(self, resource_group): - response = self.client.database_sql_vulnerability_assessments_settings.list_by_database( + def test_database_sql_vulnerability_assessments_settings_get(self, resource_group): + response = self.client.database_sql_vulnerability_assessments_settings.get( resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2022-11-01-preview", + vulnerability_assessment_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_database_sql_vulnerability_assessments_settings_get(self, resource_group): - response = self.client.database_sql_vulnerability_assessments_settings.get( + def test_database_sql_vulnerability_assessments_settings_list_by_database(self, resource_group): + response = self.client.database_sql_vulnerability_assessments_settings.list_by_database( resource_group_name=resource_group.name, server_name="str", database_name="str", - vulnerability_assessment_name="str", - api_version="2022-11-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessments_settings_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessments_settings_operations_async.py index be6fe9177cc0..acf0d962a607 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessments_settings_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_sql_vulnerability_assessments_settings_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,27 +21,25 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_database_sql_vulnerability_assessments_settings_list_by_database(self, resource_group): - response = self.client.database_sql_vulnerability_assessments_settings.list_by_database( + async def test_database_sql_vulnerability_assessments_settings_get(self, resource_group): + response = await self.client.database_sql_vulnerability_assessments_settings.get( resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2022-11-01-preview", + vulnerability_assessment_name="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_database_sql_vulnerability_assessments_settings_get(self, resource_group): - response = await self.client.database_sql_vulnerability_assessments_settings.get( + async def test_database_sql_vulnerability_assessments_settings_list_by_database(self, resource_group): + response = self.client.database_sql_vulnerability_assessments_settings.list_by_database( resource_group_name=resource_group.name, server_name="str", database_name="str", - vulnerability_assessment_name="str", - api_version="2022-11-01-preview", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_tables_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_tables_operations.py index 3da9345bab38..aaff3aa0fe8f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_tables_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_tables_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,29 +20,27 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_database_tables_list_by_schema(self, resource_group): - response = self.client.database_tables.list_by_schema( + def test_database_tables_get(self, resource_group): + response = self.client.database_tables.get( resource_group_name=resource_group.name, server_name="str", database_name="str", schema_name="str", - api_version="2020-11-01-preview", + table_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_database_tables_get(self, resource_group): - response = self.client.database_tables.get( + def test_database_tables_list_by_schema(self, resource_group): + response = self.client.database_tables.list_by_schema( resource_group_name=resource_group.name, server_name="str", database_name="str", schema_name="str", - table_name="str", - api_version="2020-11-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_tables_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_tables_operations_async.py index 5759f775ee31..216c4788c72c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_tables_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_tables_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,29 +21,27 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_database_tables_list_by_schema(self, resource_group): - response = self.client.database_tables.list_by_schema( + async def test_database_tables_get(self, resource_group): + response = await self.client.database_tables.get( resource_group_name=resource_group.name, server_name="str", database_name="str", schema_name="str", - api_version="2020-11-01-preview", + table_name="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_database_tables_get(self, resource_group): - response = await self.client.database_tables.get( + async def test_database_tables_list_by_schema(self, resource_group): + response = self.client.database_tables.list_by_schema( resource_group_name=resource_group.name, server_name="str", database_name="str", schema_name="str", - table_name="str", - api_version="2020-11-01-preview", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_usages_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_usages_operations.py index 2f4e877eddcf..3fc1a49d1433 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_usages_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_usages_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_database_usages_list_by_database(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2021-02-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_usages_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_usages_operations_async.py index 8e0fa7c1bc7e..313de6dd1471 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_usages_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_usages_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_database_usages_list_by_database(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2021-02-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_vulnerability_assessment_rule_baselines_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_vulnerability_assessment_rule_baselines_operations.py index d4cbe9ee9dc3..e719e6bc6581 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_vulnerability_assessment_rule_baselines_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_vulnerability_assessment_rule_baselines_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -28,7 +28,6 @@ def test_database_vulnerability_assessment_rule_baselines_get(self, resource_gro vulnerability_assessment_name="str", rule_id="str", baseline_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -44,8 +43,20 @@ def test_database_vulnerability_assessment_rule_baselines_create_or_update(self, vulnerability_assessment_name="str", rule_id="str", baseline_name="str", - parameters={"baselineResults": [{"result": ["str"]}], "id": "str", "name": "str", "type": "str"}, - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"baselineResults": [{"result": ["str"]}]}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -61,7 +72,6 @@ def test_database_vulnerability_assessment_rule_baselines_delete(self, resource_ vulnerability_assessment_name="str", rule_id="str", baseline_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_vulnerability_assessment_rule_baselines_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_vulnerability_assessment_rule_baselines_operations_async.py index 9a3394ad5ce9..1b8fe298b87e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_vulnerability_assessment_rule_baselines_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_vulnerability_assessment_rule_baselines_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -29,7 +29,6 @@ async def test_database_vulnerability_assessment_rule_baselines_get(self, resour vulnerability_assessment_name="str", rule_id="str", baseline_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -45,8 +44,20 @@ async def test_database_vulnerability_assessment_rule_baselines_create_or_update vulnerability_assessment_name="str", rule_id="str", baseline_name="str", - parameters={"baselineResults": [{"result": ["str"]}], "id": "str", "name": "str", "type": "str"}, - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"baselineResults": [{"result": ["str"]}]}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -62,7 +73,6 @@ async def test_database_vulnerability_assessment_rule_baselines_delete(self, res vulnerability_assessment_name="str", rule_id="str", baseline_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_vulnerability_assessment_scans_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_vulnerability_assessment_scans_operations.py index 0e665adf2342..084f318b0eb8 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_vulnerability_assessment_scans_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_vulnerability_assessment_scans_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,15 +20,14 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_database_vulnerability_assessment_scans_begin_initiate_scan(self, resource_group): - response = self.client.database_vulnerability_assessment_scans.begin_initiate_scan( + def test_database_vulnerability_assessment_scans_get(self, resource_group): + response = self.client.database_vulnerability_assessment_scans.get( resource_group_name=resource_group.name, server_name="str", database_name="str", vulnerability_assessment_name="str", scan_id="str", - api_version="2020-11-01-preview", - ).result() # call '.result()' to poll until service return final result + ) # please add some check logic here by yourself # ... @@ -41,7 +40,6 @@ def test_database_vulnerability_assessment_scans_list_by_database(self, resource server_name="str", database_name="str", vulnerability_assessment_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself @@ -49,14 +47,13 @@ def test_database_vulnerability_assessment_scans_list_by_database(self, resource @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_database_vulnerability_assessment_scans_get(self, resource_group): - response = self.client.database_vulnerability_assessment_scans.get( + def test_database_vulnerability_assessment_scans_export(self, resource_group): + response = self.client.database_vulnerability_assessment_scans.export( resource_group_name=resource_group.name, server_name="str", database_name="str", vulnerability_assessment_name="str", scan_id="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -64,15 +61,14 @@ def test_database_vulnerability_assessment_scans_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_database_vulnerability_assessment_scans_export(self, resource_group): - response = self.client.database_vulnerability_assessment_scans.export( + def test_database_vulnerability_assessment_scans_begin_initiate_scan(self, resource_group): + response = self.client.database_vulnerability_assessment_scans.begin_initiate_scan( resource_group_name=resource_group.name, server_name="str", database_name="str", vulnerability_assessment_name="str", scan_id="str", - api_version="2020-11-01-preview", - ) + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_vulnerability_assessment_scans_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_vulnerability_assessment_scans_operations_async.py index 4b4ba95c3e0a..f0242533cb86 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_vulnerability_assessment_scans_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_vulnerability_assessment_scans_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,17 +21,14 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_database_vulnerability_assessment_scans_begin_initiate_scan(self, resource_group): - response = await ( - await self.client.database_vulnerability_assessment_scans.begin_initiate_scan( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - vulnerability_assessment_name="str", - scan_id="str", - api_version="2020-11-01-preview", - ) - ).result() # call '.result()' to poll until service return final result + async def test_database_vulnerability_assessment_scans_get(self, resource_group): + response = await self.client.database_vulnerability_assessment_scans.get( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + vulnerability_assessment_name="str", + scan_id="str", + ) # please add some check logic here by yourself # ... @@ -44,7 +41,6 @@ async def test_database_vulnerability_assessment_scans_list_by_database(self, re server_name="str", database_name="str", vulnerability_assessment_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself @@ -52,14 +48,13 @@ async def test_database_vulnerability_assessment_scans_list_by_database(self, re @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_database_vulnerability_assessment_scans_get(self, resource_group): - response = await self.client.database_vulnerability_assessment_scans.get( + async def test_database_vulnerability_assessment_scans_export(self, resource_group): + response = await self.client.database_vulnerability_assessment_scans.export( resource_group_name=resource_group.name, server_name="str", database_name="str", vulnerability_assessment_name="str", scan_id="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -67,15 +62,16 @@ async def test_database_vulnerability_assessment_scans_get(self, resource_group) @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_database_vulnerability_assessment_scans_export(self, resource_group): - response = await self.client.database_vulnerability_assessment_scans.export( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - vulnerability_assessment_name="str", - scan_id="str", - api_version="2020-11-01-preview", - ) + async def test_database_vulnerability_assessment_scans_begin_initiate_scan(self, resource_group): + response = await ( + await self.client.database_vulnerability_assessment_scans.begin_initiate_scan( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + vulnerability_assessment_name="str", + scan_id="str", + ) + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_vulnerability_assessments_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_vulnerability_assessments_operations.py index 75e310638948..00e6781ca850 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_vulnerability_assessments_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_vulnerability_assessments_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ def test_database_vulnerability_assessments_get(self, resource_group): server_name="str", database_name="str", vulnerability_assessment_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -43,13 +42,22 @@ def test_database_vulnerability_assessments_create_or_update(self, resource_grou parameters={ "id": "str", "name": "str", - "recurringScans": {"emailSubscriptionAdmins": True, "emails": ["str"], "isEnabled": bool}, - "storageAccountAccessKey": "str", - "storageContainerPath": "str", - "storageContainerSasKey": "str", + "properties": { + "recurringScans": {"emailSubscriptionAdmins": bool, "emails": ["str"], "isEnabled": bool}, + "storageAccountAccessKey": "str", + "storageContainerPath": "str", + "storageContainerSasKey": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -63,7 +71,6 @@ def test_database_vulnerability_assessments_delete(self, resource_group): server_name="str", database_name="str", vulnerability_assessment_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -76,7 +83,6 @@ def test_database_vulnerability_assessments_list_by_database(self, resource_grou resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_vulnerability_assessments_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_vulnerability_assessments_operations_async.py index 8beb05636893..2d4288879a53 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_vulnerability_assessments_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_database_vulnerability_assessments_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -27,7 +27,6 @@ async def test_database_vulnerability_assessments_get(self, resource_group): server_name="str", database_name="str", vulnerability_assessment_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -44,13 +43,22 @@ async def test_database_vulnerability_assessments_create_or_update(self, resourc parameters={ "id": "str", "name": "str", - "recurringScans": {"emailSubscriptionAdmins": True, "emails": ["str"], "isEnabled": bool}, - "storageAccountAccessKey": "str", - "storageContainerPath": "str", - "storageContainerSasKey": "str", + "properties": { + "recurringScans": {"emailSubscriptionAdmins": bool, "emails": ["str"], "isEnabled": bool}, + "storageAccountAccessKey": "str", + "storageContainerPath": "str", + "storageContainerSasKey": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -64,7 +72,6 @@ async def test_database_vulnerability_assessments_delete(self, resource_group): server_name="str", database_name="str", vulnerability_assessment_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -77,7 +84,6 @@ async def test_database_vulnerability_assessments_list_by_database(self, resourc resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_databases_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_databases_operations.py index fe3764118818..185a78496396 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_databases_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_databases_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,45 +18,6 @@ class TestSqlManagementDatabasesOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_databases_list_metrics(self, resource_group): - response = self.client.databases.list_metrics( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - filter="str", - api_version="2014-04-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_databases_list_metric_definitions(self, resource_group): - response = self.client.databases.list_metric_definitions( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - api_version="2014-04-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_databases_list_by_server(self, resource_group): - response = self.client.databases.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2023-02-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_databases_get(self, resource_group): @@ -64,7 +25,6 @@ def test_databases_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2023-02-01-preview", ) # please add some check logic here by yourself @@ -79,88 +39,86 @@ def test_databases_begin_create_or_update(self, resource_group): database_name="str", parameters={ "location": "str", - "autoPauseDelay": 0, - "availabilityZone": "str", - "catalogCollation": "str", - "collation": "str", - "createMode": "str", - "creationDate": "2020-02-20 00:00:00", - "currentBackupStorageRedundancy": "str", - "currentServiceObjectiveName": "str", - "currentSku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, - "databaseId": "str", - "defaultSecondaryLocation": "str", - "earliestRestoreDate": "2020-02-20 00:00:00", - "elasticPoolId": "str", - "encryptionProtector": "str", - "encryptionProtectorAutoRotation": bool, - "failoverGroupId": "str", - "federatedClientId": "str", - "freeLimitExhaustionBehavior": "str", - "highAvailabilityReplicaCount": 0, "id": "str", "identity": { "tenantId": "str", "type": "str", "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, }, - "isInfraEncryptionEnabled": bool, - "isLedgerOn": bool, - "keys": { - "str": { - "creationDate": "2020-02-20 00:00:00", - "subregion": "str", - "thumbprint": "str", - "type": "str", - } - }, "kind": "str", - "licenseType": "str", - "longTermRetentionBackupResourceId": "str", - "maintenanceConfigurationId": "str", "managedBy": "str", - "manualCutover": bool, - "maxLogSizeBytes": 0, - "maxSizeBytes": 0, - "minCapacity": 0.0, "name": "str", - "pausedDate": "2020-02-20 00:00:00", - "performCutover": bool, - "preferredEnclaveType": "str", - "readScale": "str", - "recoverableDatabaseId": "str", - "recoveryServicesRecoveryPointId": "str", - "requestedBackupStorageRedundancy": "str", - "requestedServiceObjectiveName": "str", - "restorableDroppedDatabaseId": "str", - "restorePointInTime": "2020-02-20 00:00:00", - "resumedDate": "2020-02-20 00:00:00", - "sampleName": "str", - "secondaryType": "str", + "properties": { + "autoPauseDelay": 0, + "availabilityZone": "str", + "catalogCollation": "str", + "collation": "str", + "createMode": "str", + "creationDate": "2020-02-20 00:00:00", + "currentBackupStorageRedundancy": "str", + "currentServiceObjectiveName": "str", + "currentSku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, + "databaseId": "str", + "defaultSecondaryLocation": "str", + "earliestRestoreDate": "2020-02-20 00:00:00", + "elasticPoolId": "str", + "encryptionProtector": "str", + "encryptionProtectorAutoRotation": bool, + "failoverGroupId": "str", + "federatedClientId": "str", + "freeLimitExhaustionBehavior": "str", + "highAvailabilityReplicaCount": 0, + "isInfraEncryptionEnabled": bool, + "isLedgerOn": bool, + "keys": { + "str": { + "creationDate": "2020-02-20 00:00:00", + "keyVersion": "str", + "subregion": "str", + "thumbprint": "str", + "type": "str", + } + }, + "licenseType": "str", + "longTermRetentionBackupResourceId": "str", + "maintenanceConfigurationId": "str", + "manualCutover": bool, + "maxLogSizeBytes": 0, + "maxSizeBytes": 0, + "minCapacity": 0.0, + "pausedDate": "2020-02-20 00:00:00", + "performCutover": bool, + "preferredEnclaveType": "str", + "provisioningState": "str", + "readScale": "str", + "recoverableDatabaseId": "str", + "recoveryServicesRecoveryPointId": "str", + "requestedBackupStorageRedundancy": "str", + "requestedServiceObjectiveName": "str", + "restorableDroppedDatabaseId": "str", + "restorePointInTime": "2020-02-20 00:00:00", + "resumedDate": "2020-02-20 00:00:00", + "sampleName": "str", + "secondaryType": "str", + "sourceDatabaseDeletionDate": "2020-02-20 00:00:00", + "sourceDatabaseId": "str", + "sourceResourceId": "str", + "status": "str", + "useFreeLimit": bool, + "zoneRedundant": bool, + }, "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, - "sourceDatabaseDeletionDate": "2020-02-20 00:00:00", - "sourceDatabaseId": "str", - "sourceResourceId": "str", - "status": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", - "useFreeLimit": bool, - "zoneRedundant": bool, }, - api_version="2023-02-01-preview", - ).result() # call '.result()' to poll until service return final result - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_databases_begin_delete(self, resource_group): - response = self.client.databases.begin_delete( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - api_version="2023-02-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -174,73 +132,99 @@ def test_databases_begin_update(self, resource_group): server_name="str", database_name="str", parameters={ - "autoPauseDelay": 0, - "catalogCollation": "str", - "collation": "str", - "createMode": "str", - "creationDate": "2020-02-20 00:00:00", - "currentBackupStorageRedundancy": "str", - "currentServiceObjectiveName": "str", - "currentSku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, - "databaseId": "str", - "defaultSecondaryLocation": "str", - "earliestRestoreDate": "2020-02-20 00:00:00", - "elasticPoolId": "str", - "encryptionProtector": "str", - "encryptionProtectorAutoRotation": bool, - "failoverGroupId": "str", - "federatedClientId": "str", - "freeLimitExhaustionBehavior": "str", - "highAvailabilityReplicaCount": 0, "identity": { "tenantId": "str", "type": "str", "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, }, - "isInfraEncryptionEnabled": bool, - "isLedgerOn": bool, - "keys": { - "str": { - "creationDate": "2020-02-20 00:00:00", - "subregion": "str", - "thumbprint": "str", - "type": "str", - } + "properties": { + "autoPauseDelay": 0, + "catalogCollation": "str", + "collation": "str", + "createMode": "str", + "creationDate": "2020-02-20 00:00:00", + "currentBackupStorageRedundancy": "str", + "currentServiceObjectiveName": "str", + "currentSku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, + "databaseId": "str", + "defaultSecondaryLocation": "str", + "earliestRestoreDate": "2020-02-20 00:00:00", + "elasticPoolId": "str", + "encryptionProtector": "str", + "encryptionProtectorAutoRotation": bool, + "failoverGroupId": "str", + "federatedClientId": "str", + "freeLimitExhaustionBehavior": "str", + "highAvailabilityReplicaCount": 0, + "isInfraEncryptionEnabled": bool, + "isLedgerOn": bool, + "keys": { + "str": { + "creationDate": "2020-02-20 00:00:00", + "keyVersion": "str", + "subregion": "str", + "thumbprint": "str", + "type": "str", + } + }, + "licenseType": "str", + "longTermRetentionBackupResourceId": "str", + "maintenanceConfigurationId": "str", + "manualCutover": bool, + "maxLogSizeBytes": 0, + "maxSizeBytes": 0, + "minCapacity": 0.0, + "pausedDate": "2020-02-20 00:00:00", + "performCutover": bool, + "preferredEnclaveType": "str", + "provisioningState": "str", + "readScale": "str", + "recoverableDatabaseId": "str", + "recoveryServicesRecoveryPointId": "str", + "requestedBackupStorageRedundancy": "str", + "requestedServiceObjectiveName": "str", + "restorableDroppedDatabaseId": "str", + "restorePointInTime": "2020-02-20 00:00:00", + "resumedDate": "2020-02-20 00:00:00", + "sampleName": "str", + "secondaryType": "str", + "sourceDatabaseDeletionDate": "2020-02-20 00:00:00", + "sourceDatabaseId": "str", + "status": "str", + "useFreeLimit": bool, + "zoneRedundant": bool, }, - "licenseType": "str", - "longTermRetentionBackupResourceId": "str", - "maintenanceConfigurationId": "str", - "manualCutover": bool, - "maxLogSizeBytes": 0, - "maxSizeBytes": 0, - "minCapacity": 0.0, - "pausedDate": "2020-02-20 00:00:00", - "performCutover": bool, - "preferredEnclaveType": "str", - "readScale": "str", - "recoverableDatabaseId": "str", - "recoveryServicesRecoveryPointId": "str", - "requestedBackupStorageRedundancy": "str", - "requestedServiceObjectiveName": "str", - "restorableDroppedDatabaseId": "str", - "restorePointInTime": "2020-02-20 00:00:00", - "resumedDate": "2020-02-20 00:00:00", - "sampleName": "str", - "secondaryType": "str", "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, - "sourceDatabaseDeletionDate": "2020-02-20 00:00:00", - "sourceDatabaseId": "str", - "status": "str", "tags": {"str": "str"}, - "useFreeLimit": bool, - "zoneRedundant": bool, }, - api_version="2023-02-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_databases_begin_delete(self, resource_group): + response = self.client.databases.begin_delete( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_databases_list_by_server(self, resource_group): + response = self.client.databases.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_databases_begin_export(self, resource_group): @@ -250,14 +234,13 @@ def test_databases_begin_export(self, resource_group): database_name="str", parameters={ "administratorLogin": "str", - "administratorLoginPassword": "str", "storageKey": "str", "storageKeyType": "str", "storageUri": "str", + "administratorLoginPassword": "str", "authenticationType": "str", "networkIsolation": {"sqlServerResourceId": "str", "storageAccountResourceId": "str"}, }, - api_version="2023-02-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -270,7 +253,6 @@ def test_databases_begin_failover(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2023-02-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -285,14 +267,13 @@ def test_databases_begin_import_method(self, resource_group): database_name="str", parameters={ "administratorLogin": "str", - "administratorLoginPassword": "str", "storageKey": "str", "storageKeyType": "str", "storageUri": "str", + "administratorLoginPassword": "str", "authenticationType": "str", "networkIsolation": {"sqlServerResourceId": "str", "storageAccountResourceId": "str"}, }, - api_version="2023-02-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -306,7 +287,6 @@ def test_databases_rename(self, resource_group): server_name="str", database_name="str", parameters={"id": "str"}, - api_version="2023-02-01-preview", ) # please add some check logic here by yourself @@ -319,7 +299,6 @@ def test_databases_begin_pause(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2023-02-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -332,7 +311,6 @@ def test_databases_begin_resume(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2023-02-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -345,7 +323,6 @@ def test_databases_begin_upgrade_data_warehouse(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2023-02-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -353,12 +330,10 @@ def test_databases_begin_upgrade_data_warehouse(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_databases_list_by_elastic_pool(self, resource_group): - response = self.client.databases.list_by_elastic_pool( + def test_databases_list_inaccessible_by_server(self, resource_group): + response = self.client.databases.list_inaccessible_by_server( resource_group_name=resource_group.name, server_name="str", - elastic_pool_name="str", - api_version="2023-02-01-preview", ) result = [r for r in response] # please add some check logic here by yourself @@ -366,11 +341,11 @@ def test_databases_list_by_elastic_pool(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_databases_list_inaccessible_by_server(self, resource_group): - response = self.client.databases.list_inaccessible_by_server( + def test_databases_list_by_elastic_pool(self, resource_group): + response = self.client.databases.list_by_elastic_pool( resource_group_name=resource_group.name, server_name="str", - api_version="2023-02-01-preview", + elastic_pool_name="str", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_databases_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_databases_operations_async.py index f805eb2bba91..f4ba642ac0c0 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_databases_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_databases_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,45 +19,6 @@ class TestSqlManagementDatabasesOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_databases_list_metrics(self, resource_group): - response = self.client.databases.list_metrics( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - filter="str", - api_version="2014-04-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_databases_list_metric_definitions(self, resource_group): - response = self.client.databases.list_metric_definitions( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - api_version="2014-04-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_databases_list_by_server(self, resource_group): - response = self.client.databases.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2023-02-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_databases_get(self, resource_group): @@ -65,7 +26,6 @@ async def test_databases_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2023-02-01-preview", ) # please add some check logic here by yourself @@ -81,90 +41,86 @@ async def test_databases_begin_create_or_update(self, resource_group): database_name="str", parameters={ "location": "str", - "autoPauseDelay": 0, - "availabilityZone": "str", - "catalogCollation": "str", - "collation": "str", - "createMode": "str", - "creationDate": "2020-02-20 00:00:00", - "currentBackupStorageRedundancy": "str", - "currentServiceObjectiveName": "str", - "currentSku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, - "databaseId": "str", - "defaultSecondaryLocation": "str", - "earliestRestoreDate": "2020-02-20 00:00:00", - "elasticPoolId": "str", - "encryptionProtector": "str", - "encryptionProtectorAutoRotation": bool, - "failoverGroupId": "str", - "federatedClientId": "str", - "freeLimitExhaustionBehavior": "str", - "highAvailabilityReplicaCount": 0, "id": "str", "identity": { "tenantId": "str", "type": "str", "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, }, - "isInfraEncryptionEnabled": bool, - "isLedgerOn": bool, - "keys": { - "str": { - "creationDate": "2020-02-20 00:00:00", - "subregion": "str", - "thumbprint": "str", - "type": "str", - } - }, "kind": "str", - "licenseType": "str", - "longTermRetentionBackupResourceId": "str", - "maintenanceConfigurationId": "str", "managedBy": "str", - "manualCutover": bool, - "maxLogSizeBytes": 0, - "maxSizeBytes": 0, - "minCapacity": 0.0, "name": "str", - "pausedDate": "2020-02-20 00:00:00", - "performCutover": bool, - "preferredEnclaveType": "str", - "readScale": "str", - "recoverableDatabaseId": "str", - "recoveryServicesRecoveryPointId": "str", - "requestedBackupStorageRedundancy": "str", - "requestedServiceObjectiveName": "str", - "restorableDroppedDatabaseId": "str", - "restorePointInTime": "2020-02-20 00:00:00", - "resumedDate": "2020-02-20 00:00:00", - "sampleName": "str", - "secondaryType": "str", + "properties": { + "autoPauseDelay": 0, + "availabilityZone": "str", + "catalogCollation": "str", + "collation": "str", + "createMode": "str", + "creationDate": "2020-02-20 00:00:00", + "currentBackupStorageRedundancy": "str", + "currentServiceObjectiveName": "str", + "currentSku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, + "databaseId": "str", + "defaultSecondaryLocation": "str", + "earliestRestoreDate": "2020-02-20 00:00:00", + "elasticPoolId": "str", + "encryptionProtector": "str", + "encryptionProtectorAutoRotation": bool, + "failoverGroupId": "str", + "federatedClientId": "str", + "freeLimitExhaustionBehavior": "str", + "highAvailabilityReplicaCount": 0, + "isInfraEncryptionEnabled": bool, + "isLedgerOn": bool, + "keys": { + "str": { + "creationDate": "2020-02-20 00:00:00", + "keyVersion": "str", + "subregion": "str", + "thumbprint": "str", + "type": "str", + } + }, + "licenseType": "str", + "longTermRetentionBackupResourceId": "str", + "maintenanceConfigurationId": "str", + "manualCutover": bool, + "maxLogSizeBytes": 0, + "maxSizeBytes": 0, + "minCapacity": 0.0, + "pausedDate": "2020-02-20 00:00:00", + "performCutover": bool, + "preferredEnclaveType": "str", + "provisioningState": "str", + "readScale": "str", + "recoverableDatabaseId": "str", + "recoveryServicesRecoveryPointId": "str", + "requestedBackupStorageRedundancy": "str", + "requestedServiceObjectiveName": "str", + "restorableDroppedDatabaseId": "str", + "restorePointInTime": "2020-02-20 00:00:00", + "resumedDate": "2020-02-20 00:00:00", + "sampleName": "str", + "secondaryType": "str", + "sourceDatabaseDeletionDate": "2020-02-20 00:00:00", + "sourceDatabaseId": "str", + "sourceResourceId": "str", + "status": "str", + "useFreeLimit": bool, + "zoneRedundant": bool, + }, "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, - "sourceDatabaseDeletionDate": "2020-02-20 00:00:00", - "sourceDatabaseId": "str", - "sourceResourceId": "str", - "status": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", - "useFreeLimit": bool, - "zoneRedundant": bool, }, - api_version="2023-02-01-preview", - ) - ).result() # call '.result()' to poll until service return final result - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_databases_begin_delete(self, resource_group): - response = await ( - await self.client.databases.begin_delete( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - api_version="2023-02-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -180,74 +136,102 @@ async def test_databases_begin_update(self, resource_group): server_name="str", database_name="str", parameters={ - "autoPauseDelay": 0, - "catalogCollation": "str", - "collation": "str", - "createMode": "str", - "creationDate": "2020-02-20 00:00:00", - "currentBackupStorageRedundancy": "str", - "currentServiceObjectiveName": "str", - "currentSku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, - "databaseId": "str", - "defaultSecondaryLocation": "str", - "earliestRestoreDate": "2020-02-20 00:00:00", - "elasticPoolId": "str", - "encryptionProtector": "str", - "encryptionProtectorAutoRotation": bool, - "failoverGroupId": "str", - "federatedClientId": "str", - "freeLimitExhaustionBehavior": "str", - "highAvailabilityReplicaCount": 0, "identity": { "tenantId": "str", "type": "str", "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, }, - "isInfraEncryptionEnabled": bool, - "isLedgerOn": bool, - "keys": { - "str": { - "creationDate": "2020-02-20 00:00:00", - "subregion": "str", - "thumbprint": "str", - "type": "str", - } + "properties": { + "autoPauseDelay": 0, + "catalogCollation": "str", + "collation": "str", + "createMode": "str", + "creationDate": "2020-02-20 00:00:00", + "currentBackupStorageRedundancy": "str", + "currentServiceObjectiveName": "str", + "currentSku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, + "databaseId": "str", + "defaultSecondaryLocation": "str", + "earliestRestoreDate": "2020-02-20 00:00:00", + "elasticPoolId": "str", + "encryptionProtector": "str", + "encryptionProtectorAutoRotation": bool, + "failoverGroupId": "str", + "federatedClientId": "str", + "freeLimitExhaustionBehavior": "str", + "highAvailabilityReplicaCount": 0, + "isInfraEncryptionEnabled": bool, + "isLedgerOn": bool, + "keys": { + "str": { + "creationDate": "2020-02-20 00:00:00", + "keyVersion": "str", + "subregion": "str", + "thumbprint": "str", + "type": "str", + } + }, + "licenseType": "str", + "longTermRetentionBackupResourceId": "str", + "maintenanceConfigurationId": "str", + "manualCutover": bool, + "maxLogSizeBytes": 0, + "maxSizeBytes": 0, + "minCapacity": 0.0, + "pausedDate": "2020-02-20 00:00:00", + "performCutover": bool, + "preferredEnclaveType": "str", + "provisioningState": "str", + "readScale": "str", + "recoverableDatabaseId": "str", + "recoveryServicesRecoveryPointId": "str", + "requestedBackupStorageRedundancy": "str", + "requestedServiceObjectiveName": "str", + "restorableDroppedDatabaseId": "str", + "restorePointInTime": "2020-02-20 00:00:00", + "resumedDate": "2020-02-20 00:00:00", + "sampleName": "str", + "secondaryType": "str", + "sourceDatabaseDeletionDate": "2020-02-20 00:00:00", + "sourceDatabaseId": "str", + "status": "str", + "useFreeLimit": bool, + "zoneRedundant": bool, }, - "licenseType": "str", - "longTermRetentionBackupResourceId": "str", - "maintenanceConfigurationId": "str", - "manualCutover": bool, - "maxLogSizeBytes": 0, - "maxSizeBytes": 0, - "minCapacity": 0.0, - "pausedDate": "2020-02-20 00:00:00", - "performCutover": bool, - "preferredEnclaveType": "str", - "readScale": "str", - "recoverableDatabaseId": "str", - "recoveryServicesRecoveryPointId": "str", - "requestedBackupStorageRedundancy": "str", - "requestedServiceObjectiveName": "str", - "restorableDroppedDatabaseId": "str", - "restorePointInTime": "2020-02-20 00:00:00", - "resumedDate": "2020-02-20 00:00:00", - "sampleName": "str", - "secondaryType": "str", "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, - "sourceDatabaseDeletionDate": "2020-02-20 00:00:00", - "sourceDatabaseId": "str", - "status": "str", "tags": {"str": "str"}, - "useFreeLimit": bool, - "zoneRedundant": bool, }, - api_version="2023-02-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_databases_begin_delete(self, resource_group): + response = await ( + await self.client.databases.begin_delete( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_databases_list_by_server(self, resource_group): + response = self.client.databases.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_databases_begin_export(self, resource_group): @@ -258,14 +242,13 @@ async def test_databases_begin_export(self, resource_group): database_name="str", parameters={ "administratorLogin": "str", - "administratorLoginPassword": "str", "storageKey": "str", "storageKeyType": "str", "storageUri": "str", + "administratorLoginPassword": "str", "authenticationType": "str", "networkIsolation": {"sqlServerResourceId": "str", "storageAccountResourceId": "str"}, }, - api_version="2023-02-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -280,7 +263,6 @@ async def test_databases_begin_failover(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2023-02-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -297,14 +279,13 @@ async def test_databases_begin_import_method(self, resource_group): database_name="str", parameters={ "administratorLogin": "str", - "administratorLoginPassword": "str", "storageKey": "str", "storageKeyType": "str", "storageUri": "str", + "administratorLoginPassword": "str", "authenticationType": "str", "networkIsolation": {"sqlServerResourceId": "str", "storageAccountResourceId": "str"}, }, - api_version="2023-02-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -319,7 +300,6 @@ async def test_databases_rename(self, resource_group): server_name="str", database_name="str", parameters={"id": "str"}, - api_version="2023-02-01-preview", ) # please add some check logic here by yourself @@ -333,7 +313,6 @@ async def test_databases_begin_pause(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2023-02-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -348,7 +327,6 @@ async def test_databases_begin_resume(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2023-02-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -363,7 +341,6 @@ async def test_databases_begin_upgrade_data_warehouse(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2023-02-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -372,12 +349,10 @@ async def test_databases_begin_upgrade_data_warehouse(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_databases_list_by_elastic_pool(self, resource_group): - response = self.client.databases.list_by_elastic_pool( + async def test_databases_list_inaccessible_by_server(self, resource_group): + response = self.client.databases.list_inaccessible_by_server( resource_group_name=resource_group.name, server_name="str", - elastic_pool_name="str", - api_version="2023-02-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself @@ -385,11 +360,11 @@ async def test_databases_list_by_elastic_pool(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_databases_list_inaccessible_by_server(self, resource_group): - response = self.client.databases.list_inaccessible_by_server( + async def test_databases_list_by_elastic_pool(self, resource_group): + response = self.client.databases.list_by_elastic_pool( resource_group_name=resource_group.name, server_name="str", - api_version="2023-02-01-preview", + elastic_pool_name="str", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_deleted_servers_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_deleted_servers_operations.py index 650c9a4be163..cfed9c5d0cbf 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_deleted_servers_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_deleted_servers_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,23 +18,12 @@ class TestSqlManagementDeletedServersOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_deleted_servers_list(self, resource_group): - response = self.client.deleted_servers.list( - api_version="2020-11-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_deleted_servers_get(self, resource_group): response = self.client.deleted_servers.get( location_name="str", deleted_server_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -45,7 +34,6 @@ def test_deleted_servers_get(self, resource_group): def test_deleted_servers_list_by_location(self, resource_group): response = self.client.deleted_servers.list_by_location( location_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself @@ -57,8 +45,15 @@ def test_deleted_servers_begin_recover(self, resource_group): response = self.client.deleted_servers.begin_recover( location_name="str", deleted_server_name="str", - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_deleted_servers_list(self, resource_group): + response = self.client.deleted_servers.list() + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_deleted_servers_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_deleted_servers_operations_async.py index e8e818cce32e..0f1832c1b56a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_deleted_servers_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_deleted_servers_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,23 +19,12 @@ class TestSqlManagementDeletedServersOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_deleted_servers_list(self, resource_group): - response = self.client.deleted_servers.list( - api_version="2020-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_deleted_servers_get(self, resource_group): response = await self.client.deleted_servers.get( location_name="str", deleted_server_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -46,7 +35,6 @@ async def test_deleted_servers_get(self, resource_group): async def test_deleted_servers_list_by_location(self, resource_group): response = self.client.deleted_servers.list_by_location( location_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself @@ -59,9 +47,16 @@ async def test_deleted_servers_begin_recover(self, resource_group): await self.client.deleted_servers.begin_recover( location_name="str", deleted_server_name="str", - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_deleted_servers_list(self, resource_group): + response = self.client.deleted_servers.list() + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_distributed_availability_groups_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_distributed_availability_groups_operations.py index a38ce1604889..57dc53e959b1 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_distributed_availability_groups_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_distributed_availability_groups_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,77 +20,135 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_distributed_availability_groups_list_by_instance(self, resource_group): - response = self.client.distributed_availability_groups.list_by_instance( + def test_distributed_availability_groups_get(self, resource_group): + response = self.client.distributed_availability_groups.get( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2023-08-01-preview", + distributed_availability_group_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_distributed_availability_groups_get(self, resource_group): - response = self.client.distributed_availability_groups.get( + def test_distributed_availability_groups_begin_create_or_update(self, resource_group): + response = self.client.distributed_availability_groups.begin_create_or_update( resource_group_name=resource_group.name, managed_instance_name="str", distributed_availability_group_name="str", - api_version="2023-08-01-preview", - ) + parameters={ + "id": "str", + "name": "str", + "properties": { + "databases": [ + { + "connectedState": "str", + "databaseName": "str", + "instanceRedoReplicationLagSeconds": 0, + "instanceReplicaId": "str", + "instanceSendReplicationLagSeconds": 0, + "lastBackupLsn": "str", + "lastBackupTime": "2020-02-20 00:00:00", + "lastCommitLsn": "str", + "lastCommitTime": "2020-02-20 00:00:00", + "lastHardenedLsn": "str", + "lastHardenedTime": "2020-02-20 00:00:00", + "lastReceivedLsn": "str", + "lastReceivedTime": "2020-02-20 00:00:00", + "lastSentLsn": "str", + "lastSentTime": "2020-02-20 00:00:00", + "mostRecentLinkError": "str", + "partnerAuthCertValidity": {"certificateName": "str", "expiryDate": "2020-02-20 00:00:00"}, + "partnerReplicaId": "str", + "replicaState": "str", + "seedingProgress": "str", + "synchronizationHealth": "str", + } + ], + "distributedAvailabilityGroupId": "str", + "distributedAvailabilityGroupName": "str", + "failoverMode": "str", + "instanceAvailabilityGroupName": "str", + "instanceLinkRole": "str", + "partnerAvailabilityGroupName": "str", + "partnerEndpoint": "str", + "partnerLinkRole": "str", + "replicationMode": "str", + "seedingMode": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_distributed_availability_groups_begin_create_or_update(self, resource_group): - response = self.client.distributed_availability_groups.begin_create_or_update( + def test_distributed_availability_groups_begin_update(self, resource_group): + response = self.client.distributed_availability_groups.begin_update( resource_group_name=resource_group.name, managed_instance_name="str", distributed_availability_group_name="str", parameters={ - "databases": [ - { - "connectedState": "str", - "databaseName": "str", - "instanceRedoReplicationLagSeconds": 0, - "instanceReplicaId": "str", - "instanceSendReplicationLagSeconds": 0, - "lastBackupLsn": "str", - "lastBackupTime": "2020-02-20 00:00:00", - "lastCommitLsn": "str", - "lastCommitTime": "2020-02-20 00:00:00", - "lastHardenedLsn": "str", - "lastHardenedTime": "2020-02-20 00:00:00", - "lastReceivedLsn": "str", - "lastReceivedTime": "2020-02-20 00:00:00", - "lastSentLsn": "str", - "lastSentTime": "2020-02-20 00:00:00", - "mostRecentLinkError": "str", - "partnerAuthCertValidity": {"certificateName": "str", "expiryDate": "2020-02-20 00:00:00"}, - "partnerReplicaId": "str", - "replicaState": "str", - "seedingProgress": "str", - "synchronizationHealth": "str", - } - ], - "distributedAvailabilityGroupId": "str", - "distributedAvailabilityGroupName": "str", - "failoverMode": "str", "id": "str", - "instanceAvailabilityGroupName": "str", - "instanceLinkRole": "str", "name": "str", - "partnerAvailabilityGroupName": "str", - "partnerEndpoint": "str", - "partnerLinkRole": "str", - "replicationMode": "str", - "seedingMode": "str", + "properties": { + "databases": [ + { + "connectedState": "str", + "databaseName": "str", + "instanceRedoReplicationLagSeconds": 0, + "instanceReplicaId": "str", + "instanceSendReplicationLagSeconds": 0, + "lastBackupLsn": "str", + "lastBackupTime": "2020-02-20 00:00:00", + "lastCommitLsn": "str", + "lastCommitTime": "2020-02-20 00:00:00", + "lastHardenedLsn": "str", + "lastHardenedTime": "2020-02-20 00:00:00", + "lastReceivedLsn": "str", + "lastReceivedTime": "2020-02-20 00:00:00", + "lastSentLsn": "str", + "lastSentTime": "2020-02-20 00:00:00", + "mostRecentLinkError": "str", + "partnerAuthCertValidity": {"certificateName": "str", "expiryDate": "2020-02-20 00:00:00"}, + "partnerReplicaId": "str", + "replicaState": "str", + "seedingProgress": "str", + "synchronizationHealth": "str", + } + ], + "distributedAvailabilityGroupId": "str", + "distributedAvailabilityGroupName": "str", + "failoverMode": "str", + "instanceAvailabilityGroupName": "str", + "instanceLinkRole": "str", + "partnerAvailabilityGroupName": "str", + "partnerEndpoint": "str", + "partnerLinkRole": "str", + "replicationMode": "str", + "seedingMode": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2023-08-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -103,7 +161,6 @@ def test_distributed_availability_groups_begin_delete(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", distributed_availability_group_name="str", - api_version="2023-08-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -111,54 +168,12 @@ def test_distributed_availability_groups_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_distributed_availability_groups_begin_update(self, resource_group): - response = self.client.distributed_availability_groups.begin_update( + def test_distributed_availability_groups_list_by_instance(self, resource_group): + response = self.client.distributed_availability_groups.list_by_instance( resource_group_name=resource_group.name, managed_instance_name="str", - distributed_availability_group_name="str", - parameters={ - "databases": [ - { - "connectedState": "str", - "databaseName": "str", - "instanceRedoReplicationLagSeconds": 0, - "instanceReplicaId": "str", - "instanceSendReplicationLagSeconds": 0, - "lastBackupLsn": "str", - "lastBackupTime": "2020-02-20 00:00:00", - "lastCommitLsn": "str", - "lastCommitTime": "2020-02-20 00:00:00", - "lastHardenedLsn": "str", - "lastHardenedTime": "2020-02-20 00:00:00", - "lastReceivedLsn": "str", - "lastReceivedTime": "2020-02-20 00:00:00", - "lastSentLsn": "str", - "lastSentTime": "2020-02-20 00:00:00", - "mostRecentLinkError": "str", - "partnerAuthCertValidity": {"certificateName": "str", "expiryDate": "2020-02-20 00:00:00"}, - "partnerReplicaId": "str", - "replicaState": "str", - "seedingProgress": "str", - "synchronizationHealth": "str", - } - ], - "distributedAvailabilityGroupId": "str", - "distributedAvailabilityGroupName": "str", - "failoverMode": "str", - "id": "str", - "instanceAvailabilityGroupName": "str", - "instanceLinkRole": "str", - "name": "str", - "partnerAvailabilityGroupName": "str", - "partnerEndpoint": "str", - "partnerLinkRole": "str", - "replicationMode": "str", - "seedingMode": "str", - "type": "str", - }, - api_version="2023-08-01-preview", - ).result() # call '.result()' to poll until service return final result - + ) + result = [r for r in response] # please add some check logic here by yourself # ... @@ -170,7 +185,6 @@ def test_distributed_availability_groups_begin_failover(self, resource_group): managed_instance_name="str", distributed_availability_group_name="str", parameters={"failoverType": "str"}, - api_version="2023-08-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -184,7 +198,6 @@ def test_distributed_availability_groups_begin_set_role(self, resource_group): managed_instance_name="str", distributed_availability_group_name="str", parameters={"instanceRole": "str", "roleChangeType": "str"}, - api_version="2023-08-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_distributed_availability_groups_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_distributed_availability_groups_operations_async.py index 9b02216b0f9b..71352571a90f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_distributed_availability_groups_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_distributed_availability_groups_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,18 +19,6 @@ class TestSqlManagementDistributedAvailabilityGroupsOperationsAsync(AzureMgmtRec def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_distributed_availability_groups_list_by_instance(self, resource_group): - response = self.client.distributed_availability_groups.list_by_instance( - resource_group_name=resource_group.name, - managed_instance_name="str", - api_version="2023-08-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_distributed_availability_groups_get(self, resource_group): @@ -38,7 +26,6 @@ async def test_distributed_availability_groups_get(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", distributed_availability_group_name="str", - api_version="2023-08-01-preview", ) # please add some check logic here by yourself @@ -53,46 +40,58 @@ async def test_distributed_availability_groups_begin_create_or_update(self, reso managed_instance_name="str", distributed_availability_group_name="str", parameters={ - "databases": [ - { - "connectedState": "str", - "databaseName": "str", - "instanceRedoReplicationLagSeconds": 0, - "instanceReplicaId": "str", - "instanceSendReplicationLagSeconds": 0, - "lastBackupLsn": "str", - "lastBackupTime": "2020-02-20 00:00:00", - "lastCommitLsn": "str", - "lastCommitTime": "2020-02-20 00:00:00", - "lastHardenedLsn": "str", - "lastHardenedTime": "2020-02-20 00:00:00", - "lastReceivedLsn": "str", - "lastReceivedTime": "2020-02-20 00:00:00", - "lastSentLsn": "str", - "lastSentTime": "2020-02-20 00:00:00", - "mostRecentLinkError": "str", - "partnerAuthCertValidity": {"certificateName": "str", "expiryDate": "2020-02-20 00:00:00"}, - "partnerReplicaId": "str", - "replicaState": "str", - "seedingProgress": "str", - "synchronizationHealth": "str", - } - ], - "distributedAvailabilityGroupId": "str", - "distributedAvailabilityGroupName": "str", - "failoverMode": "str", "id": "str", - "instanceAvailabilityGroupName": "str", - "instanceLinkRole": "str", "name": "str", - "partnerAvailabilityGroupName": "str", - "partnerEndpoint": "str", - "partnerLinkRole": "str", - "replicationMode": "str", - "seedingMode": "str", + "properties": { + "databases": [ + { + "connectedState": "str", + "databaseName": "str", + "instanceRedoReplicationLagSeconds": 0, + "instanceReplicaId": "str", + "instanceSendReplicationLagSeconds": 0, + "lastBackupLsn": "str", + "lastBackupTime": "2020-02-20 00:00:00", + "lastCommitLsn": "str", + "lastCommitTime": "2020-02-20 00:00:00", + "lastHardenedLsn": "str", + "lastHardenedTime": "2020-02-20 00:00:00", + "lastReceivedLsn": "str", + "lastReceivedTime": "2020-02-20 00:00:00", + "lastSentLsn": "str", + "lastSentTime": "2020-02-20 00:00:00", + "mostRecentLinkError": "str", + "partnerAuthCertValidity": { + "certificateName": "str", + "expiryDate": "2020-02-20 00:00:00", + }, + "partnerReplicaId": "str", + "replicaState": "str", + "seedingProgress": "str", + "synchronizationHealth": "str", + } + ], + "distributedAvailabilityGroupId": "str", + "distributedAvailabilityGroupName": "str", + "failoverMode": "str", + "instanceAvailabilityGroupName": "str", + "instanceLinkRole": "str", + "partnerAvailabilityGroupName": "str", + "partnerEndpoint": "str", + "partnerLinkRole": "str", + "replicationMode": "str", + "seedingMode": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2023-08-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -101,13 +100,65 @@ async def test_distributed_availability_groups_begin_create_or_update(self, reso @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_distributed_availability_groups_begin_delete(self, resource_group): + async def test_distributed_availability_groups_begin_update(self, resource_group): response = await ( - await self.client.distributed_availability_groups.begin_delete( + await self.client.distributed_availability_groups.begin_update( resource_group_name=resource_group.name, managed_instance_name="str", distributed_availability_group_name="str", - api_version="2023-08-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": { + "databases": [ + { + "connectedState": "str", + "databaseName": "str", + "instanceRedoReplicationLagSeconds": 0, + "instanceReplicaId": "str", + "instanceSendReplicationLagSeconds": 0, + "lastBackupLsn": "str", + "lastBackupTime": "2020-02-20 00:00:00", + "lastCommitLsn": "str", + "lastCommitTime": "2020-02-20 00:00:00", + "lastHardenedLsn": "str", + "lastHardenedTime": "2020-02-20 00:00:00", + "lastReceivedLsn": "str", + "lastReceivedTime": "2020-02-20 00:00:00", + "lastSentLsn": "str", + "lastSentTime": "2020-02-20 00:00:00", + "mostRecentLinkError": "str", + "partnerAuthCertValidity": { + "certificateName": "str", + "expiryDate": "2020-02-20 00:00:00", + }, + "partnerReplicaId": "str", + "replicaState": "str", + "seedingProgress": "str", + "synchronizationHealth": "str", + } + ], + "distributedAvailabilityGroupId": "str", + "distributedAvailabilityGroupName": "str", + "failoverMode": "str", + "instanceAvailabilityGroupName": "str", + "instanceLinkRole": "str", + "partnerAvailabilityGroupName": "str", + "partnerEndpoint": "str", + "partnerLinkRole": "str", + "replicationMode": "str", + "seedingMode": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) ).result() # call '.result()' to poll until service return final result @@ -116,59 +167,29 @@ async def test_distributed_availability_groups_begin_delete(self, resource_group @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_distributed_availability_groups_begin_update(self, resource_group): + async def test_distributed_availability_groups_begin_delete(self, resource_group): response = await ( - await self.client.distributed_availability_groups.begin_update( + await self.client.distributed_availability_groups.begin_delete( resource_group_name=resource_group.name, managed_instance_name="str", distributed_availability_group_name="str", - parameters={ - "databases": [ - { - "connectedState": "str", - "databaseName": "str", - "instanceRedoReplicationLagSeconds": 0, - "instanceReplicaId": "str", - "instanceSendReplicationLagSeconds": 0, - "lastBackupLsn": "str", - "lastBackupTime": "2020-02-20 00:00:00", - "lastCommitLsn": "str", - "lastCommitTime": "2020-02-20 00:00:00", - "lastHardenedLsn": "str", - "lastHardenedTime": "2020-02-20 00:00:00", - "lastReceivedLsn": "str", - "lastReceivedTime": "2020-02-20 00:00:00", - "lastSentLsn": "str", - "lastSentTime": "2020-02-20 00:00:00", - "mostRecentLinkError": "str", - "partnerAuthCertValidity": {"certificateName": "str", "expiryDate": "2020-02-20 00:00:00"}, - "partnerReplicaId": "str", - "replicaState": "str", - "seedingProgress": "str", - "synchronizationHealth": "str", - } - ], - "distributedAvailabilityGroupId": "str", - "distributedAvailabilityGroupName": "str", - "failoverMode": "str", - "id": "str", - "instanceAvailabilityGroupName": "str", - "instanceLinkRole": "str", - "name": "str", - "partnerAvailabilityGroupName": "str", - "partnerEndpoint": "str", - "partnerLinkRole": "str", - "replicationMode": "str", - "seedingMode": "str", - "type": "str", - }, - api_version="2023-08-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_distributed_availability_groups_list_by_instance(self, resource_group): + response = self.client.distributed_availability_groups.list_by_instance( + resource_group_name=resource_group.name, + managed_instance_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_distributed_availability_groups_begin_failover(self, resource_group): @@ -178,7 +199,6 @@ async def test_distributed_availability_groups_begin_failover(self, resource_gro managed_instance_name="str", distributed_availability_group_name="str", parameters={"failoverType": "str"}, - api_version="2023-08-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -194,7 +214,6 @@ async def test_distributed_availability_groups_begin_set_role(self, resource_gro managed_instance_name="str", distributed_availability_group_name="str", parameters={"instanceRole": "str", "roleChangeType": "str"}, - api_version="2023-08-01-preview", ) ).result() # call '.result()' to poll until service return final result diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_elastic_pool_activities_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_elastic_pool_activities_operations.py deleted file mode 100644 index e6b1c483a9ef..000000000000 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_elastic_pool_activities_operations.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import pytest -from azure.mgmt.sql import SqlManagementClient - -from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy - -AZURE_LOCATION = "eastus" - - -@pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestSqlManagementElasticPoolActivitiesOperations(AzureMgmtRecordedTestCase): - def setup_method(self, method): - self.client = self.create_mgmt_client(SqlManagementClient) - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_elastic_pool_activities_list_by_elastic_pool(self, resource_group): - response = self.client.elastic_pool_activities.list_by_elastic_pool( - resource_group_name=resource_group.name, - server_name="str", - elastic_pool_name="str", - api_version="2014-04-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_elastic_pool_activities_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_elastic_pool_activities_operations_async.py deleted file mode 100644 index 8988ca16ad72..000000000000 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_elastic_pool_activities_operations_async.py +++ /dev/null @@ -1,33 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import pytest -from azure.mgmt.sql.aio import SqlManagementClient - -from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer -from devtools_testutils.aio import recorded_by_proxy_async - -AZURE_LOCATION = "eastus" - - -@pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestSqlManagementElasticPoolActivitiesOperationsAsync(AzureMgmtRecordedTestCase): - def setup_method(self, method): - self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_elastic_pool_activities_list_by_elastic_pool(self, resource_group): - response = self.client.elastic_pool_activities.list_by_elastic_pool( - resource_group_name=resource_group.name, - server_name="str", - elastic_pool_name="str", - api_version="2014-04-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_elastic_pool_database_activities_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_elastic_pool_database_activities_operations.py deleted file mode 100644 index 53f70bfa1873..000000000000 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_elastic_pool_database_activities_operations.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import pytest -from azure.mgmt.sql import SqlManagementClient - -from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy - -AZURE_LOCATION = "eastus" - - -@pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestSqlManagementElasticPoolDatabaseActivitiesOperations(AzureMgmtRecordedTestCase): - def setup_method(self, method): - self.client = self.create_mgmt_client(SqlManagementClient) - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_elastic_pool_database_activities_list_by_elastic_pool(self, resource_group): - response = self.client.elastic_pool_database_activities.list_by_elastic_pool( - resource_group_name=resource_group.name, - server_name="str", - elastic_pool_name="str", - api_version="2014-04-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_elastic_pool_database_activities_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_elastic_pool_database_activities_operations_async.py deleted file mode 100644 index 8a0ab117d50d..000000000000 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_elastic_pool_database_activities_operations_async.py +++ /dev/null @@ -1,33 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import pytest -from azure.mgmt.sql.aio import SqlManagementClient - -from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer -from devtools_testutils.aio import recorded_by_proxy_async - -AZURE_LOCATION = "eastus" - - -@pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestSqlManagementElasticPoolDatabaseActivitiesOperationsAsync(AzureMgmtRecordedTestCase): - def setup_method(self, method): - self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_elastic_pool_database_activities_list_by_elastic_pool(self, resource_group): - response = self.client.elastic_pool_database_activities.list_by_elastic_pool( - resource_group_name=resource_group.name, - server_name="str", - elastic_pool_name="str", - api_version="2014-04-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_elastic_pool_operations_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_elastic_pool_operations_operations.py index 56d318171acb..a0287d09a190 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_elastic_pool_operations_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_elastic_pool_operations_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,27 +20,25 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_elastic_pool_operations_cancel(self, resource_group): - response = self.client.elastic_pool_operations.cancel( + def test_elastic_pool_operations_list_by_elastic_pool(self, resource_group): + response = self.client.elastic_pool_operations.list_by_elastic_pool( resource_group_name=resource_group.name, server_name="str", elastic_pool_name="str", - operation_id="str", - api_version="2020-11-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_elastic_pool_operations_list_by_elastic_pool(self, resource_group): - response = self.client.elastic_pool_operations.list_by_elastic_pool( + def test_elastic_pool_operations_cancel(self, resource_group): + response = self.client.elastic_pool_operations.cancel( resource_group_name=resource_group.name, server_name="str", elastic_pool_name="str", - api_version="2020-11-01-preview", + operation_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_elastic_pool_operations_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_elastic_pool_operations_operations_async.py index 30d04a6b2e17..87c20fc180b9 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_elastic_pool_operations_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_elastic_pool_operations_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,27 +21,25 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_elastic_pool_operations_cancel(self, resource_group): - response = await self.client.elastic_pool_operations.cancel( + async def test_elastic_pool_operations_list_by_elastic_pool(self, resource_group): + response = self.client.elastic_pool_operations.list_by_elastic_pool( resource_group_name=resource_group.name, server_name="str", elastic_pool_name="str", - operation_id="str", - api_version="2020-11-01-preview", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_elastic_pool_operations_list_by_elastic_pool(self, resource_group): - response = self.client.elastic_pool_operations.list_by_elastic_pool( + async def test_elastic_pool_operations_cancel(self, resource_group): + response = await self.client.elastic_pool_operations.cancel( resource_group_name=resource_group.name, server_name="str", elastic_pool_name="str", - api_version="2020-11-01-preview", + operation_id="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_elastic_pools_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_elastic_pools_operations.py index 653f5276fe17..336d83e9491a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_elastic_pools_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_elastic_pools_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,45 +18,6 @@ class TestSqlManagementElasticPoolsOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_elastic_pools_list_metrics(self, resource_group): - response = self.client.elastic_pools.list_metrics( - resource_group_name=resource_group.name, - server_name="str", - elastic_pool_name="str", - filter="str", - api_version="2014-04-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_elastic_pools_list_metric_definitions(self, resource_group): - response = self.client.elastic_pools.list_metric_definitions( - resource_group_name=resource_group.name, - server_name="str", - elastic_pool_name="str", - api_version="2014-04-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_elastic_pools_list_by_server(self, resource_group): - response = self.client.elastic_pools.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2022-08-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_elastic_pools_get(self, resource_group): @@ -64,7 +25,6 @@ def test_elastic_pools_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", elastic_pool_name="str", - api_version="2022-08-01-preview", ) # please add some check logic here by yourself @@ -79,25 +39,36 @@ def test_elastic_pools_begin_create_or_update(self, resource_group): elastic_pool_name="str", parameters={ "location": "str", - "availabilityZone": "str", - "creationDate": "2020-02-20 00:00:00", - "highAvailabilityReplicaCount": 0, "id": "str", "kind": "str", - "licenseType": "str", - "maintenanceConfigurationId": "str", - "maxSizeBytes": 0, - "minCapacity": 0.0, "name": "str", - "perDatabaseSettings": {"maxCapacity": 0.0, "minCapacity": 0.0}, - "preferredEnclaveType": "str", + "properties": { + "autoPauseDelay": 0, + "availabilityZone": "str", + "creationDate": "2020-02-20 00:00:00", + "currentSku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, + "highAvailabilityReplicaCount": 0, + "licenseType": "str", + "maintenanceConfigurationId": "str", + "maxSizeBytes": 0, + "minCapacity": 0.0, + "perDatabaseSettings": {"autoPauseDelay": 0, "maxCapacity": 0.0, "minCapacity": 0.0}, + "preferredEnclaveType": "str", + "state": "str", + "zoneRedundant": bool, + }, "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, - "state": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", - "zoneRedundant": bool, }, - api_version="2022-08-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -105,12 +76,28 @@ def test_elastic_pools_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_elastic_pools_begin_delete(self, resource_group): - response = self.client.elastic_pools.begin_delete( + def test_elastic_pools_begin_update(self, resource_group): + response = self.client.elastic_pools.begin_update( resource_group_name=resource_group.name, server_name="str", elastic_pool_name="str", - api_version="2022-08-01-preview", + parameters={ + "properties": { + "autoPauseDelay": 0, + "availabilityZone": "str", + "currentSku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, + "highAvailabilityReplicaCount": 0, + "licenseType": "str", + "maintenanceConfigurationId": "str", + "maxSizeBytes": 0, + "minCapacity": 0.0, + "perDatabaseSettings": {"autoPauseDelay": 0, "maxCapacity": 0.0, "minCapacity": 0.0}, + "preferredEnclaveType": "str", + "zoneRedundant": bool, + }, + "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, + "tags": {"str": "str"}, + }, ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -118,30 +105,27 @@ def test_elastic_pools_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_elastic_pools_begin_update(self, resource_group): - response = self.client.elastic_pools.begin_update( + def test_elastic_pools_begin_delete(self, resource_group): + response = self.client.elastic_pools.begin_delete( resource_group_name=resource_group.name, server_name="str", elastic_pool_name="str", - parameters={ - "availabilityZone": "str", - "highAvailabilityReplicaCount": 0, - "licenseType": "str", - "maintenanceConfigurationId": "str", - "maxSizeBytes": 0, - "minCapacity": 0.0, - "perDatabaseSettings": {"maxCapacity": 0.0, "minCapacity": 0.0}, - "preferredEnclaveType": "str", - "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, - "tags": {"str": "str"}, - "zoneRedundant": bool, - }, - api_version="2022-08-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_elastic_pools_list_by_server(self, resource_group): + response = self.client.elastic_pools.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_elastic_pools_begin_failover(self, resource_group): @@ -149,7 +133,6 @@ def test_elastic_pools_begin_failover(self, resource_group): resource_group_name=resource_group.name, server_name="str", elastic_pool_name="str", - api_version="2022-08-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_elastic_pools_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_elastic_pools_operations_async.py index 6cc514565826..3c7e8221aea8 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_elastic_pools_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_elastic_pools_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,45 +19,6 @@ class TestSqlManagementElasticPoolsOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_elastic_pools_list_metrics(self, resource_group): - response = self.client.elastic_pools.list_metrics( - resource_group_name=resource_group.name, - server_name="str", - elastic_pool_name="str", - filter="str", - api_version="2014-04-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_elastic_pools_list_metric_definitions(self, resource_group): - response = self.client.elastic_pools.list_metric_definitions( - resource_group_name=resource_group.name, - server_name="str", - elastic_pool_name="str", - api_version="2014-04-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_elastic_pools_list_by_server(self, resource_group): - response = self.client.elastic_pools.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2022-08-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_elastic_pools_get(self, resource_group): @@ -65,7 +26,6 @@ async def test_elastic_pools_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", elastic_pool_name="str", - api_version="2022-08-01-preview", ) # please add some check logic here by yourself @@ -81,25 +41,36 @@ async def test_elastic_pools_begin_create_or_update(self, resource_group): elastic_pool_name="str", parameters={ "location": "str", - "availabilityZone": "str", - "creationDate": "2020-02-20 00:00:00", - "highAvailabilityReplicaCount": 0, "id": "str", "kind": "str", - "licenseType": "str", - "maintenanceConfigurationId": "str", - "maxSizeBytes": 0, - "minCapacity": 0.0, "name": "str", - "perDatabaseSettings": {"maxCapacity": 0.0, "minCapacity": 0.0}, - "preferredEnclaveType": "str", + "properties": { + "autoPauseDelay": 0, + "availabilityZone": "str", + "creationDate": "2020-02-20 00:00:00", + "currentSku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, + "highAvailabilityReplicaCount": 0, + "licenseType": "str", + "maintenanceConfigurationId": "str", + "maxSizeBytes": 0, + "minCapacity": 0.0, + "perDatabaseSettings": {"autoPauseDelay": 0, "maxCapacity": 0.0, "minCapacity": 0.0}, + "preferredEnclaveType": "str", + "state": "str", + "zoneRedundant": bool, + }, "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, - "state": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", - "zoneRedundant": bool, }, - api_version="2022-08-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -108,13 +79,29 @@ async def test_elastic_pools_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_elastic_pools_begin_delete(self, resource_group): + async def test_elastic_pools_begin_update(self, resource_group): response = await ( - await self.client.elastic_pools.begin_delete( + await self.client.elastic_pools.begin_update( resource_group_name=resource_group.name, server_name="str", elastic_pool_name="str", - api_version="2022-08-01-preview", + parameters={ + "properties": { + "autoPauseDelay": 0, + "availabilityZone": "str", + "currentSku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, + "highAvailabilityReplicaCount": 0, + "licenseType": "str", + "maintenanceConfigurationId": "str", + "maxSizeBytes": 0, + "minCapacity": 0.0, + "perDatabaseSettings": {"autoPauseDelay": 0, "maxCapacity": 0.0, "minCapacity": 0.0}, + "preferredEnclaveType": "str", + "zoneRedundant": bool, + }, + "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, + "tags": {"str": "str"}, + }, ) ).result() # call '.result()' to poll until service return final result @@ -123,32 +110,29 @@ async def test_elastic_pools_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_elastic_pools_begin_update(self, resource_group): + async def test_elastic_pools_begin_delete(self, resource_group): response = await ( - await self.client.elastic_pools.begin_update( + await self.client.elastic_pools.begin_delete( resource_group_name=resource_group.name, server_name="str", elastic_pool_name="str", - parameters={ - "availabilityZone": "str", - "highAvailabilityReplicaCount": 0, - "licenseType": "str", - "maintenanceConfigurationId": "str", - "maxSizeBytes": 0, - "minCapacity": 0.0, - "perDatabaseSettings": {"maxCapacity": 0.0, "minCapacity": 0.0}, - "preferredEnclaveType": "str", - "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, - "tags": {"str": "str"}, - "zoneRedundant": bool, - }, - api_version="2022-08-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_elastic_pools_list_by_server(self, resource_group): + response = self.client.elastic_pools.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_elastic_pools_begin_failover(self, resource_group): @@ -157,7 +141,6 @@ async def test_elastic_pools_begin_failover(self, resource_group): resource_group_name=resource_group.name, server_name="str", elastic_pool_name="str", - api_version="2022-08-01-preview", ) ).result() # call '.result()' to poll until service return final result diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_encryption_protectors_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_encryption_protectors_operations.py index f046fcb9aabe..c9f5c620081f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_encryption_protectors_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_encryption_protectors_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,18 +18,6 @@ class TestSqlManagementEncryptionProtectorsOperations(AzureMgmtRecordedTestCase) def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_encryption_protectors_list_by_server(self, resource_group): - response = self.client.encryption_protectors.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2020-11-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_encryption_protectors_get(self, resource_group): @@ -37,7 +25,6 @@ def test_encryption_protectors_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", encryption_protector_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -51,24 +38,45 @@ def test_encryption_protectors_begin_create_or_update(self, resource_group): server_name="str", encryption_protector_name="str", parameters={ - "autoRotationEnabled": bool, "id": "str", "kind": "str", "location": "str", "name": "str", - "serverKeyName": "str", - "serverKeyType": "str", - "subregion": "str", - "thumbprint": "str", + "properties": { + "serverKeyType": "str", + "autoRotationEnabled": bool, + "keyVersion": "str", + "serverKeyName": "str", + "subregion": "str", + "thumbprint": "str", + "uri": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "uri": "str", }, - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_encryption_protectors_list_by_server(self, resource_group): + response = self.client.encryption_protectors.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_encryption_protectors_begin_revalidate(self, resource_group): @@ -76,7 +84,6 @@ def test_encryption_protectors_begin_revalidate(self, resource_group): resource_group_name=resource_group.name, server_name="str", encryption_protector_name="str", - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_encryption_protectors_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_encryption_protectors_operations_async.py index 84ea0fb47e39..5531567bc355 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_encryption_protectors_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_encryption_protectors_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,18 +19,6 @@ class TestSqlManagementEncryptionProtectorsOperationsAsync(AzureMgmtRecordedTest def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_encryption_protectors_list_by_server(self, resource_group): - response = self.client.encryption_protectors.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2020-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_encryption_protectors_get(self, resource_group): @@ -38,7 +26,6 @@ async def test_encryption_protectors_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", encryption_protector_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -53,25 +40,46 @@ async def test_encryption_protectors_begin_create_or_update(self, resource_group server_name="str", encryption_protector_name="str", parameters={ - "autoRotationEnabled": bool, "id": "str", "kind": "str", "location": "str", "name": "str", - "serverKeyName": "str", - "serverKeyType": "str", - "subregion": "str", - "thumbprint": "str", + "properties": { + "serverKeyType": "str", + "autoRotationEnabled": bool, + "keyVersion": "str", + "serverKeyName": "str", + "subregion": "str", + "thumbprint": "str", + "uri": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "uri": "str", }, - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_encryption_protectors_list_by_server(self, resource_group): + response = self.client.encryption_protectors.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_encryption_protectors_begin_revalidate(self, resource_group): @@ -80,7 +88,6 @@ async def test_encryption_protectors_begin_revalidate(self, resource_group): resource_group_name=resource_group.name, server_name="str", encryption_protector_name="str", - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_endpoint_certificates_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_endpoint_certificates_operations.py index 2a6f5f84f722..7eb0f27feeac 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_endpoint_certificates_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_endpoint_certificates_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,25 +20,23 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_endpoint_certificates_list_by_instance(self, resource_group): - response = self.client.endpoint_certificates.list_by_instance( + def test_endpoint_certificates_get(self, resource_group): + response = self.client.endpoint_certificates.get( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2021-11-01-preview", + endpoint_type="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_endpoint_certificates_get(self, resource_group): - response = self.client.endpoint_certificates.get( + def test_endpoint_certificates_list_by_instance(self, resource_group): + response = self.client.endpoint_certificates.list_by_instance( resource_group_name=resource_group.name, managed_instance_name="str", - endpoint_type="str", - api_version="2021-11-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_endpoint_certificates_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_endpoint_certificates_operations_async.py index 1a261d1575d7..dbe57b658c4b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_endpoint_certificates_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_endpoint_certificates_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,25 +21,23 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_endpoint_certificates_list_by_instance(self, resource_group): - response = self.client.endpoint_certificates.list_by_instance( + async def test_endpoint_certificates_get(self, resource_group): + response = await self.client.endpoint_certificates.get( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2021-11-01-preview", + endpoint_type="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_endpoint_certificates_get(self, resource_group): - response = await self.client.endpoint_certificates.get( + async def test_endpoint_certificates_list_by_instance(self, resource_group): + response = self.client.endpoint_certificates.list_by_instance( resource_group_name=resource_group.name, managed_instance_name="str", - endpoint_type="str", - api_version="2021-11-01-preview", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_extended_database_blob_auditing_policies_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_extended_database_blob_auditing_policies_operations.py index bc31039d0575..66c6063f21f2 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_extended_database_blob_auditing_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_extended_database_blob_auditing_policies_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,19 +18,6 @@ class TestSqlManagementExtendedDatabaseBlobAuditingPoliciesOperations(AzureMgmtR def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_extended_database_blob_auditing_policies_list_by_database(self, resource_group): - response = self.client.extended_database_blob_auditing_policies.list_by_database( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - api_version="2021-11-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_extended_database_blob_auditing_policies_get(self, resource_group): @@ -39,7 +26,6 @@ def test_extended_database_blob_auditing_policies_get(self, resource_group): server_name="str", database_name="str", blob_auditing_policy_name="default", - api_version="2021-11-01-preview", ) # please add some check logic here by yourself @@ -53,24 +39,45 @@ def test_extended_database_blob_auditing_policies_create_or_update(self, resourc server_name="str", database_name="str", parameters={ - "auditActionsAndGroups": ["str"], "id": "str", - "isAzureMonitorTargetEnabled": bool, - "isManagedIdentityInUse": bool, - "isStorageSecondaryKeyInUse": bool, "name": "str", - "predicateExpression": "str", - "queueDelayMs": 0, - "retentionDays": 0, - "state": "str", - "storageAccountAccessKey": "str", - "storageAccountSubscriptionId": "str", - "storageEndpoint": "str", + "properties": { + "state": "str", + "auditActionsAndGroups": ["str"], + "isAzureMonitorTargetEnabled": bool, + "isManagedIdentityInUse": bool, + "isStorageSecondaryKeyInUse": bool, + "predicateExpression": "str", + "queueDelayMs": 0, + "retentionDays": 0, + "storageAccountAccessKey": "str", + "storageAccountSubscriptionId": "str", + "storageEndpoint": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, blob_auditing_policy_name="default", - api_version="2021-11-01-preview", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_extended_database_blob_auditing_policies_list_by_database(self, resource_group): + response = self.client.extended_database_blob_auditing_policies.list_by_database( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_extended_database_blob_auditing_policies_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_extended_database_blob_auditing_policies_operations_async.py index 3d924937a6de..2d475bbe8843 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_extended_database_blob_auditing_policies_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_extended_database_blob_auditing_policies_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,19 +19,6 @@ class TestSqlManagementExtendedDatabaseBlobAuditingPoliciesOperationsAsync(Azure def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_extended_database_blob_auditing_policies_list_by_database(self, resource_group): - response = self.client.extended_database_blob_auditing_policies.list_by_database( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - api_version="2021-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_extended_database_blob_auditing_policies_get(self, resource_group): @@ -40,7 +27,6 @@ async def test_extended_database_blob_auditing_policies_get(self, resource_group server_name="str", database_name="str", blob_auditing_policy_name="default", - api_version="2021-11-01-preview", ) # please add some check logic here by yourself @@ -54,24 +40,45 @@ async def test_extended_database_blob_auditing_policies_create_or_update(self, r server_name="str", database_name="str", parameters={ - "auditActionsAndGroups": ["str"], "id": "str", - "isAzureMonitorTargetEnabled": bool, - "isManagedIdentityInUse": bool, - "isStorageSecondaryKeyInUse": bool, "name": "str", - "predicateExpression": "str", - "queueDelayMs": 0, - "retentionDays": 0, - "state": "str", - "storageAccountAccessKey": "str", - "storageAccountSubscriptionId": "str", - "storageEndpoint": "str", + "properties": { + "state": "str", + "auditActionsAndGroups": ["str"], + "isAzureMonitorTargetEnabled": bool, + "isManagedIdentityInUse": bool, + "isStorageSecondaryKeyInUse": bool, + "predicateExpression": "str", + "queueDelayMs": 0, + "retentionDays": 0, + "storageAccountAccessKey": "str", + "storageAccountSubscriptionId": "str", + "storageEndpoint": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, blob_auditing_policy_name="default", - api_version="2021-11-01-preview", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_extended_database_blob_auditing_policies_list_by_database(self, resource_group): + response = self.client.extended_database_blob_auditing_policies.list_by_database( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_extended_server_blob_auditing_policies_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_extended_server_blob_auditing_policies_operations.py index 58ac5c7cdb21..a1b99978b240 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_extended_server_blob_auditing_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_extended_server_blob_auditing_policies_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,18 +18,6 @@ class TestSqlManagementExtendedServerBlobAuditingPoliciesOperations(AzureMgmtRec def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_extended_server_blob_auditing_policies_list_by_server(self, resource_group): - response = self.client.extended_server_blob_auditing_policies.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2021-11-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_extended_server_blob_auditing_policies_get(self, resource_group): @@ -37,7 +25,6 @@ def test_extended_server_blob_auditing_policies_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", blob_auditing_policy_name="default", - api_version="2021-11-01-preview", ) # please add some check logic here by yourself @@ -50,25 +37,45 @@ def test_extended_server_blob_auditing_policies_begin_create_or_update(self, res resource_group_name=resource_group.name, server_name="str", parameters={ - "auditActionsAndGroups": ["str"], "id": "str", - "isAzureMonitorTargetEnabled": bool, - "isDevopsAuditEnabled": bool, - "isManagedIdentityInUse": bool, - "isStorageSecondaryKeyInUse": bool, "name": "str", - "predicateExpression": "str", - "queueDelayMs": 0, - "retentionDays": 0, - "state": "str", - "storageAccountAccessKey": "str", - "storageAccountSubscriptionId": "str", - "storageEndpoint": "str", + "properties": { + "state": "str", + "auditActionsAndGroups": ["str"], + "isAzureMonitorTargetEnabled": bool, + "isDevopsAuditEnabled": bool, + "isManagedIdentityInUse": bool, + "isStorageSecondaryKeyInUse": bool, + "predicateExpression": "str", + "queueDelayMs": 0, + "retentionDays": 0, + "storageAccountAccessKey": "str", + "storageAccountSubscriptionId": "str", + "storageEndpoint": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, blob_auditing_policy_name="default", - api_version="2021-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_extended_server_blob_auditing_policies_list_by_server(self, resource_group): + response = self.client.extended_server_blob_auditing_policies.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_extended_server_blob_auditing_policies_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_extended_server_blob_auditing_policies_operations_async.py index ea516883ea68..6f7e3c547529 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_extended_server_blob_auditing_policies_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_extended_server_blob_auditing_policies_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,18 +19,6 @@ class TestSqlManagementExtendedServerBlobAuditingPoliciesOperationsAsync(AzureMg def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_extended_server_blob_auditing_policies_list_by_server(self, resource_group): - response = self.client.extended_server_blob_auditing_policies.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2021-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_extended_server_blob_auditing_policies_get(self, resource_group): @@ -38,7 +26,6 @@ async def test_extended_server_blob_auditing_policies_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", blob_auditing_policy_name="default", - api_version="2021-11-01-preview", ) # please add some check logic here by yourself @@ -52,26 +39,46 @@ async def test_extended_server_blob_auditing_policies_begin_create_or_update(sel resource_group_name=resource_group.name, server_name="str", parameters={ - "auditActionsAndGroups": ["str"], "id": "str", - "isAzureMonitorTargetEnabled": bool, - "isDevopsAuditEnabled": bool, - "isManagedIdentityInUse": bool, - "isStorageSecondaryKeyInUse": bool, "name": "str", - "predicateExpression": "str", - "queueDelayMs": 0, - "retentionDays": 0, - "state": "str", - "storageAccountAccessKey": "str", - "storageAccountSubscriptionId": "str", - "storageEndpoint": "str", + "properties": { + "state": "str", + "auditActionsAndGroups": ["str"], + "isAzureMonitorTargetEnabled": bool, + "isDevopsAuditEnabled": bool, + "isManagedIdentityInUse": bool, + "isStorageSecondaryKeyInUse": bool, + "predicateExpression": "str", + "queueDelayMs": 0, + "retentionDays": 0, + "storageAccountAccessKey": "str", + "storageAccountSubscriptionId": "str", + "storageEndpoint": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, blob_auditing_policy_name="default", - api_version="2021-11-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_extended_server_blob_auditing_policies_list_by_server(self, resource_group): + response = self.client.extended_server_blob_auditing_policies.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_failover_groups_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_failover_groups_operations.py index 3c119e0a5967..1f6b97de0646 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_failover_groups_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_failover_groups_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,18 +18,6 @@ class TestSqlManagementFailoverGroupsOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_failover_groups_list_by_server(self, resource_group): - response = self.client.failover_groups.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2023-05-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_failover_groups_get(self, resource_group): @@ -37,7 +25,6 @@ def test_failover_groups_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", failover_group_name="str", - api_version="2023-05-01-preview", ) # please add some check logic here by yourself @@ -51,20 +38,29 @@ def test_failover_groups_begin_create_or_update(self, resource_group): server_name="str", failover_group_name="str", parameters={ - "databases": ["str"], "id": "str", "location": "str", "name": "str", - "partnerServers": [{"id": "str", "location": "str", "replicationRole": "str"}], - "readOnlyEndpoint": {"failoverPolicy": "str", "targetServer": "str"}, - "readWriteEndpoint": {"failoverPolicy": "str", "failoverWithDataLossGracePeriodMinutes": 0}, - "replicationRole": "str", - "replicationState": "str", - "secondaryType": "str", + "properties": { + "partnerServers": [{"id": "str", "location": "str", "replicationRole": "str"}], + "readWriteEndpoint": {"failoverPolicy": "str", "failoverWithDataLossGracePeriodMinutes": 0}, + "databases": ["str"], + "readOnlyEndpoint": {"failoverPolicy": "str", "targetServer": "str"}, + "replicationRole": "str", + "replicationState": "str", + "secondaryType": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", }, - api_version="2023-05-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -72,12 +68,21 @@ def test_failover_groups_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_failover_groups_begin_delete(self, resource_group): - response = self.client.failover_groups.begin_delete( + def test_failover_groups_begin_update(self, resource_group): + response = self.client.failover_groups.begin_update( resource_group_name=resource_group.name, server_name="str", failover_group_name="str", - api_version="2023-05-01-preview", + parameters={ + "properties": { + "databases": ["str"], + "partnerServers": [{"id": "str", "location": "str", "replicationRole": "str"}], + "readOnlyEndpoint": {"failoverPolicy": "str", "targetServer": "str"}, + "readWriteEndpoint": {"failoverPolicy": "str", "failoverWithDataLossGracePeriodMinutes": 0}, + "secondaryType": "str", + }, + "tags": {"str": "str"}, + }, ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -85,25 +90,27 @@ def test_failover_groups_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_failover_groups_begin_update(self, resource_group): - response = self.client.failover_groups.begin_update( + def test_failover_groups_begin_delete(self, resource_group): + response = self.client.failover_groups.begin_delete( resource_group_name=resource_group.name, server_name="str", failover_group_name="str", - parameters={ - "databases": ["str"], - "partnerServers": [{"id": "str", "location": "str", "replicationRole": "str"}], - "readOnlyEndpoint": {"failoverPolicy": "str", "targetServer": "str"}, - "readWriteEndpoint": {"failoverPolicy": "str", "failoverWithDataLossGracePeriodMinutes": 0}, - "secondaryType": "str", - "tags": {"str": "str"}, - }, - api_version="2023-05-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_failover_groups_list_by_server(self, resource_group): + response = self.client.failover_groups.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_failover_groups_begin_failover(self, resource_group): @@ -111,7 +118,6 @@ def test_failover_groups_begin_failover(self, resource_group): resource_group_name=resource_group.name, server_name="str", failover_group_name="str", - api_version="2023-05-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -124,7 +130,6 @@ def test_failover_groups_begin_force_failover_allow_data_loss(self, resource_gro resource_group_name=resource_group.name, server_name="str", failover_group_name="str", - api_version="2023-05-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -137,7 +142,6 @@ def test_failover_groups_begin_try_planned_before_forced_failover(self, resource resource_group_name=resource_group.name, server_name="str", failover_group_name="str", - api_version="2023-05-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_failover_groups_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_failover_groups_operations_async.py index a020ba4596c0..876785d4fd8d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_failover_groups_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_failover_groups_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,18 +19,6 @@ class TestSqlManagementFailoverGroupsOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_failover_groups_list_by_server(self, resource_group): - response = self.client.failover_groups.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2023-05-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_failover_groups_get(self, resource_group): @@ -38,7 +26,6 @@ async def test_failover_groups_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", failover_group_name="str", - api_version="2023-05-01-preview", ) # please add some check logic here by yourself @@ -53,20 +40,29 @@ async def test_failover_groups_begin_create_or_update(self, resource_group): server_name="str", failover_group_name="str", parameters={ - "databases": ["str"], "id": "str", "location": "str", "name": "str", - "partnerServers": [{"id": "str", "location": "str", "replicationRole": "str"}], - "readOnlyEndpoint": {"failoverPolicy": "str", "targetServer": "str"}, - "readWriteEndpoint": {"failoverPolicy": "str", "failoverWithDataLossGracePeriodMinutes": 0}, - "replicationRole": "str", - "replicationState": "str", - "secondaryType": "str", + "properties": { + "partnerServers": [{"id": "str", "location": "str", "replicationRole": "str"}], + "readWriteEndpoint": {"failoverPolicy": "str", "failoverWithDataLossGracePeriodMinutes": 0}, + "databases": ["str"], + "readOnlyEndpoint": {"failoverPolicy": "str", "targetServer": "str"}, + "replicationRole": "str", + "replicationState": "str", + "secondaryType": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", }, - api_version="2023-05-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -75,13 +71,22 @@ async def test_failover_groups_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_failover_groups_begin_delete(self, resource_group): + async def test_failover_groups_begin_update(self, resource_group): response = await ( - await self.client.failover_groups.begin_delete( + await self.client.failover_groups.begin_update( resource_group_name=resource_group.name, server_name="str", failover_group_name="str", - api_version="2023-05-01-preview", + parameters={ + "properties": { + "databases": ["str"], + "partnerServers": [{"id": "str", "location": "str", "replicationRole": "str"}], + "readOnlyEndpoint": {"failoverPolicy": "str", "targetServer": "str"}, + "readWriteEndpoint": {"failoverPolicy": "str", "failoverWithDataLossGracePeriodMinutes": 0}, + "secondaryType": "str", + }, + "tags": {"str": "str"}, + }, ) ).result() # call '.result()' to poll until service return final result @@ -90,27 +95,29 @@ async def test_failover_groups_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_failover_groups_begin_update(self, resource_group): + async def test_failover_groups_begin_delete(self, resource_group): response = await ( - await self.client.failover_groups.begin_update( + await self.client.failover_groups.begin_delete( resource_group_name=resource_group.name, server_name="str", failover_group_name="str", - parameters={ - "databases": ["str"], - "partnerServers": [{"id": "str", "location": "str", "replicationRole": "str"}], - "readOnlyEndpoint": {"failoverPolicy": "str", "targetServer": "str"}, - "readWriteEndpoint": {"failoverPolicy": "str", "failoverWithDataLossGracePeriodMinutes": 0}, - "secondaryType": "str", - "tags": {"str": "str"}, - }, - api_version="2023-05-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_failover_groups_list_by_server(self, resource_group): + response = self.client.failover_groups.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_failover_groups_begin_failover(self, resource_group): @@ -119,7 +126,6 @@ async def test_failover_groups_begin_failover(self, resource_group): resource_group_name=resource_group.name, server_name="str", failover_group_name="str", - api_version="2023-05-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -134,7 +140,6 @@ async def test_failover_groups_begin_force_failover_allow_data_loss(self, resour resource_group_name=resource_group.name, server_name="str", failover_group_name="str", - api_version="2023-05-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -149,7 +154,6 @@ async def test_failover_groups_begin_try_planned_before_forced_failover(self, re resource_group_name=resource_group.name, server_name="str", failover_group_name="str", - api_version="2023-05-01-preview", ) ).result() # call '.result()' to poll until service return final result diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_firewall_rules_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_firewall_rules_operations.py index 4ecc6b5bd186..2c68734055b4 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_firewall_rules_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_firewall_rules_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_firewall_rules_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", firewall_rule_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -38,8 +37,12 @@ def test_firewall_rules_create_or_update(self, resource_group): resource_group_name=resource_group.name, server_name="str", firewall_rule_name="str", - parameters={"endIpAddress": "str", "id": "str", "name": "str", "startIpAddress": "str", "type": "str"}, - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"endIpAddress": "str", "startIpAddress": "str"}, + "type": "str", + }, ) # please add some check logic here by yourself @@ -52,7 +55,6 @@ def test_firewall_rules_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", firewall_rule_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -64,7 +66,6 @@ def test_firewall_rules_list_by_server(self, resource_group): response = self.client.firewall_rules.list_by_server( resource_group_name=resource_group.name, server_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself @@ -77,9 +78,15 @@ def test_firewall_rules_replace(self, resource_group): resource_group_name=resource_group.name, server_name="str", parameters={ - "values": [{"endIpAddress": "str", "id": "str", "name": "str", "startIpAddress": "str", "type": "str"}] + "values": [ + { + "id": "str", + "name": "str", + "properties": {"endIpAddress": "str", "startIpAddress": "str"}, + "type": "str", + } + ] }, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_firewall_rules_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_firewall_rules_operations_async.py index 58464eb5a173..c25df0dae3c4 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_firewall_rules_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_firewall_rules_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_firewall_rules_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", firewall_rule_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -39,8 +38,12 @@ async def test_firewall_rules_create_or_update(self, resource_group): resource_group_name=resource_group.name, server_name="str", firewall_rule_name="str", - parameters={"endIpAddress": "str", "id": "str", "name": "str", "startIpAddress": "str", "type": "str"}, - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"endIpAddress": "str", "startIpAddress": "str"}, + "type": "str", + }, ) # please add some check logic here by yourself @@ -53,7 +56,6 @@ async def test_firewall_rules_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", firewall_rule_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -65,7 +67,6 @@ async def test_firewall_rules_list_by_server(self, resource_group): response = self.client.firewall_rules.list_by_server( resource_group_name=resource_group.name, server_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself @@ -78,9 +79,15 @@ async def test_firewall_rules_replace(self, resource_group): resource_group_name=resource_group.name, server_name="str", parameters={ - "values": [{"endIpAddress": "str", "id": "str", "name": "str", "startIpAddress": "str", "type": "str"}] + "values": [ + { + "id": "str", + "name": "str", + "properties": {"endIpAddress": "str", "startIpAddress": "str"}, + "type": "str", + } + ] }, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_geo_backup_policies_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_geo_backup_policies_operations.py index c9fa70c8ab8a..12fb94a64c95 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_geo_backup_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_geo_backup_policies_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,22 +20,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_geo_backup_policies_create_or_update(self, resource_group): - response = self.client.geo_backup_policies.create_or_update( + def test_geo_backup_policies_get(self, resource_group): + response = self.client.geo_backup_policies.get( resource_group_name=resource_group.name, server_name="str", database_name="str", geo_backup_policy_name="str", - parameters={ - "state": "str", - "id": "str", - "kind": "str", - "location": "str", - "name": "str", - "storageType": "str", - "type": "str", - }, - api_version="2014-04-01", ) # please add some check logic here by yourself @@ -43,13 +33,28 @@ def test_geo_backup_policies_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_geo_backup_policies_get(self, resource_group): - response = self.client.geo_backup_policies.get( + def test_geo_backup_policies_create_or_update(self, resource_group): + response = self.client.geo_backup_policies.create_or_update( resource_group_name=resource_group.name, server_name="str", database_name="str", geo_backup_policy_name="str", - api_version="2014-04-01", + parameters={ + "id": "str", + "kind": "str", + "location": "str", + "name": "str", + "properties": {"state": "str", "storageType": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -57,12 +62,11 @@ def test_geo_backup_policies_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_geo_backup_policies_list_by_database(self, resource_group): - response = self.client.geo_backup_policies.list_by_database( + def test_geo_backup_policies_list(self, resource_group): + response = self.client.geo_backup_policies.list( resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2014-04-01", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_geo_backup_policies_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_geo_backup_policies_operations_async.py index 2e5689b7de1d..1248fdaea3c0 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_geo_backup_policies_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_geo_backup_policies_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,22 +21,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_geo_backup_policies_create_or_update(self, resource_group): - response = await self.client.geo_backup_policies.create_or_update( + async def test_geo_backup_policies_get(self, resource_group): + response = await self.client.geo_backup_policies.get( resource_group_name=resource_group.name, server_name="str", database_name="str", geo_backup_policy_name="str", - parameters={ - "state": "str", - "id": "str", - "kind": "str", - "location": "str", - "name": "str", - "storageType": "str", - "type": "str", - }, - api_version="2014-04-01", ) # please add some check logic here by yourself @@ -44,13 +34,28 @@ async def test_geo_backup_policies_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_geo_backup_policies_get(self, resource_group): - response = await self.client.geo_backup_policies.get( + async def test_geo_backup_policies_create_or_update(self, resource_group): + response = await self.client.geo_backup_policies.create_or_update( resource_group_name=resource_group.name, server_name="str", database_name="str", geo_backup_policy_name="str", - api_version="2014-04-01", + parameters={ + "id": "str", + "kind": "str", + "location": "str", + "name": "str", + "properties": {"state": "str", "storageType": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -58,12 +63,11 @@ async def test_geo_backup_policies_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_geo_backup_policies_list_by_database(self, resource_group): - response = self.client.geo_backup_policies.list_by_database( + async def test_geo_backup_policies_list(self, resource_group): + response = self.client.geo_backup_policies.list( resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2014-04-01", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_instance_failover_groups_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_instance_failover_groups_operations.py index 7f340e10b873..f62b922a69e7 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_instance_failover_groups_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_instance_failover_groups_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,18 +18,6 @@ class TestSqlManagementInstanceFailoverGroupsOperations(AzureMgmtRecordedTestCas def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_instance_failover_groups_list_by_location(self, resource_group): - response = self.client.instance_failover_groups.list_by_location( - resource_group_name=resource_group.name, - location_name="str", - api_version="2022-05-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_instance_failover_groups_get(self, resource_group): @@ -37,7 +25,6 @@ def test_instance_failover_groups_get(self, resource_group): resource_group_name=resource_group.name, location_name="str", failover_group_name="str", - api_version="2022-05-01-preview", ) # please add some check logic here by yourself @@ -52,17 +39,26 @@ def test_instance_failover_groups_begin_create_or_update(self, resource_group): failover_group_name="str", parameters={ "id": "str", - "managedInstancePairs": [{"partnerManagedInstanceId": "str", "primaryManagedInstanceId": "str"}], "name": "str", - "partnerRegions": [{"location": "str", "replicationRole": "str"}], - "readOnlyEndpoint": {"failoverPolicy": "str"}, - "readWriteEndpoint": {"failoverPolicy": "str", "failoverWithDataLossGracePeriodMinutes": 0}, - "replicationRole": "str", - "replicationState": "str", - "secondaryType": "str", + "properties": { + "managedInstancePairs": [{"partnerManagedInstanceId": "str", "primaryManagedInstanceId": "str"}], + "partnerRegions": [{"location": "str", "replicationRole": "str"}], + "readWriteEndpoint": {"failoverPolicy": "str", "failoverWithDataLossGracePeriodMinutes": 0}, + "readOnlyEndpoint": {"failoverPolicy": "str"}, + "replicationRole": "str", + "replicationState": "str", + "secondaryType": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2022-05-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -75,12 +71,22 @@ def test_instance_failover_groups_begin_delete(self, resource_group): resource_group_name=resource_group.name, location_name="str", failover_group_name="str", - api_version="2022-05-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_instance_failover_groups_list_by_location(self, resource_group): + response = self.client.instance_failover_groups.list_by_location( + resource_group_name=resource_group.name, + location_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_instance_failover_groups_begin_failover(self, resource_group): @@ -88,7 +94,6 @@ def test_instance_failover_groups_begin_failover(self, resource_group): resource_group_name=resource_group.name, location_name="str", failover_group_name="str", - api_version="2022-05-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -101,7 +106,6 @@ def test_instance_failover_groups_begin_force_failover_allow_data_loss(self, res resource_group_name=resource_group.name, location_name="str", failover_group_name="str", - api_version="2022-05-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_instance_failover_groups_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_instance_failover_groups_operations_async.py index c90ff8d192f7..f92cccbb01d1 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_instance_failover_groups_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_instance_failover_groups_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,18 +19,6 @@ class TestSqlManagementInstanceFailoverGroupsOperationsAsync(AzureMgmtRecordedTe def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_instance_failover_groups_list_by_location(self, resource_group): - response = self.client.instance_failover_groups.list_by_location( - resource_group_name=resource_group.name, - location_name="str", - api_version="2022-05-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_instance_failover_groups_get(self, resource_group): @@ -38,7 +26,6 @@ async def test_instance_failover_groups_get(self, resource_group): resource_group_name=resource_group.name, location_name="str", failover_group_name="str", - api_version="2022-05-01-preview", ) # please add some check logic here by yourself @@ -54,17 +41,28 @@ async def test_instance_failover_groups_begin_create_or_update(self, resource_gr failover_group_name="str", parameters={ "id": "str", - "managedInstancePairs": [{"partnerManagedInstanceId": "str", "primaryManagedInstanceId": "str"}], "name": "str", - "partnerRegions": [{"location": "str", "replicationRole": "str"}], - "readOnlyEndpoint": {"failoverPolicy": "str"}, - "readWriteEndpoint": {"failoverPolicy": "str", "failoverWithDataLossGracePeriodMinutes": 0}, - "replicationRole": "str", - "replicationState": "str", - "secondaryType": "str", + "properties": { + "managedInstancePairs": [ + {"partnerManagedInstanceId": "str", "primaryManagedInstanceId": "str"} + ], + "partnerRegions": [{"location": "str", "replicationRole": "str"}], + "readWriteEndpoint": {"failoverPolicy": "str", "failoverWithDataLossGracePeriodMinutes": 0}, + "readOnlyEndpoint": {"failoverPolicy": "str"}, + "replicationRole": "str", + "replicationState": "str", + "secondaryType": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2022-05-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -79,13 +77,23 @@ async def test_instance_failover_groups_begin_delete(self, resource_group): resource_group_name=resource_group.name, location_name="str", failover_group_name="str", - api_version="2022-05-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_instance_failover_groups_list_by_location(self, resource_group): + response = self.client.instance_failover_groups.list_by_location( + resource_group_name=resource_group.name, + location_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_instance_failover_groups_begin_failover(self, resource_group): @@ -94,7 +102,6 @@ async def test_instance_failover_groups_begin_failover(self, resource_group): resource_group_name=resource_group.name, location_name="str", failover_group_name="str", - api_version="2022-05-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -109,7 +116,6 @@ async def test_instance_failover_groups_begin_force_failover_allow_data_loss(sel resource_group_name=resource_group.name, location_name="str", failover_group_name="str", - api_version="2022-05-01-preview", ) ).result() # call '.result()' to poll until service return final result diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_instance_pool_operations_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_instance_pool_operations_operations.py index 617aa17ea5d0..3732d06c3e93 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_instance_pool_operations_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_instance_pool_operations_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,25 +20,23 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_instance_pool_operations_list_by_instance_pool(self, resource_group): - response = self.client.instance_pool_operations.list_by_instance_pool( + def test_instance_pool_operations_get(self, resource_group): + response = self.client.instance_pool_operations.get( resource_group_name=resource_group.name, instance_pool_name="str", - api_version="2024-11-01-preview", + operation_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_instance_pool_operations_get(self, resource_group): - response = self.client.instance_pool_operations.get( + def test_instance_pool_operations_list_by_instance_pool(self, resource_group): + response = self.client.instance_pool_operations.list_by_instance_pool( resource_group_name=resource_group.name, instance_pool_name="str", - operation_id="str", - api_version="2024-11-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_instance_pool_operations_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_instance_pool_operations_operations_async.py index 5aa0ad5a2e08..7e673ab6152f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_instance_pool_operations_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_instance_pool_operations_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,25 +21,23 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_instance_pool_operations_list_by_instance_pool(self, resource_group): - response = self.client.instance_pool_operations.list_by_instance_pool( + async def test_instance_pool_operations_get(self, resource_group): + response = await self.client.instance_pool_operations.get( resource_group_name=resource_group.name, instance_pool_name="str", - api_version="2024-11-01-preview", + operation_id="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_instance_pool_operations_get(self, resource_group): - response = await self.client.instance_pool_operations.get( + async def test_instance_pool_operations_list_by_instance_pool(self, resource_group): + response = self.client.instance_pool_operations.list_by_instance_pool( resource_group_name=resource_group.name, instance_pool_name="str", - operation_id="str", - api_version="2024-11-01-preview", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_instance_pools_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_instance_pools_operations.py index e035b9e2b2fd..1ed0cd7eccb4 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_instance_pools_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_instance_pools_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,34 +18,12 @@ class TestSqlManagementInstancePoolsOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_instance_pools_list(self, resource_group): - response = self.client.instance_pools.list( - api_version="2023-05-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_instance_pools_list_by_resource_group(self, resource_group): - response = self.client.instance_pools.list_by_resource_group( - resource_group_name=resource_group.name, - api_version="2023-05-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_instance_pools_get(self, resource_group): response = self.client.instance_pools.get( resource_group_name=resource_group.name, instance_pool_name="str", - api_version="2023-05-01-preview", ) # please add some check logic here by yourself @@ -59,18 +37,27 @@ def test_instance_pools_begin_create_or_update(self, resource_group): instance_pool_name="str", parameters={ "location": "str", - "dnsZone": "str", "id": "str", - "licenseType": "str", - "maintenanceConfigurationId": "str", "name": "str", + "properties": { + "licenseType": "str", + "subnetId": "str", + "vCores": 0, + "dnsZone": "str", + "maintenanceConfigurationId": "str", + }, "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, - "subnetId": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", - "vCores": 0, }, - api_version="2023-05-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -78,11 +65,21 @@ def test_instance_pools_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_instance_pools_begin_delete(self, resource_group): - response = self.client.instance_pools.begin_delete( + def test_instance_pools_begin_update(self, resource_group): + response = self.client.instance_pools.begin_update( resource_group_name=resource_group.name, instance_pool_name="str", - api_version="2023-05-01-preview", + parameters={ + "properties": { + "licenseType": "str", + "subnetId": "str", + "vCores": 0, + "dnsZone": "str", + "maintenanceConfigurationId": "str", + }, + "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, + "tags": {"str": "str"}, + }, ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -90,21 +87,29 @@ def test_instance_pools_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_instance_pools_begin_update(self, resource_group): - response = self.client.instance_pools.begin_update( + def test_instance_pools_begin_delete(self, resource_group): + response = self.client.instance_pools.begin_delete( resource_group_name=resource_group.name, instance_pool_name="str", - parameters={ - "dnsZone": "str", - "licenseType": "str", - "maintenanceConfigurationId": "str", - "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, - "subnetId": "str", - "tags": {"str": "str"}, - "vCores": 0, - }, - api_version="2023-05-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_instance_pools_list_by_resource_group(self, resource_group): + response = self.client.instance_pools.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_instance_pools_list(self, resource_group): + response = self.client.instance_pools.list() + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_instance_pools_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_instance_pools_operations_async.py index e9a85fb61e1f..aac7f53b640a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_instance_pools_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_instance_pools_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,34 +19,12 @@ class TestSqlManagementInstancePoolsOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_instance_pools_list(self, resource_group): - response = self.client.instance_pools.list( - api_version="2023-05-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_instance_pools_list_by_resource_group(self, resource_group): - response = self.client.instance_pools.list_by_resource_group( - resource_group_name=resource_group.name, - api_version="2023-05-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_instance_pools_get(self, resource_group): response = await self.client.instance_pools.get( resource_group_name=resource_group.name, instance_pool_name="str", - api_version="2023-05-01-preview", ) # please add some check logic here by yourself @@ -61,18 +39,27 @@ async def test_instance_pools_begin_create_or_update(self, resource_group): instance_pool_name="str", parameters={ "location": "str", - "dnsZone": "str", "id": "str", - "licenseType": "str", - "maintenanceConfigurationId": "str", "name": "str", + "properties": { + "licenseType": "str", + "subnetId": "str", + "vCores": 0, + "dnsZone": "str", + "maintenanceConfigurationId": "str", + }, "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, - "subnetId": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", - "vCores": 0, }, - api_version="2023-05-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -81,12 +68,22 @@ async def test_instance_pools_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_instance_pools_begin_delete(self, resource_group): + async def test_instance_pools_begin_update(self, resource_group): response = await ( - await self.client.instance_pools.begin_delete( + await self.client.instance_pools.begin_update( resource_group_name=resource_group.name, instance_pool_name="str", - api_version="2023-05-01-preview", + parameters={ + "properties": { + "licenseType": "str", + "subnetId": "str", + "vCores": 0, + "dnsZone": "str", + "maintenanceConfigurationId": "str", + }, + "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, + "tags": {"str": "str"}, + }, ) ).result() # call '.result()' to poll until service return final result @@ -95,23 +92,31 @@ async def test_instance_pools_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_instance_pools_begin_update(self, resource_group): + async def test_instance_pools_begin_delete(self, resource_group): response = await ( - await self.client.instance_pools.begin_update( + await self.client.instance_pools.begin_delete( resource_group_name=resource_group.name, instance_pool_name="str", - parameters={ - "dnsZone": "str", - "licenseType": "str", - "maintenanceConfigurationId": "str", - "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, - "subnetId": "str", - "tags": {"str": "str"}, - "vCores": 0, - }, - api_version="2023-05-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_instance_pools_list_by_resource_group(self, resource_group): + response = self.client.instance_pools.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_instance_pools_list(self, resource_group): + response = self.client.instance_pools.list() + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_ipv6_firewall_rules_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_ipv6_firewall_rules_operations.py index 881ca95d82fa..e37fcb03a70a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_ipv6_firewall_rules_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_ipv6_firewall_rules_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,18 +18,6 @@ class TestSqlManagementIPv6FirewallRulesOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_ipv6_firewall_rules_list_by_server(self, resource_group): - response = self.client.ipv6_firewall_rules.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2022-11-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_ipv6_firewall_rules_get(self, resource_group): @@ -37,7 +25,6 @@ def test_ipv6_firewall_rules_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", firewall_rule_name="str", - api_version="2022-11-01-preview", ) # please add some check logic here by yourself @@ -50,8 +37,12 @@ def test_ipv6_firewall_rules_create_or_update(self, resource_group): resource_group_name=resource_group.name, server_name="str", firewall_rule_name="str", - parameters={"endIPv6Address": "str", "id": "str", "name": "str", "startIPv6Address": "str", "type": "str"}, - api_version="2022-11-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"endIPv6Address": "str", "startIPv6Address": "str"}, + "type": "str", + }, ) # please add some check logic here by yourself @@ -64,8 +55,18 @@ def test_ipv6_firewall_rules_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", firewall_rule_name="str", - api_version="2022-11-01-preview", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_ipv6_firewall_rules_list_by_server(self, resource_group): + response = self.client.ipv6_firewall_rules.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_ipv6_firewall_rules_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_ipv6_firewall_rules_operations_async.py index 7a104d6f4dd8..98f6b47a76e7 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_ipv6_firewall_rules_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_ipv6_firewall_rules_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,18 +19,6 @@ class TestSqlManagementIPv6FirewallRulesOperationsAsync(AzureMgmtRecordedTestCas def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_ipv6_firewall_rules_list_by_server(self, resource_group): - response = self.client.ipv6_firewall_rules.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2022-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_ipv6_firewall_rules_get(self, resource_group): @@ -38,7 +26,6 @@ async def test_ipv6_firewall_rules_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", firewall_rule_name="str", - api_version="2022-11-01-preview", ) # please add some check logic here by yourself @@ -51,8 +38,12 @@ async def test_ipv6_firewall_rules_create_or_update(self, resource_group): resource_group_name=resource_group.name, server_name="str", firewall_rule_name="str", - parameters={"endIPv6Address": "str", "id": "str", "name": "str", "startIPv6Address": "str", "type": "str"}, - api_version="2022-11-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"endIPv6Address": "str", "startIPv6Address": "str"}, + "type": "str", + }, ) # please add some check logic here by yourself @@ -65,8 +56,18 @@ async def test_ipv6_firewall_rules_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", firewall_rule_name="str", - api_version="2022-11-01-preview", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_ipv6_firewall_rules_list_by_server(self, resource_group): + response = self.client.ipv6_firewall_rules.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_agents_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_agents_operations.py index 0f5ec1b75b3a..829608a997f7 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_agents_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_agents_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,18 +18,6 @@ class TestSqlManagementJobAgentsOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_job_agents_list_by_server(self, resource_group): - response = self.client.job_agents.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2020-11-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_job_agents_get(self, resource_group): @@ -37,7 +25,6 @@ def test_job_agents_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", job_agent_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -52,15 +39,26 @@ def test_job_agents_begin_create_or_update(self, resource_group): job_agent_name="str", parameters={ "location": "str", - "databaseId": "str", "id": "str", + "identity": { + "type": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, "name": "str", + "properties": {"databaseId": "str", "state": "str"}, "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, - "state": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", }, - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -68,12 +66,20 @@ def test_job_agents_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_job_agents_begin_delete(self, resource_group): - response = self.client.job_agents.begin_delete( + def test_job_agents_begin_update(self, resource_group): + response = self.client.job_agents.begin_update( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", - api_version="2020-11-01-preview", + parameters={ + "identity": { + "type": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, + "tags": {"str": "str"}, + }, ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -81,14 +87,23 @@ def test_job_agents_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_job_agents_begin_update(self, resource_group): - response = self.client.job_agents.begin_update( + def test_job_agents_begin_delete(self, resource_group): + response = self.client.job_agents.begin_delete( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", - parameters={"tags": {"str": "str"}}, - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_job_agents_list_by_server(self, resource_group): + response = self.client.job_agents.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_agents_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_agents_operations_async.py index bc54ee605a51..d54f3b5b3b96 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_agents_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_agents_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,18 +19,6 @@ class TestSqlManagementJobAgentsOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_job_agents_list_by_server(self, resource_group): - response = self.client.job_agents.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2020-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_job_agents_get(self, resource_group): @@ -38,7 +26,6 @@ async def test_job_agents_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", job_agent_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -54,15 +41,26 @@ async def test_job_agents_begin_create_or_update(self, resource_group): job_agent_name="str", parameters={ "location": "str", - "databaseId": "str", "id": "str", + "identity": { + "type": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, "name": "str", + "properties": {"databaseId": "str", "state": "str"}, "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, - "state": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", }, - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -71,13 +69,21 @@ async def test_job_agents_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_job_agents_begin_delete(self, resource_group): + async def test_job_agents_begin_update(self, resource_group): response = await ( - await self.client.job_agents.begin_delete( + await self.client.job_agents.begin_update( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", - api_version="2020-11-01-preview", + parameters={ + "identity": { + "type": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, + "tags": {"str": "str"}, + }, ) ).result() # call '.result()' to poll until service return final result @@ -86,16 +92,25 @@ async def test_job_agents_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_job_agents_begin_update(self, resource_group): + async def test_job_agents_begin_delete(self, resource_group): response = await ( - await self.client.job_agents.begin_update( + await self.client.job_agents.begin_delete( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", - parameters={"tags": {"str": "str"}}, - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_job_agents_list_by_server(self, resource_group): + response = self.client.job_agents.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_credentials_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_credentials_operations.py index f33e1eaa8dc0..60597a804cb0 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_credentials_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_credentials_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,26 +20,39 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_job_credentials_list_by_agent(self, resource_group): - response = self.client.job_credentials.list_by_agent( + def test_job_credentials_get(self, resource_group): + response = self.client.job_credentials.get( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", - api_version="2020-11-01-preview", + credential_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_job_credentials_get(self, resource_group): - response = self.client.job_credentials.get( + def test_job_credentials_create_or_update(self, resource_group): + response = self.client.job_credentials.create_or_update( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", credential_name="str", - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"password": "str", "username": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -47,14 +60,12 @@ def test_job_credentials_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_job_credentials_create_or_update(self, resource_group): - response = self.client.job_credentials.create_or_update( + def test_job_credentials_delete(self, resource_group): + response = self.client.job_credentials.delete( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", credential_name="str", - parameters={"id": "str", "name": "str", "password": "str", "type": "str", "username": "str"}, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -62,14 +73,12 @@ def test_job_credentials_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_job_credentials_delete(self, resource_group): - response = self.client.job_credentials.delete( + def test_job_credentials_list_by_agent(self, resource_group): + response = self.client.job_credentials.list_by_agent( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", - credential_name="str", - api_version="2020-11-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_credentials_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_credentials_operations_async.py index 5dbd338ebcbd..85d2d6c047d0 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_credentials_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_credentials_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,26 +21,39 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_job_credentials_list_by_agent(self, resource_group): - response = self.client.job_credentials.list_by_agent( + async def test_job_credentials_get(self, resource_group): + response = await self.client.job_credentials.get( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", - api_version="2020-11-01-preview", + credential_name="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_job_credentials_get(self, resource_group): - response = await self.client.job_credentials.get( + async def test_job_credentials_create_or_update(self, resource_group): + response = await self.client.job_credentials.create_or_update( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", credential_name="str", - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"password": "str", "username": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -48,14 +61,12 @@ async def test_job_credentials_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_job_credentials_create_or_update(self, resource_group): - response = await self.client.job_credentials.create_or_update( + async def test_job_credentials_delete(self, resource_group): + response = await self.client.job_credentials.delete( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", credential_name="str", - parameters={"id": "str", "name": "str", "password": "str", "type": "str", "username": "str"}, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -63,14 +74,12 @@ async def test_job_credentials_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_job_credentials_delete(self, resource_group): - response = await self.client.job_credentials.delete( + async def test_job_credentials_list_by_agent(self, resource_group): + response = self.client.job_credentials.list_by_agent( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", - credential_name="str", - api_version="2020-11-01-preview", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_executions_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_executions_operations.py index 79cd8188c71c..ad3c09a715cf 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_executions_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_executions_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,42 +20,42 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_job_executions_list_by_agent(self, resource_group): - response = self.client.job_executions.list_by_agent( + def test_job_executions_get(self, resource_group): + response = self.client.job_executions.get( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", - api_version="2020-11-01-preview", + job_name="str", + job_execution_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_job_executions_cancel(self, resource_group): - response = self.client.job_executions.cancel( + def test_job_executions_begin_create_or_update(self, resource_group): + response = self.client.job_executions.begin_create_or_update( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", job_name="str", job_execution_id="str", - api_version="2020-11-01-preview", - ) + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_job_executions_begin_create(self, resource_group): - response = self.client.job_executions.begin_create( + def test_job_executions_cancel(self, resource_group): + response = self.client.job_executions.cancel( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", job_name="str", - api_version="2020-11-01-preview", - ).result() # call '.result()' to poll until service return final result + job_execution_id="str", + ) # please add some check logic here by yourself # ... @@ -68,7 +68,6 @@ def test_job_executions_list_by_job(self, resource_group): server_name="str", job_agent_name="str", job_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself @@ -76,29 +75,24 @@ def test_job_executions_list_by_job(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_job_executions_get(self, resource_group): - response = self.client.job_executions.get( + def test_job_executions_list_by_agent(self, resource_group): + response = self.client.job_executions.list_by_agent( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", - job_name="str", - job_execution_id="str", - api_version="2020-11-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_job_executions_begin_create_or_update(self, resource_group): - response = self.client.job_executions.begin_create_or_update( + def test_job_executions_begin_create(self, resource_group): + response = self.client.job_executions.begin_create( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", job_name="str", - job_execution_id="str", - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_executions_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_executions_operations_async.py index 0bd8a0627996..63eb8cb85899 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_executions_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_executions_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,27 +21,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_job_executions_list_by_agent(self, resource_group): - response = self.client.job_executions.list_by_agent( - resource_group_name=resource_group.name, - server_name="str", - job_agent_name="str", - api_version="2020-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_job_executions_cancel(self, resource_group): - response = await self.client.job_executions.cancel( + async def test_job_executions_get(self, resource_group): + response = await self.client.job_executions.get( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", job_name="str", job_execution_id="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -49,20 +35,34 @@ async def test_job_executions_cancel(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_job_executions_begin_create(self, resource_group): + async def test_job_executions_begin_create_or_update(self, resource_group): response = await ( - await self.client.job_executions.begin_create( + await self.client.job_executions.begin_create_or_update( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", job_name="str", - api_version="2020-11-01-preview", + job_execution_id="str", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_job_executions_cancel(self, resource_group): + response = await self.client.job_executions.cancel( + resource_group_name=resource_group.name, + server_name="str", + job_agent_name="str", + job_name="str", + job_execution_id="str", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_job_executions_list_by_job(self, resource_group): @@ -71,7 +71,6 @@ async def test_job_executions_list_by_job(self, resource_group): server_name="str", job_agent_name="str", job_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself @@ -79,30 +78,25 @@ async def test_job_executions_list_by_job(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_job_executions_get(self, resource_group): - response = await self.client.job_executions.get( + async def test_job_executions_list_by_agent(self, resource_group): + response = self.client.job_executions.list_by_agent( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", - job_name="str", - job_execution_id="str", - api_version="2020-11-01-preview", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_job_executions_begin_create_or_update(self, resource_group): + async def test_job_executions_begin_create(self, resource_group): response = await ( - await self.client.job_executions.begin_create_or_update( + await self.client.job_executions.begin_create( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", job_name="str", - job_execution_id="str", - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_private_endpoints_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_private_endpoints_operations.py index 4e1b6272194d..35064f0fcb5e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_private_endpoints_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_private_endpoints_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,19 +18,6 @@ class TestSqlManagementJobPrivateEndpointsOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_job_private_endpoints_list_by_agent(self, resource_group): - response = self.client.job_private_endpoints.list_by_agent( - resource_group_name=resource_group.name, - server_name="str", - job_agent_name="str", - api_version="2023-05-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_job_private_endpoints_get(self, resource_group): @@ -39,7 +26,6 @@ def test_job_private_endpoints_get(self, resource_group): server_name="str", job_agent_name="str", private_endpoint_name="str", - api_version="2023-05-01-preview", ) # please add some check logic here by yourself @@ -56,11 +42,17 @@ def test_job_private_endpoints_begin_create_or_update(self, resource_group): parameters={ "id": "str", "name": "str", - "privateEndpointId": "str", - "targetServerAzureResourceId": "str", + "properties": {"targetServerAzureResourceId": "str", "privateEndpointId": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2023-05-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -74,8 +66,19 @@ def test_job_private_endpoints_begin_delete(self, resource_group): server_name="str", job_agent_name="str", private_endpoint_name="str", - api_version="2023-05-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_job_private_endpoints_list_by_agent(self, resource_group): + response = self.client.job_private_endpoints.list_by_agent( + resource_group_name=resource_group.name, + server_name="str", + job_agent_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_private_endpoints_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_private_endpoints_operations_async.py index 5e8857c4192d..67fd0d46edbd 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_private_endpoints_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_private_endpoints_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,19 +19,6 @@ class TestSqlManagementJobPrivateEndpointsOperationsAsync(AzureMgmtRecordedTestC def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_job_private_endpoints_list_by_agent(self, resource_group): - response = self.client.job_private_endpoints.list_by_agent( - resource_group_name=resource_group.name, - server_name="str", - job_agent_name="str", - api_version="2023-05-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_job_private_endpoints_get(self, resource_group): @@ -40,7 +27,6 @@ async def test_job_private_endpoints_get(self, resource_group): server_name="str", job_agent_name="str", private_endpoint_name="str", - api_version="2023-05-01-preview", ) # please add some check logic here by yourself @@ -58,11 +44,17 @@ async def test_job_private_endpoints_begin_create_or_update(self, resource_group parameters={ "id": "str", "name": "str", - "privateEndpointId": "str", - "targetServerAzureResourceId": "str", + "properties": {"targetServerAzureResourceId": "str", "privateEndpointId": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2023-05-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -78,9 +70,20 @@ async def test_job_private_endpoints_begin_delete(self, resource_group): server_name="str", job_agent_name="str", private_endpoint_name="str", - api_version="2023-05-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_job_private_endpoints_list_by_agent(self, resource_group): + response = self.client.job_private_endpoints.list_by_agent( + resource_group_name=resource_group.name, + server_name="str", + job_agent_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_step_executions_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_step_executions_operations.py index d4c668a71735..a627dac62cf5 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_step_executions_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_step_executions_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,31 +20,29 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_job_step_executions_list_by_job_execution(self, resource_group): - response = self.client.job_step_executions.list_by_job_execution( + def test_job_step_executions_get(self, resource_group): + response = self.client.job_step_executions.get( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", job_name="str", job_execution_id="str", - api_version="2020-11-01-preview", + step_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_job_step_executions_get(self, resource_group): - response = self.client.job_step_executions.get( + def test_job_step_executions_list_by_job_execution(self, resource_group): + response = self.client.job_step_executions.list_by_job_execution( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", job_name="str", job_execution_id="str", - step_name="str", - api_version="2020-11-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_step_executions_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_step_executions_operations_async.py index 5eae04256e5f..2ac91dce6787 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_step_executions_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_step_executions_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,31 +21,29 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_job_step_executions_list_by_job_execution(self, resource_group): - response = self.client.job_step_executions.list_by_job_execution( + async def test_job_step_executions_get(self, resource_group): + response = await self.client.job_step_executions.get( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", job_name="str", job_execution_id="str", - api_version="2020-11-01-preview", + step_name="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_job_step_executions_get(self, resource_group): - response = await self.client.job_step_executions.get( + async def test_job_step_executions_list_by_job_execution(self, resource_group): + response = self.client.job_step_executions.list_by_job_execution( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", job_name="str", job_execution_id="str", - step_name="str", - api_version="2020-11-01-preview", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_steps_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_steps_operations.py index b11054b20b36..46415b37063c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_steps_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_steps_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,30 +20,63 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_job_steps_list_by_version(self, resource_group): - response = self.client.job_steps.list_by_version( + def test_job_steps_get(self, resource_group): + response = self.client.job_steps.get( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", job_name="str", - job_version=0, - api_version="2020-11-01-preview", + step_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_job_steps_get_by_version(self, resource_group): - response = self.client.job_steps.get_by_version( + def test_job_steps_create_or_update(self, resource_group): + response = self.client.job_steps.create_or_update( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", job_name="str", - job_version=0, step_name="str", - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": { + "action": {"value": "str", "source": "str", "type": "str"}, + "targetGroup": "str", + "credential": "str", + "executionOptions": { + "initialRetryIntervalSeconds": 0, + "maximumRetryIntervalSeconds": 0, + "retryAttempts": 0, + "retryIntervalBackoffMultiplier": 0.0, + "timeoutSeconds": 0, + }, + "output": { + "databaseName": "str", + "serverName": "str", + "tableName": "str", + "credential": "str", + "resourceGroupName": "str", + "schemaName": "str", + "subscriptionId": "str", + "type": "str", + }, + "stepId": 0, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -51,69 +84,41 @@ def test_job_steps_get_by_version(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_job_steps_list_by_job(self, resource_group): - response = self.client.job_steps.list_by_job( + def test_job_steps_delete(self, resource_group): + response = self.client.job_steps.delete( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", job_name="str", - api_version="2020-11-01-preview", + step_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_job_steps_get(self, resource_group): - response = self.client.job_steps.get( + def test_job_steps_list_by_job(self, resource_group): + response = self.client.job_steps.list_by_job( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", job_name="str", - step_name="str", - api_version="2020-11-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_job_steps_create_or_update(self, resource_group): - response = self.client.job_steps.create_or_update( + def test_job_steps_get_by_version(self, resource_group): + response = self.client.job_steps.get_by_version( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", job_name="str", + job_version=0, step_name="str", - parameters={ - "action": {"value": "str", "source": "Inline", "type": "TSql"}, - "credential": "str", - "executionOptions": { - "initialRetryIntervalSeconds": 1, - "maximumRetryIntervalSeconds": 120, - "retryAttempts": 10, - "retryIntervalBackoffMultiplier": 2, - "timeoutSeconds": 43200, - }, - "id": "str", - "name": "str", - "output": { - "credential": "str", - "databaseName": "str", - "serverName": "str", - "tableName": "str", - "resourceGroupName": "str", - "schemaName": "dbo", - "subscriptionId": "str", - "type": "SqlDatabase", - }, - "stepId": 0, - "targetGroup": "str", - "type": "str", - }, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -121,15 +126,14 @@ def test_job_steps_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_job_steps_delete(self, resource_group): - response = self.client.job_steps.delete( + def test_job_steps_list_by_version(self, resource_group): + response = self.client.job_steps.list_by_version( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", job_name="str", - step_name="str", - api_version="2020-11-01-preview", + job_version=0, ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_steps_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_steps_operations_async.py index 982064a9c7b9..d1cd96dcaf4f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_steps_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_steps_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,30 +21,63 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_job_steps_list_by_version(self, resource_group): - response = self.client.job_steps.list_by_version( + async def test_job_steps_get(self, resource_group): + response = await self.client.job_steps.get( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", job_name="str", - job_version=0, - api_version="2020-11-01-preview", + step_name="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_job_steps_get_by_version(self, resource_group): - response = await self.client.job_steps.get_by_version( + async def test_job_steps_create_or_update(self, resource_group): + response = await self.client.job_steps.create_or_update( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", job_name="str", - job_version=0, step_name="str", - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": { + "action": {"value": "str", "source": "str", "type": "str"}, + "targetGroup": "str", + "credential": "str", + "executionOptions": { + "initialRetryIntervalSeconds": 0, + "maximumRetryIntervalSeconds": 0, + "retryAttempts": 0, + "retryIntervalBackoffMultiplier": 0.0, + "timeoutSeconds": 0, + }, + "output": { + "databaseName": "str", + "serverName": "str", + "tableName": "str", + "credential": "str", + "resourceGroupName": "str", + "schemaName": "str", + "subscriptionId": "str", + "type": "str", + }, + "stepId": 0, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -52,69 +85,41 @@ async def test_job_steps_get_by_version(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_job_steps_list_by_job(self, resource_group): - response = self.client.job_steps.list_by_job( + async def test_job_steps_delete(self, resource_group): + response = await self.client.job_steps.delete( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", job_name="str", - api_version="2020-11-01-preview", + step_name="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_job_steps_get(self, resource_group): - response = await self.client.job_steps.get( + async def test_job_steps_list_by_job(self, resource_group): + response = self.client.job_steps.list_by_job( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", job_name="str", - step_name="str", - api_version="2020-11-01-preview", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_job_steps_create_or_update(self, resource_group): - response = await self.client.job_steps.create_or_update( + async def test_job_steps_get_by_version(self, resource_group): + response = await self.client.job_steps.get_by_version( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", job_name="str", + job_version=0, step_name="str", - parameters={ - "action": {"value": "str", "source": "Inline", "type": "TSql"}, - "credential": "str", - "executionOptions": { - "initialRetryIntervalSeconds": 1, - "maximumRetryIntervalSeconds": 120, - "retryAttempts": 10, - "retryIntervalBackoffMultiplier": 2, - "timeoutSeconds": 43200, - }, - "id": "str", - "name": "str", - "output": { - "credential": "str", - "databaseName": "str", - "serverName": "str", - "tableName": "str", - "resourceGroupName": "str", - "schemaName": "dbo", - "subscriptionId": "str", - "type": "SqlDatabase", - }, - "stepId": 0, - "targetGroup": "str", - "type": "str", - }, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -122,15 +127,14 @@ async def test_job_steps_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_job_steps_delete(self, resource_group): - response = await self.client.job_steps.delete( + async def test_job_steps_list_by_version(self, resource_group): + response = self.client.job_steps.list_by_version( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", job_name="str", - step_name="str", - api_version="2020-11-01-preview", + job_version=0, ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_target_executions_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_target_executions_operations.py index 9d24d373f218..ec5613a3d15e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_target_executions_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_target_executions_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,16 +20,17 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_job_target_executions_list_by_job_execution(self, resource_group): - response = self.client.job_target_executions.list_by_job_execution( + def test_job_target_executions_get(self, resource_group): + response = self.client.job_target_executions.get( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", job_name="str", job_execution_id="str", - api_version="2020-11-01-preview", + step_name="str", + target_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @@ -43,7 +44,6 @@ def test_job_target_executions_list_by_step(self, resource_group): job_name="str", job_execution_id="str", step_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself @@ -51,17 +51,14 @@ def test_job_target_executions_list_by_step(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_job_target_executions_get(self, resource_group): - response = self.client.job_target_executions.get( + def test_job_target_executions_list_by_job_execution(self, resource_group): + response = self.client.job_target_executions.list_by_job_execution( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", job_name="str", job_execution_id="str", - step_name="str", - target_id="str", - api_version="2020-11-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_target_executions_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_target_executions_operations_async.py index 4c79a338dfa3..b6dd2f4c4e1f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_target_executions_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_target_executions_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,16 +21,17 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_job_target_executions_list_by_job_execution(self, resource_group): - response = self.client.job_target_executions.list_by_job_execution( + async def test_job_target_executions_get(self, resource_group): + response = await self.client.job_target_executions.get( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", job_name="str", job_execution_id="str", - api_version="2020-11-01-preview", + step_name="str", + target_id="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @@ -44,7 +45,6 @@ async def test_job_target_executions_list_by_step(self, resource_group): job_name="str", job_execution_id="str", step_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself @@ -52,17 +52,14 @@ async def test_job_target_executions_list_by_step(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_job_target_executions_get(self, resource_group): - response = await self.client.job_target_executions.get( + async def test_job_target_executions_list_by_job_execution(self, resource_group): + response = self.client.job_target_executions.list_by_job_execution( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", job_name="str", job_execution_id="str", - step_name="str", - target_id="str", - api_version="2020-11-01-preview", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_target_groups_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_target_groups_operations.py index 0e5c67afbe68..ae18ae9f2e3a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_target_groups_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_target_groups_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,19 +18,6 @@ class TestSqlManagementJobTargetGroupsOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_job_target_groups_list_by_agent(self, resource_group): - response = self.client.job_target_groups.list_by_agent( - resource_group_name=resource_group.name, - server_name="str", - job_agent_name="str", - api_version="2020-11-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_job_target_groups_get(self, resource_group): @@ -39,7 +26,6 @@ def test_job_target_groups_get(self, resource_group): server_name="str", job_agent_name="str", target_group_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -55,21 +41,30 @@ def test_job_target_groups_create_or_update(self, resource_group): target_group_name="str", parameters={ "id": "str", - "members": [ - { - "type": "str", - "databaseName": "str", - "elasticPoolName": "str", - "membershipType": "Include", - "refreshCredential": "str", - "serverName": "str", - "shardMapName": "str", - } - ], "name": "str", + "properties": { + "members": [ + { + "type": "str", + "databaseName": "str", + "elasticPoolName": "str", + "membershipType": "str", + "refreshCredential": "str", + "serverName": "str", + "shardMapName": "str", + } + ] + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -83,8 +78,19 @@ def test_job_target_groups_delete(self, resource_group): server_name="str", job_agent_name="str", target_group_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_job_target_groups_list_by_agent(self, resource_group): + response = self.client.job_target_groups.list_by_agent( + resource_group_name=resource_group.name, + server_name="str", + job_agent_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_target_groups_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_target_groups_operations_async.py index fdee974b4793..c5701e98db96 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_target_groups_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_target_groups_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,19 +19,6 @@ class TestSqlManagementJobTargetGroupsOperationsAsync(AzureMgmtRecordedTestCase) def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_job_target_groups_list_by_agent(self, resource_group): - response = self.client.job_target_groups.list_by_agent( - resource_group_name=resource_group.name, - server_name="str", - job_agent_name="str", - api_version="2020-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_job_target_groups_get(self, resource_group): @@ -40,7 +27,6 @@ async def test_job_target_groups_get(self, resource_group): server_name="str", job_agent_name="str", target_group_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -56,21 +42,30 @@ async def test_job_target_groups_create_or_update(self, resource_group): target_group_name="str", parameters={ "id": "str", - "members": [ - { - "type": "str", - "databaseName": "str", - "elasticPoolName": "str", - "membershipType": "Include", - "refreshCredential": "str", - "serverName": "str", - "shardMapName": "str", - } - ], "name": "str", + "properties": { + "members": [ + { + "type": "str", + "databaseName": "str", + "elasticPoolName": "str", + "membershipType": "str", + "refreshCredential": "str", + "serverName": "str", + "shardMapName": "str", + } + ] + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -84,8 +79,19 @@ async def test_job_target_groups_delete(self, resource_group): server_name="str", job_agent_name="str", target_group_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_job_target_groups_list_by_agent(self, resource_group): + response = self.client.job_target_groups.list_by_agent( + resource_group_name=resource_group.name, + server_name="str", + job_agent_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_versions_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_versions_operations.py index 71becdd28580..573bb6df58e9 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_versions_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_versions_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,29 +20,27 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_job_versions_list_by_job(self, resource_group): - response = self.client.job_versions.list_by_job( + def test_job_versions_get(self, resource_group): + response = self.client.job_versions.get( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", job_name="str", - api_version="2020-11-01-preview", + job_version=0, ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_job_versions_get(self, resource_group): - response = self.client.job_versions.get( + def test_job_versions_list_by_job(self, resource_group): + response = self.client.job_versions.list_by_job( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", job_name="str", - job_version=0, - api_version="2020-11-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_versions_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_versions_operations_async.py index 7f969279da7a..c52615788c57 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_versions_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_job_versions_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,29 +21,27 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_job_versions_list_by_job(self, resource_group): - response = self.client.job_versions.list_by_job( + async def test_job_versions_get(self, resource_group): + response = await self.client.job_versions.get( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", job_name="str", - api_version="2020-11-01-preview", + job_version=0, ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_job_versions_get(self, resource_group): - response = await self.client.job_versions.get( + async def test_job_versions_list_by_job(self, resource_group): + response = self.client.job_versions.list_by_job( resource_group_name=resource_group.name, server_name="str", job_agent_name="str", job_name="str", - job_version=0, - api_version="2020-11-01-preview", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_jobs_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_jobs_operations.py index feb9ff0d48b7..a87ea23a50c3 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_jobs_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_jobs_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,19 +18,6 @@ class TestSqlManagementJobsOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_jobs_list_by_agent(self, resource_group): - response = self.client.jobs.list_by_agent( - resource_group_name=resource_group.name, - server_name="str", - job_agent_name="str", - api_version="2020-11-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_jobs_get(self, resource_group): @@ -39,7 +26,6 @@ def test_jobs_get(self, resource_group): server_name="str", job_agent_name="str", job_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -54,20 +40,29 @@ def test_jobs_create_or_update(self, resource_group): job_agent_name="str", job_name="str", parameters={ - "description": "", "id": "str", "name": "str", - "schedule": { - "enabled": bool, - "endTime": "9999-12-31T11:59:59+00:00", - "interval": "str", - "startTime": "0001-01-01T00:00:00+00:00", - "type": "Once", + "properties": { + "description": "str", + "schedule": { + "enabled": bool, + "endTime": "2020-02-20 00:00:00", + "interval": "str", + "startTime": "2020-02-20 00:00:00", + "type": "str", + }, + "version": 0, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", }, "type": "str", - "version": 0, }, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -81,8 +76,19 @@ def test_jobs_delete(self, resource_group): server_name="str", job_agent_name="str", job_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_jobs_list_by_agent(self, resource_group): + response = self.client.jobs.list_by_agent( + resource_group_name=resource_group.name, + server_name="str", + job_agent_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_jobs_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_jobs_operations_async.py index dcc56a7a60a1..2edee24abee7 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_jobs_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_jobs_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,19 +19,6 @@ class TestSqlManagementJobsOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_jobs_list_by_agent(self, resource_group): - response = self.client.jobs.list_by_agent( - resource_group_name=resource_group.name, - server_name="str", - job_agent_name="str", - api_version="2020-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_jobs_get(self, resource_group): @@ -40,7 +27,6 @@ async def test_jobs_get(self, resource_group): server_name="str", job_agent_name="str", job_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -55,20 +41,29 @@ async def test_jobs_create_or_update(self, resource_group): job_agent_name="str", job_name="str", parameters={ - "description": "", "id": "str", "name": "str", - "schedule": { - "enabled": bool, - "endTime": "9999-12-31T11:59:59+00:00", - "interval": "str", - "startTime": "0001-01-01T00:00:00+00:00", - "type": "Once", + "properties": { + "description": "str", + "schedule": { + "enabled": bool, + "endTime": "2020-02-20 00:00:00", + "interval": "str", + "startTime": "2020-02-20 00:00:00", + "type": "str", + }, + "version": 0, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", }, "type": "str", - "version": 0, }, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -82,8 +77,19 @@ async def test_jobs_delete(self, resource_group): server_name="str", job_agent_name="str", job_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_jobs_list_by_agent(self, resource_group): + response = self.client.jobs.list_by_agent( + resource_group_name=resource_group.name, + server_name="str", + job_agent_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_ledger_digest_uploads_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_ledger_digest_uploads_operations.py index fa433bae2b18..86e2e51f0157 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_ledger_digest_uploads_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_ledger_digest_uploads_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ def test_ledger_digest_uploads_get(self, resource_group): server_name="str", database_name="str", ledger_digest_uploads="str", - api_version="2021-02-01-preview", ) # please add some check logic here by yourself @@ -40,8 +39,20 @@ def test_ledger_digest_uploads_begin_create_or_update(self, resource_group): server_name="str", database_name="str", ledger_digest_uploads="str", - parameters={"digestStorageEndpoint": "str", "id": "str", "name": "str", "state": "str", "type": "str"}, - api_version="2021-02-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"digestStorageEndpoint": "str", "state": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -54,7 +65,6 @@ def test_ledger_digest_uploads_list_by_database(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2021-02-01-preview", ) result = [r for r in response] # please add some check logic here by yourself @@ -68,7 +78,6 @@ def test_ledger_digest_uploads_begin_disable(self, resource_group): server_name="str", database_name="str", ledger_digest_uploads="str", - api_version="2021-02-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_ledger_digest_uploads_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_ledger_digest_uploads_operations_async.py index 2e467e98f33a..1af875a01977 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_ledger_digest_uploads_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_ledger_digest_uploads_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -27,7 +27,6 @@ async def test_ledger_digest_uploads_get(self, resource_group): server_name="str", database_name="str", ledger_digest_uploads="str", - api_version="2021-02-01-preview", ) # please add some check logic here by yourself @@ -42,8 +41,20 @@ async def test_ledger_digest_uploads_begin_create_or_update(self, resource_group server_name="str", database_name="str", ledger_digest_uploads="str", - parameters={"digestStorageEndpoint": "str", "id": "str", "name": "str", "state": "str", "type": "str"}, - api_version="2021-02-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"digestStorageEndpoint": "str", "state": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) ).result() # call '.result()' to poll until service return final result @@ -57,7 +68,6 @@ async def test_ledger_digest_uploads_list_by_database(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2021-02-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself @@ -72,7 +82,6 @@ async def test_ledger_digest_uploads_begin_disable(self, resource_group): server_name="str", database_name="str", ledger_digest_uploads="str", - api_version="2021-02-01-preview", ) ).result() # call '.result()' to poll until service return final result diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_long_term_retention_backups_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_long_term_retention_backups_operations.py index 4716e5b4affb..0ff217547163 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_long_term_retention_backups_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_long_term_retention_backups_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,65 +20,39 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_long_term_retention_backups_list_by_location(self, resource_group): - response = self.client.long_term_retention_backups.list_by_location( - location_name="str", - api_version="2024-11-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_long_term_retention_backups_list_by_server(self, resource_group): - response = self.client.long_term_retention_backups.list_by_server( - location_name="str", - long_term_retention_server_name="str", - api_version="2024-11-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_long_term_retention_backups_list_by_database(self, resource_group): - response = self.client.long_term_retention_backups.list_by_database( + def test_long_term_retention_backups_get(self, resource_group): + response = self.client.long_term_retention_backups.get( location_name="str", long_term_retention_server_name="str", long_term_retention_database_name="str", - api_version="2024-11-01-preview", + backup_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_long_term_retention_backups_get(self, resource_group): - response = self.client.long_term_retention_backups.get( + def test_long_term_retention_backups_begin_delete(self, resource_group): + response = self.client.long_term_retention_backups.begin_delete( location_name="str", long_term_retention_server_name="str", long_term_retention_database_name="str", backup_name="str", - api_version="2024-11-01-preview", - ) + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_long_term_retention_backups_begin_delete(self, resource_group): - response = self.client.long_term_retention_backups.begin_delete( + def test_long_term_retention_backups_list_by_database(self, resource_group): + response = self.client.long_term_retention_backups.list_by_database( location_name="str", long_term_retention_server_name="str", long_term_retention_database_name="str", - backup_name="str", - api_version="2024-11-01-preview", - ).result() # call '.result()' to poll until service return final result - + ) + result = [r for r in response] # please add some check logic here by yourself # ... @@ -91,7 +65,6 @@ def test_long_term_retention_backups_begin_change_access_tier(self, resource_gro long_term_retention_database_name="str", backup_name="str", parameters={"backupStorageAccessTier": "str", "operationMode": "str"}, - api_version="2024-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -106,14 +79,15 @@ def test_long_term_retention_backups_begin_copy(self, resource_group): long_term_retention_database_name="str", backup_name="str", parameters={ - "targetBackupStorageRedundancy": "str", - "targetDatabaseName": "str", - "targetResourceGroup": "str", - "targetServerFullyQualifiedDomainName": "str", - "targetServerResourceId": "str", - "targetSubscriptionId": "str", + "properties": { + "targetBackupStorageRedundancy": "str", + "targetDatabaseName": "str", + "targetResourceGroup": "str", + "targetServerFullyQualifiedDomainName": "str", + "targetServerResourceId": "str", + "targetSubscriptionId": "str", + } }, - api_version="2024-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -127,7 +101,6 @@ def test_long_term_retention_backups_begin_lock_time_based_immutability(self, re long_term_retention_server_name="str", long_term_retention_database_name="str", backup_name="str", - api_version="2024-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -141,7 +114,6 @@ def test_long_term_retention_backups_begin_remove_legal_hold_immutability(self, long_term_retention_server_name="str", long_term_retention_database_name="str", backup_name="str", - api_version="2024-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -155,7 +127,6 @@ def test_long_term_retention_backups_begin_remove_time_based_immutability(self, long_term_retention_server_name="str", long_term_retention_database_name="str", backup_name="str", - api_version="2024-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -169,7 +140,6 @@ def test_long_term_retention_backups_begin_set_legal_hold_immutability(self, res long_term_retention_server_name="str", long_term_retention_database_name="str", backup_name="str", - api_version="2024-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -183,8 +153,7 @@ def test_long_term_retention_backups_begin_update(self, resource_group): long_term_retention_server_name="str", long_term_retention_database_name="str", backup_name="str", - parameters={"requestedBackupStorageRedundancy": "str"}, - api_version="2024-11-01-preview", + parameters={"properties": {"requestedBackupStorageRedundancy": "str"}}, ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -192,70 +161,42 @@ def test_long_term_retention_backups_begin_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_long_term_retention_backups_list_by_resource_group_location(self, resource_group): - response = self.client.long_term_retention_backups.list_by_resource_group_location( - resource_group_name=resource_group.name, - location_name="str", - api_version="2024-11-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_long_term_retention_backups_list_by_resource_group_server(self, resource_group): - response = self.client.long_term_retention_backups.list_by_resource_group_server( - resource_group_name=resource_group.name, - location_name="str", - long_term_retention_server_name="str", - api_version="2024-11-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_long_term_retention_backups_list_by_resource_group_database(self, resource_group): - response = self.client.long_term_retention_backups.list_by_resource_group_database( + def test_long_term_retention_backups_get_by_resource_group(self, resource_group): + response = self.client.long_term_retention_backups.get_by_resource_group( resource_group_name=resource_group.name, location_name="str", long_term_retention_server_name="str", long_term_retention_database_name="str", - api_version="2024-11-01-preview", + backup_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_long_term_retention_backups_get_by_resource_group(self, resource_group): - response = self.client.long_term_retention_backups.get_by_resource_group( + def test_long_term_retention_backups_begin_delete_by_resource_group(self, resource_group): + response = self.client.long_term_retention_backups.begin_delete_by_resource_group( resource_group_name=resource_group.name, location_name="str", long_term_retention_server_name="str", long_term_retention_database_name="str", backup_name="str", - api_version="2024-11-01-preview", - ) + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_long_term_retention_backups_begin_delete_by_resource_group(self, resource_group): - response = self.client.long_term_retention_backups.begin_delete_by_resource_group( + def test_long_term_retention_backups_list_by_resource_group_database(self, resource_group): + response = self.client.long_term_retention_backups.list_by_resource_group_database( resource_group_name=resource_group.name, location_name="str", long_term_retention_server_name="str", long_term_retention_database_name="str", - backup_name="str", - api_version="2024-11-01-preview", - ).result() # call '.result()' to poll until service return final result - + ) + result = [r for r in response] # please add some check logic here by yourself # ... @@ -269,7 +210,6 @@ def test_long_term_retention_backups_begin_change_access_tier_by_resource_group( long_term_retention_database_name="str", backup_name="str", parameters={"backupStorageAccessTier": "str", "operationMode": "str"}, - api_version="2024-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -285,14 +225,15 @@ def test_long_term_retention_backups_begin_copy_by_resource_group(self, resource long_term_retention_database_name="str", backup_name="str", parameters={ - "targetBackupStorageRedundancy": "str", - "targetDatabaseName": "str", - "targetResourceGroup": "str", - "targetServerFullyQualifiedDomainName": "str", - "targetServerResourceId": "str", - "targetSubscriptionId": "str", + "properties": { + "targetBackupStorageRedundancy": "str", + "targetDatabaseName": "str", + "targetResourceGroup": "str", + "targetServerFullyQualifiedDomainName": "str", + "targetServerResourceId": "str", + "targetSubscriptionId": "str", + } }, - api_version="2024-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -307,7 +248,6 @@ def test_long_term_retention_backups_begin_lock_time_based_immutability_by_resou long_term_retention_server_name="str", long_term_retention_database_name="str", backup_name="str", - api_version="2024-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -322,7 +262,6 @@ def test_long_term_retention_backups_begin_remove_legal_hold_immutability_by_res long_term_retention_server_name="str", long_term_retention_database_name="str", backup_name="str", - api_version="2024-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -337,7 +276,6 @@ def test_long_term_retention_backups_begin_remove_time_based_immutability_by_res long_term_retention_server_name="str", long_term_retention_database_name="str", backup_name="str", - api_version="2024-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -352,7 +290,6 @@ def test_long_term_retention_backups_begin_set_legal_hold_immutability_by_resour long_term_retention_server_name="str", long_term_retention_database_name="str", backup_name="str", - api_version="2024-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -367,9 +304,52 @@ def test_long_term_retention_backups_begin_update_by_resource_group(self, resour long_term_retention_server_name="str", long_term_retention_database_name="str", backup_name="str", - parameters={"requestedBackupStorageRedundancy": "str"}, - api_version="2024-11-01-preview", + parameters={"properties": {"requestedBackupStorageRedundancy": "str"}}, ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_long_term_retention_backups_list_by_location(self, resource_group): + response = self.client.long_term_retention_backups.list_by_location( + location_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_long_term_retention_backups_list_by_server(self, resource_group): + response = self.client.long_term_retention_backups.list_by_server( + location_name="str", + long_term_retention_server_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_long_term_retention_backups_list_by_resource_group_location(self, resource_group): + response = self.client.long_term_retention_backups.list_by_resource_group_location( + resource_group_name=resource_group.name, + location_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_long_term_retention_backups_list_by_resource_group_server(self, resource_group): + response = self.client.long_term_retention_backups.list_by_resource_group_server( + resource_group_name=resource_group.name, + location_name="str", + long_term_retention_server_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_long_term_retention_backups_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_long_term_retention_backups_operations_async.py index 2b1a6be21192..4117e84b2a35 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_long_term_retention_backups_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_long_term_retention_backups_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,42 +19,6 @@ class TestSqlManagementLongTermRetentionBackupsOperationsAsync(AzureMgmtRecorded def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_long_term_retention_backups_list_by_location(self, resource_group): - response = self.client.long_term_retention_backups.list_by_location( - location_name="str", - api_version="2024-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_long_term_retention_backups_list_by_server(self, resource_group): - response = self.client.long_term_retention_backups.list_by_server( - location_name="str", - long_term_retention_server_name="str", - api_version="2024-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_long_term_retention_backups_list_by_database(self, resource_group): - response = self.client.long_term_retention_backups.list_by_database( - location_name="str", - long_term_retention_server_name="str", - long_term_retention_database_name="str", - api_version="2024-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_long_term_retention_backups_get(self, resource_group): @@ -63,7 +27,6 @@ async def test_long_term_retention_backups_get(self, resource_group): long_term_retention_server_name="str", long_term_retention_database_name="str", backup_name="str", - api_version="2024-11-01-preview", ) # please add some check logic here by yourself @@ -78,13 +41,24 @@ async def test_long_term_retention_backups_begin_delete(self, resource_group): long_term_retention_server_name="str", long_term_retention_database_name="str", backup_name="str", - api_version="2024-11-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_long_term_retention_backups_list_by_database(self, resource_group): + response = self.client.long_term_retention_backups.list_by_database( + location_name="str", + long_term_retention_server_name="str", + long_term_retention_database_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_long_term_retention_backups_begin_change_access_tier(self, resource_group): @@ -95,7 +69,6 @@ async def test_long_term_retention_backups_begin_change_access_tier(self, resour long_term_retention_database_name="str", backup_name="str", parameters={"backupStorageAccessTier": "str", "operationMode": "str"}, - api_version="2024-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -112,14 +85,15 @@ async def test_long_term_retention_backups_begin_copy(self, resource_group): long_term_retention_database_name="str", backup_name="str", parameters={ - "targetBackupStorageRedundancy": "str", - "targetDatabaseName": "str", - "targetResourceGroup": "str", - "targetServerFullyQualifiedDomainName": "str", - "targetServerResourceId": "str", - "targetSubscriptionId": "str", + "properties": { + "targetBackupStorageRedundancy": "str", + "targetDatabaseName": "str", + "targetResourceGroup": "str", + "targetServerFullyQualifiedDomainName": "str", + "targetServerResourceId": "str", + "targetSubscriptionId": "str", + } }, - api_version="2024-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -135,7 +109,6 @@ async def test_long_term_retention_backups_begin_lock_time_based_immutability(se long_term_retention_server_name="str", long_term_retention_database_name="str", backup_name="str", - api_version="2024-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -151,7 +124,6 @@ async def test_long_term_retention_backups_begin_remove_legal_hold_immutability( long_term_retention_server_name="str", long_term_retention_database_name="str", backup_name="str", - api_version="2024-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -167,7 +139,6 @@ async def test_long_term_retention_backups_begin_remove_time_based_immutability( long_term_retention_server_name="str", long_term_retention_database_name="str", backup_name="str", - api_version="2024-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -183,7 +154,6 @@ async def test_long_term_retention_backups_begin_set_legal_hold_immutability(sel long_term_retention_server_name="str", long_term_retention_database_name="str", backup_name="str", - api_version="2024-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -199,53 +169,13 @@ async def test_long_term_retention_backups_begin_update(self, resource_group): long_term_retention_server_name="str", long_term_retention_database_name="str", backup_name="str", - parameters={"requestedBackupStorageRedundancy": "str"}, - api_version="2024-11-01-preview", + parameters={"properties": {"requestedBackupStorageRedundancy": "str"}}, ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_long_term_retention_backups_list_by_resource_group_location(self, resource_group): - response = self.client.long_term_retention_backups.list_by_resource_group_location( - resource_group_name=resource_group.name, - location_name="str", - api_version="2024-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_long_term_retention_backups_list_by_resource_group_server(self, resource_group): - response = self.client.long_term_retention_backups.list_by_resource_group_server( - resource_group_name=resource_group.name, - location_name="str", - long_term_retention_server_name="str", - api_version="2024-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_long_term_retention_backups_list_by_resource_group_database(self, resource_group): - response = self.client.long_term_retention_backups.list_by_resource_group_database( - resource_group_name=resource_group.name, - location_name="str", - long_term_retention_server_name="str", - long_term_retention_database_name="str", - api_version="2024-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_long_term_retention_backups_get_by_resource_group(self, resource_group): @@ -255,7 +185,6 @@ async def test_long_term_retention_backups_get_by_resource_group(self, resource_ long_term_retention_server_name="str", long_term_retention_database_name="str", backup_name="str", - api_version="2024-11-01-preview", ) # please add some check logic here by yourself @@ -271,13 +200,25 @@ async def test_long_term_retention_backups_begin_delete_by_resource_group(self, long_term_retention_server_name="str", long_term_retention_database_name="str", backup_name="str", - api_version="2024-11-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_long_term_retention_backups_list_by_resource_group_database(self, resource_group): + response = self.client.long_term_retention_backups.list_by_resource_group_database( + resource_group_name=resource_group.name, + location_name="str", + long_term_retention_server_name="str", + long_term_retention_database_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_long_term_retention_backups_begin_change_access_tier_by_resource_group(self, resource_group): @@ -289,7 +230,6 @@ async def test_long_term_retention_backups_begin_change_access_tier_by_resource_ long_term_retention_database_name="str", backup_name="str", parameters={"backupStorageAccessTier": "str", "operationMode": "str"}, - api_version="2024-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -307,14 +247,15 @@ async def test_long_term_retention_backups_begin_copy_by_resource_group(self, re long_term_retention_database_name="str", backup_name="str", parameters={ - "targetBackupStorageRedundancy": "str", - "targetDatabaseName": "str", - "targetResourceGroup": "str", - "targetServerFullyQualifiedDomainName": "str", - "targetServerResourceId": "str", - "targetSubscriptionId": "str", + "properties": { + "targetBackupStorageRedundancy": "str", + "targetDatabaseName": "str", + "targetResourceGroup": "str", + "targetServerFullyQualifiedDomainName": "str", + "targetServerResourceId": "str", + "targetSubscriptionId": "str", + } }, - api_version="2024-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -333,7 +274,6 @@ async def test_long_term_retention_backups_begin_lock_time_based_immutability_by long_term_retention_server_name="str", long_term_retention_database_name="str", backup_name="str", - api_version="2024-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -352,7 +292,6 @@ async def test_long_term_retention_backups_begin_remove_legal_hold_immutability_ long_term_retention_server_name="str", long_term_retention_database_name="str", backup_name="str", - api_version="2024-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -371,7 +310,6 @@ async def test_long_term_retention_backups_begin_remove_time_based_immutability_ long_term_retention_server_name="str", long_term_retention_database_name="str", backup_name="str", - api_version="2024-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -390,7 +328,6 @@ async def test_long_term_retention_backups_begin_set_legal_hold_immutability_by_ long_term_retention_server_name="str", long_term_retention_database_name="str", backup_name="str", - api_version="2024-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -407,10 +344,53 @@ async def test_long_term_retention_backups_begin_update_by_resource_group(self, long_term_retention_server_name="str", long_term_retention_database_name="str", backup_name="str", - parameters={"requestedBackupStorageRedundancy": "str"}, - api_version="2024-11-01-preview", + parameters={"properties": {"requestedBackupStorageRedundancy": "str"}}, ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_long_term_retention_backups_list_by_location(self, resource_group): + response = self.client.long_term_retention_backups.list_by_location( + location_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_long_term_retention_backups_list_by_server(self, resource_group): + response = self.client.long_term_retention_backups.list_by_server( + location_name="str", + long_term_retention_server_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_long_term_retention_backups_list_by_resource_group_location(self, resource_group): + response = self.client.long_term_retention_backups.list_by_resource_group_location( + resource_group_name=resource_group.name, + location_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_long_term_retention_backups_list_by_resource_group_server(self, resource_group): + response = self.client.long_term_retention_backups.list_by_resource_group_server( + resource_group_name=resource_group.name, + location_name="str", + long_term_retention_server_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_long_term_retention_managed_instance_backups_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_long_term_retention_managed_instance_backups_operations.py index e0dcc7cc9b03..cbd3397ce314 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_long_term_retention_managed_instance_backups_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_long_term_retention_managed_instance_backups_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,13 +20,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_long_term_retention_managed_instance_backups_get(self, resource_group): - response = self.client.long_term_retention_managed_instance_backups.get( + def test_long_term_retention_managed_instance_backups_get_by_resource_group(self, resource_group): + response = self.client.long_term_retention_managed_instance_backups.get_by_resource_group( + resource_group_name=resource_group.name, location_name="str", managed_instance_name="str", database_name="str", backup_name="str", - api_version="2021-05-01-preview", ) # please add some check logic here by yourself @@ -34,13 +34,13 @@ def test_long_term_retention_managed_instance_backups_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_long_term_retention_managed_instance_backups_begin_delete(self, resource_group): - response = self.client.long_term_retention_managed_instance_backups.begin_delete( + def test_long_term_retention_managed_instance_backups_begin_delete_by_resource_group(self, resource_group): + response = self.client.long_term_retention_managed_instance_backups.begin_delete_by_resource_group( + resource_group_name=resource_group.name, location_name="str", managed_instance_name="str", database_name="str", backup_name="str", - api_version="2021-05-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -48,12 +48,12 @@ def test_long_term_retention_managed_instance_backups_begin_delete(self, resourc @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_long_term_retention_managed_instance_backups_list_by_database(self, resource_group): - response = self.client.long_term_retention_managed_instance_backups.list_by_database( + def test_long_term_retention_managed_instance_backups_list_by_resource_group_database(self, resource_group): + response = self.client.long_term_retention_managed_instance_backups.list_by_resource_group_database( + resource_group_name=resource_group.name, location_name="str", managed_instance_name="str", database_name="str", - api_version="2021-05-01-preview", ) result = [r for r in response] # please add some check logic here by yourself @@ -61,66 +61,58 @@ def test_long_term_retention_managed_instance_backups_list_by_database(self, res @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_long_term_retention_managed_instance_backups_list_by_instance(self, resource_group): - response = self.client.long_term_retention_managed_instance_backups.list_by_instance( + def test_long_term_retention_managed_instance_backups_get(self, resource_group): + response = self.client.long_term_retention_managed_instance_backups.get( location_name="str", managed_instance_name="str", - api_version="2021-05-01-preview", + database_name="str", + backup_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_long_term_retention_managed_instance_backups_list_by_location(self, resource_group): - response = self.client.long_term_retention_managed_instance_backups.list_by_location( + def test_long_term_retention_managed_instance_backups_begin_delete(self, resource_group): + response = self.client.long_term_retention_managed_instance_backups.begin_delete( location_name="str", - api_version="2021-05-01-preview", - ) - result = [r for r in response] + managed_instance_name="str", + database_name="str", + backup_name="str", + ).result() # call '.result()' to poll until service return final result + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_long_term_retention_managed_instance_backups_get_by_resource_group(self, resource_group): - response = self.client.long_term_retention_managed_instance_backups.get_by_resource_group( - resource_group_name=resource_group.name, + def test_long_term_retention_managed_instance_backups_list_by_database(self, resource_group): + response = self.client.long_term_retention_managed_instance_backups.list_by_database( location_name="str", managed_instance_name="str", database_name="str", - backup_name="str", - api_version="2021-05-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_long_term_retention_managed_instance_backups_begin_delete_by_resource_group(self, resource_group): - response = self.client.long_term_retention_managed_instance_backups.begin_delete_by_resource_group( - resource_group_name=resource_group.name, + def test_long_term_retention_managed_instance_backups_list_by_location(self, resource_group): + response = self.client.long_term_retention_managed_instance_backups.list_by_location( location_name="str", - managed_instance_name="str", - database_name="str", - backup_name="str", - api_version="2021-05-01-preview", - ).result() # call '.result()' to poll until service return final result - + ) + result = [r for r in response] # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_long_term_retention_managed_instance_backups_list_by_resource_group_database(self, resource_group): - response = self.client.long_term_retention_managed_instance_backups.list_by_resource_group_database( - resource_group_name=resource_group.name, + def test_long_term_retention_managed_instance_backups_list_by_instance(self, resource_group): + response = self.client.long_term_retention_managed_instance_backups.list_by_instance( location_name="str", managed_instance_name="str", - database_name="str", - api_version="2021-05-01-preview", ) result = [r for r in response] # please add some check logic here by yourself @@ -128,12 +120,10 @@ def test_long_term_retention_managed_instance_backups_list_by_resource_group_dat @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_long_term_retention_managed_instance_backups_list_by_resource_group_instance(self, resource_group): - response = self.client.long_term_retention_managed_instance_backups.list_by_resource_group_instance( + def test_long_term_retention_managed_instance_backups_list_by_resource_group_location(self, resource_group): + response = self.client.long_term_retention_managed_instance_backups.list_by_resource_group_location( resource_group_name=resource_group.name, location_name="str", - managed_instance_name="str", - api_version="2021-05-01-preview", ) result = [r for r in response] # please add some check logic here by yourself @@ -141,11 +131,11 @@ def test_long_term_retention_managed_instance_backups_list_by_resource_group_ins @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_long_term_retention_managed_instance_backups_list_by_resource_group_location(self, resource_group): - response = self.client.long_term_retention_managed_instance_backups.list_by_resource_group_location( + def test_long_term_retention_managed_instance_backups_list_by_resource_group_instance(self, resource_group): + response = self.client.long_term_retention_managed_instance_backups.list_by_resource_group_instance( resource_group_name=resource_group.name, location_name="str", - api_version="2021-05-01-preview", + managed_instance_name="str", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_long_term_retention_managed_instance_backups_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_long_term_retention_managed_instance_backups_operations_async.py index 628cebf3e3a5..920f40969d7e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_long_term_retention_managed_instance_backups_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_long_term_retention_managed_instance_backups_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,13 +21,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_long_term_retention_managed_instance_backups_get(self, resource_group): - response = await self.client.long_term_retention_managed_instance_backups.get( + async def test_long_term_retention_managed_instance_backups_get_by_resource_group(self, resource_group): + response = await self.client.long_term_retention_managed_instance_backups.get_by_resource_group( + resource_group_name=resource_group.name, location_name="str", managed_instance_name="str", database_name="str", backup_name="str", - api_version="2021-05-01-preview", ) # please add some check logic here by yourself @@ -35,14 +35,14 @@ async def test_long_term_retention_managed_instance_backups_get(self, resource_g @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_long_term_retention_managed_instance_backups_begin_delete(self, resource_group): + async def test_long_term_retention_managed_instance_backups_begin_delete_by_resource_group(self, resource_group): response = await ( - await self.client.long_term_retention_managed_instance_backups.begin_delete( + await self.client.long_term_retention_managed_instance_backups.begin_delete_by_resource_group( + resource_group_name=resource_group.name, location_name="str", managed_instance_name="str", database_name="str", backup_name="str", - api_version="2021-05-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -51,12 +51,12 @@ async def test_long_term_retention_managed_instance_backups_begin_delete(self, r @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_long_term_retention_managed_instance_backups_list_by_database(self, resource_group): - response = self.client.long_term_retention_managed_instance_backups.list_by_database( + async def test_long_term_retention_managed_instance_backups_list_by_resource_group_database(self, resource_group): + response = self.client.long_term_retention_managed_instance_backups.list_by_resource_group_database( + resource_group_name=resource_group.name, location_name="str", managed_instance_name="str", database_name="str", - api_version="2021-05-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself @@ -64,37 +64,12 @@ async def test_long_term_retention_managed_instance_backups_list_by_database(sel @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_long_term_retention_managed_instance_backups_list_by_instance(self, resource_group): - response = self.client.long_term_retention_managed_instance_backups.list_by_instance( - location_name="str", - managed_instance_name="str", - api_version="2021-05-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_long_term_retention_managed_instance_backups_list_by_location(self, resource_group): - response = self.client.long_term_retention_managed_instance_backups.list_by_location( - location_name="str", - api_version="2021-05-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_long_term_retention_managed_instance_backups_get_by_resource_group(self, resource_group): - response = await self.client.long_term_retention_managed_instance_backups.get_by_resource_group( - resource_group_name=resource_group.name, + async def test_long_term_retention_managed_instance_backups_get(self, resource_group): + response = await self.client.long_term_retention_managed_instance_backups.get( location_name="str", managed_instance_name="str", database_name="str", backup_name="str", - api_version="2021-05-01-preview", ) # please add some check logic here by yourself @@ -102,15 +77,13 @@ async def test_long_term_retention_managed_instance_backups_get_by_resource_grou @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_long_term_retention_managed_instance_backups_begin_delete_by_resource_group(self, resource_group): + async def test_long_term_retention_managed_instance_backups_begin_delete(self, resource_group): response = await ( - await self.client.long_term_retention_managed_instance_backups.begin_delete_by_resource_group( - resource_group_name=resource_group.name, + await self.client.long_term_retention_managed_instance_backups.begin_delete( location_name="str", managed_instance_name="str", database_name="str", backup_name="str", - api_version="2021-05-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -119,13 +92,11 @@ async def test_long_term_retention_managed_instance_backups_begin_delete_by_reso @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_long_term_retention_managed_instance_backups_list_by_resource_group_database(self, resource_group): - response = self.client.long_term_retention_managed_instance_backups.list_by_resource_group_database( - resource_group_name=resource_group.name, + async def test_long_term_retention_managed_instance_backups_list_by_database(self, resource_group): + response = self.client.long_term_retention_managed_instance_backups.list_by_database( location_name="str", managed_instance_name="str", database_name="str", - api_version="2021-05-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself @@ -133,12 +104,20 @@ async def test_long_term_retention_managed_instance_backups_list_by_resource_gro @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_long_term_retention_managed_instance_backups_list_by_resource_group_instance(self, resource_group): - response = self.client.long_term_retention_managed_instance_backups.list_by_resource_group_instance( - resource_group_name=resource_group.name, + async def test_long_term_retention_managed_instance_backups_list_by_location(self, resource_group): + response = self.client.long_term_retention_managed_instance_backups.list_by_location( + location_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_long_term_retention_managed_instance_backups_list_by_instance(self, resource_group): + response = self.client.long_term_retention_managed_instance_backups.list_by_instance( location_name="str", managed_instance_name="str", - api_version="2021-05-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself @@ -150,7 +129,18 @@ async def test_long_term_retention_managed_instance_backups_list_by_resource_gro response = self.client.long_term_retention_managed_instance_backups.list_by_resource_group_location( resource_group_name=resource_group.name, location_name="str", - api_version="2021-05-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_long_term_retention_managed_instance_backups_list_by_resource_group_instance(self, resource_group): + response = self.client.long_term_retention_managed_instance_backups.list_by_resource_group_instance( + resource_group_name=resource_group.name, + location_name="str", + managed_instance_name="str", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_long_term_retention_policies_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_long_term_retention_policies_operations.py index d994095ca7bf..f3ca6ccafc8b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_long_term_retention_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_long_term_retention_policies_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,19 +18,6 @@ class TestSqlManagementLongTermRetentionPoliciesOperations(AzureMgmtRecordedTest def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_long_term_retention_policies_list_by_database(self, resource_group): - response = self.client.long_term_retention_policies.list_by_database( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - api_version="2024-11-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_long_term_retention_policies_get(self, resource_group): @@ -39,7 +26,6 @@ def test_long_term_retention_policies_get(self, resource_group): server_name="str", database_name="str", policy_name="str", - api_version="2024-11-01-preview", ) # please add some check logic here by yourself @@ -55,17 +41,38 @@ def test_long_term_retention_policies_begin_create_or_update(self, resource_grou policy_name="str", parameters={ "id": "str", - "monthlyRetention": "str", "name": "str", - "timeBasedImmutability": "str", - "timeBasedImmutabilityMode": "str", + "properties": { + "monthlyRetention": "str", + "timeBasedImmutability": "str", + "timeBasedImmutabilityMode": "str", + "weekOfYear": 0, + "weeklyRetention": "str", + "yearlyRetention": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "weekOfYear": 0, - "weeklyRetention": "str", - "yearlyRetention": "str", }, - api_version="2024-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_long_term_retention_policies_list_by_database(self, resource_group): + response = self.client.long_term_retention_policies.list_by_database( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_long_term_retention_policies_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_long_term_retention_policies_operations_async.py index 0b7490e11573..db7fc41068f1 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_long_term_retention_policies_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_long_term_retention_policies_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,19 +19,6 @@ class TestSqlManagementLongTermRetentionPoliciesOperationsAsync(AzureMgmtRecorde def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_long_term_retention_policies_list_by_database(self, resource_group): - response = self.client.long_term_retention_policies.list_by_database( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - api_version="2024-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_long_term_retention_policies_get(self, resource_group): @@ -40,7 +27,6 @@ async def test_long_term_retention_policies_get(self, resource_group): server_name="str", database_name="str", policy_name="str", - api_version="2024-11-01-preview", ) # please add some check logic here by yourself @@ -57,18 +43,39 @@ async def test_long_term_retention_policies_begin_create_or_update(self, resourc policy_name="str", parameters={ "id": "str", - "monthlyRetention": "str", "name": "str", - "timeBasedImmutability": "str", - "timeBasedImmutabilityMode": "str", + "properties": { + "monthlyRetention": "str", + "timeBasedImmutability": "str", + "timeBasedImmutabilityMode": "str", + "weekOfYear": 0, + "weeklyRetention": "str", + "yearlyRetention": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "weekOfYear": 0, - "weeklyRetention": "str", - "yearlyRetention": "str", }, - api_version="2024-11-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_long_term_retention_policies_list_by_database(self, resource_group): + response = self.client.long_term_retention_policies.list_by_database( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_maintenance_window_options_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_maintenance_window_options_operations.py index 58f069840ef3..7198de9959c3 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_maintenance_window_options_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_maintenance_window_options_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ def test_maintenance_window_options_get(self, resource_group): server_name="str", database_name="str", maintenance_window_options_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_maintenance_window_options_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_maintenance_window_options_operations_async.py index b689406046a9..d60c77b12247 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_maintenance_window_options_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_maintenance_window_options_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -27,7 +27,6 @@ async def test_maintenance_window_options_get(self, resource_group): server_name="str", database_name="str", maintenance_window_options_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_maintenance_windows_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_maintenance_windows_operations.py index f7dd56f94e21..ad6ebac64ecb 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_maintenance_windows_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_maintenance_windows_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ def test_maintenance_windows_get(self, resource_group): server_name="str", database_name="str", maintenance_window_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -39,14 +38,21 @@ def test_maintenance_windows_create_or_update(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", - maintenance_window_name="str", parameters={ "id": "str", "name": "str", - "timeRanges": [{"dayOfWeek": "str", "duration": "str", "startTime": "str"}], + "properties": {"timeRanges": [{"dayOfWeek": "str", "duration": "str", "startTime": "str"}]}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2020-11-01-preview", + maintenance_window_name="str", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_maintenance_windows_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_maintenance_windows_operations_async.py index 3af1fad351d6..6bb92f7b0efd 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_maintenance_windows_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_maintenance_windows_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -27,7 +27,6 @@ async def test_maintenance_windows_get(self, resource_group): server_name="str", database_name="str", maintenance_window_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -40,14 +39,21 @@ async def test_maintenance_windows_create_or_update(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", - maintenance_window_name="str", parameters={ "id": "str", "name": "str", - "timeRanges": [{"dayOfWeek": "str", "duration": "str", "startTime": "str"}], + "properties": {"timeRanges": [{"dayOfWeek": "str", "duration": "str", "startTime": "str"}]}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2020-11-01-preview", + maintenance_window_name="str", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_backup_short_term_retention_policies_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_backup_short_term_retention_policies_operations.py index 4640ecf1bb72..eb992893ed90 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_backup_short_term_retention_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_backup_short_term_retention_policies_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ def test_managed_backup_short_term_retention_policies_get(self, resource_group): managed_instance_name="str", database_name="str", policy_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -40,8 +39,20 @@ def test_managed_backup_short_term_retention_policies_begin_create_or_update(sel managed_instance_name="str", database_name="str", policy_name="str", - parameters={"id": "str", "name": "str", "retentionDays": 0, "type": "str"}, - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"retentionDays": 0}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -55,8 +66,20 @@ def test_managed_backup_short_term_retention_policies_begin_update(self, resourc managed_instance_name="str", database_name="str", policy_name="str", - parameters={"id": "str", "name": "str", "retentionDays": 0, "type": "str"}, - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"retentionDays": 0}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -69,7 +92,6 @@ def test_managed_backup_short_term_retention_policies_list_by_database(self, res resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_backup_short_term_retention_policies_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_backup_short_term_retention_policies_operations_async.py index dba67bf9b180..49226feea440 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_backup_short_term_retention_policies_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_backup_short_term_retention_policies_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -27,7 +27,6 @@ async def test_managed_backup_short_term_retention_policies_get(self, resource_g managed_instance_name="str", database_name="str", policy_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -42,8 +41,20 @@ async def test_managed_backup_short_term_retention_policies_begin_create_or_upda managed_instance_name="str", database_name="str", policy_name="str", - parameters={"id": "str", "name": "str", "retentionDays": 0, "type": "str"}, - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"retentionDays": 0}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) ).result() # call '.result()' to poll until service return final result @@ -59,8 +70,20 @@ async def test_managed_backup_short_term_retention_policies_begin_update(self, r managed_instance_name="str", database_name="str", policy_name="str", - parameters={"id": "str", "name": "str", "retentionDays": 0, "type": "str"}, - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"retentionDays": 0}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) ).result() # call '.result()' to poll until service return final result @@ -74,7 +97,6 @@ async def test_managed_backup_short_term_retention_policies_list_by_database(sel resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_advanced_threat_protection_settings_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_advanced_threat_protection_settings_operations.py index 8af4d7f892e9..a9d9c4560f85 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_advanced_threat_protection_settings_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_advanced_threat_protection_settings_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,19 +18,6 @@ class TestSqlManagementManagedDatabaseAdvancedThreatProtectionSettingsOperations def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_managed_database_advanced_threat_protection_settings_list_by_database(self, resource_group): - response = self.client.managed_database_advanced_threat_protection_settings.list_by_database( - resource_group_name=resource_group.name, - managed_instance_name="str", - database_name="str", - api_version="2022-02-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_managed_database_advanced_threat_protection_settings_get(self, resource_group): @@ -39,7 +26,6 @@ def test_managed_database_advanced_threat_protection_settings_get(self, resource managed_instance_name="str", database_name="str", advanced_threat_protection_name="str", - api_version="2022-02-01-preview", ) # please add some check logic here by yourself @@ -54,10 +40,9 @@ def test_managed_database_advanced_threat_protection_settings_create_or_update(s database_name="str", advanced_threat_protection_name="str", parameters={ - "creationTime": "2020-02-20 00:00:00", "id": "str", "name": "str", - "state": "str", + "properties": {"state": "str", "creationTime": "2020-02-20 00:00:00"}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -68,8 +53,19 @@ def test_managed_database_advanced_threat_protection_settings_create_or_update(s }, "type": "str", }, - api_version="2022-02-01-preview", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_managed_database_advanced_threat_protection_settings_list_by_database(self, resource_group): + response = self.client.managed_database_advanced_threat_protection_settings.list_by_database( + resource_group_name=resource_group.name, + managed_instance_name="str", + database_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_advanced_threat_protection_settings_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_advanced_threat_protection_settings_operations_async.py index 0b5fc607e665..c8bb656a5e3c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_advanced_threat_protection_settings_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_advanced_threat_protection_settings_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,19 +19,6 @@ class TestSqlManagementManagedDatabaseAdvancedThreatProtectionSettingsOperations def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_managed_database_advanced_threat_protection_settings_list_by_database(self, resource_group): - response = self.client.managed_database_advanced_threat_protection_settings.list_by_database( - resource_group_name=resource_group.name, - managed_instance_name="str", - database_name="str", - api_version="2022-02-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_managed_database_advanced_threat_protection_settings_get(self, resource_group): @@ -40,7 +27,6 @@ async def test_managed_database_advanced_threat_protection_settings_get(self, re managed_instance_name="str", database_name="str", advanced_threat_protection_name="str", - api_version="2022-02-01-preview", ) # please add some check logic here by yourself @@ -55,10 +41,9 @@ async def test_managed_database_advanced_threat_protection_settings_create_or_up database_name="str", advanced_threat_protection_name="str", parameters={ - "creationTime": "2020-02-20 00:00:00", "id": "str", "name": "str", - "state": "str", + "properties": {"state": "str", "creationTime": "2020-02-20 00:00:00"}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -69,8 +54,19 @@ async def test_managed_database_advanced_threat_protection_settings_create_or_up }, "type": "str", }, - api_version="2022-02-01-preview", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_managed_database_advanced_threat_protection_settings_list_by_database(self, resource_group): + response = self.client.managed_database_advanced_threat_protection_settings.list_by_database( + resource_group_name=resource_group.name, + managed_instance_name="str", + database_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_columns_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_columns_operations.py index 109b62b037e5..b64bcc974195 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_columns_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_columns_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,14 +20,16 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_managed_database_columns_list_by_database(self, resource_group): - response = self.client.managed_database_columns.list_by_database( + def test_managed_database_columns_get(self, resource_group): + response = self.client.managed_database_columns.get( resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", - api_version="2020-11-01-preview", + schema_name="str", + table_name="str", + column_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @@ -40,7 +42,6 @@ def test_managed_database_columns_list_by_table(self, resource_group): database_name="str", schema_name="str", table_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself @@ -48,16 +49,12 @@ def test_managed_database_columns_list_by_table(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_managed_database_columns_get(self, resource_group): - response = self.client.managed_database_columns.get( + def test_managed_database_columns_list_by_database(self, resource_group): + response = self.client.managed_database_columns.list_by_database( resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", - schema_name="str", - table_name="str", - column_name="str", - api_version="2020-11-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_columns_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_columns_operations_async.py index e7a9182a06dc..30556268f417 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_columns_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_columns_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,14 +21,16 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_managed_database_columns_list_by_database(self, resource_group): - response = self.client.managed_database_columns.list_by_database( + async def test_managed_database_columns_get(self, resource_group): + response = await self.client.managed_database_columns.get( resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", - api_version="2020-11-01-preview", + schema_name="str", + table_name="str", + column_name="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @@ -41,7 +43,6 @@ async def test_managed_database_columns_list_by_table(self, resource_group): database_name="str", schema_name="str", table_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself @@ -49,16 +50,12 @@ async def test_managed_database_columns_list_by_table(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_managed_database_columns_get(self, resource_group): - response = await self.client.managed_database_columns.get( + async def test_managed_database_columns_list_by_database(self, resource_group): + response = self.client.managed_database_columns.list_by_database( resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", - schema_name="str", - table_name="str", - column_name="str", - api_version="2020-11-01-preview", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_move_operations_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_move_operations_operations.py index a33e6f053aed..60911cb8430f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_move_operations_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_move_operations_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,25 +20,23 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_managed_database_move_operations_list_by_location(self, resource_group): - response = self.client.managed_database_move_operations.list_by_location( + def test_managed_database_move_operations_get(self, resource_group): + response = self.client.managed_database_move_operations.get( resource_group_name=resource_group.name, location_name="str", - api_version="2022-05-01-preview", + operation_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_managed_database_move_operations_get(self, resource_group): - response = self.client.managed_database_move_operations.get( + def test_managed_database_move_operations_list_by_location(self, resource_group): + response = self.client.managed_database_move_operations.list_by_location( resource_group_name=resource_group.name, location_name="str", - operation_id="str", - api_version="2022-05-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_move_operations_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_move_operations_operations_async.py index 16cf1b5ee9a8..c28d04918bc1 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_move_operations_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_move_operations_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,25 +21,23 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_managed_database_move_operations_list_by_location(self, resource_group): - response = self.client.managed_database_move_operations.list_by_location( + async def test_managed_database_move_operations_get(self, resource_group): + response = await self.client.managed_database_move_operations.get( resource_group_name=resource_group.name, location_name="str", - api_version="2022-05-01-preview", + operation_id="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_managed_database_move_operations_get(self, resource_group): - response = await self.client.managed_database_move_operations.get( + async def test_managed_database_move_operations_list_by_location(self, resource_group): + response = self.client.managed_database_move_operations.list_by_location( resource_group_name=resource_group.name, location_name="str", - operation_id="str", - api_version="2022-05-01-preview", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_queries_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_queries_operations.py index cefa10f54851..973d31522f18 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_queries_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_queries_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ def test_managed_database_queries_get(self, resource_group): managed_instance_name="str", database_name="str", query_id="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -40,7 +39,6 @@ def test_managed_database_queries_list_by_query(self, resource_group): managed_instance_name="str", database_name="str", query_id="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_queries_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_queries_operations_async.py index 8988d0d031c9..27c6d340a5ad 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_queries_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_queries_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -27,7 +27,6 @@ async def test_managed_database_queries_get(self, resource_group): managed_instance_name="str", database_name="str", query_id="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -41,7 +40,6 @@ async def test_managed_database_queries_list_by_query(self, resource_group): managed_instance_name="str", database_name="str", query_id="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_recommended_sensitivity_labels_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_recommended_sensitivity_labels_operations.py index bc6f8ea7abae..4e39635fa10d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_recommended_sensitivity_labels_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_recommended_sensitivity_labels_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -28,17 +28,21 @@ def test_managed_database_recommended_sensitivity_labels_update(self, resource_g parameters={ "operations": [ { - "column": "str", "id": "str", "name": "str", - "op": "str", - "schema": "str", - "table": "str", + "properties": {"column": "str", "op": "str", "schema": "str", "table": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", } ] }, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_recommended_sensitivity_labels_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_recommended_sensitivity_labels_operations_async.py index 54c0dd25683a..eaf3daaed755 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_recommended_sensitivity_labels_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_recommended_sensitivity_labels_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -29,17 +29,21 @@ async def test_managed_database_recommended_sensitivity_labels_update(self, reso parameters={ "operations": [ { - "column": "str", "id": "str", "name": "str", - "op": "str", - "schema": "str", - "table": "str", + "properties": {"column": "str", "op": "str", "schema": "str", "table": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", } ] }, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_restore_details_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_restore_details_operations.py index 52dc919fd6f8..78c2ac1ccf36 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_restore_details_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_restore_details_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ def test_managed_database_restore_details_get(self, resource_group): managed_instance_name="str", database_name="str", restore_details_name="str", - api_version="2022-05-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_restore_details_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_restore_details_operations_async.py index f5e3e1d657f0..c3ea46a8ab43 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_restore_details_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_restore_details_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -27,7 +27,6 @@ async def test_managed_database_restore_details_get(self, resource_group): managed_instance_name="str", database_name="str", restore_details_name="str", - api_version="2022-05-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_schemas_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_schemas_operations.py index b9787152f37d..ce0c75e14390 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_schemas_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_schemas_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,27 +20,25 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_managed_database_schemas_list_by_database(self, resource_group): - response = self.client.managed_database_schemas.list_by_database( + def test_managed_database_schemas_get(self, resource_group): + response = self.client.managed_database_schemas.get( resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", - api_version="2020-11-01-preview", + schema_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_managed_database_schemas_get(self, resource_group): - response = self.client.managed_database_schemas.get( + def test_managed_database_schemas_list_by_database(self, resource_group): + response = self.client.managed_database_schemas.list_by_database( resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", - schema_name="str", - api_version="2020-11-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_schemas_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_schemas_operations_async.py index 7e94e6926e4b..935a22569aa3 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_schemas_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_schemas_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,27 +21,25 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_managed_database_schemas_list_by_database(self, resource_group): - response = self.client.managed_database_schemas.list_by_database( + async def test_managed_database_schemas_get(self, resource_group): + response = await self.client.managed_database_schemas.get( resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", - api_version="2020-11-01-preview", + schema_name="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_managed_database_schemas_get(self, resource_group): - response = await self.client.managed_database_schemas.get( + async def test_managed_database_schemas_list_by_database(self, resource_group): + response = self.client.managed_database_schemas.list_by_database( resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", - schema_name="str", - api_version="2020-11-01-preview", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_security_alert_policies_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_security_alert_policies_operations.py index 61ed6b296283..19d756a1511f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_security_alert_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_security_alert_policies_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ def test_managed_database_security_alert_policies_get(self, resource_group): managed_instance_name="str", database_name="str", security_alert_policy_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -41,19 +40,28 @@ def test_managed_database_security_alert_policies_create_or_update(self, resourc database_name="str", security_alert_policy_name="str", parameters={ - "creationTime": "2020-02-20 00:00:00", - "disabledAlerts": ["str"], - "emailAccountAdmins": bool, - "emailAddresses": ["str"], "id": "str", "name": "str", - "retentionDays": 0, - "state": "str", - "storageAccountAccessKey": "str", - "storageEndpoint": "str", + "properties": { + "state": "str", + "creationTime": "2020-02-20 00:00:00", + "disabledAlerts": ["str"], + "emailAccountAdmins": bool, + "emailAddresses": ["str"], + "retentionDays": 0, + "storageAccountAccessKey": "str", + "storageEndpoint": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -66,7 +74,6 @@ def test_managed_database_security_alert_policies_list_by_database(self, resourc resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_security_alert_policies_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_security_alert_policies_operations_async.py index 93ba32dd3e26..c325b540dabd 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_security_alert_policies_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_security_alert_policies_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -27,7 +27,6 @@ async def test_managed_database_security_alert_policies_get(self, resource_group managed_instance_name="str", database_name="str", security_alert_policy_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -42,19 +41,28 @@ async def test_managed_database_security_alert_policies_create_or_update(self, r database_name="str", security_alert_policy_name="str", parameters={ - "creationTime": "2020-02-20 00:00:00", - "disabledAlerts": ["str"], - "emailAccountAdmins": bool, - "emailAddresses": ["str"], "id": "str", "name": "str", - "retentionDays": 0, - "state": "str", - "storageAccountAccessKey": "str", - "storageEndpoint": "str", + "properties": { + "state": "str", + "creationTime": "2020-02-20 00:00:00", + "disabledAlerts": ["str"], + "emailAccountAdmins": bool, + "emailAddresses": ["str"], + "retentionDays": 0, + "storageAccountAccessKey": "str", + "storageEndpoint": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -67,7 +75,6 @@ async def test_managed_database_security_alert_policies_list_by_database(self, r resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_security_events_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_security_events_operations.py index f384fcc7c123..f73b80cf4f4f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_security_events_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_security_events_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_managed_database_security_events_list_by_database(self, resource_group) resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_security_events_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_security_events_operations_async.py index d2cb171f098e..a0a704c5fbeb 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_security_events_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_security_events_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_managed_database_security_events_list_by_database(self, resource_ resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_sensitivity_labels_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_sensitivity_labels_operations.py index 2c5dd67a1254..e171387b0757 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_sensitivity_labels_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_sensitivity_labels_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -29,7 +29,6 @@ def test_managed_database_sensitivity_labels_get(self, resource_group): table_name="str", column_name="str", sensitivity_label_source="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -46,22 +45,32 @@ def test_managed_database_sensitivity_labels_create_or_update(self, resource_gro table_name="str", column_name="str", parameters={ - "columnName": "str", "id": "str", - "informationType": "str", - "informationTypeId": "str", - "isDisabled": bool, - "labelId": "str", - "labelName": "str", "managedBy": "str", "name": "str", - "rank": "str", - "schemaName": "str", - "tableName": "str", + "properties": { + "clientClassificationSource": "str", + "columnName": "str", + "informationType": "str", + "informationTypeId": "str", + "isDisabled": bool, + "labelId": "str", + "labelName": "str", + "rank": "str", + "schemaName": "str", + "tableName": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, sensitivity_label_source="current", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -78,7 +87,6 @@ def test_managed_database_sensitivity_labels_delete(self, resource_group): table_name="str", column_name="str", sensitivity_label_source="current", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -95,7 +103,6 @@ def test_managed_database_sensitivity_labels_disable_recommendation(self, resour table_name="str", column_name="str", sensitivity_label_source="recommended", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -112,7 +119,6 @@ def test_managed_database_sensitivity_labels_enable_recommendation(self, resourc table_name="str", column_name="str", sensitivity_label_source="recommended", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -125,7 +131,6 @@ def test_managed_database_sensitivity_labels_list_current_by_database(self, reso resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself @@ -141,32 +146,52 @@ def test_managed_database_sensitivity_labels_update(self, resource_group): parameters={ "operations": [ { - "column": "str", "id": "str", "name": "str", - "op": "str", - "schema": "str", - "sensitivityLabel": { - "columnName": "str", - "id": "str", - "informationType": "str", - "informationTypeId": "str", - "isDisabled": bool, - "labelId": "str", - "labelName": "str", - "managedBy": "str", - "name": "str", - "rank": "str", - "schemaName": "str", - "tableName": "str", - "type": "str", + "properties": { + "column": "str", + "op": "str", + "schema": "str", + "table": "str", + "sensitivityLabel": { + "id": "str", + "managedBy": "str", + "name": "str", + "properties": { + "clientClassificationSource": "str", + "columnName": "str", + "informationType": "str", + "informationTypeId": "str", + "isDisabled": bool, + "labelId": "str", + "labelName": "str", + "rank": "str", + "schemaName": "str", + "tableName": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", }, - "table": "str", "type": "str", } ] }, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -179,7 +204,18 @@ def test_managed_database_sensitivity_labels_list_recommended_by_database(self, resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", - api_version="2020-11-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_managed_database_sensitivity_labels_list_by_database(self, resource_group): + response = self.client.managed_database_sensitivity_labels.list_by_database( + resource_group_name=resource_group.name, + managed_instance_name="str", + database_name="str", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_sensitivity_labels_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_sensitivity_labels_operations_async.py index fe12cbc9778f..a2418d7f5908 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_sensitivity_labels_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_sensitivity_labels_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -30,7 +30,6 @@ async def test_managed_database_sensitivity_labels_get(self, resource_group): table_name="str", column_name="str", sensitivity_label_source="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -47,22 +46,32 @@ async def test_managed_database_sensitivity_labels_create_or_update(self, resour table_name="str", column_name="str", parameters={ - "columnName": "str", "id": "str", - "informationType": "str", - "informationTypeId": "str", - "isDisabled": bool, - "labelId": "str", - "labelName": "str", "managedBy": "str", "name": "str", - "rank": "str", - "schemaName": "str", - "tableName": "str", + "properties": { + "clientClassificationSource": "str", + "columnName": "str", + "informationType": "str", + "informationTypeId": "str", + "isDisabled": bool, + "labelId": "str", + "labelName": "str", + "rank": "str", + "schemaName": "str", + "tableName": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, sensitivity_label_source="current", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -79,7 +88,6 @@ async def test_managed_database_sensitivity_labels_delete(self, resource_group): table_name="str", column_name="str", sensitivity_label_source="current", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -96,7 +104,6 @@ async def test_managed_database_sensitivity_labels_disable_recommendation(self, table_name="str", column_name="str", sensitivity_label_source="recommended", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -113,7 +120,6 @@ async def test_managed_database_sensitivity_labels_enable_recommendation(self, r table_name="str", column_name="str", sensitivity_label_source="recommended", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -126,7 +132,6 @@ async def test_managed_database_sensitivity_labels_list_current_by_database(self resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself @@ -142,32 +147,52 @@ async def test_managed_database_sensitivity_labels_update(self, resource_group): parameters={ "operations": [ { - "column": "str", "id": "str", "name": "str", - "op": "str", - "schema": "str", - "sensitivityLabel": { - "columnName": "str", - "id": "str", - "informationType": "str", - "informationTypeId": "str", - "isDisabled": bool, - "labelId": "str", - "labelName": "str", - "managedBy": "str", - "name": "str", - "rank": "str", - "schemaName": "str", - "tableName": "str", - "type": "str", + "properties": { + "column": "str", + "op": "str", + "schema": "str", + "table": "str", + "sensitivityLabel": { + "id": "str", + "managedBy": "str", + "name": "str", + "properties": { + "clientClassificationSource": "str", + "columnName": "str", + "informationType": "str", + "informationTypeId": "str", + "isDisabled": bool, + "labelId": "str", + "labelName": "str", + "rank": "str", + "schemaName": "str", + "tableName": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", }, - "table": "str", "type": "str", } ] }, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -180,7 +205,18 @@ async def test_managed_database_sensitivity_labels_list_recommended_by_database( resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", - api_version="2020-11-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_managed_database_sensitivity_labels_list_by_database(self, resource_group): + response = self.client.managed_database_sensitivity_labels.list_by_database( + resource_group_name=resource_group.name, + managed_instance_name="str", + database_name="str", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_tables_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_tables_operations.py index 372f578580b7..bc7926813984 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_tables_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_tables_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,29 +20,27 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_managed_database_tables_list_by_schema(self, resource_group): - response = self.client.managed_database_tables.list_by_schema( + def test_managed_database_tables_get(self, resource_group): + response = self.client.managed_database_tables.get( resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", schema_name="str", - api_version="2020-11-01-preview", + table_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_managed_database_tables_get(self, resource_group): - response = self.client.managed_database_tables.get( + def test_managed_database_tables_list_by_schema(self, resource_group): + response = self.client.managed_database_tables.list_by_schema( resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", schema_name="str", - table_name="str", - api_version="2020-11-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_tables_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_tables_operations_async.py index 3f4bd8bbfa64..843f47f5691a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_tables_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_tables_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,29 +21,27 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_managed_database_tables_list_by_schema(self, resource_group): - response = self.client.managed_database_tables.list_by_schema( + async def test_managed_database_tables_get(self, resource_group): + response = await self.client.managed_database_tables.get( resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", schema_name="str", - api_version="2020-11-01-preview", + table_name="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_managed_database_tables_get(self, resource_group): - response = await self.client.managed_database_tables.get( + async def test_managed_database_tables_list_by_schema(self, resource_group): + response = self.client.managed_database_tables.list_by_schema( resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", schema_name="str", - table_name="str", - api_version="2020-11-01-preview", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_transparent_data_encryption_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_transparent_data_encryption_operations.py index 49784755fbf9..59c6ffcb0d6e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_transparent_data_encryption_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_transparent_data_encryption_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ def test_managed_database_transparent_data_encryption_get(self, resource_group): managed_instance_name="str", database_name="str", tde_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -40,8 +39,20 @@ def test_managed_database_transparent_data_encryption_create_or_update(self, res managed_instance_name="str", database_name="str", tde_name="str", - parameters={"id": "str", "name": "str", "state": "str", "type": "str"}, - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"state": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -54,7 +65,6 @@ def test_managed_database_transparent_data_encryption_list_by_database(self, res resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_transparent_data_encryption_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_transparent_data_encryption_operations_async.py index b8a884d0f02a..089d7209933f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_transparent_data_encryption_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_transparent_data_encryption_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -27,7 +27,6 @@ async def test_managed_database_transparent_data_encryption_get(self, resource_g managed_instance_name="str", database_name="str", tde_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -41,8 +40,20 @@ async def test_managed_database_transparent_data_encryption_create_or_update(sel managed_instance_name="str", database_name="str", tde_name="str", - parameters={"id": "str", "name": "str", "state": "str", "type": "str"}, - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"state": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -55,7 +66,6 @@ async def test_managed_database_transparent_data_encryption_list_by_database(sel resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_vulnerability_assessment_rule_baselines_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_vulnerability_assessment_rule_baselines_operations.py index ccd5b0cf9363..e49713e9bbc9 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_vulnerability_assessment_rule_baselines_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_vulnerability_assessment_rule_baselines_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -28,7 +28,6 @@ def test_managed_database_vulnerability_assessment_rule_baselines_get(self, reso vulnerability_assessment_name="str", rule_id="str", baseline_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -44,8 +43,20 @@ def test_managed_database_vulnerability_assessment_rule_baselines_create_or_upda vulnerability_assessment_name="str", rule_id="str", baseline_name="str", - parameters={"baselineResults": [{"result": ["str"]}], "id": "str", "name": "str", "type": "str"}, - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"baselineResults": [{"result": ["str"]}]}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -61,7 +72,6 @@ def test_managed_database_vulnerability_assessment_rule_baselines_delete(self, r vulnerability_assessment_name="str", rule_id="str", baseline_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_vulnerability_assessment_rule_baselines_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_vulnerability_assessment_rule_baselines_operations_async.py index 8a67c0272453..92406b83d71a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_vulnerability_assessment_rule_baselines_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_vulnerability_assessment_rule_baselines_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -29,7 +29,6 @@ async def test_managed_database_vulnerability_assessment_rule_baselines_get(self vulnerability_assessment_name="str", rule_id="str", baseline_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -45,8 +44,20 @@ async def test_managed_database_vulnerability_assessment_rule_baselines_create_o vulnerability_assessment_name="str", rule_id="str", baseline_name="str", - parameters={"baselineResults": [{"result": ["str"]}], "id": "str", "name": "str", "type": "str"}, - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"baselineResults": [{"result": ["str"]}]}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -62,7 +73,6 @@ async def test_managed_database_vulnerability_assessment_rule_baselines_delete(s vulnerability_assessment_name="str", rule_id="str", baseline_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_vulnerability_assessment_scans_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_vulnerability_assessment_scans_operations.py index 123e56446b8d..53d1dce0b01e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_vulnerability_assessment_scans_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_vulnerability_assessment_scans_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,59 +20,55 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_managed_database_vulnerability_assessment_scans_begin_initiate_scan(self, resource_group): - response = self.client.managed_database_vulnerability_assessment_scans.begin_initiate_scan( + def test_managed_database_vulnerability_assessment_scans_get(self, resource_group): + response = self.client.managed_database_vulnerability_assessment_scans.get( resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", vulnerability_assessment_name="str", scan_id="str", - api_version="2020-11-01-preview", - ).result() # call '.result()' to poll until service return final result + ) # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_managed_database_vulnerability_assessment_scans_export(self, resource_group): - response = self.client.managed_database_vulnerability_assessment_scans.export( + def test_managed_database_vulnerability_assessment_scans_list_by_database(self, resource_group): + response = self.client.managed_database_vulnerability_assessment_scans.list_by_database( resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", vulnerability_assessment_name="str", - scan_id="str", - api_version="2020-11-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_managed_database_vulnerability_assessment_scans_list_by_database(self, resource_group): - response = self.client.managed_database_vulnerability_assessment_scans.list_by_database( + def test_managed_database_vulnerability_assessment_scans_export(self, resource_group): + response = self.client.managed_database_vulnerability_assessment_scans.export( resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", vulnerability_assessment_name="str", - api_version="2020-11-01-preview", + scan_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_managed_database_vulnerability_assessment_scans_get(self, resource_group): - response = self.client.managed_database_vulnerability_assessment_scans.get( + def test_managed_database_vulnerability_assessment_scans_begin_initiate_scan(self, resource_group): + response = self.client.managed_database_vulnerability_assessment_scans.begin_initiate_scan( resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", vulnerability_assessment_name="str", scan_id="str", - api_version="2020-11-01-preview", - ) + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_vulnerability_assessment_scans_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_vulnerability_assessment_scans_operations_async.py index d9728882a296..4a34242a92bd 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_vulnerability_assessment_scans_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_vulnerability_assessment_scans_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,31 +21,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_managed_database_vulnerability_assessment_scans_begin_initiate_scan(self, resource_group): - response = await ( - await self.client.managed_database_vulnerability_assessment_scans.begin_initiate_scan( - resource_group_name=resource_group.name, - managed_instance_name="str", - database_name="str", - vulnerability_assessment_name="str", - scan_id="str", - api_version="2020-11-01-preview", - ) - ).result() # call '.result()' to poll until service return final result - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_managed_database_vulnerability_assessment_scans_export(self, resource_group): - response = await self.client.managed_database_vulnerability_assessment_scans.export( + async def test_managed_database_vulnerability_assessment_scans_get(self, resource_group): + response = await self.client.managed_database_vulnerability_assessment_scans.get( resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", vulnerability_assessment_name="str", scan_id="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -59,7 +41,6 @@ async def test_managed_database_vulnerability_assessment_scans_list_by_database( managed_instance_name="str", database_name="str", vulnerability_assessment_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself @@ -67,15 +48,30 @@ async def test_managed_database_vulnerability_assessment_scans_list_by_database( @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_managed_database_vulnerability_assessment_scans_get(self, resource_group): - response = await self.client.managed_database_vulnerability_assessment_scans.get( + async def test_managed_database_vulnerability_assessment_scans_export(self, resource_group): + response = await self.client.managed_database_vulnerability_assessment_scans.export( resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", vulnerability_assessment_name="str", scan_id="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_managed_database_vulnerability_assessment_scans_begin_initiate_scan(self, resource_group): + response = await ( + await self.client.managed_database_vulnerability_assessment_scans.begin_initiate_scan( + resource_group_name=resource_group.name, + managed_instance_name="str", + database_name="str", + vulnerability_assessment_name="str", + scan_id="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_vulnerability_assessments_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_vulnerability_assessments_operations.py index 30ef65ffec49..68ed9bb212d8 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_vulnerability_assessments_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_vulnerability_assessments_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ def test_managed_database_vulnerability_assessments_get(self, resource_group): managed_instance_name="str", database_name="str", vulnerability_assessment_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -43,13 +42,22 @@ def test_managed_database_vulnerability_assessments_create_or_update(self, resou parameters={ "id": "str", "name": "str", - "recurringScans": {"emailSubscriptionAdmins": True, "emails": ["str"], "isEnabled": bool}, - "storageAccountAccessKey": "str", - "storageContainerPath": "str", - "storageContainerSasKey": "str", + "properties": { + "recurringScans": {"emailSubscriptionAdmins": bool, "emails": ["str"], "isEnabled": bool}, + "storageAccountAccessKey": "str", + "storageContainerPath": "str", + "storageContainerSasKey": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -63,7 +71,6 @@ def test_managed_database_vulnerability_assessments_delete(self, resource_group) managed_instance_name="str", database_name="str", vulnerability_assessment_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -76,7 +83,6 @@ def test_managed_database_vulnerability_assessments_list_by_database(self, resou resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_vulnerability_assessments_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_vulnerability_assessments_operations_async.py index fd7f67a8acfd..30c7d2d8ac70 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_vulnerability_assessments_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_database_vulnerability_assessments_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -27,7 +27,6 @@ async def test_managed_database_vulnerability_assessments_get(self, resource_gro managed_instance_name="str", database_name="str", vulnerability_assessment_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -44,13 +43,22 @@ async def test_managed_database_vulnerability_assessments_create_or_update(self, parameters={ "id": "str", "name": "str", - "recurringScans": {"emailSubscriptionAdmins": True, "emails": ["str"], "isEnabled": bool}, - "storageAccountAccessKey": "str", - "storageContainerPath": "str", - "storageContainerSasKey": "str", + "properties": { + "recurringScans": {"emailSubscriptionAdmins": bool, "emails": ["str"], "isEnabled": bool}, + "storageAccountAccessKey": "str", + "storageContainerPath": "str", + "storageContainerSasKey": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -64,7 +72,6 @@ async def test_managed_database_vulnerability_assessments_delete(self, resource_ managed_instance_name="str", database_name="str", vulnerability_assessment_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -77,7 +84,6 @@ async def test_managed_database_vulnerability_assessments_list_by_database(self, resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_databases_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_databases_operations.py index 8edb91568806..7949279951ef 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_databases_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_databases_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,18 +18,6 @@ class TestSqlManagementManagedDatabasesOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_managed_databases_list_by_instance(self, resource_group): - response = self.client.managed_databases.list_by_instance( - resource_group_name=resource_group.name, - managed_instance_name="str", - api_version="2022-08-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_managed_databases_get(self, resource_group): @@ -37,7 +25,6 @@ def test_managed_databases_get(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", - api_version="2022-08-01-preview", ) # please add some check logic here by yourself @@ -52,34 +39,49 @@ def test_managed_databases_begin_create_or_update(self, resource_group): database_name="str", parameters={ "location": "str", - "autoCompleteRestore": bool, - "catalogCollation": "str", - "collation": "str", - "createMode": "str", - "creationDate": "2020-02-20 00:00:00", - "crossSubscriptionRestorableDroppedDatabaseId": "str", - "crossSubscriptionSourceDatabaseId": "str", - "crossSubscriptionTargetManagedInstanceId": "str", - "defaultSecondaryLocation": "str", - "earliestRestorePoint": "2020-02-20 00:00:00", - "failoverGroupId": "str", "id": "str", - "isLedgerOn": bool, - "lastBackupName": "str", - "longTermRetentionBackupResourceId": "str", "name": "str", - "recoverableDatabaseId": "str", - "restorableDroppedDatabaseId": "str", - "restorePointInTime": "2020-02-20 00:00:00", - "sourceDatabaseId": "str", - "status": "str", - "storageContainerIdentity": "str", - "storageContainerSasToken": "str", - "storageContainerUri": "str", + "properties": { + "autoCompleteRestore": bool, + "catalogCollation": "str", + "collation": "str", + "createMode": "str", + "creationDate": "2020-02-20 00:00:00", + "crossSubscriptionRestorableDroppedDatabaseId": "str", + "crossSubscriptionSourceDatabaseId": "str", + "crossSubscriptionTargetManagedInstanceId": "str", + "defaultSecondaryLocation": "str", + "earliestRestorePoint": "2020-02-20 00:00:00", + "extendedAccessibilityInfo": { + "inaccessibilityReasonDescription": "str", + "inaccessibilityReasonErrorCode": "str", + "inaccessibilityReasonKind": "str", + "inaccessibilityReasonTdeKeyUri": "str", + }, + "failoverGroupId": "str", + "isLedgerOn": bool, + "lastBackupName": "str", + "longTermRetentionBackupResourceId": "str", + "recoverableDatabaseId": "str", + "restorableDroppedDatabaseId": "str", + "restorePointInTime": "2020-02-20 00:00:00", + "sourceDatabaseId": "str", + "status": "str", + "storageContainerIdentity": "str", + "storageContainerSasToken": "str", + "storageContainerUri": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", }, - api_version="2022-08-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -87,12 +89,44 @@ def test_managed_databases_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_managed_databases_begin_delete(self, resource_group): - response = self.client.managed_databases.begin_delete( + def test_managed_databases_begin_update(self, resource_group): + response = self.client.managed_databases.begin_update( resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", - api_version="2022-08-01-preview", + parameters={ + "properties": { + "autoCompleteRestore": bool, + "catalogCollation": "str", + "collation": "str", + "createMode": "str", + "creationDate": "2020-02-20 00:00:00", + "crossSubscriptionRestorableDroppedDatabaseId": "str", + "crossSubscriptionSourceDatabaseId": "str", + "crossSubscriptionTargetManagedInstanceId": "str", + "defaultSecondaryLocation": "str", + "earliestRestorePoint": "2020-02-20 00:00:00", + "extendedAccessibilityInfo": { + "inaccessibilityReasonDescription": "str", + "inaccessibilityReasonErrorCode": "str", + "inaccessibilityReasonKind": "str", + "inaccessibilityReasonTdeKeyUri": "str", + }, + "failoverGroupId": "str", + "isLedgerOn": bool, + "lastBackupName": "str", + "longTermRetentionBackupResourceId": "str", + "recoverableDatabaseId": "str", + "restorableDroppedDatabaseId": "str", + "restorePointInTime": "2020-02-20 00:00:00", + "sourceDatabaseId": "str", + "status": "str", + "storageContainerIdentity": "str", + "storageContainerSasToken": "str", + "storageContainerUri": "str", + }, + "tags": {"str": "str"}, + }, ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -100,42 +134,27 @@ def test_managed_databases_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_managed_databases_begin_update(self, resource_group): - response = self.client.managed_databases.begin_update( + def test_managed_databases_begin_delete(self, resource_group): + response = self.client.managed_databases.begin_delete( resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", - parameters={ - "autoCompleteRestore": bool, - "catalogCollation": "str", - "collation": "str", - "createMode": "str", - "creationDate": "2020-02-20 00:00:00", - "crossSubscriptionRestorableDroppedDatabaseId": "str", - "crossSubscriptionSourceDatabaseId": "str", - "crossSubscriptionTargetManagedInstanceId": "str", - "defaultSecondaryLocation": "str", - "earliestRestorePoint": "2020-02-20 00:00:00", - "failoverGroupId": "str", - "isLedgerOn": bool, - "lastBackupName": "str", - "longTermRetentionBackupResourceId": "str", - "recoverableDatabaseId": "str", - "restorableDroppedDatabaseId": "str", - "restorePointInTime": "2020-02-20 00:00:00", - "sourceDatabaseId": "str", - "status": "str", - "storageContainerIdentity": "str", - "storageContainerSasToken": "str", - "storageContainerUri": "str", - "tags": {"str": "str"}, - }, - api_version="2022-08-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_managed_databases_list_by_instance(self, resource_group): + response = self.client.managed_databases.list_by_instance( + resource_group_name=resource_group.name, + managed_instance_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_managed_databases_begin_cancel_move(self, resource_group): @@ -144,7 +163,6 @@ def test_managed_databases_begin_cancel_move(self, resource_group): managed_instance_name="str", database_name="str", parameters={"destinationManagedDatabaseId": "str"}, - api_version="2022-08-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -158,7 +176,6 @@ def test_managed_databases_begin_complete_move(self, resource_group): managed_instance_name="str", database_name="str", parameters={"destinationManagedDatabaseId": "str"}, - api_version="2022-08-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -172,7 +189,18 @@ def test_managed_databases_begin_complete_restore(self, resource_group): managed_instance_name="str", database_name="str", parameters={"lastBackupName": "str"}, - api_version="2022-08-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_managed_databases_begin_reevaluate_inaccessible_database_state(self, resource_group): + response = self.client.managed_databases.begin_reevaluate_inaccessible_database_state( + resource_group_name=resource_group.name, + managed_instance_name="str", + database_name="str", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -186,7 +214,6 @@ def test_managed_databases_begin_start_move(self, resource_group): managed_instance_name="str", database_name="str", parameters={"destinationManagedDatabaseId": "str", "operationMode": "str"}, - api_version="2022-08-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -198,7 +225,6 @@ def test_managed_databases_list_inaccessible_by_instance(self, resource_group): response = self.client.managed_databases.list_inaccessible_by_instance( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2022-08-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_databases_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_databases_operations_async.py index 170ff5f896fe..a2cebd7cfd25 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_databases_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_databases_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,18 +19,6 @@ class TestSqlManagementManagedDatabasesOperationsAsync(AzureMgmtRecordedTestCase def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_managed_databases_list_by_instance(self, resource_group): - response = self.client.managed_databases.list_by_instance( - resource_group_name=resource_group.name, - managed_instance_name="str", - api_version="2022-08-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_managed_databases_get(self, resource_group): @@ -38,7 +26,6 @@ async def test_managed_databases_get(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", - api_version="2022-08-01-preview", ) # please add some check logic here by yourself @@ -54,34 +41,49 @@ async def test_managed_databases_begin_create_or_update(self, resource_group): database_name="str", parameters={ "location": "str", - "autoCompleteRestore": bool, - "catalogCollation": "str", - "collation": "str", - "createMode": "str", - "creationDate": "2020-02-20 00:00:00", - "crossSubscriptionRestorableDroppedDatabaseId": "str", - "crossSubscriptionSourceDatabaseId": "str", - "crossSubscriptionTargetManagedInstanceId": "str", - "defaultSecondaryLocation": "str", - "earliestRestorePoint": "2020-02-20 00:00:00", - "failoverGroupId": "str", "id": "str", - "isLedgerOn": bool, - "lastBackupName": "str", - "longTermRetentionBackupResourceId": "str", "name": "str", - "recoverableDatabaseId": "str", - "restorableDroppedDatabaseId": "str", - "restorePointInTime": "2020-02-20 00:00:00", - "sourceDatabaseId": "str", - "status": "str", - "storageContainerIdentity": "str", - "storageContainerSasToken": "str", - "storageContainerUri": "str", + "properties": { + "autoCompleteRestore": bool, + "catalogCollation": "str", + "collation": "str", + "createMode": "str", + "creationDate": "2020-02-20 00:00:00", + "crossSubscriptionRestorableDroppedDatabaseId": "str", + "crossSubscriptionSourceDatabaseId": "str", + "crossSubscriptionTargetManagedInstanceId": "str", + "defaultSecondaryLocation": "str", + "earliestRestorePoint": "2020-02-20 00:00:00", + "extendedAccessibilityInfo": { + "inaccessibilityReasonDescription": "str", + "inaccessibilityReasonErrorCode": "str", + "inaccessibilityReasonKind": "str", + "inaccessibilityReasonTdeKeyUri": "str", + }, + "failoverGroupId": "str", + "isLedgerOn": bool, + "lastBackupName": "str", + "longTermRetentionBackupResourceId": "str", + "recoverableDatabaseId": "str", + "restorableDroppedDatabaseId": "str", + "restorePointInTime": "2020-02-20 00:00:00", + "sourceDatabaseId": "str", + "status": "str", + "storageContainerIdentity": "str", + "storageContainerSasToken": "str", + "storageContainerUri": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", }, - api_version="2022-08-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -90,13 +92,45 @@ async def test_managed_databases_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_managed_databases_begin_delete(self, resource_group): + async def test_managed_databases_begin_update(self, resource_group): response = await ( - await self.client.managed_databases.begin_delete( + await self.client.managed_databases.begin_update( resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", - api_version="2022-08-01-preview", + parameters={ + "properties": { + "autoCompleteRestore": bool, + "catalogCollation": "str", + "collation": "str", + "createMode": "str", + "creationDate": "2020-02-20 00:00:00", + "crossSubscriptionRestorableDroppedDatabaseId": "str", + "crossSubscriptionSourceDatabaseId": "str", + "crossSubscriptionTargetManagedInstanceId": "str", + "defaultSecondaryLocation": "str", + "earliestRestorePoint": "2020-02-20 00:00:00", + "extendedAccessibilityInfo": { + "inaccessibilityReasonDescription": "str", + "inaccessibilityReasonErrorCode": "str", + "inaccessibilityReasonKind": "str", + "inaccessibilityReasonTdeKeyUri": "str", + }, + "failoverGroupId": "str", + "isLedgerOn": bool, + "lastBackupName": "str", + "longTermRetentionBackupResourceId": "str", + "recoverableDatabaseId": "str", + "restorableDroppedDatabaseId": "str", + "restorePointInTime": "2020-02-20 00:00:00", + "sourceDatabaseId": "str", + "status": "str", + "storageContainerIdentity": "str", + "storageContainerSasToken": "str", + "storageContainerUri": "str", + }, + "tags": {"str": "str"}, + }, ) ).result() # call '.result()' to poll until service return final result @@ -105,44 +139,29 @@ async def test_managed_databases_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_managed_databases_begin_update(self, resource_group): + async def test_managed_databases_begin_delete(self, resource_group): response = await ( - await self.client.managed_databases.begin_update( + await self.client.managed_databases.begin_delete( resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", - parameters={ - "autoCompleteRestore": bool, - "catalogCollation": "str", - "collation": "str", - "createMode": "str", - "creationDate": "2020-02-20 00:00:00", - "crossSubscriptionRestorableDroppedDatabaseId": "str", - "crossSubscriptionSourceDatabaseId": "str", - "crossSubscriptionTargetManagedInstanceId": "str", - "defaultSecondaryLocation": "str", - "earliestRestorePoint": "2020-02-20 00:00:00", - "failoverGroupId": "str", - "isLedgerOn": bool, - "lastBackupName": "str", - "longTermRetentionBackupResourceId": "str", - "recoverableDatabaseId": "str", - "restorableDroppedDatabaseId": "str", - "restorePointInTime": "2020-02-20 00:00:00", - "sourceDatabaseId": "str", - "status": "str", - "storageContainerIdentity": "str", - "storageContainerSasToken": "str", - "storageContainerUri": "str", - "tags": {"str": "str"}, - }, - api_version="2022-08-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_managed_databases_list_by_instance(self, resource_group): + response = self.client.managed_databases.list_by_instance( + resource_group_name=resource_group.name, + managed_instance_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_managed_databases_begin_cancel_move(self, resource_group): @@ -152,7 +171,6 @@ async def test_managed_databases_begin_cancel_move(self, resource_group): managed_instance_name="str", database_name="str", parameters={"destinationManagedDatabaseId": "str"}, - api_version="2022-08-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -168,7 +186,6 @@ async def test_managed_databases_begin_complete_move(self, resource_group): managed_instance_name="str", database_name="str", parameters={"destinationManagedDatabaseId": "str"}, - api_version="2022-08-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -184,7 +201,20 @@ async def test_managed_databases_begin_complete_restore(self, resource_group): managed_instance_name="str", database_name="str", parameters={"lastBackupName": "str"}, - api_version="2022-08-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_managed_databases_begin_reevaluate_inaccessible_database_state(self, resource_group): + response = await ( + await self.client.managed_databases.begin_reevaluate_inaccessible_database_state( + resource_group_name=resource_group.name, + managed_instance_name="str", + database_name="str", ) ).result() # call '.result()' to poll until service return final result @@ -200,7 +230,6 @@ async def test_managed_databases_begin_start_move(self, resource_group): managed_instance_name="str", database_name="str", parameters={"destinationManagedDatabaseId": "str", "operationMode": "str"}, - api_version="2022-08-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -213,7 +242,6 @@ async def test_managed_databases_list_inaccessible_by_instance(self, resource_gr response = self.client.managed_databases.list_inaccessible_by_instance( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2022-08-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_administrators_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_administrators_operations.py index b4720a72b44b..7b1763777d37 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_administrators_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_administrators_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,18 +18,6 @@ class TestSqlManagementManagedInstanceAdministratorsOperations(AzureMgmtRecorded def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_managed_instance_administrators_list_by_instance(self, resource_group): - response = self.client.managed_instance_administrators.list_by_instance( - resource_group_name=resource_group.name, - managed_instance_name="str", - api_version="2020-11-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_managed_instance_administrators_get(self, resource_group): @@ -37,7 +25,6 @@ def test_managed_instance_administrators_get(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", administrator_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -51,15 +38,19 @@ def test_managed_instance_administrators_begin_create_or_update(self, resource_g managed_instance_name="str", administrator_name="str", parameters={ - "administratorType": "str", "id": "str", - "login": "str", "name": "str", - "sid": "str", - "tenantId": "str", + "properties": {"administratorType": "str", "login": "str", "sid": "str", "tenantId": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -72,8 +63,18 @@ def test_managed_instance_administrators_begin_delete(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", administrator_name="str", - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_managed_instance_administrators_list_by_instance(self, resource_group): + response = self.client.managed_instance_administrators.list_by_instance( + resource_group_name=resource_group.name, + managed_instance_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_administrators_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_administrators_operations_async.py index 6199c44820f1..4959deb92d2c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_administrators_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_administrators_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,18 +19,6 @@ class TestSqlManagementManagedInstanceAdministratorsOperationsAsync(AzureMgmtRec def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_managed_instance_administrators_list_by_instance(self, resource_group): - response = self.client.managed_instance_administrators.list_by_instance( - resource_group_name=resource_group.name, - managed_instance_name="str", - api_version="2020-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_managed_instance_administrators_get(self, resource_group): @@ -38,7 +26,6 @@ async def test_managed_instance_administrators_get(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", administrator_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -53,15 +40,19 @@ async def test_managed_instance_administrators_begin_create_or_update(self, reso managed_instance_name="str", administrator_name="str", parameters={ - "administratorType": "str", "id": "str", - "login": "str", "name": "str", - "sid": "str", - "tenantId": "str", + "properties": {"administratorType": "str", "login": "str", "sid": "str", "tenantId": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -76,9 +67,19 @@ async def test_managed_instance_administrators_begin_delete(self, resource_group resource_group_name=resource_group.name, managed_instance_name="str", administrator_name="str", - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_managed_instance_administrators_list_by_instance(self, resource_group): + response = self.client.managed_instance_administrators.list_by_instance( + resource_group_name=resource_group.name, + managed_instance_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_advanced_threat_protection_settings_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_advanced_threat_protection_settings_operations.py index 8eda99ed16b3..1e1f4498682a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_advanced_threat_protection_settings_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_advanced_threat_protection_settings_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,18 +18,6 @@ class TestSqlManagementManagedInstanceAdvancedThreatProtectionSettingsOperations def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_managed_instance_advanced_threat_protection_settings_list_by_instance(self, resource_group): - response = self.client.managed_instance_advanced_threat_protection_settings.list_by_instance( - resource_group_name=resource_group.name, - managed_instance_name="str", - api_version="2022-02-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_managed_instance_advanced_threat_protection_settings_get(self, resource_group): @@ -37,7 +25,6 @@ def test_managed_instance_advanced_threat_protection_settings_get(self, resource resource_group_name=resource_group.name, managed_instance_name="str", advanced_threat_protection_name="str", - api_version="2022-02-01-preview", ) # please add some check logic here by yourself @@ -51,10 +38,9 @@ def test_managed_instance_advanced_threat_protection_settings_begin_create_or_up managed_instance_name="str", advanced_threat_protection_name="str", parameters={ - "creationTime": "2020-02-20 00:00:00", "id": "str", "name": "str", - "state": "str", + "properties": {"state": "str", "creationTime": "2020-02-20 00:00:00"}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -65,8 +51,18 @@ def test_managed_instance_advanced_threat_protection_settings_begin_create_or_up }, "type": "str", }, - api_version="2022-02-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_managed_instance_advanced_threat_protection_settings_list_by_instance(self, resource_group): + response = self.client.managed_instance_advanced_threat_protection_settings.list_by_instance( + resource_group_name=resource_group.name, + managed_instance_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_advanced_threat_protection_settings_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_advanced_threat_protection_settings_operations_async.py index 1bcad0c66602..16aaf51d9f59 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_advanced_threat_protection_settings_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_advanced_threat_protection_settings_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,18 +19,6 @@ class TestSqlManagementManagedInstanceAdvancedThreatProtectionSettingsOperations def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_managed_instance_advanced_threat_protection_settings_list_by_instance(self, resource_group): - response = self.client.managed_instance_advanced_threat_protection_settings.list_by_instance( - resource_group_name=resource_group.name, - managed_instance_name="str", - api_version="2022-02-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_managed_instance_advanced_threat_protection_settings_get(self, resource_group): @@ -38,7 +26,6 @@ async def test_managed_instance_advanced_threat_protection_settings_get(self, re resource_group_name=resource_group.name, managed_instance_name="str", advanced_threat_protection_name="str", - api_version="2022-02-01-preview", ) # please add some check logic here by yourself @@ -53,10 +40,9 @@ async def test_managed_instance_advanced_threat_protection_settings_begin_create managed_instance_name="str", advanced_threat_protection_name="str", parameters={ - "creationTime": "2020-02-20 00:00:00", "id": "str", "name": "str", - "state": "str", + "properties": {"state": "str", "creationTime": "2020-02-20 00:00:00"}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -67,9 +53,19 @@ async def test_managed_instance_advanced_threat_protection_settings_begin_create }, "type": "str", }, - api_version="2022-02-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_managed_instance_advanced_threat_protection_settings_list_by_instance(self, resource_group): + response = self.client.managed_instance_advanced_threat_protection_settings.list_by_instance( + resource_group_name=resource_group.name, + managed_instance_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_azure_ad_only_authentications_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_azure_ad_only_authentications_operations.py index f128bd387c81..40a748b68c97 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_azure_ad_only_authentications_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_azure_ad_only_authentications_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_managed_instance_azure_ad_only_authentications_get(self, resource_group resource_group_name=resource_group.name, managed_instance_name="str", authentication_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -38,8 +37,20 @@ def test_managed_instance_azure_ad_only_authentications_begin_create_or_update(s resource_group_name=resource_group.name, managed_instance_name="str", authentication_name="str", - parameters={"azureADOnlyAuthentication": bool, "id": "str", "name": "str", "type": "str"}, - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"azureADOnlyAuthentication": bool}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -52,7 +63,6 @@ def test_managed_instance_azure_ad_only_authentications_begin_delete(self, resou resource_group_name=resource_group.name, managed_instance_name="str", authentication_name="str", - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -64,7 +74,6 @@ def test_managed_instance_azure_ad_only_authentications_list_by_instance(self, r response = self.client.managed_instance_azure_ad_only_authentications.list_by_instance( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_azure_ad_only_authentications_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_azure_ad_only_authentications_operations_async.py index 18f6e5c838d5..4cff2f2cf9a6 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_azure_ad_only_authentications_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_azure_ad_only_authentications_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_managed_instance_azure_ad_only_authentications_get(self, resource resource_group_name=resource_group.name, managed_instance_name="str", authentication_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -40,8 +39,20 @@ async def test_managed_instance_azure_ad_only_authentications_begin_create_or_up resource_group_name=resource_group.name, managed_instance_name="str", authentication_name="str", - parameters={"azureADOnlyAuthentication": bool, "id": "str", "name": "str", "type": "str"}, - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"azureADOnlyAuthentication": bool}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) ).result() # call '.result()' to poll until service return final result @@ -56,7 +67,6 @@ async def test_managed_instance_azure_ad_only_authentications_begin_delete(self, resource_group_name=resource_group.name, managed_instance_name="str", authentication_name="str", - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -69,7 +79,6 @@ async def test_managed_instance_azure_ad_only_authentications_list_by_instance(s response = self.client.managed_instance_azure_ad_only_authentications.list_by_instance( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_dtcs_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_dtcs_operations.py index 54c9a0e7afd1..731092aa0909 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_dtcs_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_dtcs_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,18 +18,6 @@ class TestSqlManagementManagedInstanceDtcsOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_managed_instance_dtcs_list_by_managed_instance(self, resource_group): - response = self.client.managed_instance_dtcs.list_by_managed_instance( - resource_group_name=resource_group.name, - managed_instance_name="str", - api_version="2022-05-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_managed_instance_dtcs_get(self, resource_group): @@ -37,7 +25,6 @@ def test_managed_instance_dtcs_get(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", dtc_name="str", - api_version="2022-05-01-preview", ) # please add some check logic here by yourself @@ -51,27 +38,48 @@ def test_managed_instance_dtcs_begin_create_or_update(self, resource_group): managed_instance_name="str", dtc_name="str", parameters={ - "dtcEnabled": bool, - "dtcHostNameDnsSuffix": "str", - "externalDnsSuffixSearchList": ["str"], "id": "str", "name": "str", - "provisioningState": "str", - "securitySettings": { - "snaLu6point2TransactionsEnabled": bool, - "transactionManagerCommunicationSettings": { - "allowInboundEnabled": bool, - "allowOutboundEnabled": bool, - "authentication": "str", + "properties": { + "dtcEnabled": bool, + "dtcHostNameDnsSuffix": "str", + "externalDnsSuffixSearchList": ["str"], + "fqdnEnabled": bool, + "provisioningState": "str", + "securitySettings": { + "snaLu6point2TransactionsEnabled": bool, + "transactionManagerCommunicationSettings": { + "allowInboundEnabled": bool, + "allowOutboundEnabled": bool, + "authentication": "str", + }, + "xaTransactionsDefaultTimeout": 0, + "xaTransactionsEnabled": bool, + "xaTransactionsMaximumTimeout": 0, }, - "xaTransactionsDefaultTimeout": 0, - "xaTransactionsEnabled": bool, - "xaTransactionsMaximumTimeout": 0, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", }, "type": "str", }, - api_version="2022-05-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_managed_instance_dtcs_list_by_managed_instance(self, resource_group): + response = self.client.managed_instance_dtcs.list_by_managed_instance( + resource_group_name=resource_group.name, + managed_instance_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_dtcs_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_dtcs_operations_async.py index dce21860d607..4d9938afa833 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_dtcs_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_dtcs_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,18 +19,6 @@ class TestSqlManagementManagedInstanceDtcsOperationsAsync(AzureMgmtRecordedTestC def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_managed_instance_dtcs_list_by_managed_instance(self, resource_group): - response = self.client.managed_instance_dtcs.list_by_managed_instance( - resource_group_name=resource_group.name, - managed_instance_name="str", - api_version="2022-05-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_managed_instance_dtcs_get(self, resource_group): @@ -38,7 +26,6 @@ async def test_managed_instance_dtcs_get(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", dtc_name="str", - api_version="2022-05-01-preview", ) # please add some check logic here by yourself @@ -53,28 +40,49 @@ async def test_managed_instance_dtcs_begin_create_or_update(self, resource_group managed_instance_name="str", dtc_name="str", parameters={ - "dtcEnabled": bool, - "dtcHostNameDnsSuffix": "str", - "externalDnsSuffixSearchList": ["str"], "id": "str", "name": "str", - "provisioningState": "str", - "securitySettings": { - "snaLu6point2TransactionsEnabled": bool, - "transactionManagerCommunicationSettings": { - "allowInboundEnabled": bool, - "allowOutboundEnabled": bool, - "authentication": "str", + "properties": { + "dtcEnabled": bool, + "dtcHostNameDnsSuffix": "str", + "externalDnsSuffixSearchList": ["str"], + "fqdnEnabled": bool, + "provisioningState": "str", + "securitySettings": { + "snaLu6point2TransactionsEnabled": bool, + "transactionManagerCommunicationSettings": { + "allowInboundEnabled": bool, + "allowOutboundEnabled": bool, + "authentication": "str", + }, + "xaTransactionsDefaultTimeout": 0, + "xaTransactionsEnabled": bool, + "xaTransactionsMaximumTimeout": 0, }, - "xaTransactionsDefaultTimeout": 0, - "xaTransactionsEnabled": bool, - "xaTransactionsMaximumTimeout": 0, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", }, "type": "str", }, - api_version="2022-05-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_managed_instance_dtcs_list_by_managed_instance(self, resource_group): + response = self.client.managed_instance_dtcs.list_by_managed_instance( + resource_group_name=resource_group.name, + managed_instance_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_encryption_protectors_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_encryption_protectors_operations.py index 62c55bcfe71f..4c9ef1262287 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_encryption_protectors_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_encryption_protectors_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,61 +20,67 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_managed_instance_encryption_protectors_begin_revalidate(self, resource_group): - response = self.client.managed_instance_encryption_protectors.begin_revalidate( + def test_managed_instance_encryption_protectors_get(self, resource_group): + response = self.client.managed_instance_encryption_protectors.get( resource_group_name=resource_group.name, managed_instance_name="str", encryption_protector_name="str", - api_version="2020-11-01-preview", - ).result() # call '.result()' to poll until service return final result + ) # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_managed_instance_encryption_protectors_list_by_instance(self, resource_group): - response = self.client.managed_instance_encryption_protectors.list_by_instance( + def test_managed_instance_encryption_protectors_begin_create_or_update(self, resource_group): + response = self.client.managed_instance_encryption_protectors.begin_create_or_update( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2020-11-01-preview", - ) - result = [r for r in response] + encryption_protector_name="str", + parameters={ + "id": "str", + "kind": "str", + "name": "str", + "properties": { + "serverKeyType": "str", + "autoRotationEnabled": bool, + "serverKeyName": "str", + "thumbprint": "str", + "uri": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ).result() # call '.result()' to poll until service return final result + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_managed_instance_encryption_protectors_get(self, resource_group): - response = self.client.managed_instance_encryption_protectors.get( + def test_managed_instance_encryption_protectors_list_by_instance(self, resource_group): + response = self.client.managed_instance_encryption_protectors.list_by_instance( resource_group_name=resource_group.name, managed_instance_name="str", - encryption_protector_name="str", - api_version="2020-11-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_managed_instance_encryption_protectors_begin_create_or_update(self, resource_group): - response = self.client.managed_instance_encryption_protectors.begin_create_or_update( + def test_managed_instance_encryption_protectors_begin_revalidate(self, resource_group): + response = self.client.managed_instance_encryption_protectors.begin_revalidate( resource_group_name=resource_group.name, managed_instance_name="str", encryption_protector_name="str", - parameters={ - "autoRotationEnabled": bool, - "id": "str", - "kind": "str", - "name": "str", - "serverKeyName": "str", - "serverKeyType": "str", - "thumbprint": "str", - "type": "str", - "uri": "str", - }, - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_encryption_protectors_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_encryption_protectors_operations_async.py index efecbf45e81c..4181e560a4cc 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_encryption_protectors_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_encryption_protectors_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,13 +21,45 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_managed_instance_encryption_protectors_begin_revalidate(self, resource_group): + async def test_managed_instance_encryption_protectors_get(self, resource_group): + response = await self.client.managed_instance_encryption_protectors.get( + resource_group_name=resource_group.name, + managed_instance_name="str", + encryption_protector_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_managed_instance_encryption_protectors_begin_create_or_update(self, resource_group): response = await ( - await self.client.managed_instance_encryption_protectors.begin_revalidate( + await self.client.managed_instance_encryption_protectors.begin_create_or_update( resource_group_name=resource_group.name, managed_instance_name="str", encryption_protector_name="str", - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "kind": "str", + "name": "str", + "properties": { + "serverKeyType": "str", + "autoRotationEnabled": bool, + "serverKeyName": "str", + "thumbprint": "str", + "uri": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) ).result() # call '.result()' to poll until service return final result @@ -40,7 +72,6 @@ async def test_managed_instance_encryption_protectors_list_by_instance(self, res response = self.client.managed_instance_encryption_protectors.list_by_instance( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself @@ -48,37 +79,12 @@ async def test_managed_instance_encryption_protectors_list_by_instance(self, res @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_managed_instance_encryption_protectors_get(self, resource_group): - response = await self.client.managed_instance_encryption_protectors.get( - resource_group_name=resource_group.name, - managed_instance_name="str", - encryption_protector_name="str", - api_version="2020-11-01-preview", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_managed_instance_encryption_protectors_begin_create_or_update(self, resource_group): + async def test_managed_instance_encryption_protectors_begin_revalidate(self, resource_group): response = await ( - await self.client.managed_instance_encryption_protectors.begin_create_or_update( + await self.client.managed_instance_encryption_protectors.begin_revalidate( resource_group_name=resource_group.name, managed_instance_name="str", encryption_protector_name="str", - parameters={ - "autoRotationEnabled": bool, - "id": "str", - "kind": "str", - "name": "str", - "serverKeyName": "str", - "serverKeyType": "str", - "thumbprint": "str", - "type": "str", - "uri": "str", - }, - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_keys_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_keys_operations.py index cb49ae5331e0..6b785d2eca65 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_keys_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_keys_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,18 +18,6 @@ class TestSqlManagementManagedInstanceKeysOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_managed_instance_keys_list_by_instance(self, resource_group): - response = self.client.managed_instance_keys.list_by_instance( - resource_group_name=resource_group.name, - managed_instance_name="str", - api_version="2020-11-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_managed_instance_keys_get(self, resource_group): @@ -37,7 +25,6 @@ def test_managed_instance_keys_get(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", key_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -51,17 +38,26 @@ def test_managed_instance_keys_begin_create_or_update(self, resource_group): managed_instance_name="str", key_name="str", parameters={ - "autoRotationEnabled": bool, - "creationDate": "2020-02-20 00:00:00", "id": "str", "kind": "str", "name": "str", - "serverKeyType": "str", - "thumbprint": "str", + "properties": { + "serverKeyType": "str", + "autoRotationEnabled": bool, + "creationDate": "2020-02-20 00:00:00", + "thumbprint": "str", + "uri": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "uri": "str", }, - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -74,8 +70,18 @@ def test_managed_instance_keys_begin_delete(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", key_name="str", - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_managed_instance_keys_list_by_instance(self, resource_group): + response = self.client.managed_instance_keys.list_by_instance( + resource_group_name=resource_group.name, + managed_instance_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_keys_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_keys_operations_async.py index 9d7f8c1582c3..cc7fb95206e3 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_keys_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_keys_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,18 +19,6 @@ class TestSqlManagementManagedInstanceKeysOperationsAsync(AzureMgmtRecordedTestC def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_managed_instance_keys_list_by_instance(self, resource_group): - response = self.client.managed_instance_keys.list_by_instance( - resource_group_name=resource_group.name, - managed_instance_name="str", - api_version="2020-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_managed_instance_keys_get(self, resource_group): @@ -38,7 +26,6 @@ async def test_managed_instance_keys_get(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", key_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -53,17 +40,26 @@ async def test_managed_instance_keys_begin_create_or_update(self, resource_group managed_instance_name="str", key_name="str", parameters={ - "autoRotationEnabled": bool, - "creationDate": "2020-02-20 00:00:00", "id": "str", "kind": "str", "name": "str", - "serverKeyType": "str", - "thumbprint": "str", + "properties": { + "serverKeyType": "str", + "autoRotationEnabled": bool, + "creationDate": "2020-02-20 00:00:00", + "thumbprint": "str", + "uri": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "uri": "str", }, - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -78,9 +74,19 @@ async def test_managed_instance_keys_begin_delete(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", key_name="str", - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_managed_instance_keys_list_by_instance(self, resource_group): + response = self.client.managed_instance_keys.list_by_instance( + resource_group_name=resource_group.name, + managed_instance_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_long_term_retention_policies_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_long_term_retention_policies_operations.py index 626aaf821d2c..9cd23c6250e5 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_long_term_retention_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_long_term_retention_policies_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ def test_managed_instance_long_term_retention_policies_get(self, resource_group) managed_instance_name="str", database_name="str", policy_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -42,14 +41,37 @@ def test_managed_instance_long_term_retention_policies_begin_create_or_update(se policy_name="str", parameters={ "id": "str", - "monthlyRetention": "str", "name": "str", + "properties": { + "backupStorageAccessTier": "str", + "monthlyRetention": "str", + "weekOfYear": 0, + "weeklyRetention": "str", + "yearlyRetention": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "weekOfYear": 0, - "weeklyRetention": "str", - "yearlyRetention": "str", }, - api_version="2020-11-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_managed_instance_long_term_retention_policies_begin_delete(self, resource_group): + response = self.client.managed_instance_long_term_retention_policies.begin_delete( + resource_group_name=resource_group.name, + managed_instance_name="str", + database_name="str", + policy_name="str", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -62,7 +84,6 @@ def test_managed_instance_long_term_retention_policies_list_by_database(self, re resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_long_term_retention_policies_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_long_term_retention_policies_operations_async.py index d344d9367a74..26cc1c970588 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_long_term_retention_policies_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_long_term_retention_policies_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -27,7 +27,6 @@ async def test_managed_instance_long_term_retention_policies_get(self, resource_ managed_instance_name="str", database_name="str", policy_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -44,14 +43,39 @@ async def test_managed_instance_long_term_retention_policies_begin_create_or_upd policy_name="str", parameters={ "id": "str", - "monthlyRetention": "str", "name": "str", + "properties": { + "backupStorageAccessTier": "str", + "monthlyRetention": "str", + "weekOfYear": 0, + "weeklyRetention": "str", + "yearlyRetention": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "weekOfYear": 0, - "weeklyRetention": "str", - "yearlyRetention": "str", }, - api_version="2020-11-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_managed_instance_long_term_retention_policies_begin_delete(self, resource_group): + response = await ( + await self.client.managed_instance_long_term_retention_policies.begin_delete( + resource_group_name=resource_group.name, + managed_instance_name="str", + database_name="str", + policy_name="str", ) ).result() # call '.result()' to poll until service return final result @@ -65,7 +89,6 @@ async def test_managed_instance_long_term_retention_policies_list_by_database(se resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_operations_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_operations_operations.py index 557af70d53c7..fbd3afcbc81c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_operations_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_operations_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,26 +20,24 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_managed_instance_operations_list_by_managed_instance(self, resource_group): - response = self.client.managed_instance_operations.list_by_managed_instance( + def test_managed_instance_operations_get(self, resource_group): + response = self.client.managed_instance_operations.get( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2020-11-01-preview", + operation_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_managed_instance_operations_get(self, resource_group): - response = self.client.managed_instance_operations.get( + def test_managed_instance_operations_list_by_managed_instance(self, resource_group): + response = self.client.managed_instance_operations.list_by_managed_instance( resource_group_name=resource_group.name, managed_instance_name="str", - operation_id="str", - api_version="2020-11-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... @@ -50,7 +48,6 @@ def test_managed_instance_operations_cancel(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", operation_id="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_operations_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_operations_operations_async.py index 1b948c0c76b4..70bcc4bc05f7 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_operations_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_operations_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,26 +21,24 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_managed_instance_operations_list_by_managed_instance(self, resource_group): - response = self.client.managed_instance_operations.list_by_managed_instance( + async def test_managed_instance_operations_get(self, resource_group): + response = await self.client.managed_instance_operations.get( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2020-11-01-preview", + operation_id="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_managed_instance_operations_get(self, resource_group): - response = await self.client.managed_instance_operations.get( + async def test_managed_instance_operations_list_by_managed_instance(self, resource_group): + response = self.client.managed_instance_operations.list_by_managed_instance( resource_group_name=resource_group.name, managed_instance_name="str", - operation_id="str", - api_version="2020-11-01-preview", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... @@ -51,7 +49,6 @@ async def test_managed_instance_operations_cancel(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", operation_id="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_private_endpoint_connections_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_private_endpoint_connections_operations.py index f22c0f136da1..4009e7db9762 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_private_endpoint_connections_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_private_endpoint_connections_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_managed_instance_private_endpoint_connections_get(self, resource_group) resource_group_name=resource_group.name, managed_instance_name="str", private_endpoint_connection_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -41,12 +40,25 @@ def test_managed_instance_private_endpoint_connections_begin_create_or_update(se parameters={ "id": "str", "name": "str", - "privateEndpoint": {"id": "str"}, - "privateLinkServiceConnectionState": {"description": "str", "status": "str", "actionsRequired": "str"}, - "provisioningState": "str", + "properties": { + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "description": "str", + "status": "str", + "actionsRequired": "str", + }, + "provisioningState": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -59,7 +71,6 @@ def test_managed_instance_private_endpoint_connections_begin_delete(self, resour resource_group_name=resource_group.name, managed_instance_name="str", private_endpoint_connection_name="str", - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -71,7 +82,6 @@ def test_managed_instance_private_endpoint_connections_list_by_managed_instance( response = self.client.managed_instance_private_endpoint_connections.list_by_managed_instance( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_private_endpoint_connections_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_private_endpoint_connections_operations_async.py index 9923e9479647..0f1491d1c04b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_private_endpoint_connections_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_private_endpoint_connections_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_managed_instance_private_endpoint_connections_get(self, resource_ resource_group_name=resource_group.name, managed_instance_name="str", private_endpoint_connection_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -43,16 +42,25 @@ async def test_managed_instance_private_endpoint_connections_begin_create_or_upd parameters={ "id": "str", "name": "str", - "privateEndpoint": {"id": "str"}, - "privateLinkServiceConnectionState": { - "description": "str", - "status": "str", - "actionsRequired": "str", + "properties": { + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "description": "str", + "status": "str", + "actionsRequired": "str", + }, + "provisioningState": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", }, - "provisioningState": "str", "type": "str", }, - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -67,7 +75,6 @@ async def test_managed_instance_private_endpoint_connections_begin_delete(self, resource_group_name=resource_group.name, managed_instance_name="str", private_endpoint_connection_name="str", - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -80,7 +87,6 @@ async def test_managed_instance_private_endpoint_connections_list_by_managed_ins response = self.client.managed_instance_private_endpoint_connections.list_by_managed_instance( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_private_link_resources_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_private_link_resources_operations.py index 3bdb2153e9f6..4ce41edee25b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_private_link_resources_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_private_link_resources_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,25 +20,23 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_managed_instance_private_link_resources_list_by_managed_instance(self, resource_group): - response = self.client.managed_instance_private_link_resources.list_by_managed_instance( + def test_managed_instance_private_link_resources_get(self, resource_group): + response = self.client.managed_instance_private_link_resources.get( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2020-11-01-preview", + group_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_managed_instance_private_link_resources_get(self, resource_group): - response = self.client.managed_instance_private_link_resources.get( + def test_managed_instance_private_link_resources_list_by_managed_instance(self, resource_group): + response = self.client.managed_instance_private_link_resources.list_by_managed_instance( resource_group_name=resource_group.name, managed_instance_name="str", - group_name="str", - api_version="2020-11-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_private_link_resources_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_private_link_resources_operations_async.py index a6ca8fb44025..33184af705b1 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_private_link_resources_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_private_link_resources_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,25 +21,23 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_managed_instance_private_link_resources_list_by_managed_instance(self, resource_group): - response = self.client.managed_instance_private_link_resources.list_by_managed_instance( + async def test_managed_instance_private_link_resources_get(self, resource_group): + response = await self.client.managed_instance_private_link_resources.get( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2020-11-01-preview", + group_name="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_managed_instance_private_link_resources_get(self, resource_group): - response = await self.client.managed_instance_private_link_resources.get( + async def test_managed_instance_private_link_resources_list_by_managed_instance(self, resource_group): + response = self.client.managed_instance_private_link_resources.list_by_managed_instance( resource_group_name=resource_group.name, managed_instance_name="str", - group_name="str", - api_version="2020-11-01-preview", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_tde_certificates_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_tde_certificates_operations.py index 8ca01bb33bba..7e2e251f4263 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_tde_certificates_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_tde_certificates_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,8 +24,20 @@ def test_managed_instance_tde_certificates_begin_create(self, resource_group): response = self.client.managed_instance_tde_certificates.begin_create( resource_group_name=resource_group.name, managed_instance_name="str", - parameters={"certPassword": "str", "id": "str", "name": "str", "privateBlob": "str", "type": "str"}, - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"privateBlob": "str", "certPassword": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_tde_certificates_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_tde_certificates_operations_async.py index eec00fb81aef..dbee5e1963fc 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_tde_certificates_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_tde_certificates_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,8 +26,20 @@ async def test_managed_instance_tde_certificates_begin_create(self, resource_gro await self.client.managed_instance_tde_certificates.begin_create( resource_group_name=resource_group.name, managed_instance_name="str", - parameters={"certPassword": "str", "id": "str", "name": "str", "privateBlob": "str", "type": "str"}, - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"privateBlob": "str", "certPassword": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) ).result() # call '.result()' to poll until service return final result diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_vulnerability_assessments_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_vulnerability_assessments_operations.py index dd88325274b6..6cfe7dd02309 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_vulnerability_assessments_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_vulnerability_assessments_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_managed_instance_vulnerability_assessments_get(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", vulnerability_assessment_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -41,13 +40,22 @@ def test_managed_instance_vulnerability_assessments_create_or_update(self, resou parameters={ "id": "str", "name": "str", - "recurringScans": {"emailSubscriptionAdmins": True, "emails": ["str"], "isEnabled": bool}, - "storageAccountAccessKey": "str", - "storageContainerPath": "str", - "storageContainerSasKey": "str", + "properties": { + "storageContainerPath": "str", + "recurringScans": {"emailSubscriptionAdmins": bool, "emails": ["str"], "isEnabled": bool}, + "storageAccountAccessKey": "str", + "storageContainerSasKey": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -60,7 +68,6 @@ def test_managed_instance_vulnerability_assessments_delete(self, resource_group) resource_group_name=resource_group.name, managed_instance_name="str", vulnerability_assessment_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -72,7 +79,6 @@ def test_managed_instance_vulnerability_assessments_list_by_instance(self, resou response = self.client.managed_instance_vulnerability_assessments.list_by_instance( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_vulnerability_assessments_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_vulnerability_assessments_operations_async.py index 1f60a4ff0ca4..9a7caa200d51 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_vulnerability_assessments_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instance_vulnerability_assessments_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_managed_instance_vulnerability_assessments_get(self, resource_gro resource_group_name=resource_group.name, managed_instance_name="str", vulnerability_assessment_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -42,13 +41,22 @@ async def test_managed_instance_vulnerability_assessments_create_or_update(self, parameters={ "id": "str", "name": "str", - "recurringScans": {"emailSubscriptionAdmins": True, "emails": ["str"], "isEnabled": bool}, - "storageAccountAccessKey": "str", - "storageContainerPath": "str", - "storageContainerSasKey": "str", + "properties": { + "storageContainerPath": "str", + "recurringScans": {"emailSubscriptionAdmins": bool, "emails": ["str"], "isEnabled": bool}, + "storageAccountAccessKey": "str", + "storageContainerSasKey": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -61,7 +69,6 @@ async def test_managed_instance_vulnerability_assessments_delete(self, resource_ resource_group_name=resource_group.name, managed_instance_name="str", vulnerability_assessment_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -73,7 +80,6 @@ async def test_managed_instance_vulnerability_assessments_list_by_instance(self, response = self.client.managed_instance_vulnerability_assessments.list_by_instance( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instances_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instances_operations.py index f230d1871216..35235e031ff6 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instances_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instances_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,46 +18,12 @@ class TestSqlManagementManagedInstancesOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_managed_instances_list(self, resource_group): - response = self.client.managed_instances.list( - api_version="2023-05-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_managed_instances_list_by_instance_pool(self, resource_group): - response = self.client.managed_instances.list_by_instance_pool( - resource_group_name=resource_group.name, - instance_pool_name="str", - api_version="2023-05-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_managed_instances_list_by_resource_group(self, resource_group): - response = self.client.managed_instances.list_by_resource_group( - resource_group_name=resource_group.name, - api_version="2023-05-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_managed_instances_get(self, resource_group): response = self.client.managed_instances.get( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2023-05-01-preview", ) # please add some check logic here by yourself @@ -71,27 +37,6 @@ def test_managed_instances_begin_create_or_update(self, resource_group): managed_instance_name="str", parameters={ "location": "str", - "administratorLogin": "str", - "administratorLoginPassword": "str", - "administrators": { - "administratorType": "str", - "azureADOnlyAuthentication": bool, - "login": "str", - "principalType": "str", - "sid": "str", - "tenantId": "str", - }, - "authenticationMetadata": "str", - "collation": "str", - "createTime": "2020-02-20 00:00:00", - "currentBackupStorageRedundancy": "str", - "databaseFormat": "str", - "dnsZone": "str", - "dnsZonePartner": "str", - "externalGovernanceStatus": "str", - "fullyQualifiedDomainName": "str", - "hybridSecondaryUsage": "str", - "hybridSecondaryUsageDetected": "str", "id": "str", "identity": { "principalId": "str", @@ -99,63 +44,83 @@ def test_managed_instances_begin_create_or_update(self, resource_group): "type": "str", "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, }, - "instancePoolId": "str", - "isGeneralPurposeV2": bool, - "keyId": "str", - "licenseType": "str", - "maintenanceConfigurationId": "str", - "managedInstanceCreateMode": "str", - "minimalTlsVersion": "str", "name": "str", - "pricingModel": "str", - "primaryUserAssignedIdentityId": "str", - "privateEndpointConnections": [ - { - "id": "str", - "properties": { - "privateEndpoint": {"id": "str"}, - "privateLinkServiceConnectionState": { - "description": "str", - "status": "str", - "actionsRequired": "str", + "properties": { + "administratorLogin": "str", + "administratorLoginPassword": "str", + "administrators": { + "administratorType": "str", + "azureADOnlyAuthentication": bool, + "login": "str", + "principalType": "str", + "sid": "str", + "tenantId": "str", + }, + "authenticationMetadata": "str", + "collation": "str", + "createTime": "2020-02-20 00:00:00", + "currentBackupStorageRedundancy": "str", + "databaseFormat": "str", + "dnsZone": "str", + "dnsZonePartner": "str", + "externalGovernanceStatus": "str", + "fullyQualifiedDomainName": "str", + "hybridSecondaryUsage": "str", + "hybridSecondaryUsageDetected": "str", + "instancePoolId": "str", + "isGeneralPurposeV2": bool, + "keyId": "str", + "licenseType": "str", + "maintenanceConfigurationId": "str", + "managedInstanceCreateMode": "str", + "memorySizeInGB": 0, + "minimalTlsVersion": "str", + "pricingModel": "str", + "primaryUserAssignedIdentityId": "str", + "privateEndpointConnections": [ + { + "id": "str", + "properties": { + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "description": "str", + "status": "str", + "actionsRequired": "str", + }, + "provisioningState": "str", }, - "provisioningState": "str", - }, - } - ], - "provisioningState": "str", - "proxyOverride": "str", - "publicDataEndpointEnabled": bool, - "requestedBackupStorageRedundancy": "str", - "restorePointInTime": "2020-02-20 00:00:00", - "servicePrincipal": {"clientId": "str", "principalId": "str", "tenantId": "str", "type": "str"}, + } + ], + "provisioningState": "str", + "proxyOverride": "str", + "publicDataEndpointEnabled": bool, + "requestedBackupStorageRedundancy": "str", + "requestedLogicalAvailabilityZone": "str", + "restorePointInTime": "2020-02-20 00:00:00", + "servicePrincipal": {"clientId": "str", "principalId": "str", "tenantId": "str", "type": "str"}, + "sourceManagedInstanceId": "str", + "state": "str", + "storageIOps": 0, + "storageSizeInGB": 0, + "storageThroughputMBps": 0, + "subnetId": "str", + "timezoneId": "str", + "vCores": 0, + "virtualClusterId": "str", + "zoneRedundant": bool, + }, "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, - "sourceManagedInstanceId": "str", - "state": "str", - "storageIOps": 0, - "storageSizeInGB": 0, - "storageThroughputMBps": 0, - "subnetId": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, - "timezoneId": "str", "type": "str", - "vCores": 0, - "virtualClusterId": "str", - "zoneRedundant": bool, }, - api_version="2023-05-01-preview", - ).result() # call '.result()' to poll until service return final result - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_managed_instances_begin_delete(self, resource_group): - response = self.client.managed_instances.begin_delete( - resource_group_name=resource_group.name, - managed_instance_name="str", - api_version="2023-05-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -168,88 +133,119 @@ def test_managed_instances_begin_update(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", parameters={ - "administratorLogin": "str", - "administratorLoginPassword": "str", - "administrators": { - "administratorType": "str", - "azureADOnlyAuthentication": bool, - "login": "str", - "principalType": "str", - "sid": "str", - "tenantId": "str", - }, - "authenticationMetadata": "str", - "collation": "str", - "createTime": "2020-02-20 00:00:00", - "currentBackupStorageRedundancy": "str", - "databaseFormat": "str", - "dnsZone": "str", - "dnsZonePartner": "str", - "externalGovernanceStatus": "str", - "fullyQualifiedDomainName": "str", - "hybridSecondaryUsage": "str", - "hybridSecondaryUsageDetected": "str", "identity": { "principalId": "str", "tenantId": "str", "type": "str", "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, }, - "instancePoolId": "str", - "isGeneralPurposeV2": bool, - "keyId": "str", - "licenseType": "str", - "maintenanceConfigurationId": "str", - "managedInstanceCreateMode": "str", - "minimalTlsVersion": "str", - "pricingModel": "str", - "primaryUserAssignedIdentityId": "str", - "privateEndpointConnections": [ - { - "id": "str", - "properties": { - "privateEndpoint": {"id": "str"}, - "privateLinkServiceConnectionState": { - "description": "str", - "status": "str", - "actionsRequired": "str", + "properties": { + "administratorLogin": "str", + "administratorLoginPassword": "str", + "administrators": { + "administratorType": "str", + "azureADOnlyAuthentication": bool, + "login": "str", + "principalType": "str", + "sid": "str", + "tenantId": "str", + }, + "authenticationMetadata": "str", + "collation": "str", + "createTime": "2020-02-20 00:00:00", + "currentBackupStorageRedundancy": "str", + "databaseFormat": "str", + "dnsZone": "str", + "dnsZonePartner": "str", + "externalGovernanceStatus": "str", + "fullyQualifiedDomainName": "str", + "hybridSecondaryUsage": "str", + "hybridSecondaryUsageDetected": "str", + "instancePoolId": "str", + "isGeneralPurposeV2": bool, + "keyId": "str", + "licenseType": "str", + "maintenanceConfigurationId": "str", + "managedInstanceCreateMode": "str", + "memorySizeInGB": 0, + "minimalTlsVersion": "str", + "pricingModel": "str", + "primaryUserAssignedIdentityId": "str", + "privateEndpointConnections": [ + { + "id": "str", + "properties": { + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "description": "str", + "status": "str", + "actionsRequired": "str", + }, + "provisioningState": "str", }, - "provisioningState": "str", - }, - } - ], - "provisioningState": "str", - "proxyOverride": "str", - "publicDataEndpointEnabled": bool, - "requestedBackupStorageRedundancy": "str", - "restorePointInTime": "2020-02-20 00:00:00", - "servicePrincipal": {"clientId": "str", "principalId": "str", "tenantId": "str", "type": "str"}, + } + ], + "provisioningState": "str", + "proxyOverride": "str", + "publicDataEndpointEnabled": bool, + "requestedBackupStorageRedundancy": "str", + "requestedLogicalAvailabilityZone": "str", + "restorePointInTime": "2020-02-20 00:00:00", + "servicePrincipal": {"clientId": "str", "principalId": "str", "tenantId": "str", "type": "str"}, + "sourceManagedInstanceId": "str", + "state": "str", + "storageIOps": 0, + "storageSizeInGB": 0, + "storageThroughputMBps": 0, + "subnetId": "str", + "timezoneId": "str", + "vCores": 0, + "virtualClusterId": "str", + "zoneRedundant": bool, + }, "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, - "sourceManagedInstanceId": "str", - "state": "str", - "storageIOps": 0, - "storageSizeInGB": 0, - "storageThroughputMBps": 0, - "subnetId": "str", "tags": {"str": "str"}, - "timezoneId": "str", - "vCores": 0, - "virtualClusterId": "str", - "zoneRedundant": bool, }, - api_version="2023-05-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_managed_instances_begin_delete(self, resource_group): + response = self.client.managed_instances.begin_delete( + resource_group_name=resource_group.name, + managed_instance_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_managed_instances_list_by_resource_group(self, resource_group): + response = self.client.managed_instances.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_managed_instances_list(self, resource_group): + response = self.client.managed_instances.list() + result = [r for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_managed_instances_begin_failover(self, resource_group): response = self.client.managed_instances.begin_failover( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2023-05-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -261,19 +257,28 @@ def test_managed_instances_list_outbound_network_dependencies_by_managed_instanc response = self.client.managed_instances.list_outbound_network_dependencies_by_managed_instance( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2023-05-01-preview", ) result = [r for r in response] # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_managed_instances_begin_reevaluate_inaccessible_database_state(self, resource_group): + response = self.client.managed_instances.begin_reevaluate_inaccessible_database_state( + resource_group_name=resource_group.name, + managed_instance_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_managed_instances_begin_refresh_status(self, resource_group): response = self.client.managed_instances.begin_refresh_status( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2023-05-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -285,7 +290,6 @@ def test_managed_instances_begin_start(self, resource_group): response = self.client.managed_instances.begin_start( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2023-05-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -297,7 +301,6 @@ def test_managed_instances_begin_stop(self, resource_group): response = self.client.managed_instances.begin_stop( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2023-05-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -309,7 +312,29 @@ def test_managed_instances_list_by_managed_instance(self, resource_group): response = self.client.managed_instances.list_by_managed_instance( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2023-05-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_managed_instances_begin_validate_azure_key_vault_encryption_key(self, resource_group): + response = self.client.managed_instances.begin_validate_azure_key_vault_encryption_key( + resource_group_name=resource_group.name, + managed_instance_name="str", + parameters={"tdeKeyUri": "str"}, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_managed_instances_list_by_instance_pool(self, resource_group): + response = self.client.managed_instances.list_by_instance_pool( + resource_group_name=resource_group.name, + instance_pool_name="str", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instances_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instances_operations_async.py index 32253e5e0f49..40fa0e69f32a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instances_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_instances_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,46 +19,12 @@ class TestSqlManagementManagedInstancesOperationsAsync(AzureMgmtRecordedTestCase def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_managed_instances_list(self, resource_group): - response = self.client.managed_instances.list( - api_version="2023-05-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_managed_instances_list_by_instance_pool(self, resource_group): - response = self.client.managed_instances.list_by_instance_pool( - resource_group_name=resource_group.name, - instance_pool_name="str", - api_version="2023-05-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_managed_instances_list_by_resource_group(self, resource_group): - response = self.client.managed_instances.list_by_resource_group( - resource_group_name=resource_group.name, - api_version="2023-05-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_managed_instances_get(self, resource_group): response = await self.client.managed_instances.get( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2023-05-01-preview", ) # please add some check logic here by yourself @@ -73,27 +39,6 @@ async def test_managed_instances_begin_create_or_update(self, resource_group): managed_instance_name="str", parameters={ "location": "str", - "administratorLogin": "str", - "administratorLoginPassword": "str", - "administrators": { - "administratorType": "str", - "azureADOnlyAuthentication": bool, - "login": "str", - "principalType": "str", - "sid": "str", - "tenantId": "str", - }, - "authenticationMetadata": "str", - "collation": "str", - "createTime": "2020-02-20 00:00:00", - "currentBackupStorageRedundancy": "str", - "databaseFormat": "str", - "dnsZone": "str", - "dnsZonePartner": "str", - "externalGovernanceStatus": "str", - "fullyQualifiedDomainName": "str", - "hybridSecondaryUsage": "str", - "hybridSecondaryUsageDetected": "str", "id": "str", "identity": { "principalId": "str", @@ -101,65 +46,83 @@ async def test_managed_instances_begin_create_or_update(self, resource_group): "type": "str", "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, }, - "instancePoolId": "str", - "isGeneralPurposeV2": bool, - "keyId": "str", - "licenseType": "str", - "maintenanceConfigurationId": "str", - "managedInstanceCreateMode": "str", - "minimalTlsVersion": "str", "name": "str", - "pricingModel": "str", - "primaryUserAssignedIdentityId": "str", - "privateEndpointConnections": [ - { - "id": "str", - "properties": { - "privateEndpoint": {"id": "str"}, - "privateLinkServiceConnectionState": { - "description": "str", - "status": "str", - "actionsRequired": "str", + "properties": { + "administratorLogin": "str", + "administratorLoginPassword": "str", + "administrators": { + "administratorType": "str", + "azureADOnlyAuthentication": bool, + "login": "str", + "principalType": "str", + "sid": "str", + "tenantId": "str", + }, + "authenticationMetadata": "str", + "collation": "str", + "createTime": "2020-02-20 00:00:00", + "currentBackupStorageRedundancy": "str", + "databaseFormat": "str", + "dnsZone": "str", + "dnsZonePartner": "str", + "externalGovernanceStatus": "str", + "fullyQualifiedDomainName": "str", + "hybridSecondaryUsage": "str", + "hybridSecondaryUsageDetected": "str", + "instancePoolId": "str", + "isGeneralPurposeV2": bool, + "keyId": "str", + "licenseType": "str", + "maintenanceConfigurationId": "str", + "managedInstanceCreateMode": "str", + "memorySizeInGB": 0, + "minimalTlsVersion": "str", + "pricingModel": "str", + "primaryUserAssignedIdentityId": "str", + "privateEndpointConnections": [ + { + "id": "str", + "properties": { + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "description": "str", + "status": "str", + "actionsRequired": "str", + }, + "provisioningState": "str", }, - "provisioningState": "str", - }, - } - ], - "provisioningState": "str", - "proxyOverride": "str", - "publicDataEndpointEnabled": bool, - "requestedBackupStorageRedundancy": "str", - "restorePointInTime": "2020-02-20 00:00:00", - "servicePrincipal": {"clientId": "str", "principalId": "str", "tenantId": "str", "type": "str"}, + } + ], + "provisioningState": "str", + "proxyOverride": "str", + "publicDataEndpointEnabled": bool, + "requestedBackupStorageRedundancy": "str", + "requestedLogicalAvailabilityZone": "str", + "restorePointInTime": "2020-02-20 00:00:00", + "servicePrincipal": {"clientId": "str", "principalId": "str", "tenantId": "str", "type": "str"}, + "sourceManagedInstanceId": "str", + "state": "str", + "storageIOps": 0, + "storageSizeInGB": 0, + "storageThroughputMBps": 0, + "subnetId": "str", + "timezoneId": "str", + "vCores": 0, + "virtualClusterId": "str", + "zoneRedundant": bool, + }, "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, - "sourceManagedInstanceId": "str", - "state": "str", - "storageIOps": 0, - "storageSizeInGB": 0, - "storageThroughputMBps": 0, - "subnetId": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, - "timezoneId": "str", "type": "str", - "vCores": 0, - "virtualClusterId": "str", - "zoneRedundant": bool, }, - api_version="2023-05-01-preview", - ) - ).result() # call '.result()' to poll until service return final result - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_managed_instances_begin_delete(self, resource_group): - response = await ( - await self.client.managed_instances.begin_delete( - resource_group_name=resource_group.name, - managed_instance_name="str", - api_version="2023-05-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -174,82 +137,116 @@ async def test_managed_instances_begin_update(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", parameters={ - "administratorLogin": "str", - "administratorLoginPassword": "str", - "administrators": { - "administratorType": "str", - "azureADOnlyAuthentication": bool, - "login": "str", - "principalType": "str", - "sid": "str", - "tenantId": "str", - }, - "authenticationMetadata": "str", - "collation": "str", - "createTime": "2020-02-20 00:00:00", - "currentBackupStorageRedundancy": "str", - "databaseFormat": "str", - "dnsZone": "str", - "dnsZonePartner": "str", - "externalGovernanceStatus": "str", - "fullyQualifiedDomainName": "str", - "hybridSecondaryUsage": "str", - "hybridSecondaryUsageDetected": "str", "identity": { "principalId": "str", "tenantId": "str", "type": "str", "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, }, - "instancePoolId": "str", - "isGeneralPurposeV2": bool, - "keyId": "str", - "licenseType": "str", - "maintenanceConfigurationId": "str", - "managedInstanceCreateMode": "str", - "minimalTlsVersion": "str", - "pricingModel": "str", - "primaryUserAssignedIdentityId": "str", - "privateEndpointConnections": [ - { - "id": "str", - "properties": { - "privateEndpoint": {"id": "str"}, - "privateLinkServiceConnectionState": { - "description": "str", - "status": "str", - "actionsRequired": "str", + "properties": { + "administratorLogin": "str", + "administratorLoginPassword": "str", + "administrators": { + "administratorType": "str", + "azureADOnlyAuthentication": bool, + "login": "str", + "principalType": "str", + "sid": "str", + "tenantId": "str", + }, + "authenticationMetadata": "str", + "collation": "str", + "createTime": "2020-02-20 00:00:00", + "currentBackupStorageRedundancy": "str", + "databaseFormat": "str", + "dnsZone": "str", + "dnsZonePartner": "str", + "externalGovernanceStatus": "str", + "fullyQualifiedDomainName": "str", + "hybridSecondaryUsage": "str", + "hybridSecondaryUsageDetected": "str", + "instancePoolId": "str", + "isGeneralPurposeV2": bool, + "keyId": "str", + "licenseType": "str", + "maintenanceConfigurationId": "str", + "managedInstanceCreateMode": "str", + "memorySizeInGB": 0, + "minimalTlsVersion": "str", + "pricingModel": "str", + "primaryUserAssignedIdentityId": "str", + "privateEndpointConnections": [ + { + "id": "str", + "properties": { + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "description": "str", + "status": "str", + "actionsRequired": "str", + }, + "provisioningState": "str", }, - "provisioningState": "str", - }, - } - ], - "provisioningState": "str", - "proxyOverride": "str", - "publicDataEndpointEnabled": bool, - "requestedBackupStorageRedundancy": "str", - "restorePointInTime": "2020-02-20 00:00:00", - "servicePrincipal": {"clientId": "str", "principalId": "str", "tenantId": "str", "type": "str"}, + } + ], + "provisioningState": "str", + "proxyOverride": "str", + "publicDataEndpointEnabled": bool, + "requestedBackupStorageRedundancy": "str", + "requestedLogicalAvailabilityZone": "str", + "restorePointInTime": "2020-02-20 00:00:00", + "servicePrincipal": {"clientId": "str", "principalId": "str", "tenantId": "str", "type": "str"}, + "sourceManagedInstanceId": "str", + "state": "str", + "storageIOps": 0, + "storageSizeInGB": 0, + "storageThroughputMBps": 0, + "subnetId": "str", + "timezoneId": "str", + "vCores": 0, + "virtualClusterId": "str", + "zoneRedundant": bool, + }, "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, - "sourceManagedInstanceId": "str", - "state": "str", - "storageIOps": 0, - "storageSizeInGB": 0, - "storageThroughputMBps": 0, - "subnetId": "str", "tags": {"str": "str"}, - "timezoneId": "str", - "vCores": 0, - "virtualClusterId": "str", - "zoneRedundant": bool, }, - api_version="2023-05-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_managed_instances_begin_delete(self, resource_group): + response = await ( + await self.client.managed_instances.begin_delete( + resource_group_name=resource_group.name, + managed_instance_name="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_managed_instances_list_by_resource_group(self, resource_group): + response = self.client.managed_instances.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_managed_instances_list(self, resource_group): + response = self.client.managed_instances.list() + result = [r async for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_managed_instances_begin_failover(self, resource_group): @@ -257,7 +254,6 @@ async def test_managed_instances_begin_failover(self, resource_group): await self.client.managed_instances.begin_failover( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2023-05-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -270,12 +266,24 @@ async def test_managed_instances_list_outbound_network_dependencies_by_managed_i response = self.client.managed_instances.list_outbound_network_dependencies_by_managed_instance( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2023-05-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_managed_instances_begin_reevaluate_inaccessible_database_state(self, resource_group): + response = await ( + await self.client.managed_instances.begin_reevaluate_inaccessible_database_state( + resource_group_name=resource_group.name, + managed_instance_name="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_managed_instances_begin_refresh_status(self, resource_group): @@ -283,7 +291,6 @@ async def test_managed_instances_begin_refresh_status(self, resource_group): await self.client.managed_instances.begin_refresh_status( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2023-05-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -297,7 +304,6 @@ async def test_managed_instances_begin_start(self, resource_group): await self.client.managed_instances.begin_start( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2023-05-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -311,7 +317,6 @@ async def test_managed_instances_begin_stop(self, resource_group): await self.client.managed_instances.begin_stop( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2023-05-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -324,7 +329,31 @@ async def test_managed_instances_list_by_managed_instance(self, resource_group): response = self.client.managed_instances.list_by_managed_instance( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2023-05-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_managed_instances_begin_validate_azure_key_vault_encryption_key(self, resource_group): + response = await ( + await self.client.managed_instances.begin_validate_azure_key_vault_encryption_key( + resource_group_name=resource_group.name, + managed_instance_name="str", + parameters={"tdeKeyUri": "str"}, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_managed_instances_list_by_instance_pool(self, resource_group): + response = self.client.managed_instances.list_by_instance_pool( + resource_group_name=resource_group.name, + instance_pool_name="str", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_ledger_digest_uploads_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_ledger_digest_uploads_operations.py index fbb2f8614129..11c9115c94df 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_ledger_digest_uploads_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_ledger_digest_uploads_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,43 +20,53 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_managed_ledger_digest_uploads_list_by_database(self, resource_group): - response = self.client.managed_ledger_digest_uploads.list_by_database( + def test_managed_ledger_digest_uploads_get(self, resource_group): + response = self.client.managed_ledger_digest_uploads.get( resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", - api_version="2022-08-01-preview", + ledger_digest_uploads="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_managed_ledger_digest_uploads_get(self, resource_group): - response = self.client.managed_ledger_digest_uploads.get( + def test_managed_ledger_digest_uploads_begin_create_or_update(self, resource_group): + response = self.client.managed_ledger_digest_uploads.begin_create_or_update( resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", ledger_digest_uploads="str", - api_version="2022-08-01-preview", - ) + parameters={ + "id": "str", + "name": "str", + "properties": {"digestStorageEndpoint": "str", "state": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_managed_ledger_digest_uploads_begin_create_or_update(self, resource_group): - response = self.client.managed_ledger_digest_uploads.begin_create_or_update( + def test_managed_ledger_digest_uploads_list_by_database(self, resource_group): + response = self.client.managed_ledger_digest_uploads.list_by_database( resource_group_name=resource_group.name, managed_instance_name="str", database_name="str", - ledger_digest_uploads="str", - parameters={"digestStorageEndpoint": "str", "id": "str", "name": "str", "state": "str", "type": "str"}, - api_version="2022-08-01-preview", - ).result() # call '.result()' to poll until service return final result - + ) + result = [r for r in response] # please add some check logic here by yourself # ... @@ -68,7 +78,6 @@ def test_managed_ledger_digest_uploads_begin_disable(self, resource_group): managed_instance_name="str", database_name="str", ledger_digest_uploads="str", - api_version="2022-08-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_ledger_digest_uploads_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_ledger_digest_uploads_operations_async.py index b9524b23e9cf..1c2f7f71903b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_ledger_digest_uploads_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_ledger_digest_uploads_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,19 +19,6 @@ class TestSqlManagementManagedLedgerDigestUploadsOperationsAsync(AzureMgmtRecord def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_managed_ledger_digest_uploads_list_by_database(self, resource_group): - response = self.client.managed_ledger_digest_uploads.list_by_database( - resource_group_name=resource_group.name, - managed_instance_name="str", - database_name="str", - api_version="2022-08-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_managed_ledger_digest_uploads_get(self, resource_group): @@ -40,7 +27,6 @@ async def test_managed_ledger_digest_uploads_get(self, resource_group): managed_instance_name="str", database_name="str", ledger_digest_uploads="str", - api_version="2022-08-01-preview", ) # please add some check logic here by yourself @@ -55,14 +41,38 @@ async def test_managed_ledger_digest_uploads_begin_create_or_update(self, resour managed_instance_name="str", database_name="str", ledger_digest_uploads="str", - parameters={"digestStorageEndpoint": "str", "id": "str", "name": "str", "state": "str", "type": "str"}, - api_version="2022-08-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"digestStorageEndpoint": "str", "state": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_managed_ledger_digest_uploads_list_by_database(self, resource_group): + response = self.client.managed_ledger_digest_uploads.list_by_database( + resource_group_name=resource_group.name, + managed_instance_name="str", + database_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_managed_ledger_digest_uploads_begin_disable(self, resource_group): @@ -72,7 +82,6 @@ async def test_managed_ledger_digest_uploads_begin_disable(self, resource_group) managed_instance_name="str", database_name="str", ledger_digest_uploads="str", - api_version="2022-08-01-preview", ) ).result() # call '.result()' to poll until service return final result diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_restorable_dropped_database_backup_short_term_retention_policies_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_restorable_dropped_database_backup_short_term_retention_policies_operations.py index 1f97c8393c74..23a3ab3d9480 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_restorable_dropped_database_backup_short_term_retention_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_restorable_dropped_database_backup_short_term_retention_policies_operations.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -29,7 +29,6 @@ def test_managed_restorable_dropped_database_backup_short_term_retention_policie managed_instance_name="str", restorable_dropped_database_id="str", policy_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -46,8 +45,20 @@ def test_managed_restorable_dropped_database_backup_short_term_retention_policie managed_instance_name="str", restorable_dropped_database_id="str", policy_name="str", - parameters={"id": "str", "name": "str", "retentionDays": 0, "type": "str"}, - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"retentionDays": 0}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ).result() ) # call '.result()' to poll until service return final result @@ -64,8 +75,20 @@ def test_managed_restorable_dropped_database_backup_short_term_retention_policie managed_instance_name="str", restorable_dropped_database_id="str", policy_name="str", - parameters={"id": "str", "name": "str", "retentionDays": 0, "type": "str"}, - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"retentionDays": 0}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -80,7 +103,6 @@ def test_managed_restorable_dropped_database_backup_short_term_retention_policie resource_group_name=resource_group.name, managed_instance_name="str", restorable_dropped_database_id="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_restorable_dropped_database_backup_short_term_retention_policies_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_restorable_dropped_database_backup_short_term_retention_policies_operations_async.py index b6c6bc98a32f..428a86d3b46f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_restorable_dropped_database_backup_short_term_retention_policies_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_restorable_dropped_database_backup_short_term_retention_policies_operations_async.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -30,7 +30,6 @@ async def test_managed_restorable_dropped_database_backup_short_term_retention_p managed_instance_name="str", restorable_dropped_database_id="str", policy_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -47,8 +46,20 @@ async def test_managed_restorable_dropped_database_backup_short_term_retention_p managed_instance_name="str", restorable_dropped_database_id="str", policy_name="str", - parameters={"id": "str", "name": "str", "retentionDays": 0, "type": "str"}, - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"retentionDays": 0}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) ).result() # call '.result()' to poll until service return final result @@ -66,8 +77,20 @@ async def test_managed_restorable_dropped_database_backup_short_term_retention_p managed_instance_name="str", restorable_dropped_database_id="str", policy_name="str", - parameters={"id": "str", "name": "str", "retentionDays": 0, "type": "str"}, - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"retentionDays": 0}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) ).result() # call '.result()' to poll until service return final result @@ -83,7 +106,6 @@ async def test_managed_restorable_dropped_database_backup_short_term_retention_p resource_group_name=resource_group.name, managed_instance_name="str", restorable_dropped_database_id="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_server_dns_aliases_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_server_dns_aliases_operations.py index a0ad267ce1b9..ccc6bb6d6179 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_server_dns_aliases_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_server_dns_aliases_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,18 +18,6 @@ class TestSqlManagementManagedServerDnsAliasesOperations(AzureMgmtRecordedTestCa def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_managed_server_dns_aliases_list_by_managed_instance(self, resource_group): - response = self.client.managed_server_dns_aliases.list_by_managed_instance( - resource_group_name=resource_group.name, - managed_instance_name="str", - api_version="2021-11-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_managed_server_dns_aliases_get(self, resource_group): @@ -37,7 +25,6 @@ def test_managed_server_dns_aliases_get(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", dns_alias_name="str", - api_version="2021-11-01-preview", ) # please add some check logic here by yourself @@ -50,8 +37,7 @@ def test_managed_server_dns_aliases_begin_create_or_update(self, resource_group) resource_group_name=resource_group.name, managed_instance_name="str", dns_alias_name="str", - parameters={"createDnsRecord": True}, - api_version="2021-11-01-preview", + parameters={"createDnsRecord": bool}, ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -64,12 +50,22 @@ def test_managed_server_dns_aliases_begin_delete(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", dns_alias_name="str", - api_version="2021-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_managed_server_dns_aliases_list_by_managed_instance(self, resource_group): + response = self.client.managed_server_dns_aliases.list_by_managed_instance( + resource_group_name=resource_group.name, + managed_instance_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_managed_server_dns_aliases_begin_acquire(self, resource_group): @@ -78,7 +74,6 @@ def test_managed_server_dns_aliases_begin_acquire(self, resource_group): managed_instance_name="str", dns_alias_name="str", parameters={"oldManagedServerDnsAliasResourceId": "str"}, - api_version="2021-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_server_dns_aliases_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_server_dns_aliases_operations_async.py index 39db4bd72fdd..728c03fb79b8 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_server_dns_aliases_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_server_dns_aliases_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,18 +19,6 @@ class TestSqlManagementManagedServerDnsAliasesOperationsAsync(AzureMgmtRecordedT def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_managed_server_dns_aliases_list_by_managed_instance(self, resource_group): - response = self.client.managed_server_dns_aliases.list_by_managed_instance( - resource_group_name=resource_group.name, - managed_instance_name="str", - api_version="2021-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_managed_server_dns_aliases_get(self, resource_group): @@ -38,7 +26,6 @@ async def test_managed_server_dns_aliases_get(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", dns_alias_name="str", - api_version="2021-11-01-preview", ) # please add some check logic here by yourself @@ -52,8 +39,7 @@ async def test_managed_server_dns_aliases_begin_create_or_update(self, resource_ resource_group_name=resource_group.name, managed_instance_name="str", dns_alias_name="str", - parameters={"createDnsRecord": True}, - api_version="2021-11-01-preview", + parameters={"createDnsRecord": bool}, ) ).result() # call '.result()' to poll until service return final result @@ -68,13 +54,23 @@ async def test_managed_server_dns_aliases_begin_delete(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", dns_alias_name="str", - api_version="2021-11-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_managed_server_dns_aliases_list_by_managed_instance(self, resource_group): + response = self.client.managed_server_dns_aliases.list_by_managed_instance( + resource_group_name=resource_group.name, + managed_instance_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_managed_server_dns_aliases_begin_acquire(self, resource_group): @@ -84,7 +80,6 @@ async def test_managed_server_dns_aliases_begin_acquire(self, resource_group): managed_instance_name="str", dns_alias_name="str", parameters={"oldManagedServerDnsAliasResourceId": "str"}, - api_version="2021-11-01-preview", ) ).result() # call '.result()' to poll until service return final result diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_server_security_alert_policies_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_server_security_alert_policies_operations.py index 18f4b0d56efb..2384efc048bb 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_server_security_alert_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_server_security_alert_policies_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_managed_server_security_alert_policies_get(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", security_alert_policy_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -39,16 +38,18 @@ def test_managed_server_security_alert_policies_begin_create_or_update(self, res managed_instance_name="str", security_alert_policy_name="str", parameters={ - "creationTime": "2020-02-20 00:00:00", - "disabledAlerts": ["str"], - "emailAccountAdmins": bool, - "emailAddresses": ["str"], "id": "str", "name": "str", - "retentionDays": 0, - "state": "str", - "storageAccountAccessKey": "str", - "storageEndpoint": "str", + "properties": { + "state": "str", + "creationTime": "2020-02-20 00:00:00", + "disabledAlerts": ["str"], + "emailAccountAdmins": bool, + "emailAddresses": ["str"], + "retentionDays": 0, + "storageAccountAccessKey": "str", + "storageEndpoint": "str", + }, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -59,7 +60,6 @@ def test_managed_server_security_alert_policies_begin_create_or_update(self, res }, "type": "str", }, - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -71,7 +71,6 @@ def test_managed_server_security_alert_policies_list_by_instance(self, resource_ response = self.client.managed_server_security_alert_policies.list_by_instance( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_server_security_alert_policies_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_server_security_alert_policies_operations_async.py index cf7435235ec7..7e91d286c24d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_server_security_alert_policies_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_managed_server_security_alert_policies_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_managed_server_security_alert_policies_get(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", security_alert_policy_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -41,16 +40,18 @@ async def test_managed_server_security_alert_policies_begin_create_or_update(sel managed_instance_name="str", security_alert_policy_name="str", parameters={ - "creationTime": "2020-02-20 00:00:00", - "disabledAlerts": ["str"], - "emailAccountAdmins": bool, - "emailAddresses": ["str"], "id": "str", "name": "str", - "retentionDays": 0, - "state": "str", - "storageAccountAccessKey": "str", - "storageEndpoint": "str", + "properties": { + "state": "str", + "creationTime": "2020-02-20 00:00:00", + "disabledAlerts": ["str"], + "emailAccountAdmins": bool, + "emailAddresses": ["str"], + "retentionDays": 0, + "storageAccountAccessKey": "str", + "storageEndpoint": "str", + }, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -61,7 +62,6 @@ async def test_managed_server_security_alert_policies_begin_create_or_update(sel }, "type": "str", }, - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -74,7 +74,6 @@ async def test_managed_server_security_alert_policies_list_by_instance(self, res response = self.client.managed_server_security_alert_policies.list_by_instance( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_network_security_perimeter_configurations_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_network_security_perimeter_configurations_operations.py index 082ef375e132..2f1ed58bbe9f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_network_security_perimeter_configurations_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_network_security_perimeter_configurations_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,26 +20,24 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_network_security_perimeter_configurations_list_by_server(self, resource_group): - response = self.client.network_security_perimeter_configurations.list_by_server( + def test_network_security_perimeter_configurations_get(self, resource_group): + response = self.client.network_security_perimeter_configurations.get( resource_group_name=resource_group.name, server_name="str", - api_version="2024-11-01-preview", + nsp_config_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_network_security_perimeter_configurations_get(self, resource_group): - response = self.client.network_security_perimeter_configurations.get( + def test_network_security_perimeter_configurations_list_by_server(self, resource_group): + response = self.client.network_security_perimeter_configurations.list_by_server( resource_group_name=resource_group.name, server_name="str", - nsp_config_name="str", - api_version="2024-11-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... @@ -50,7 +48,6 @@ def test_network_security_perimeter_configurations_begin_reconcile(self, resourc resource_group_name=resource_group.name, server_name="str", nsp_config_name="str", - api_version="2024-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_network_security_perimeter_configurations_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_network_security_perimeter_configurations_operations_async.py index d910d7aaeaa5..7304fb9e2b56 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_network_security_perimeter_configurations_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_network_security_perimeter_configurations_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,26 +21,24 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_network_security_perimeter_configurations_list_by_server(self, resource_group): - response = self.client.network_security_perimeter_configurations.list_by_server( + async def test_network_security_perimeter_configurations_get(self, resource_group): + response = await self.client.network_security_perimeter_configurations.get( resource_group_name=resource_group.name, server_name="str", - api_version="2024-11-01-preview", + nsp_config_name="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_network_security_perimeter_configurations_get(self, resource_group): - response = await self.client.network_security_perimeter_configurations.get( + async def test_network_security_perimeter_configurations_list_by_server(self, resource_group): + response = self.client.network_security_perimeter_configurations.list_by_server( resource_group_name=resource_group.name, server_name="str", - nsp_config_name="str", - api_version="2024-11-01-preview", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... @@ -52,7 +50,6 @@ async def test_network_security_perimeter_configurations_begin_reconcile(self, r resource_group_name=resource_group.name, server_name="str", nsp_config_name="str", - api_version="2024-11-01-preview", ) ).result() # call '.result()' to poll until service return final result diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_operations.py index 075121208531..39bf47cd4c68 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,9 +21,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_operations_list(self, resource_group): - response = self.client.operations.list( - api_version="2020-11-01-preview", - ) + response = self.client.operations.list() result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_operations_async.py index 69384b0abb48..f067b48b1cff 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -22,9 +22,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_operations_list(self, resource_group): - response = self.client.operations.list( - api_version="2020-11-01-preview", - ) + response = self.client.operations.list() result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_outbound_firewall_rules_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_outbound_firewall_rules_operations.py index 9dab0024095e..044e5b94976d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_outbound_firewall_rules_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_outbound_firewall_rules_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_outbound_firewall_rules_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", outbound_rule_fqdn="str", - api_version="2021-02-01-preview", ) # please add some check logic here by yourself @@ -38,8 +37,6 @@ def test_outbound_firewall_rules_begin_create_or_update(self, resource_group): resource_group_name=resource_group.name, server_name="str", outbound_rule_fqdn="str", - parameters={"id": "str", "name": "str", "provisioningState": "str", "type": "str"}, - api_version="2021-02-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -52,7 +49,6 @@ def test_outbound_firewall_rules_begin_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", outbound_rule_fqdn="str", - api_version="2021-02-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -64,7 +60,6 @@ def test_outbound_firewall_rules_list_by_server(self, resource_group): response = self.client.outbound_firewall_rules.list_by_server( resource_group_name=resource_group.name, server_name="str", - api_version="2021-02-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_outbound_firewall_rules_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_outbound_firewall_rules_operations_async.py index 13ce5a5ab0bb..3b4e7880e13b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_outbound_firewall_rules_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_outbound_firewall_rules_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_outbound_firewall_rules_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", outbound_rule_fqdn="str", - api_version="2021-02-01-preview", ) # please add some check logic here by yourself @@ -40,8 +39,6 @@ async def test_outbound_firewall_rules_begin_create_or_update(self, resource_gro resource_group_name=resource_group.name, server_name="str", outbound_rule_fqdn="str", - parameters={"id": "str", "name": "str", "provisioningState": "str", "type": "str"}, - api_version="2021-02-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -56,7 +53,6 @@ async def test_outbound_firewall_rules_begin_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", outbound_rule_fqdn="str", - api_version="2021-02-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -69,7 +65,6 @@ async def test_outbound_firewall_rules_list_by_server(self, resource_group): response = self.client.outbound_firewall_rules.list_by_server( resource_group_name=resource_group.name, server_name="str", - api_version="2021-02-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_private_endpoint_connections_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_private_endpoint_connections_operations.py index bdfe959f96ed..ea00f2538c9a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_private_endpoint_connections_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_private_endpoint_connections_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,18 +18,6 @@ class TestSqlManagementPrivateEndpointConnectionsOperations(AzureMgmtRecordedTes def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_private_endpoint_connections_list_by_server(self, resource_group): - response = self.client.private_endpoint_connections.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2022-08-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_private_endpoint_connections_get(self, resource_group): @@ -37,7 +25,6 @@ def test_private_endpoint_connections_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", private_endpoint_connection_name="str", - api_version="2022-08-01-preview", ) # please add some check logic here by yourself @@ -51,15 +38,28 @@ def test_private_endpoint_connections_begin_create_or_update(self, resource_grou server_name="str", private_endpoint_connection_name="str", parameters={ - "groupIds": ["str"], "id": "str", "name": "str", - "privateEndpoint": {"id": "str"}, - "privateLinkServiceConnectionState": {"description": "str", "status": "str", "actionsRequired": "str"}, - "provisioningState": "str", + "properties": { + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "description": "str", + "status": "str", + "actionsRequired": "str", + }, + "provisioningState": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2022-08-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -72,8 +72,18 @@ def test_private_endpoint_connections_begin_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", private_endpoint_connection_name="str", - api_version="2022-08-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connections_list_by_server(self, resource_group): + response = self.client.private_endpoint_connections.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_private_endpoint_connections_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_private_endpoint_connections_operations_async.py index 55cf005e8087..88f3700bb463 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_private_endpoint_connections_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_private_endpoint_connections_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,18 +19,6 @@ class TestSqlManagementPrivateEndpointConnectionsOperationsAsync(AzureMgmtRecord def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_private_endpoint_connections_list_by_server(self, resource_group): - response = self.client.private_endpoint_connections.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2022-08-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_private_endpoint_connections_get(self, resource_group): @@ -38,7 +26,6 @@ async def test_private_endpoint_connections_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", private_endpoint_connection_name="str", - api_version="2022-08-01-preview", ) # please add some check logic here by yourself @@ -53,19 +40,28 @@ async def test_private_endpoint_connections_begin_create_or_update(self, resourc server_name="str", private_endpoint_connection_name="str", parameters={ - "groupIds": ["str"], "id": "str", "name": "str", - "privateEndpoint": {"id": "str"}, - "privateLinkServiceConnectionState": { - "description": "str", - "status": "str", - "actionsRequired": "str", + "properties": { + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "description": "str", + "status": "str", + "actionsRequired": "str", + }, + "provisioningState": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", }, - "provisioningState": "str", "type": "str", }, - api_version="2022-08-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -80,9 +76,19 @@ async def test_private_endpoint_connections_begin_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", private_endpoint_connection_name="str", - api_version="2022-08-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connections_list_by_server(self, resource_group): + response = self.client.private_endpoint_connections.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_private_link_resources_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_private_link_resources_operations.py index a9c4182c2e74..8c1d83c82933 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_private_link_resources_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_private_link_resources_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,25 +20,23 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_private_link_resources_list_by_server(self, resource_group): - response = self.client.private_link_resources.list_by_server( + def test_private_link_resources_get(self, resource_group): + response = self.client.private_link_resources.get( resource_group_name=resource_group.name, server_name="str", - api_version="2020-11-01-preview", + group_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_private_link_resources_get(self, resource_group): - response = self.client.private_link_resources.get( + def test_private_link_resources_list_by_server(self, resource_group): + response = self.client.private_link_resources.list_by_server( resource_group_name=resource_group.name, server_name="str", - group_name="str", - api_version="2020-11-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_private_link_resources_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_private_link_resources_operations_async.py index b767354cb5ea..71989ececd3e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_private_link_resources_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_private_link_resources_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,25 +21,23 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_private_link_resources_list_by_server(self, resource_group): - response = self.client.private_link_resources.list_by_server( + async def test_private_link_resources_get(self, resource_group): + response = await self.client.private_link_resources.get( resource_group_name=resource_group.name, server_name="str", - api_version="2020-11-01-preview", + group_name="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_private_link_resources_get(self, resource_group): - response = await self.client.private_link_resources.get( + async def test_private_link_resources_list_by_server(self, resource_group): + response = self.client.private_link_resources.list_by_server( resource_group_name=resource_group.name, server_name="str", - group_name="str", - api_version="2020-11-01-preview", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_recommended_sensitivity_labels_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_recommended_sensitivity_labels_operations.py index f9581d6f0f81..e040b53f2f91 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_recommended_sensitivity_labels_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_recommended_sensitivity_labels_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -28,17 +28,21 @@ def test_recommended_sensitivity_labels_update(self, resource_group): parameters={ "operations": [ { - "column": "str", "id": "str", "name": "str", - "op": "str", - "schema": "str", - "table": "str", + "properties": {"column": "str", "op": "str", "schema": "str", "table": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", } ] }, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_recommended_sensitivity_labels_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_recommended_sensitivity_labels_operations_async.py index a9805e82f9a9..869fd6ef2317 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_recommended_sensitivity_labels_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_recommended_sensitivity_labels_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -29,17 +29,21 @@ async def test_recommended_sensitivity_labels_update(self, resource_group): parameters={ "operations": [ { - "column": "str", "id": "str", "name": "str", - "op": "str", - "schema": "str", - "table": "str", + "properties": {"column": "str", "op": "str", "schema": "str", "table": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", } ] }, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_recoverable_databases_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_recoverable_databases_operations.py index fa9784cf95e9..385e66a48408 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_recoverable_databases_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_recoverable_databases_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,25 +20,23 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_recoverable_databases_list_by_server(self, resource_group): - response = self.client.recoverable_databases.list_by_server( + def test_recoverable_databases_get(self, resource_group): + response = self.client.recoverable_databases.get( resource_group_name=resource_group.name, server_name="str", - api_version="2022-08-01-preview", + database_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_recoverable_databases_get(self, resource_group): - response = self.client.recoverable_databases.get( + def test_recoverable_databases_list_by_server(self, resource_group): + response = self.client.recoverable_databases.list_by_server( resource_group_name=resource_group.name, server_name="str", - database_name="str", - api_version="2022-08-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_recoverable_databases_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_recoverable_databases_operations_async.py index 2c82dc4ba693..b8352292dbcb 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_recoverable_databases_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_recoverable_databases_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,25 +21,23 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_recoverable_databases_list_by_server(self, resource_group): - response = self.client.recoverable_databases.list_by_server( + async def test_recoverable_databases_get(self, resource_group): + response = await self.client.recoverable_databases.get( resource_group_name=resource_group.name, server_name="str", - api_version="2022-08-01-preview", + database_name="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_recoverable_databases_get(self, resource_group): - response = await self.client.recoverable_databases.get( + async def test_recoverable_databases_list_by_server(self, resource_group): + response = self.client.recoverable_databases.list_by_server( resource_group_name=resource_group.name, server_name="str", - database_name="str", - api_version="2022-08-01-preview", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_recoverable_managed_databases_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_recoverable_managed_databases_operations.py index d0313b458aa5..75cd391d1583 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_recoverable_managed_databases_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_recoverable_managed_databases_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,25 +20,23 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_recoverable_managed_databases_list_by_instance(self, resource_group): - response = self.client.recoverable_managed_databases.list_by_instance( + def test_recoverable_managed_databases_get(self, resource_group): + response = self.client.recoverable_managed_databases.get( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2020-11-01-preview", + recoverable_database_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_recoverable_managed_databases_get(self, resource_group): - response = self.client.recoverable_managed_databases.get( + def test_recoverable_managed_databases_list_by_instance(self, resource_group): + response = self.client.recoverable_managed_databases.list_by_instance( resource_group_name=resource_group.name, managed_instance_name="str", - recoverable_database_name="str", - api_version="2020-11-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_recoverable_managed_databases_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_recoverable_managed_databases_operations_async.py index c13ded5d7f1b..3ab0fe51cacc 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_recoverable_managed_databases_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_recoverable_managed_databases_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,25 +21,23 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_recoverable_managed_databases_list_by_instance(self, resource_group): - response = self.client.recoverable_managed_databases.list_by_instance( + async def test_recoverable_managed_databases_get(self, resource_group): + response = await self.client.recoverable_managed_databases.get( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2020-11-01-preview", + recoverable_database_name="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_recoverable_managed_databases_get(self, resource_group): - response = await self.client.recoverable_managed_databases.get( + async def test_recoverable_managed_databases_list_by_instance(self, resource_group): + response = self.client.recoverable_managed_databases.list_by_instance( resource_group_name=resource_group.name, managed_instance_name="str", - recoverable_database_name="str", - api_version="2020-11-01-preview", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_replication_links_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_replication_links_operations.py index e729382c249d..7efddf847d62 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_replication_links_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_replication_links_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,57 +20,79 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_replication_links_list_by_database(self, resource_group): - response = self.client.replication_links.list_by_database( + def test_replication_links_get(self, resource_group): + response = self.client.replication_links.get( resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2023-05-01-preview", + link_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_replication_links_get(self, resource_group): - response = self.client.replication_links.get( + def test_replication_links_begin_create_or_update(self, resource_group): + response = self.client.replication_links.begin_create_or_update( resource_group_name=resource_group.name, server_name="str", database_name="str", link_id="str", - api_version="2023-05-01-preview", - ) + parameters={ + "id": "str", + "name": "str", + "properties": { + "isTerminationAllowed": bool, + "linkType": "str", + "partnerDatabase": "str", + "partnerDatabaseId": "str", + "partnerLocation": "str", + "partnerRole": "str", + "partnerServer": "str", + "percentComplete": 0, + "replicationMode": "str", + "replicationState": "str", + "role": "str", + "startTime": "2020-02-20 00:00:00", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_replication_links_begin_create_or_update(self, resource_group): - response = self.client.replication_links.begin_create_or_update( + def test_replication_links_begin_update(self, resource_group): + response = self.client.replication_links.begin_update( resource_group_name=resource_group.name, server_name="str", database_name="str", link_id="str", parameters={ "id": "str", - "isTerminationAllowed": bool, - "linkType": "str", "name": "str", - "partnerDatabase": "str", - "partnerDatabaseId": "str", - "partnerLocation": "str", - "partnerRole": "str", - "partnerServer": "str", - "percentComplete": 0, - "replicationMode": "str", - "replicationState": "str", - "role": "str", - "startTime": "2020-02-20 00:00:00", + "properties": {"linkType": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2023-05-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -84,7 +106,6 @@ def test_replication_links_begin_delete(self, resource_group): server_name="str", database_name="str", link_id="str", - api_version="2023-05-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -92,16 +113,13 @@ def test_replication_links_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_replication_links_begin_update(self, resource_group): - response = self.client.replication_links.begin_update( + def test_replication_links_list_by_database(self, resource_group): + response = self.client.replication_links.list_by_database( resource_group_name=resource_group.name, server_name="str", database_name="str", - link_id="str", - parameters={"id": "str", "linkType": "str", "name": "str", "type": "str"}, - api_version="2023-05-01-preview", - ).result() # call '.result()' to poll until service return final result - + ) + result = [r for r in response] # please add some check logic here by yourself # ... @@ -113,7 +131,6 @@ def test_replication_links_begin_failover(self, resource_group): server_name="str", database_name="str", link_id="str", - api_version="2023-05-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -127,7 +144,6 @@ def test_replication_links_begin_failover_allow_data_loss(self, resource_group): server_name="str", database_name="str", link_id="str", - api_version="2023-05-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -139,7 +155,6 @@ def test_replication_links_list_by_server(self, resource_group): response = self.client.replication_links.list_by_server( resource_group_name=resource_group.name, server_name="str", - api_version="2023-05-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_replication_links_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_replication_links_operations_async.py index 413c94962382..e8f73d2eb83e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_replication_links_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_replication_links_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,19 +19,6 @@ class TestSqlManagementReplicationLinksOperationsAsync(AzureMgmtRecordedTestCase def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_replication_links_list_by_database(self, resource_group): - response = self.client.replication_links.list_by_database( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - api_version="2023-05-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_replication_links_get(self, resource_group): @@ -40,7 +27,6 @@ async def test_replication_links_get(self, resource_group): server_name="str", database_name="str", link_id="str", - api_version="2023-05-01-preview", ) # please add some check logic here by yourself @@ -57,22 +43,31 @@ async def test_replication_links_begin_create_or_update(self, resource_group): link_id="str", parameters={ "id": "str", - "isTerminationAllowed": bool, - "linkType": "str", "name": "str", - "partnerDatabase": "str", - "partnerDatabaseId": "str", - "partnerLocation": "str", - "partnerRole": "str", - "partnerServer": "str", - "percentComplete": 0, - "replicationMode": "str", - "replicationState": "str", - "role": "str", - "startTime": "2020-02-20 00:00:00", + "properties": { + "isTerminationAllowed": bool, + "linkType": "str", + "partnerDatabase": "str", + "partnerDatabaseId": "str", + "partnerLocation": "str", + "partnerRole": "str", + "partnerServer": "str", + "percentComplete": 0, + "replicationMode": "str", + "replicationState": "str", + "role": "str", + "startTime": "2020-02-20 00:00:00", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2023-05-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -81,14 +76,27 @@ async def test_replication_links_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_replication_links_begin_delete(self, resource_group): + async def test_replication_links_begin_update(self, resource_group): response = await ( - await self.client.replication_links.begin_delete( + await self.client.replication_links.begin_update( resource_group_name=resource_group.name, server_name="str", database_name="str", link_id="str", - api_version="2023-05-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"linkType": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) ).result() # call '.result()' to poll until service return final result @@ -97,21 +105,31 @@ async def test_replication_links_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_replication_links_begin_update(self, resource_group): + async def test_replication_links_begin_delete(self, resource_group): response = await ( - await self.client.replication_links.begin_update( + await self.client.replication_links.begin_delete( resource_group_name=resource_group.name, server_name="str", database_name="str", link_id="str", - parameters={"id": "str", "linkType": "str", "name": "str", "type": "str"}, - api_version="2023-05-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_replication_links_list_by_database(self, resource_group): + response = self.client.replication_links.list_by_database( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_replication_links_begin_failover(self, resource_group): @@ -121,7 +139,6 @@ async def test_replication_links_begin_failover(self, resource_group): server_name="str", database_name="str", link_id="str", - api_version="2023-05-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -137,7 +154,6 @@ async def test_replication_links_begin_failover_allow_data_loss(self, resource_g server_name="str", database_name="str", link_id="str", - api_version="2023-05-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -150,7 +166,6 @@ async def test_replication_links_list_by_server(self, resource_group): response = self.client.replication_links.list_by_server( resource_group_name=resource_group.name, server_name="str", - api_version="2023-05-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_restorable_dropped_databases_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_restorable_dropped_databases_operations.py index c7f456d144e7..4e9324d8f243 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_restorable_dropped_databases_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_restorable_dropped_databases_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,25 +20,23 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_restorable_dropped_databases_list_by_server(self, resource_group): - response = self.client.restorable_dropped_databases.list_by_server( + def test_restorable_dropped_databases_get(self, resource_group): + response = self.client.restorable_dropped_databases.get( resource_group_name=resource_group.name, server_name="str", - api_version="2022-08-01-preview", + restorable_dropped_database_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_restorable_dropped_databases_get(self, resource_group): - response = self.client.restorable_dropped_databases.get( + def test_restorable_dropped_databases_list_by_server(self, resource_group): + response = self.client.restorable_dropped_databases.list_by_server( resource_group_name=resource_group.name, server_name="str", - restorable_dropped_database_id="str", - api_version="2022-08-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_restorable_dropped_databases_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_restorable_dropped_databases_operations_async.py index e877d2d9394a..72d44a52fac8 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_restorable_dropped_databases_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_restorable_dropped_databases_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,25 +21,23 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_restorable_dropped_databases_list_by_server(self, resource_group): - response = self.client.restorable_dropped_databases.list_by_server( + async def test_restorable_dropped_databases_get(self, resource_group): + response = await self.client.restorable_dropped_databases.get( resource_group_name=resource_group.name, server_name="str", - api_version="2022-08-01-preview", + restorable_dropped_database_id="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_restorable_dropped_databases_get(self, resource_group): - response = await self.client.restorable_dropped_databases.get( + async def test_restorable_dropped_databases_list_by_server(self, resource_group): + response = self.client.restorable_dropped_databases.list_by_server( resource_group_name=resource_group.name, server_name="str", - restorable_dropped_database_id="str", - api_version="2022-08-01-preview", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_restorable_dropped_managed_databases_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_restorable_dropped_managed_databases_operations.py index 48b24e11fbb8..b0a0701ef269 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_restorable_dropped_managed_databases_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_restorable_dropped_managed_databases_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,25 +20,23 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_restorable_dropped_managed_databases_list_by_instance(self, resource_group): - response = self.client.restorable_dropped_managed_databases.list_by_instance( + def test_restorable_dropped_managed_databases_get(self, resource_group): + response = self.client.restorable_dropped_managed_databases.get( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2021-05-01-preview", + restorable_dropped_database_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_restorable_dropped_managed_databases_get(self, resource_group): - response = self.client.restorable_dropped_managed_databases.get( + def test_restorable_dropped_managed_databases_list_by_instance(self, resource_group): + response = self.client.restorable_dropped_managed_databases.list_by_instance( resource_group_name=resource_group.name, managed_instance_name="str", - restorable_dropped_database_id="str", - api_version="2021-05-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_restorable_dropped_managed_databases_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_restorable_dropped_managed_databases_operations_async.py index 395f08dd16be..ab735b2f4992 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_restorable_dropped_managed_databases_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_restorable_dropped_managed_databases_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,25 +21,23 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_restorable_dropped_managed_databases_list_by_instance(self, resource_group): - response = self.client.restorable_dropped_managed_databases.list_by_instance( + async def test_restorable_dropped_managed_databases_get(self, resource_group): + response = await self.client.restorable_dropped_managed_databases.get( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2021-05-01-preview", + restorable_dropped_database_id="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_restorable_dropped_managed_databases_get(self, resource_group): - response = await self.client.restorable_dropped_managed_databases.get( + async def test_restorable_dropped_managed_databases_list_by_instance(self, resource_group): + response = self.client.restorable_dropped_managed_databases.list_by_instance( resource_group_name=resource_group.name, managed_instance_name="str", - restorable_dropped_database_id="str", - api_version="2021-05-01-preview", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_restore_points_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_restore_points_operations.py index 2045cea002f1..363e849dc730 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_restore_points_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_restore_points_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,55 +20,51 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_restore_points_list_by_database(self, resource_group): - response = self.client.restore_points.list_by_database( + def test_restore_points_get(self, resource_group): + response = self.client.restore_points.get( resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2020-11-01-preview", + restore_point_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_restore_points_begin_create(self, resource_group): - response = self.client.restore_points.begin_create( + def test_restore_points_delete(self, resource_group): + response = self.client.restore_points.delete( resource_group_name=resource_group.name, server_name="str", database_name="str", - parameters={"restorePointLabel": "str"}, - api_version="2020-11-01-preview", - ).result() # call '.result()' to poll until service return final result + restore_point_name="str", + ) # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_restore_points_get(self, resource_group): - response = self.client.restore_points.get( + def test_restore_points_list_by_database(self, resource_group): + response = self.client.restore_points.list_by_database( resource_group_name=resource_group.name, server_name="str", database_name="str", - restore_point_name="str", - api_version="2020-11-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_restore_points_delete(self, resource_group): - response = self.client.restore_points.delete( + def test_restore_points_begin_create(self, resource_group): + response = self.client.restore_points.begin_create( resource_group_name=resource_group.name, server_name="str", database_name="str", - restore_point_name="str", - api_version="2020-11-01-preview", - ) + parameters={"restorePointLabel": "str"}, + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_restore_points_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_restore_points_operations_async.py index 264a7b3a98a6..423ec8c26cf6 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_restore_points_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_restore_points_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,42 +21,25 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_restore_points_list_by_database(self, resource_group): - response = self.client.restore_points.list_by_database( + async def test_restore_points_get(self, resource_group): + response = await self.client.restore_points.get( resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2020-11-01-preview", + restore_point_name="str", ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_restore_points_begin_create(self, resource_group): - response = await ( - await self.client.restore_points.begin_create( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - parameters={"restorePointLabel": "str"}, - api_version="2020-11-01-preview", - ) - ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_restore_points_get(self, resource_group): - response = await self.client.restore_points.get( + async def test_restore_points_delete(self, resource_group): + response = await self.client.restore_points.delete( resource_group_name=resource_group.name, server_name="str", database_name="str", restore_point_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -64,14 +47,27 @@ async def test_restore_points_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_restore_points_delete(self, resource_group): - response = await self.client.restore_points.delete( + async def test_restore_points_list_by_database(self, resource_group): + response = self.client.restore_points.list_by_database( resource_group_name=resource_group.name, server_name="str", database_name="str", - restore_point_name="str", - api_version="2020-11-01-preview", ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_restore_points_begin_create(self, resource_group): + response = await ( + await self.client.restore_points.begin_create( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + parameters={"restorePointLabel": "str"}, + ) + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sensitivity_labels_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sensitivity_labels_operations.py index e1ad5f777bba..201d340e7c7f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sensitivity_labels_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sensitivity_labels_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_sensitivity_labels_list_current_by_database(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself @@ -41,32 +40,52 @@ def test_sensitivity_labels_update(self, resource_group): parameters={ "operations": [ { - "column": "str", "id": "str", "name": "str", - "op": "str", - "schema": "str", - "sensitivityLabel": { - "columnName": "str", - "id": "str", - "informationType": "str", - "informationTypeId": "str", - "isDisabled": bool, - "labelId": "str", - "labelName": "str", - "managedBy": "str", - "name": "str", - "rank": "str", - "schemaName": "str", - "tableName": "str", - "type": "str", + "properties": { + "column": "str", + "op": "str", + "schema": "str", + "table": "str", + "sensitivityLabel": { + "id": "str", + "managedBy": "str", + "name": "str", + "properties": { + "clientClassificationSource": "str", + "columnName": "str", + "informationType": "str", + "informationTypeId": "str", + "isDisabled": bool, + "labelId": "str", + "labelName": "str", + "rank": "str", + "schemaName": "str", + "tableName": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", }, - "table": "str", "type": "str", } ] }, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -79,7 +98,6 @@ def test_sensitivity_labels_list_recommended_by_database(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself @@ -87,16 +105,27 @@ def test_sensitivity_labels_list_recommended_by_database(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sensitivity_labels_enable_recommendation(self, resource_group): - response = self.client.sensitivity_labels.enable_recommendation( + def test_sensitivity_labels_list_by_database(self, resource_group): + response = self.client.sensitivity_labels.list_by_database( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sensitivity_labels_get(self, resource_group): + response = self.client.sensitivity_labels.get( resource_group_name=resource_group.name, server_name="str", database_name="str", schema_name="str", table_name="str", column_name="str", - sensitivity_label_source="recommended", - api_version="2020-11-01-preview", + sensitivity_label_source="str", ) # please add some check logic here by yourself @@ -104,16 +133,41 @@ def test_sensitivity_labels_enable_recommendation(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sensitivity_labels_disable_recommendation(self, resource_group): - response = self.client.sensitivity_labels.disable_recommendation( + def test_sensitivity_labels_create_or_update(self, resource_group): + response = self.client.sensitivity_labels.create_or_update( resource_group_name=resource_group.name, server_name="str", database_name="str", schema_name="str", table_name="str", column_name="str", - sensitivity_label_source="recommended", - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "managedBy": "str", + "name": "str", + "properties": { + "clientClassificationSource": "str", + "columnName": "str", + "informationType": "str", + "informationTypeId": "str", + "isDisabled": bool, + "labelId": "str", + "labelName": "str", + "rank": "str", + "schemaName": "str", + "tableName": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + sensitivity_label_source="current", ) # please add some check logic here by yourself @@ -121,16 +175,15 @@ def test_sensitivity_labels_disable_recommendation(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sensitivity_labels_get(self, resource_group): - response = self.client.sensitivity_labels.get( + def test_sensitivity_labels_delete(self, resource_group): + response = self.client.sensitivity_labels.delete( resource_group_name=resource_group.name, server_name="str", database_name="str", schema_name="str", table_name="str", column_name="str", - sensitivity_label_source="str", - api_version="2020-11-01-preview", + sensitivity_label_source="current", ) # please add some check logic here by yourself @@ -138,31 +191,15 @@ def test_sensitivity_labels_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sensitivity_labels_create_or_update(self, resource_group): - response = self.client.sensitivity_labels.create_or_update( + def test_sensitivity_labels_disable_recommendation(self, resource_group): + response = self.client.sensitivity_labels.disable_recommendation( resource_group_name=resource_group.name, server_name="str", database_name="str", schema_name="str", table_name="str", column_name="str", - parameters={ - "columnName": "str", - "id": "str", - "informationType": "str", - "informationTypeId": "str", - "isDisabled": bool, - "labelId": "str", - "labelName": "str", - "managedBy": "str", - "name": "str", - "rank": "str", - "schemaName": "str", - "tableName": "str", - "type": "str", - }, - sensitivity_label_source="current", - api_version="2020-11-01-preview", + sensitivity_label_source="recommended", ) # please add some check logic here by yourself @@ -170,16 +207,15 @@ def test_sensitivity_labels_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sensitivity_labels_delete(self, resource_group): - response = self.client.sensitivity_labels.delete( + def test_sensitivity_labels_enable_recommendation(self, resource_group): + response = self.client.sensitivity_labels.enable_recommendation( resource_group_name=resource_group.name, server_name="str", database_name="str", schema_name="str", table_name="str", column_name="str", - sensitivity_label_source="current", - api_version="2020-11-01-preview", + sensitivity_label_source="recommended", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sensitivity_labels_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sensitivity_labels_operations_async.py index aae7e3af0c12..6acea12e1e86 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sensitivity_labels_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sensitivity_labels_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_sensitivity_labels_list_current_by_database(self, resource_group) resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself @@ -42,32 +41,52 @@ async def test_sensitivity_labels_update(self, resource_group): parameters={ "operations": [ { - "column": "str", "id": "str", "name": "str", - "op": "str", - "schema": "str", - "sensitivityLabel": { - "columnName": "str", - "id": "str", - "informationType": "str", - "informationTypeId": "str", - "isDisabled": bool, - "labelId": "str", - "labelName": "str", - "managedBy": "str", - "name": "str", - "rank": "str", - "schemaName": "str", - "tableName": "str", - "type": "str", + "properties": { + "column": "str", + "op": "str", + "schema": "str", + "table": "str", + "sensitivityLabel": { + "id": "str", + "managedBy": "str", + "name": "str", + "properties": { + "clientClassificationSource": "str", + "columnName": "str", + "informationType": "str", + "informationTypeId": "str", + "isDisabled": bool, + "labelId": "str", + "labelName": "str", + "rank": "str", + "schemaName": "str", + "tableName": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", }, - "table": "str", "type": "str", } ] }, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -80,7 +99,6 @@ async def test_sensitivity_labels_list_recommended_by_database(self, resource_gr resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself @@ -88,16 +106,27 @@ async def test_sensitivity_labels_list_recommended_by_database(self, resource_gr @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_sensitivity_labels_enable_recommendation(self, resource_group): - response = await self.client.sensitivity_labels.enable_recommendation( + async def test_sensitivity_labels_list_by_database(self, resource_group): + response = self.client.sensitivity_labels.list_by_database( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sensitivity_labels_get(self, resource_group): + response = await self.client.sensitivity_labels.get( resource_group_name=resource_group.name, server_name="str", database_name="str", schema_name="str", table_name="str", column_name="str", - sensitivity_label_source="recommended", - api_version="2020-11-01-preview", + sensitivity_label_source="str", ) # please add some check logic here by yourself @@ -105,16 +134,41 @@ async def test_sensitivity_labels_enable_recommendation(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_sensitivity_labels_disable_recommendation(self, resource_group): - response = await self.client.sensitivity_labels.disable_recommendation( + async def test_sensitivity_labels_create_or_update(self, resource_group): + response = await self.client.sensitivity_labels.create_or_update( resource_group_name=resource_group.name, server_name="str", database_name="str", schema_name="str", table_name="str", column_name="str", - sensitivity_label_source="recommended", - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "managedBy": "str", + "name": "str", + "properties": { + "clientClassificationSource": "str", + "columnName": "str", + "informationType": "str", + "informationTypeId": "str", + "isDisabled": bool, + "labelId": "str", + "labelName": "str", + "rank": "str", + "schemaName": "str", + "tableName": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + sensitivity_label_source="current", ) # please add some check logic here by yourself @@ -122,16 +176,15 @@ async def test_sensitivity_labels_disable_recommendation(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_sensitivity_labels_get(self, resource_group): - response = await self.client.sensitivity_labels.get( + async def test_sensitivity_labels_delete(self, resource_group): + response = await self.client.sensitivity_labels.delete( resource_group_name=resource_group.name, server_name="str", database_name="str", schema_name="str", table_name="str", column_name="str", - sensitivity_label_source="str", - api_version="2020-11-01-preview", + sensitivity_label_source="current", ) # please add some check logic here by yourself @@ -139,31 +192,15 @@ async def test_sensitivity_labels_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_sensitivity_labels_create_or_update(self, resource_group): - response = await self.client.sensitivity_labels.create_or_update( + async def test_sensitivity_labels_disable_recommendation(self, resource_group): + response = await self.client.sensitivity_labels.disable_recommendation( resource_group_name=resource_group.name, server_name="str", database_name="str", schema_name="str", table_name="str", column_name="str", - parameters={ - "columnName": "str", - "id": "str", - "informationType": "str", - "informationTypeId": "str", - "isDisabled": bool, - "labelId": "str", - "labelName": "str", - "managedBy": "str", - "name": "str", - "rank": "str", - "schemaName": "str", - "tableName": "str", - "type": "str", - }, - sensitivity_label_source="current", - api_version="2020-11-01-preview", + sensitivity_label_source="recommended", ) # please add some check logic here by yourself @@ -171,16 +208,15 @@ async def test_sensitivity_labels_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_sensitivity_labels_delete(self, resource_group): - response = await self.client.sensitivity_labels.delete( + async def test_sensitivity_labels_enable_recommendation(self, resource_group): + response = await self.client.sensitivity_labels.enable_recommendation( resource_group_name=resource_group.name, server_name="str", database_name="str", schema_name="str", table_name="str", column_name="str", - sensitivity_label_source="current", - api_version="2020-11-01-preview", + sensitivity_label_source="recommended", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_advanced_threat_protection_settings_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_advanced_threat_protection_settings_operations.py index 0692c96005ca..9caca64f5a40 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_advanced_threat_protection_settings_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_advanced_threat_protection_settings_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,18 +18,6 @@ class TestSqlManagementServerAdvancedThreatProtectionSettingsOperations(AzureMgm def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_server_advanced_threat_protection_settings_list_by_server(self, resource_group): - response = self.client.server_advanced_threat_protection_settings.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2021-11-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_server_advanced_threat_protection_settings_get(self, resource_group): @@ -37,7 +25,6 @@ def test_server_advanced_threat_protection_settings_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", advanced_threat_protection_name="str", - api_version="2021-11-01-preview", ) # please add some check logic here by yourself @@ -51,10 +38,9 @@ def test_server_advanced_threat_protection_settings_begin_create_or_update(self, server_name="str", advanced_threat_protection_name="str", parameters={ - "creationTime": "2020-02-20 00:00:00", "id": "str", "name": "str", - "state": "str", + "properties": {"state": "str", "creationTime": "2020-02-20 00:00:00"}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -65,8 +51,18 @@ def test_server_advanced_threat_protection_settings_begin_create_or_update(self, }, "type": "str", }, - api_version="2021-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_server_advanced_threat_protection_settings_list_by_server(self, resource_group): + response = self.client.server_advanced_threat_protection_settings.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_advanced_threat_protection_settings_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_advanced_threat_protection_settings_operations_async.py index 17481c353c3b..6620125fa74c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_advanced_threat_protection_settings_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_advanced_threat_protection_settings_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,18 +19,6 @@ class TestSqlManagementServerAdvancedThreatProtectionSettingsOperationsAsync(Azu def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_server_advanced_threat_protection_settings_list_by_server(self, resource_group): - response = self.client.server_advanced_threat_protection_settings.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2021-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_server_advanced_threat_protection_settings_get(self, resource_group): @@ -38,7 +26,6 @@ async def test_server_advanced_threat_protection_settings_get(self, resource_gro resource_group_name=resource_group.name, server_name="str", advanced_threat_protection_name="str", - api_version="2021-11-01-preview", ) # please add some check logic here by yourself @@ -53,10 +40,9 @@ async def test_server_advanced_threat_protection_settings_begin_create_or_update server_name="str", advanced_threat_protection_name="str", parameters={ - "creationTime": "2020-02-20 00:00:00", "id": "str", "name": "str", - "state": "str", + "properties": {"state": "str", "creationTime": "2020-02-20 00:00:00"}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -67,9 +53,19 @@ async def test_server_advanced_threat_protection_settings_begin_create_or_update }, "type": "str", }, - api_version="2021-11-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_server_advanced_threat_protection_settings_list_by_server(self, resource_group): + response = self.client.server_advanced_threat_protection_settings.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_advisors_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_advisors_operations.py index b67cfd24bf68..9eb1e077e1a9 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_advisors_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_advisors_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,18 +18,6 @@ class TestSqlManagementServerAdvisorsOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_server_advisors_list_by_server(self, resource_group): - response = self.client.server_advisors.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2020-11-01-preview", - ) - - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_server_advisors_get(self, resource_group): @@ -37,7 +25,6 @@ def test_server_advisors_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", advisor_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -51,78 +38,108 @@ def test_server_advisors_update(self, resource_group): server_name="str", advisor_name="str", parameters={ - "advisorStatus": "str", - "autoExecuteStatus": "str", - "autoExecuteStatusInheritedFrom": "str", "id": "str", "kind": "str", - "lastChecked": "2020-02-20 00:00:00", "location": "str", "name": "str", - "recommendationsStatus": "str", - "recommendedActions": [ - { - "details": {"str": {}}, - "errorDetails": {"errorCode": "str", "isRetryable": "str"}, - "estimatedImpact": [ - { - "absoluteValue": 0.0, - "changeValueAbsolute": 0.0, - "changeValueRelative": 0.0, - "dimensionName": "str", - "unit": "str", - } - ], - "executeActionDuration": "str", - "executeActionInitiatedBy": "str", - "executeActionInitiatedTime": "2020-02-20 00:00:00", - "executeActionStartTime": "2020-02-20 00:00:00", - "id": "str", - "implementationDetails": {"method": "str", "script": "str"}, - "isArchivedAction": bool, - "isExecutableAction": bool, - "isRevertableAction": bool, - "kind": "str", - "lastRefresh": "2020-02-20 00:00:00", - "linkedObjects": ["str"], - "location": "str", - "name": "str", - "observedImpact": [ - { - "absoluteValue": 0.0, - "changeValueAbsolute": 0.0, - "changeValueRelative": 0.0, - "dimensionName": "str", - "unit": "str", - } - ], - "recommendationReason": "str", - "revertActionDuration": "str", - "revertActionInitiatedBy": "str", - "revertActionInitiatedTime": "2020-02-20 00:00:00", - "revertActionStartTime": "2020-02-20 00:00:00", - "score": 0, - "state": { - "currentValue": "str", - "actionInitiatedBy": "str", - "lastModified": "2020-02-20 00:00:00", - }, - "timeSeries": [ - { - "metricName": "str", - "startTime": "2020-02-20 00:00:00", - "timeGrain": "str", - "unit": "str", - "value": 0.0, - } - ], - "type": "str", - "validSince": "2020-02-20 00:00:00", - } - ], + "properties": { + "autoExecuteStatus": "str", + "advisorStatus": "str", + "autoExecuteStatusInheritedFrom": "str", + "lastChecked": "2020-02-20 00:00:00", + "recommendationsStatus": "str", + "recommendedActions": [ + { + "id": "str", + "kind": "str", + "location": "str", + "name": "str", + "properties": { + "state": { + "currentValue": "str", + "actionInitiatedBy": "str", + "lastModified": "2020-02-20 00:00:00", + }, + "details": {"str": "str"}, + "errorDetails": {"errorCode": "str", "isRetryable": "str"}, + "estimatedImpact": [ + { + "absoluteValue": 0.0, + "changeValueAbsolute": 0.0, + "changeValueRelative": 0.0, + "dimensionName": "str", + "unit": "str", + } + ], + "executeActionDuration": "1 day, 0:00:00", + "executeActionInitiatedBy": "str", + "executeActionInitiatedTime": "2020-02-20 00:00:00", + "executeActionStartTime": "2020-02-20 00:00:00", + "implementationDetails": {"method": "str", "script": "str"}, + "isArchivedAction": bool, + "isExecutableAction": bool, + "isRevertableAction": bool, + "lastRefresh": "2020-02-20 00:00:00", + "linkedObjects": ["str"], + "observedImpact": [ + { + "absoluteValue": 0.0, + "changeValueAbsolute": 0.0, + "changeValueRelative": 0.0, + "dimensionName": "str", + "unit": "str", + } + ], + "recommendationReason": "str", + "revertActionDuration": "1 day, 0:00:00", + "revertActionInitiatedBy": "str", + "revertActionInitiatedTime": "2020-02-20 00:00:00", + "revertActionStartTime": "2020-02-20 00:00:00", + "score": 0, + "timeSeries": [ + { + "metricName": "str", + "startTime": "2020-02-20 00:00:00", + "timeGrain": "str", + "unit": "str", + "value": 0.0, + } + ], + "validSince": "2020-02-20 00:00:00", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + } + ], + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2020-11-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_server_advisors_list_by_server(self, resource_group): + response = self.client.server_advisors.list_by_server( + resource_group_name=resource_group.name, + server_name="str", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_advisors_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_advisors_operations_async.py index c7b921f80ba5..a52a4d88b97e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_advisors_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_advisors_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,18 +19,6 @@ class TestSqlManagementServerAdvisorsOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_server_advisors_list_by_server(self, resource_group): - response = await self.client.server_advisors.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2020-11-01-preview", - ) - - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_server_advisors_get(self, resource_group): @@ -38,7 +26,6 @@ async def test_server_advisors_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", advisor_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -52,78 +39,108 @@ async def test_server_advisors_update(self, resource_group): server_name="str", advisor_name="str", parameters={ - "advisorStatus": "str", - "autoExecuteStatus": "str", - "autoExecuteStatusInheritedFrom": "str", "id": "str", "kind": "str", - "lastChecked": "2020-02-20 00:00:00", "location": "str", "name": "str", - "recommendationsStatus": "str", - "recommendedActions": [ - { - "details": {"str": {}}, - "errorDetails": {"errorCode": "str", "isRetryable": "str"}, - "estimatedImpact": [ - { - "absoluteValue": 0.0, - "changeValueAbsolute": 0.0, - "changeValueRelative": 0.0, - "dimensionName": "str", - "unit": "str", - } - ], - "executeActionDuration": "str", - "executeActionInitiatedBy": "str", - "executeActionInitiatedTime": "2020-02-20 00:00:00", - "executeActionStartTime": "2020-02-20 00:00:00", - "id": "str", - "implementationDetails": {"method": "str", "script": "str"}, - "isArchivedAction": bool, - "isExecutableAction": bool, - "isRevertableAction": bool, - "kind": "str", - "lastRefresh": "2020-02-20 00:00:00", - "linkedObjects": ["str"], - "location": "str", - "name": "str", - "observedImpact": [ - { - "absoluteValue": 0.0, - "changeValueAbsolute": 0.0, - "changeValueRelative": 0.0, - "dimensionName": "str", - "unit": "str", - } - ], - "recommendationReason": "str", - "revertActionDuration": "str", - "revertActionInitiatedBy": "str", - "revertActionInitiatedTime": "2020-02-20 00:00:00", - "revertActionStartTime": "2020-02-20 00:00:00", - "score": 0, - "state": { - "currentValue": "str", - "actionInitiatedBy": "str", - "lastModified": "2020-02-20 00:00:00", - }, - "timeSeries": [ - { - "metricName": "str", - "startTime": "2020-02-20 00:00:00", - "timeGrain": "str", - "unit": "str", - "value": 0.0, - } - ], - "type": "str", - "validSince": "2020-02-20 00:00:00", - } - ], + "properties": { + "autoExecuteStatus": "str", + "advisorStatus": "str", + "autoExecuteStatusInheritedFrom": "str", + "lastChecked": "2020-02-20 00:00:00", + "recommendationsStatus": "str", + "recommendedActions": [ + { + "id": "str", + "kind": "str", + "location": "str", + "name": "str", + "properties": { + "state": { + "currentValue": "str", + "actionInitiatedBy": "str", + "lastModified": "2020-02-20 00:00:00", + }, + "details": {"str": "str"}, + "errorDetails": {"errorCode": "str", "isRetryable": "str"}, + "estimatedImpact": [ + { + "absoluteValue": 0.0, + "changeValueAbsolute": 0.0, + "changeValueRelative": 0.0, + "dimensionName": "str", + "unit": "str", + } + ], + "executeActionDuration": "1 day, 0:00:00", + "executeActionInitiatedBy": "str", + "executeActionInitiatedTime": "2020-02-20 00:00:00", + "executeActionStartTime": "2020-02-20 00:00:00", + "implementationDetails": {"method": "str", "script": "str"}, + "isArchivedAction": bool, + "isExecutableAction": bool, + "isRevertableAction": bool, + "lastRefresh": "2020-02-20 00:00:00", + "linkedObjects": ["str"], + "observedImpact": [ + { + "absoluteValue": 0.0, + "changeValueAbsolute": 0.0, + "changeValueRelative": 0.0, + "dimensionName": "str", + "unit": "str", + } + ], + "recommendationReason": "str", + "revertActionDuration": "1 day, 0:00:00", + "revertActionInitiatedBy": "str", + "revertActionInitiatedTime": "2020-02-20 00:00:00", + "revertActionStartTime": "2020-02-20 00:00:00", + "score": 0, + "timeSeries": [ + { + "metricName": "str", + "startTime": "2020-02-20 00:00:00", + "timeGrain": "str", + "unit": "str", + "value": 0.0, + } + ], + "validSince": "2020-02-20 00:00:00", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + } + ], + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2020-11-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_server_advisors_list_by_server(self, resource_group): + response = await self.client.server_advisors.list_by_server( + resource_group_name=resource_group.name, + server_name="str", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_automatic_tuning_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_automatic_tuning_operations.py index 4ef3627bd371..32bf50b6d197 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_automatic_tuning_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_automatic_tuning_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,7 +24,6 @@ def test_server_automatic_tuning_get(self, resource_group): response = self.client.server_automatic_tuning.get( resource_group_name=resource_group.name, server_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -37,14 +36,25 @@ def test_server_automatic_tuning_update(self, resource_group): resource_group_name=resource_group.name, server_name="str", parameters={ - "actualState": "str", - "desiredState": "str", "id": "str", "name": "str", - "options": {"str": {"actualState": "str", "desiredState": "str", "reasonCode": 0, "reasonDesc": "str"}}, + "properties": { + "actualState": "str", + "desiredState": "str", + "options": { + "str": {"actualState": "str", "desiredState": "str", "reasonCode": 0, "reasonDesc": "str"} + }, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_automatic_tuning_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_automatic_tuning_operations_async.py index aee3914f7207..75f8be9e3944 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_automatic_tuning_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_automatic_tuning_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ async def test_server_automatic_tuning_get(self, resource_group): response = await self.client.server_automatic_tuning.get( resource_group_name=resource_group.name, server_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -38,14 +37,25 @@ async def test_server_automatic_tuning_update(self, resource_group): resource_group_name=resource_group.name, server_name="str", parameters={ - "actualState": "str", - "desiredState": "str", "id": "str", "name": "str", - "options": {"str": {"actualState": "str", "desiredState": "str", "reasonCode": 0, "reasonDesc": "str"}}, + "properties": { + "actualState": "str", + "desiredState": "str", + "options": { + "str": {"actualState": "str", "desiredState": "str", "reasonCode": 0, "reasonDesc": "str"} + }, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_azure_ad_administrators_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_azure_ad_administrators_operations.py index 6ff85657fe22..703502ec3f0e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_azure_ad_administrators_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_azure_ad_administrators_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_server_azure_ad_administrators_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", administrator_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -39,16 +38,25 @@ def test_server_azure_ad_administrators_begin_create_or_update(self, resource_gr server_name="str", administrator_name="str", parameters={ - "administratorType": "str", - "azureADOnlyAuthentication": bool, "id": "str", - "login": "str", "name": "str", - "sid": "str", - "tenantId": "str", + "properties": { + "login": "str", + "sid": "str", + "administratorType": "str", + "azureADOnlyAuthentication": bool, + "tenantId": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -61,7 +69,6 @@ def test_server_azure_ad_administrators_begin_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", administrator_name="str", - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -73,7 +80,6 @@ def test_server_azure_ad_administrators_list_by_server(self, resource_group): response = self.client.server_azure_ad_administrators.list_by_server( resource_group_name=resource_group.name, server_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_azure_ad_administrators_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_azure_ad_administrators_operations_async.py index 07fa1a7fca1f..015d1cbb33c7 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_azure_ad_administrators_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_azure_ad_administrators_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_server_azure_ad_administrators_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", administrator_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -41,16 +40,25 @@ async def test_server_azure_ad_administrators_begin_create_or_update(self, resou server_name="str", administrator_name="str", parameters={ - "administratorType": "str", - "azureADOnlyAuthentication": bool, "id": "str", - "login": "str", "name": "str", - "sid": "str", - "tenantId": "str", + "properties": { + "login": "str", + "sid": "str", + "administratorType": "str", + "azureADOnlyAuthentication": bool, + "tenantId": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -65,7 +73,6 @@ async def test_server_azure_ad_administrators_begin_delete(self, resource_group) resource_group_name=resource_group.name, server_name="str", administrator_name="str", - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -78,7 +85,6 @@ async def test_server_azure_ad_administrators_list_by_server(self, resource_grou response = self.client.server_azure_ad_administrators.list_by_server( resource_group_name=resource_group.name, server_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_azure_ad_only_authentications_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_azure_ad_only_authentications_operations.py index 5cfe94beab40..558a88ded28e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_azure_ad_only_authentications_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_azure_ad_only_authentications_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_server_azure_ad_only_authentications_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", authentication_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -38,8 +37,20 @@ def test_server_azure_ad_only_authentications_begin_create_or_update(self, resou resource_group_name=resource_group.name, server_name="str", authentication_name="str", - parameters={"azureADOnlyAuthentication": bool, "id": "str", "name": "str", "type": "str"}, - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"azureADOnlyAuthentication": bool}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -52,7 +63,6 @@ def test_server_azure_ad_only_authentications_begin_delete(self, resource_group) resource_group_name=resource_group.name, server_name="str", authentication_name="str", - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -64,7 +74,6 @@ def test_server_azure_ad_only_authentications_list_by_server(self, resource_grou response = self.client.server_azure_ad_only_authentications.list_by_server( resource_group_name=resource_group.name, server_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_azure_ad_only_authentications_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_azure_ad_only_authentications_operations_async.py index 4ee031acce81..f3e63ebc86b9 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_azure_ad_only_authentications_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_azure_ad_only_authentications_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_server_azure_ad_only_authentications_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", authentication_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -40,8 +39,20 @@ async def test_server_azure_ad_only_authentications_begin_create_or_update(self, resource_group_name=resource_group.name, server_name="str", authentication_name="str", - parameters={"azureADOnlyAuthentication": bool, "id": "str", "name": "str", "type": "str"}, - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"azureADOnlyAuthentication": bool}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) ).result() # call '.result()' to poll until service return final result @@ -56,7 +67,6 @@ async def test_server_azure_ad_only_authentications_begin_delete(self, resource_ resource_group_name=resource_group.name, server_name="str", authentication_name="str", - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -69,7 +79,6 @@ async def test_server_azure_ad_only_authentications_list_by_server(self, resourc response = self.client.server_azure_ad_only_authentications.list_by_server( resource_group_name=resource_group.name, server_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_blob_auditing_policies_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_blob_auditing_policies_operations.py index 16df7dada803..84ff15c3026d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_blob_auditing_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_blob_auditing_policies_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,18 +18,6 @@ class TestSqlManagementServerBlobAuditingPoliciesOperations(AzureMgmtRecordedTes def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_server_blob_auditing_policies_list_by_server(self, resource_group): - response = self.client.server_blob_auditing_policies.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2021-11-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_server_blob_auditing_policies_get(self, resource_group): @@ -37,7 +25,6 @@ def test_server_blob_auditing_policies_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", blob_auditing_policy_name="default", - api_version="2021-11-01-preview", ) # please add some check logic here by yourself @@ -50,24 +37,44 @@ def test_server_blob_auditing_policies_begin_create_or_update(self, resource_gro resource_group_name=resource_group.name, server_name="str", parameters={ - "auditActionsAndGroups": ["str"], "id": "str", - "isAzureMonitorTargetEnabled": bool, - "isDevopsAuditEnabled": bool, - "isManagedIdentityInUse": bool, - "isStorageSecondaryKeyInUse": bool, "name": "str", - "queueDelayMs": 0, - "retentionDays": 0, - "state": "str", - "storageAccountAccessKey": "str", - "storageAccountSubscriptionId": "str", - "storageEndpoint": "str", + "properties": { + "state": "str", + "auditActionsAndGroups": ["str"], + "isAzureMonitorTargetEnabled": bool, + "isDevopsAuditEnabled": bool, + "isManagedIdentityInUse": bool, + "isStorageSecondaryKeyInUse": bool, + "queueDelayMs": 0, + "retentionDays": 0, + "storageAccountAccessKey": "str", + "storageAccountSubscriptionId": "str", + "storageEndpoint": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, blob_auditing_policy_name="default", - api_version="2021-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_server_blob_auditing_policies_list_by_server(self, resource_group): + response = self.client.server_blob_auditing_policies.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_blob_auditing_policies_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_blob_auditing_policies_operations_async.py index a1dc30178d19..30636c31d551 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_blob_auditing_policies_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_blob_auditing_policies_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,18 +19,6 @@ class TestSqlManagementServerBlobAuditingPoliciesOperationsAsync(AzureMgmtRecord def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_server_blob_auditing_policies_list_by_server(self, resource_group): - response = self.client.server_blob_auditing_policies.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2021-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_server_blob_auditing_policies_get(self, resource_group): @@ -38,7 +26,6 @@ async def test_server_blob_auditing_policies_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", blob_auditing_policy_name="default", - api_version="2021-11-01-preview", ) # please add some check logic here by yourself @@ -52,25 +39,45 @@ async def test_server_blob_auditing_policies_begin_create_or_update(self, resour resource_group_name=resource_group.name, server_name="str", parameters={ - "auditActionsAndGroups": ["str"], "id": "str", - "isAzureMonitorTargetEnabled": bool, - "isDevopsAuditEnabled": bool, - "isManagedIdentityInUse": bool, - "isStorageSecondaryKeyInUse": bool, "name": "str", - "queueDelayMs": 0, - "retentionDays": 0, - "state": "str", - "storageAccountAccessKey": "str", - "storageAccountSubscriptionId": "str", - "storageEndpoint": "str", + "properties": { + "state": "str", + "auditActionsAndGroups": ["str"], + "isAzureMonitorTargetEnabled": bool, + "isDevopsAuditEnabled": bool, + "isManagedIdentityInUse": bool, + "isStorageSecondaryKeyInUse": bool, + "queueDelayMs": 0, + "retentionDays": 0, + "storageAccountAccessKey": "str", + "storageAccountSubscriptionId": "str", + "storageEndpoint": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, blob_auditing_policy_name="default", - api_version="2021-11-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_server_blob_auditing_policies_list_by_server(self, resource_group): + response = self.client.server_blob_auditing_policies.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_communication_links_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_communication_links_operations.py deleted file mode 100644 index c08490fcf61d..000000000000 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_communication_links_operations.py +++ /dev/null @@ -1,79 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import pytest -from azure.mgmt.sql import SqlManagementClient - -from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy - -AZURE_LOCATION = "eastus" - - -@pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestSqlManagementServerCommunicationLinksOperations(AzureMgmtRecordedTestCase): - def setup_method(self, method): - self.client = self.create_mgmt_client(SqlManagementClient) - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_server_communication_links_delete(self, resource_group): - response = self.client.server_communication_links.delete( - resource_group_name=resource_group.name, - server_name="str", - communication_link_name="str", - api_version="2014-04-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_server_communication_links_get(self, resource_group): - response = self.client.server_communication_links.get( - resource_group_name=resource_group.name, - server_name="str", - communication_link_name="str", - api_version="2014-04-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_server_communication_links_begin_create_or_update(self, resource_group): - response = self.client.server_communication_links.begin_create_or_update( - resource_group_name=resource_group.name, - server_name="str", - communication_link_name="str", - parameters={ - "id": "str", - "kind": "str", - "location": "str", - "name": "str", - "partnerServer": "str", - "state": "str", - "type": "str", - }, - api_version="2014-04-01", - ).result() # call '.result()' to poll until service return final result - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_server_communication_links_list_by_server(self, resource_group): - response = self.client.server_communication_links.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2014-04-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_communication_links_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_communication_links_operations_async.py deleted file mode 100644 index 23cfa2569a43..000000000000 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_communication_links_operations_async.py +++ /dev/null @@ -1,82 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import pytest -from azure.mgmt.sql.aio import SqlManagementClient - -from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer -from devtools_testutils.aio import recorded_by_proxy_async - -AZURE_LOCATION = "eastus" - - -@pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestSqlManagementServerCommunicationLinksOperationsAsync(AzureMgmtRecordedTestCase): - def setup_method(self, method): - self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_server_communication_links_delete(self, resource_group): - response = await self.client.server_communication_links.delete( - resource_group_name=resource_group.name, - server_name="str", - communication_link_name="str", - api_version="2014-04-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_server_communication_links_get(self, resource_group): - response = await self.client.server_communication_links.get( - resource_group_name=resource_group.name, - server_name="str", - communication_link_name="str", - api_version="2014-04-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_server_communication_links_begin_create_or_update(self, resource_group): - response = await ( - await self.client.server_communication_links.begin_create_or_update( - resource_group_name=resource_group.name, - server_name="str", - communication_link_name="str", - parameters={ - "id": "str", - "kind": "str", - "location": "str", - "name": "str", - "partnerServer": "str", - "state": "str", - "type": "str", - }, - api_version="2014-04-01", - ) - ).result() # call '.result()' to poll until service return final result - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_server_communication_links_list_by_server(self, resource_group): - response = self.client.server_communication_links.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2014-04-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_configuration_options_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_configuration_options_operations.py index 6dd321cc91a7..d8957d3c650e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_configuration_options_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_configuration_options_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,18 +18,6 @@ class TestSqlManagementServerConfigurationOptionsOperations(AzureMgmtRecordedTes def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_server_configuration_options_list_by_managed_instance(self, resource_group): - response = self.client.server_configuration_options.list_by_managed_instance( - resource_group_name=resource_group.name, - managed_instance_name="str", - api_version="2022-08-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_server_configuration_options_get(self, resource_group): @@ -37,7 +25,6 @@ def test_server_configuration_options_get(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", server_configuration_option_name="str", - api_version="2022-08-01-preview", ) # please add some check logic here by yourself @@ -53,12 +40,29 @@ def test_server_configuration_options_begin_create_or_update(self, resource_grou parameters={ "id": "str", "name": "str", - "provisioningState": "str", - "serverConfigurationOptionValue": 0, + "properties": {"serverConfigurationOptionValue": 0, "provisioningState": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2022-08-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_server_configuration_options_list_by_managed_instance(self, resource_group): + response = self.client.server_configuration_options.list_by_managed_instance( + resource_group_name=resource_group.name, + managed_instance_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_configuration_options_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_configuration_options_operations_async.py index 2c86435f159a..04b08743c0d8 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_configuration_options_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_configuration_options_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,18 +19,6 @@ class TestSqlManagementServerConfigurationOptionsOperationsAsync(AzureMgmtRecord def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_server_configuration_options_list_by_managed_instance(self, resource_group): - response = self.client.server_configuration_options.list_by_managed_instance( - resource_group_name=resource_group.name, - managed_instance_name="str", - api_version="2022-08-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_server_configuration_options_get(self, resource_group): @@ -38,7 +26,6 @@ async def test_server_configuration_options_get(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", server_configuration_option_name="str", - api_version="2022-08-01-preview", ) # please add some check logic here by yourself @@ -55,13 +42,30 @@ async def test_server_configuration_options_begin_create_or_update(self, resourc parameters={ "id": "str", "name": "str", - "provisioningState": "str", - "serverConfigurationOptionValue": 0, + "properties": {"serverConfigurationOptionValue": 0, "provisioningState": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2022-08-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_server_configuration_options_list_by_managed_instance(self, resource_group): + response = self.client.server_configuration_options.list_by_managed_instance( + resource_group_name=resource_group.name, + managed_instance_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_connection_policies_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_connection_policies_operations.py index 2facbb9a698d..3c212b966dd6 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_connection_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_connection_policies_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_server_connection_policies_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", connection_policy_name="str", - api_version="2021-05-01-preview", ) # please add some check logic here by yourself @@ -39,14 +38,21 @@ def test_server_connection_policies_begin_create_or_update(self, resource_group) server_name="str", connection_policy_name="str", parameters={ - "connectionType": "str", "id": "str", "kind": "str", "location": "str", "name": "str", + "properties": {"connectionType": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2021-05-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -58,7 +64,6 @@ def test_server_connection_policies_list_by_server(self, resource_group): response = self.client.server_connection_policies.list_by_server( resource_group_name=resource_group.name, server_name="str", - api_version="2021-05-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_connection_policies_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_connection_policies_operations_async.py index b1cfcdb176e2..e45e13db27b5 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_connection_policies_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_connection_policies_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_server_connection_policies_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", connection_policy_name="str", - api_version="2021-05-01-preview", ) # please add some check logic here by yourself @@ -41,14 +40,21 @@ async def test_server_connection_policies_begin_create_or_update(self, resource_ server_name="str", connection_policy_name="str", parameters={ - "connectionType": "str", "id": "str", "kind": "str", "location": "str", "name": "str", + "properties": {"connectionType": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2021-05-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -61,7 +67,6 @@ async def test_server_connection_policies_list_by_server(self, resource_group): response = self.client.server_connection_policies.list_by_server( resource_group_name=resource_group.name, server_name="str", - api_version="2021-05-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_dev_ops_audit_settings_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_dev_ops_audit_settings_operations.py index 547eee1771e4..e5249eb7ab35 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_dev_ops_audit_settings_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_dev_ops_audit_settings_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,18 +18,6 @@ class TestSqlManagementServerDevOpsAuditSettingsOperations(AzureMgmtRecordedTest def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_server_dev_ops_audit_settings_list_by_server(self, resource_group): - response = self.client.server_dev_ops_audit_settings.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2022-02-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_server_dev_ops_audit_settings_get(self, resource_group): @@ -37,7 +25,6 @@ def test_server_dev_ops_audit_settings_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", dev_ops_auditing_settings_name="str", - api_version="2022-02-01-preview", ) # please add some check logic here by yourself @@ -52,13 +39,15 @@ def test_server_dev_ops_audit_settings_begin_create_or_update(self, resource_gro dev_ops_auditing_settings_name="str", parameters={ "id": "str", - "isAzureMonitorTargetEnabled": bool, - "isManagedIdentityInUse": bool, "name": "str", - "state": "str", - "storageAccountAccessKey": "str", - "storageAccountSubscriptionId": "str", - "storageEndpoint": "str", + "properties": { + "state": "str", + "isAzureMonitorTargetEnabled": bool, + "isManagedIdentityInUse": bool, + "storageAccountAccessKey": "str", + "storageAccountSubscriptionId": "str", + "storageEndpoint": "str", + }, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -69,8 +58,18 @@ def test_server_dev_ops_audit_settings_begin_create_or_update(self, resource_gro }, "type": "str", }, - api_version="2022-02-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_server_dev_ops_audit_settings_list_by_server(self, resource_group): + response = self.client.server_dev_ops_audit_settings.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_dev_ops_audit_settings_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_dev_ops_audit_settings_operations_async.py index e98bad58de79..fe41aee952eb 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_dev_ops_audit_settings_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_dev_ops_audit_settings_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,18 +19,6 @@ class TestSqlManagementServerDevOpsAuditSettingsOperationsAsync(AzureMgmtRecorde def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_server_dev_ops_audit_settings_list_by_server(self, resource_group): - response = self.client.server_dev_ops_audit_settings.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2022-02-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_server_dev_ops_audit_settings_get(self, resource_group): @@ -38,7 +26,6 @@ async def test_server_dev_ops_audit_settings_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", dev_ops_auditing_settings_name="str", - api_version="2022-02-01-preview", ) # please add some check logic here by yourself @@ -54,13 +41,15 @@ async def test_server_dev_ops_audit_settings_begin_create_or_update(self, resour dev_ops_auditing_settings_name="str", parameters={ "id": "str", - "isAzureMonitorTargetEnabled": bool, - "isManagedIdentityInUse": bool, "name": "str", - "state": "str", - "storageAccountAccessKey": "str", - "storageAccountSubscriptionId": "str", - "storageEndpoint": "str", + "properties": { + "state": "str", + "isAzureMonitorTargetEnabled": bool, + "isManagedIdentityInUse": bool, + "storageAccountAccessKey": "str", + "storageAccountSubscriptionId": "str", + "storageEndpoint": "str", + }, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -71,9 +60,19 @@ async def test_server_dev_ops_audit_settings_begin_create_or_update(self, resour }, "type": "str", }, - api_version="2022-02-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_server_dev_ops_audit_settings_list_by_server(self, resource_group): + response = self.client.server_dev_ops_audit_settings.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_dns_aliases_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_dns_aliases_operations.py index 17f4c5da272a..0f6fbb89b091 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_dns_aliases_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_dns_aliases_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_server_dns_aliases_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", dns_alias_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -38,7 +37,6 @@ def test_server_dns_aliases_begin_create_or_update(self, resource_group): resource_group_name=resource_group.name, server_name="str", dns_alias_name="str", - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -51,7 +49,6 @@ def test_server_dns_aliases_begin_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", dns_alias_name="str", - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -63,7 +60,6 @@ def test_server_dns_aliases_list_by_server(self, resource_group): response = self.client.server_dns_aliases.list_by_server( resource_group_name=resource_group.name, server_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself @@ -77,7 +73,6 @@ def test_server_dns_aliases_begin_acquire(self, resource_group): server_name="str", dns_alias_name="str", parameters={"oldServerDnsAliasId": "str"}, - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_dns_aliases_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_dns_aliases_operations_async.py index 4ef14e88e586..caefbd7b61ba 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_dns_aliases_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_dns_aliases_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_server_dns_aliases_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", dns_alias_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -40,7 +39,6 @@ async def test_server_dns_aliases_begin_create_or_update(self, resource_group): resource_group_name=resource_group.name, server_name="str", dns_alias_name="str", - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -55,7 +53,6 @@ async def test_server_dns_aliases_begin_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", dns_alias_name="str", - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -68,7 +65,6 @@ async def test_server_dns_aliases_list_by_server(self, resource_group): response = self.client.server_dns_aliases.list_by_server( resource_group_name=resource_group.name, server_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself @@ -83,7 +79,6 @@ async def test_server_dns_aliases_begin_acquire(self, resource_group): server_name="str", dns_alias_name="str", parameters={"oldServerDnsAliasId": "str"}, - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_keys_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_keys_operations.py index bfb7f51a16d2..3a994f23c1b8 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_keys_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_keys_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,18 +18,6 @@ class TestSqlManagementServerKeysOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_server_keys_list_by_server(self, resource_group): - response = self.client.server_keys.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2020-11-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_server_keys_get(self, resource_group): @@ -37,7 +25,6 @@ def test_server_keys_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", key_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -51,19 +38,29 @@ def test_server_keys_begin_create_or_update(self, resource_group): server_name="str", key_name="str", parameters={ - "autoRotationEnabled": bool, - "creationDate": "2020-02-20 00:00:00", "id": "str", "kind": "str", "location": "str", "name": "str", - "serverKeyType": "str", - "subregion": "str", - "thumbprint": "str", + "properties": { + "serverKeyType": "str", + "autoRotationEnabled": bool, + "creationDate": "2020-02-20 00:00:00", + "keyVersion": "str", + "subregion": "str", + "thumbprint": "str", + "uri": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "uri": "str", }, - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -76,8 +73,18 @@ def test_server_keys_begin_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", key_name="str", - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_server_keys_list_by_server(self, resource_group): + response = self.client.server_keys.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_keys_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_keys_operations_async.py index 6a1cb467f9e4..da3cf5847d0c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_keys_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_keys_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,18 +19,6 @@ class TestSqlManagementServerKeysOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_server_keys_list_by_server(self, resource_group): - response = self.client.server_keys.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2020-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_server_keys_get(self, resource_group): @@ -38,7 +26,6 @@ async def test_server_keys_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", key_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -53,19 +40,29 @@ async def test_server_keys_begin_create_or_update(self, resource_group): server_name="str", key_name="str", parameters={ - "autoRotationEnabled": bool, - "creationDate": "2020-02-20 00:00:00", "id": "str", "kind": "str", "location": "str", "name": "str", - "serverKeyType": "str", - "subregion": "str", - "thumbprint": "str", + "properties": { + "serverKeyType": "str", + "autoRotationEnabled": bool, + "creationDate": "2020-02-20 00:00:00", + "keyVersion": "str", + "subregion": "str", + "thumbprint": "str", + "uri": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "uri": "str", }, - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -80,9 +77,19 @@ async def test_server_keys_begin_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", key_name="str", - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_server_keys_list_by_server(self, resource_group): + response = self.client.server_keys.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_operations_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_operations_operations.py index e631f6193744..35aa6e7ba8ad 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_operations_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_operations_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,7 +24,6 @@ def test_server_operations_list_by_server(self, resource_group): response = self.client.server_operations.list_by_server( resource_group_name=resource_group.name, server_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_operations_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_operations_operations_async.py index 4be30b1107d3..fadf41abb859 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_operations_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_operations_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ async def test_server_operations_list_by_server(self, resource_group): response = self.client.server_operations.list_by_server( resource_group_name=resource_group.name, server_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_security_alert_policies_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_security_alert_policies_operations.py index 42a1240d2ab5..e12645176698 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_security_alert_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_security_alert_policies_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_server_security_alert_policies_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", security_alert_policy_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -39,16 +38,18 @@ def test_server_security_alert_policies_begin_create_or_update(self, resource_gr server_name="str", security_alert_policy_name="str", parameters={ - "creationTime": "2020-02-20 00:00:00", - "disabledAlerts": ["str"], - "emailAccountAdmins": bool, - "emailAddresses": ["str"], "id": "str", "name": "str", - "retentionDays": 0, - "state": "str", - "storageAccountAccessKey": "str", - "storageEndpoint": "str", + "properties": { + "state": "str", + "creationTime": "2020-02-20 00:00:00", + "disabledAlerts": ["str"], + "emailAccountAdmins": bool, + "emailAddresses": ["str"], + "retentionDays": 0, + "storageAccountAccessKey": "str", + "storageEndpoint": "str", + }, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -59,7 +60,6 @@ def test_server_security_alert_policies_begin_create_or_update(self, resource_gr }, "type": "str", }, - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -71,7 +71,6 @@ def test_server_security_alert_policies_list_by_server(self, resource_group): response = self.client.server_security_alert_policies.list_by_server( resource_group_name=resource_group.name, server_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_security_alert_policies_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_security_alert_policies_operations_async.py index 0ebd68914a78..166193a1762f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_security_alert_policies_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_security_alert_policies_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_server_security_alert_policies_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", security_alert_policy_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -41,16 +40,18 @@ async def test_server_security_alert_policies_begin_create_or_update(self, resou server_name="str", security_alert_policy_name="str", parameters={ - "creationTime": "2020-02-20 00:00:00", - "disabledAlerts": ["str"], - "emailAccountAdmins": bool, - "emailAddresses": ["str"], "id": "str", "name": "str", - "retentionDays": 0, - "state": "str", - "storageAccountAccessKey": "str", - "storageEndpoint": "str", + "properties": { + "state": "str", + "creationTime": "2020-02-20 00:00:00", + "disabledAlerts": ["str"], + "emailAccountAdmins": bool, + "emailAddresses": ["str"], + "retentionDays": 0, + "storageAccountAccessKey": "str", + "storageEndpoint": "str", + }, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -61,7 +62,6 @@ async def test_server_security_alert_policies_begin_create_or_update(self, resou }, "type": "str", }, - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -74,7 +74,6 @@ async def test_server_security_alert_policies_list_by_server(self, resource_grou response = self.client.server_security_alert_policies.list_by_server( resource_group_name=resource_group.name, server_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_trust_certificates_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_trust_certificates_operations.py index dc78c0213e02..891edb72d8cc 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_trust_certificates_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_trust_certificates_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,18 +18,6 @@ class TestSqlManagementServerTrustCertificatesOperations(AzureMgmtRecordedTestCa def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_server_trust_certificates_list_by_instance(self, resource_group): - response = self.client.server_trust_certificates.list_by_instance( - resource_group_name=resource_group.name, - managed_instance_name="str", - api_version="2021-11-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_server_trust_certificates_get(self, resource_group): @@ -37,7 +25,6 @@ def test_server_trust_certificates_get(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", certificate_name="str", - api_version="2021-11-01-preview", ) # please add some check logic here by yourself @@ -51,14 +38,19 @@ def test_server_trust_certificates_begin_create_or_update(self, resource_group): managed_instance_name="str", certificate_name="str", parameters={ - "certificateName": "str", "id": "str", "name": "str", - "publicBlob": "str", - "thumbprint": "str", + "properties": {"certificateName": "str", "publicBlob": "str", "thumbprint": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2021-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -71,8 +63,18 @@ def test_server_trust_certificates_begin_delete(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", certificate_name="str", - api_version="2021-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_server_trust_certificates_list_by_instance(self, resource_group): + response = self.client.server_trust_certificates.list_by_instance( + resource_group_name=resource_group.name, + managed_instance_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_trust_certificates_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_trust_certificates_operations_async.py index 8d110865ff69..2332f4f55ba2 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_trust_certificates_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_trust_certificates_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,18 +19,6 @@ class TestSqlManagementServerTrustCertificatesOperationsAsync(AzureMgmtRecordedT def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_server_trust_certificates_list_by_instance(self, resource_group): - response = self.client.server_trust_certificates.list_by_instance( - resource_group_name=resource_group.name, - managed_instance_name="str", - api_version="2021-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_server_trust_certificates_get(self, resource_group): @@ -38,7 +26,6 @@ async def test_server_trust_certificates_get(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", certificate_name="str", - api_version="2021-11-01-preview", ) # please add some check logic here by yourself @@ -53,14 +40,19 @@ async def test_server_trust_certificates_begin_create_or_update(self, resource_g managed_instance_name="str", certificate_name="str", parameters={ - "certificateName": "str", "id": "str", "name": "str", - "publicBlob": "str", - "thumbprint": "str", + "properties": {"certificateName": "str", "publicBlob": "str", "thumbprint": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2021-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -75,9 +67,19 @@ async def test_server_trust_certificates_begin_delete(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", certificate_name="str", - api_version="2021-11-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_server_trust_certificates_list_by_instance(self, resource_group): + response = self.client.server_trust_certificates.list_by_instance( + resource_group_name=resource_group.name, + managed_instance_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_trust_groups_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_trust_groups_operations.py index a42ba198b725..3f937584a350 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_trust_groups_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_trust_groups_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_server_trust_groups_get(self, resource_group): resource_group_name=resource_group.name, location_name="str", server_trust_group_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -39,13 +38,19 @@ def test_server_trust_groups_begin_create_or_update(self, resource_group): location_name="str", server_trust_group_name="str", parameters={ - "groupMembers": [{"serverId": "str"}], "id": "str", "name": "str", - "trustScopes": ["str"], + "properties": {"groupMembers": [{"serverId": "str"}], "trustScopes": ["str"]}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -58,7 +63,6 @@ def test_server_trust_groups_begin_delete(self, resource_group): resource_group_name=resource_group.name, location_name="str", server_trust_group_name="str", - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -70,7 +74,6 @@ def test_server_trust_groups_list_by_location(self, resource_group): response = self.client.server_trust_groups.list_by_location( resource_group_name=resource_group.name, location_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself @@ -82,7 +85,6 @@ def test_server_trust_groups_list_by_instance(self, resource_group): response = self.client.server_trust_groups.list_by_instance( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_trust_groups_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_trust_groups_operations_async.py index 526a2b780544..100498ab6f44 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_trust_groups_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_trust_groups_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_server_trust_groups_get(self, resource_group): resource_group_name=resource_group.name, location_name="str", server_trust_group_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -41,13 +40,19 @@ async def test_server_trust_groups_begin_create_or_update(self, resource_group): location_name="str", server_trust_group_name="str", parameters={ - "groupMembers": [{"serverId": "str"}], "id": "str", "name": "str", - "trustScopes": ["str"], + "properties": {"groupMembers": [{"serverId": "str"}], "trustScopes": ["str"]}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -62,7 +67,6 @@ async def test_server_trust_groups_begin_delete(self, resource_group): resource_group_name=resource_group.name, location_name="str", server_trust_group_name="str", - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -75,7 +79,6 @@ async def test_server_trust_groups_list_by_location(self, resource_group): response = self.client.server_trust_groups.list_by_location( resource_group_name=resource_group.name, location_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself @@ -87,7 +90,6 @@ async def test_server_trust_groups_list_by_instance(self, resource_group): response = self.client.server_trust_groups.list_by_instance( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_usages_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_usages_operations.py index 5e0829956557..8823d2605836 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_usages_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_usages_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,7 +24,6 @@ def test_server_usages_list_by_server(self, resource_group): response = self.client.server_usages.list_by_server( resource_group_name=resource_group.name, server_name="str", - api_version="2014-04-01", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_usages_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_usages_operations_async.py index 859aa73cd7fb..2f265061b655 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_usages_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_usages_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ async def test_server_usages_list_by_server(self, resource_group): response = self.client.server_usages.list_by_server( resource_group_name=resource_group.name, server_name="str", - api_version="2014-04-01", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_vulnerability_assessments_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_vulnerability_assessments_operations.py index 0ff7bb8ce725..6f5d2562d1ca 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_vulnerability_assessments_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_vulnerability_assessments_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_server_vulnerability_assessments_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", vulnerability_assessment_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -41,13 +40,22 @@ def test_server_vulnerability_assessments_create_or_update(self, resource_group) parameters={ "id": "str", "name": "str", - "recurringScans": {"emailSubscriptionAdmins": True, "emails": ["str"], "isEnabled": bool}, - "storageAccountAccessKey": "str", - "storageContainerPath": "str", - "storageContainerSasKey": "str", + "properties": { + "storageContainerPath": "str", + "recurringScans": {"emailSubscriptionAdmins": bool, "emails": ["str"], "isEnabled": bool}, + "storageAccountAccessKey": "str", + "storageContainerSasKey": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -60,7 +68,6 @@ def test_server_vulnerability_assessments_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", vulnerability_assessment_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -72,7 +79,6 @@ def test_server_vulnerability_assessments_list_by_server(self, resource_group): response = self.client.server_vulnerability_assessments.list_by_server( resource_group_name=resource_group.name, server_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_vulnerability_assessments_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_vulnerability_assessments_operations_async.py index 2898f0f6ae29..93a9e1d67ca7 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_vulnerability_assessments_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_server_vulnerability_assessments_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_server_vulnerability_assessments_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", vulnerability_assessment_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -42,13 +41,22 @@ async def test_server_vulnerability_assessments_create_or_update(self, resource_ parameters={ "id": "str", "name": "str", - "recurringScans": {"emailSubscriptionAdmins": True, "emails": ["str"], "isEnabled": bool}, - "storageAccountAccessKey": "str", - "storageContainerPath": "str", - "storageContainerSasKey": "str", + "properties": { + "storageContainerPath": "str", + "recurringScans": {"emailSubscriptionAdmins": bool, "emails": ["str"], "isEnabled": bool}, + "storageAccountAccessKey": "str", + "storageContainerSasKey": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -61,7 +69,6 @@ async def test_server_vulnerability_assessments_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", vulnerability_assessment_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -73,7 +80,6 @@ async def test_server_vulnerability_assessments_list_by_server(self, resource_gr response = self.client.server_vulnerability_assessments.list_by_server( resource_group_name=resource_group.name, server_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_servers_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_servers_operations.py index a0dcf0b74857..340383d1d1f1 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_servers_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_servers_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,45 +18,12 @@ class TestSqlManagementServersOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_servers_check_name_availability(self, resource_group): - response = self.client.servers.check_name_availability( - parameters={"name": "str", "type": "Microsoft.Sql/servers"}, - api_version="2024-11-01-preview", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_servers_list(self, resource_group): - response = self.client.servers.list( - api_version="2024-11-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_servers_list_by_resource_group(self, resource_group): - response = self.client.servers.list_by_resource_group( - resource_group_name=resource_group.name, - api_version="2024-11-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_servers_get(self, resource_group): response = self.client.servers.get( resource_group_name=resource_group.name, server_name="str", - api_version="2024-11-01-preview", ) # please add some check logic here by yourself @@ -70,20 +37,6 @@ def test_servers_begin_create_or_update(self, resource_group): server_name="str", parameters={ "location": "str", - "administratorLogin": "str", - "administratorLoginPassword": "str", - "administrators": { - "administratorType": "str", - "azureADOnlyAuthentication": bool, - "login": "str", - "principalType": "str", - "sid": "str", - "tenantId": "str", - }, - "createMode": "str", - "externalGovernanceStatus": "str", - "federatedClientId": "str", - "fullyQualifiedDomainName": "str", "id": "str", "identity": { "principalId": "str", @@ -91,49 +44,60 @@ def test_servers_begin_create_or_update(self, resource_group): "type": "str", "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, }, - "isIPv6Enabled": "str", - "keyId": "str", "kind": "str", - "minimalTlsVersion": "str", "name": "str", - "primaryUserAssignedIdentityId": "str", - "privateEndpointConnections": [ - { - "id": "str", - "properties": { - "groupIds": ["str"], - "privateEndpoint": {"id": "str"}, - "privateLinkServiceConnectionState": { - "description": "str", - "status": "str", - "actionsRequired": "str", + "properties": { + "administratorLogin": "str", + "administratorLoginPassword": "str", + "administrators": { + "administratorType": "str", + "azureADOnlyAuthentication": bool, + "login": "str", + "principalType": "str", + "sid": "str", + "tenantId": "str", + }, + "createMode": "str", + "externalGovernanceStatus": "str", + "federatedClientId": "str", + "fullyQualifiedDomainName": "str", + "isIPv6Enabled": "str", + "keyId": "str", + "minimalTlsVersion": "str", + "primaryUserAssignedIdentityId": "str", + "privateEndpointConnections": [ + { + "id": "str", + "properties": { + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "description": "str", + "status": "str", + "actionsRequired": "str", + }, + "provisioningState": "str", }, - "provisioningState": "str", - }, - } - ], - "publicNetworkAccess": "str", - "restrictOutboundNetworkAccess": "str", - "retentionDays": 0, - "state": "str", + } + ], + "publicNetworkAccess": "str", + "restrictOutboundNetworkAccess": "str", + "retentionDays": 0, + "state": "str", + "version": "str", + "workspaceFeature": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", - "version": "str", - "workspaceFeature": "str", }, - api_version="2024-11-01-preview", - ).result() # call '.result()' to poll until service return final result - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_servers_begin_delete(self, resource_group): - response = self.client.servers.begin_delete( - resource_group_name=resource_group.name, - server_name="str", - api_version="2024-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -146,59 +110,89 @@ def test_servers_begin_update(self, resource_group): resource_group_name=resource_group.name, server_name="str", parameters={ - "administratorLogin": "str", - "administratorLoginPassword": "str", - "administrators": { - "administratorType": "str", - "azureADOnlyAuthentication": bool, - "login": "str", - "principalType": "str", - "sid": "str", - "tenantId": "str", - }, - "createMode": "str", - "externalGovernanceStatus": "str", - "federatedClientId": "str", - "fullyQualifiedDomainName": "str", "identity": { "principalId": "str", "tenantId": "str", "type": "str", "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, }, - "isIPv6Enabled": "str", - "keyId": "str", - "minimalTlsVersion": "str", - "primaryUserAssignedIdentityId": "str", - "privateEndpointConnections": [ - { - "id": "str", - "properties": { - "groupIds": ["str"], - "privateEndpoint": {"id": "str"}, - "privateLinkServiceConnectionState": { - "description": "str", - "status": "str", - "actionsRequired": "str", + "properties": { + "administratorLogin": "str", + "administratorLoginPassword": "str", + "administrators": { + "administratorType": "str", + "azureADOnlyAuthentication": bool, + "login": "str", + "principalType": "str", + "sid": "str", + "tenantId": "str", + }, + "createMode": "str", + "externalGovernanceStatus": "str", + "federatedClientId": "str", + "fullyQualifiedDomainName": "str", + "isIPv6Enabled": "str", + "keyId": "str", + "minimalTlsVersion": "str", + "primaryUserAssignedIdentityId": "str", + "privateEndpointConnections": [ + { + "id": "str", + "properties": { + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "description": "str", + "status": "str", + "actionsRequired": "str", + }, + "provisioningState": "str", }, - "provisioningState": "str", - }, - } - ], - "publicNetworkAccess": "str", - "restrictOutboundNetworkAccess": "str", - "retentionDays": 0, - "state": "str", + } + ], + "publicNetworkAccess": "str", + "restrictOutboundNetworkAccess": "str", + "retentionDays": 0, + "state": "str", + "version": "str", + "workspaceFeature": "str", + }, "tags": {"str": "str"}, - "version": "str", - "workspaceFeature": "str", }, - api_version="2024-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_servers_begin_delete(self, resource_group): + response = self.client.servers.begin_delete( + resource_group_name=resource_group.name, + server_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_servers_list_by_resource_group(self, resource_group): + response = self.client.servers.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_servers_list(self, resource_group): + response = self.client.servers.list() + result = [r for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_servers_begin_import_database(self, resource_group): @@ -218,7 +212,6 @@ def test_servers_begin_import_database(self, resource_group): "networkIsolation": {"sqlServerResourceId": "str", "storageAccountResourceId": "str"}, "serviceObjectiveName": "str", }, - api_version="2024-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -230,8 +223,17 @@ def test_servers_begin_refresh_status(self, resource_group): response = self.client.servers.begin_refresh_status( resource_group_name=resource_group.name, server_name="str", - api_version="2024-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_servers_check_name_availability(self, resource_group): + response = self.client.servers.check_name_availability( + parameters={"name": "str", "type": "str"}, + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_servers_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_servers_operations_async.py index 31d0b8ea3eb4..1ac6d5b2d71c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_servers_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_servers_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,45 +19,12 @@ class TestSqlManagementServersOperationsAsync(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_servers_check_name_availability(self, resource_group): - response = await self.client.servers.check_name_availability( - parameters={"name": "str", "type": "Microsoft.Sql/servers"}, - api_version="2024-11-01-preview", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_servers_list(self, resource_group): - response = self.client.servers.list( - api_version="2024-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_servers_list_by_resource_group(self, resource_group): - response = self.client.servers.list_by_resource_group( - resource_group_name=resource_group.name, - api_version="2024-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_servers_get(self, resource_group): response = await self.client.servers.get( resource_group_name=resource_group.name, server_name="str", - api_version="2024-11-01-preview", ) # please add some check logic here by yourself @@ -72,20 +39,6 @@ async def test_servers_begin_create_or_update(self, resource_group): server_name="str", parameters={ "location": "str", - "administratorLogin": "str", - "administratorLoginPassword": "str", - "administrators": { - "administratorType": "str", - "azureADOnlyAuthentication": bool, - "login": "str", - "principalType": "str", - "sid": "str", - "tenantId": "str", - }, - "createMode": "str", - "externalGovernanceStatus": "str", - "federatedClientId": "str", - "fullyQualifiedDomainName": "str", "id": "str", "identity": { "principalId": "str", @@ -93,51 +46,60 @@ async def test_servers_begin_create_or_update(self, resource_group): "type": "str", "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, }, - "isIPv6Enabled": "str", - "keyId": "str", "kind": "str", - "minimalTlsVersion": "str", "name": "str", - "primaryUserAssignedIdentityId": "str", - "privateEndpointConnections": [ - { - "id": "str", - "properties": { - "groupIds": ["str"], - "privateEndpoint": {"id": "str"}, - "privateLinkServiceConnectionState": { - "description": "str", - "status": "str", - "actionsRequired": "str", + "properties": { + "administratorLogin": "str", + "administratorLoginPassword": "str", + "administrators": { + "administratorType": "str", + "azureADOnlyAuthentication": bool, + "login": "str", + "principalType": "str", + "sid": "str", + "tenantId": "str", + }, + "createMode": "str", + "externalGovernanceStatus": "str", + "federatedClientId": "str", + "fullyQualifiedDomainName": "str", + "isIPv6Enabled": "str", + "keyId": "str", + "minimalTlsVersion": "str", + "primaryUserAssignedIdentityId": "str", + "privateEndpointConnections": [ + { + "id": "str", + "properties": { + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "description": "str", + "status": "str", + "actionsRequired": "str", + }, + "provisioningState": "str", }, - "provisioningState": "str", - }, - } - ], - "publicNetworkAccess": "str", - "restrictOutboundNetworkAccess": "str", - "retentionDays": 0, - "state": "str", + } + ], + "publicNetworkAccess": "str", + "restrictOutboundNetworkAccess": "str", + "retentionDays": 0, + "state": "str", + "version": "str", + "workspaceFeature": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "tags": {"str": "str"}, "type": "str", - "version": "str", - "workspaceFeature": "str", }, - api_version="2024-11-01-preview", - ) - ).result() # call '.result()' to poll until service return final result - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_servers_begin_delete(self, resource_group): - response = await ( - await self.client.servers.begin_delete( - resource_group_name=resource_group.name, - server_name="str", - api_version="2024-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -152,60 +114,92 @@ async def test_servers_begin_update(self, resource_group): resource_group_name=resource_group.name, server_name="str", parameters={ - "administratorLogin": "str", - "administratorLoginPassword": "str", - "administrators": { - "administratorType": "str", - "azureADOnlyAuthentication": bool, - "login": "str", - "principalType": "str", - "sid": "str", - "tenantId": "str", - }, - "createMode": "str", - "externalGovernanceStatus": "str", - "federatedClientId": "str", - "fullyQualifiedDomainName": "str", "identity": { "principalId": "str", "tenantId": "str", "type": "str", "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, }, - "isIPv6Enabled": "str", - "keyId": "str", - "minimalTlsVersion": "str", - "primaryUserAssignedIdentityId": "str", - "privateEndpointConnections": [ - { - "id": "str", - "properties": { - "groupIds": ["str"], - "privateEndpoint": {"id": "str"}, - "privateLinkServiceConnectionState": { - "description": "str", - "status": "str", - "actionsRequired": "str", + "properties": { + "administratorLogin": "str", + "administratorLoginPassword": "str", + "administrators": { + "administratorType": "str", + "azureADOnlyAuthentication": bool, + "login": "str", + "principalType": "str", + "sid": "str", + "tenantId": "str", + }, + "createMode": "str", + "externalGovernanceStatus": "str", + "federatedClientId": "str", + "fullyQualifiedDomainName": "str", + "isIPv6Enabled": "str", + "keyId": "str", + "minimalTlsVersion": "str", + "primaryUserAssignedIdentityId": "str", + "privateEndpointConnections": [ + { + "id": "str", + "properties": { + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "description": "str", + "status": "str", + "actionsRequired": "str", + }, + "provisioningState": "str", }, - "provisioningState": "str", - }, - } - ], - "publicNetworkAccess": "str", - "restrictOutboundNetworkAccess": "str", - "retentionDays": 0, - "state": "str", + } + ], + "publicNetworkAccess": "str", + "restrictOutboundNetworkAccess": "str", + "retentionDays": 0, + "state": "str", + "version": "str", + "workspaceFeature": "str", + }, "tags": {"str": "str"}, - "version": "str", - "workspaceFeature": "str", }, - api_version="2024-11-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_servers_begin_delete(self, resource_group): + response = await ( + await self.client.servers.begin_delete( + resource_group_name=resource_group.name, + server_name="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_servers_list_by_resource_group(self, resource_group): + response = self.client.servers.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_servers_list(self, resource_group): + response = self.client.servers.list() + result = [r async for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_servers_begin_import_database(self, resource_group): @@ -226,7 +220,6 @@ async def test_servers_begin_import_database(self, resource_group): "networkIsolation": {"sqlServerResourceId": "str", "storageAccountResourceId": "str"}, "serviceObjectiveName": "str", }, - api_version="2024-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -240,9 +233,18 @@ async def test_servers_begin_refresh_status(self, resource_group): await self.client.servers.begin_refresh_status( resource_group_name=resource_group.name, server_name="str", - api_version="2024-11-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_servers_check_name_availability(self, resource_group): + response = await self.client.servers.check_name_availability( + parameters={"name": "str", "type": "str"}, + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_service_objectives_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_service_objectives_operations.py deleted file mode 100644 index 828408498333..000000000000 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_service_objectives_operations.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. -# -------------------------------------------------------------------------- -import pytest -from azure.mgmt.sql import SqlManagementClient - -from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy - -AZURE_LOCATION = "eastus" - - -@pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestSqlManagementServiceObjectivesOperations(AzureMgmtRecordedTestCase): - def setup_method(self, method): - self.client = self.create_mgmt_client(SqlManagementClient) - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_service_objectives_get(self, resource_group): - response = self.client.service_objectives.get( - resource_group_name=resource_group.name, - server_name="str", - service_objective_name="str", - api_version="2014-04-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_service_objectives_list_by_server(self, resource_group): - response = self.client.service_objectives.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2014-04-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_service_objectives_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_service_objectives_operations_async.py deleted file mode 100644 index a27ba1a2b92a..000000000000 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_service_objectives_operations_async.py +++ /dev/null @@ -1,45 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import pytest -from azure.mgmt.sql.aio import SqlManagementClient - -from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer -from devtools_testutils.aio import recorded_by_proxy_async - -AZURE_LOCATION = "eastus" - - -@pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestSqlManagementServiceObjectivesOperationsAsync(AzureMgmtRecordedTestCase): - def setup_method(self, method): - self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_service_objectives_get(self, resource_group): - response = await self.client.service_objectives.get( - resource_group_name=resource_group.name, - server_name="str", - service_objective_name="str", - api_version="2014-04-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_service_objectives_list_by_server(self, resource_group): - response = self.client.service_objectives.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2014-04-01", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_agent_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_agent_operations.py index a396c4762ff3..2101ce3997d7 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_agent_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_agent_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,7 +24,6 @@ def test_sql_agent_get(self, resource_group): response = self.client.sql_agent.get( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -36,8 +35,20 @@ def test_sql_agent_create_or_update(self, resource_group): response = self.client.sql_agent.create_or_update( resource_group_name=resource_group.name, managed_instance_name="str", - parameters={"id": "str", "name": "str", "state": "str", "type": "str"}, - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"state": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_agent_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_agent_operations_async.py index b51db5013d2a..467356639af5 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_agent_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_agent_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ async def test_sql_agent_get(self, resource_group): response = await self.client.sql_agent.get( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -37,8 +36,20 @@ async def test_sql_agent_create_or_update(self, resource_group): response = await self.client.sql_agent.create_or_update( resource_group_name=resource_group.name, managed_instance_name="str", - parameters={"id": "str", "name": "str", "state": "str", "type": "str"}, - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"state": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_baseline_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_baseline_operations.py index bdbc96890e13..7552abee0e2a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_baseline_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_baseline_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,29 +20,27 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sql_vulnerability_assessment_baseline_list_by_sql_vulnerability_assessment(self, resource_group): - response = self.client.sql_vulnerability_assessment_baseline.list_by_sql_vulnerability_assessment( + def test_sql_vulnerability_assessment_baseline_get(self, resource_group): + response = self.client.sql_vulnerability_assessment_baseline.get( resource_group_name=resource_group.name, server_name="str", vulnerability_assessment_name="str", - system_database_name="master", - api_version="2022-11-01-preview", + baseline_name="str", + system_database_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sql_vulnerability_assessment_baseline_get(self, resource_group): - response = self.client.sql_vulnerability_assessment_baseline.get( + def test_sql_vulnerability_assessment_baseline_list_by_sql_vulnerability_assessment(self, resource_group): + response = self.client.sql_vulnerability_assessment_baseline.list_by_sql_vulnerability_assessment( resource_group_name=resource_group.name, server_name="str", vulnerability_assessment_name="str", - baseline_name="str", - system_database_name="master", - api_version="2022-11-01-preview", + system_database_name="str", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_baseline_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_baseline_operations_async.py index b66492b887d5..d317886063ce 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_baseline_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_baseline_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,29 +21,27 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_sql_vulnerability_assessment_baseline_list_by_sql_vulnerability_assessment(self, resource_group): - response = self.client.sql_vulnerability_assessment_baseline.list_by_sql_vulnerability_assessment( + async def test_sql_vulnerability_assessment_baseline_get(self, resource_group): + response = await self.client.sql_vulnerability_assessment_baseline.get( resource_group_name=resource_group.name, server_name="str", vulnerability_assessment_name="str", - system_database_name="master", - api_version="2022-11-01-preview", + baseline_name="str", + system_database_name="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_sql_vulnerability_assessment_baseline_get(self, resource_group): - response = await self.client.sql_vulnerability_assessment_baseline.get( + async def test_sql_vulnerability_assessment_baseline_list_by_sql_vulnerability_assessment(self, resource_group): + response = self.client.sql_vulnerability_assessment_baseline.list_by_sql_vulnerability_assessment( resource_group_name=resource_group.name, server_name="str", vulnerability_assessment_name="str", - baseline_name="str", - system_database_name="master", - api_version="2022-11-01-preview", + system_database_name="str", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_baselines_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_baselines_operations.py index e5032cee4b89..a8c42b2a916b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_baselines_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_baselines_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -28,9 +28,8 @@ def test_sql_vulnerability_assessment_baselines_create_or_update(self, resource_ baseline_name="str", parameters={ "id": "str", - "latestScan": bool, "name": "str", - "results": {"str": [["str"]]}, + "properties": {"latestScan": bool, "results": {"str": [["str"]]}}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -41,8 +40,7 @@ def test_sql_vulnerability_assessment_baselines_create_or_update(self, resource_ }, "type": "str", }, - system_database_name="master", - api_version="2022-11-01-preview", + system_database_name="str", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_baselines_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_baselines_operations_async.py index cac2bcca1c8a..58da32a96f6f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_baselines_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_baselines_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -29,9 +29,8 @@ async def test_sql_vulnerability_assessment_baselines_create_or_update(self, res baseline_name="str", parameters={ "id": "str", - "latestScan": bool, "name": "str", - "results": {"str": [["str"]]}, + "properties": {"latestScan": bool, "results": {"str": [["str"]]}}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -42,8 +41,7 @@ async def test_sql_vulnerability_assessment_baselines_create_or_update(self, res }, "type": "str", }, - system_database_name="master", - api_version="2022-11-01-preview", + system_database_name="str", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_execute_scan_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_execute_scan_operations.py index 15a930463fe3..69ac30f02e2e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_execute_scan_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_execute_scan_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,8 +25,7 @@ def test_sql_vulnerability_assessment_execute_scan_begin_execute(self, resource_ resource_group_name=resource_group.name, server_name="str", vulnerability_assessment_name="str", - system_database_name="master", - api_version="2022-11-01-preview", + system_database_name="str", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_execute_scan_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_execute_scan_operations_async.py index e9b7257d7167..f784dbdcad4d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_execute_scan_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_execute_scan_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -27,8 +27,7 @@ async def test_sql_vulnerability_assessment_execute_scan_begin_execute(self, res resource_group_name=resource_group.name, server_name="str", vulnerability_assessment_name="str", - system_database_name="master", - api_version="2022-11-01-preview", + system_database_name="str", ) ).result() # call '.result()' to poll until service return final result diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_rule_baseline_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_rule_baseline_operations.py index e5cfbfe3abd5..c3e51e38b284 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_rule_baseline_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_rule_baseline_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,21 +18,6 @@ class TestSqlManagementSqlVulnerabilityAssessmentRuleBaselineOperations(AzureMgm def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_sql_vulnerability_assessment_rule_baseline_list_by_baseline(self, resource_group): - response = self.client.sql_vulnerability_assessment_rule_baseline.list_by_baseline( - resource_group_name=resource_group.name, - server_name="str", - vulnerability_assessment_name="str", - baseline_name="str", - system_database_name="master", - api_version="2022-11-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_sql_vulnerability_assessment_rule_baseline_get(self, resource_group): @@ -42,8 +27,7 @@ def test_sql_vulnerability_assessment_rule_baseline_get(self, resource_group): vulnerability_assessment_name="str", baseline_name="str", rule_id="str", - system_database_name="master", - api_version="2022-11-01-preview", + system_database_name="str", ) # please add some check logic here by yourself @@ -60,9 +44,8 @@ def test_sql_vulnerability_assessment_rule_baseline_create_or_update(self, resou rule_id="str", parameters={ "id": "str", - "latestScan": bool, "name": "str", - "results": [["str"]], + "properties": {"latestScan": bool, "results": [["str"]]}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -73,9 +56,22 @@ def test_sql_vulnerability_assessment_rule_baseline_create_or_update(self, resou }, "type": "str", }, - system_database_name="master", - api_version="2022-11-01-preview", + system_database_name="str", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_vulnerability_assessment_rule_baseline_list_by_baseline(self, resource_group): + response = self.client.sql_vulnerability_assessment_rule_baseline.list_by_baseline( + resource_group_name=resource_group.name, + server_name="str", + vulnerability_assessment_name="str", + baseline_name="str", + system_database_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_rule_baseline_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_rule_baseline_operations_async.py index f3592e74b051..2c3264f99933 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_rule_baseline_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_rule_baseline_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,21 +19,6 @@ class TestSqlManagementSqlVulnerabilityAssessmentRuleBaselineOperationsAsync(Azu def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_sql_vulnerability_assessment_rule_baseline_list_by_baseline(self, resource_group): - response = self.client.sql_vulnerability_assessment_rule_baseline.list_by_baseline( - resource_group_name=resource_group.name, - server_name="str", - vulnerability_assessment_name="str", - baseline_name="str", - system_database_name="master", - api_version="2022-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_sql_vulnerability_assessment_rule_baseline_get(self, resource_group): @@ -43,8 +28,7 @@ async def test_sql_vulnerability_assessment_rule_baseline_get(self, resource_gro vulnerability_assessment_name="str", baseline_name="str", rule_id="str", - system_database_name="master", - api_version="2022-11-01-preview", + system_database_name="str", ) # please add some check logic here by yourself @@ -61,9 +45,8 @@ async def test_sql_vulnerability_assessment_rule_baseline_create_or_update(self, rule_id="str", parameters={ "id": "str", - "latestScan": bool, "name": "str", - "results": [["str"]], + "properties": {"latestScan": bool, "results": [["str"]]}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -74,9 +57,22 @@ async def test_sql_vulnerability_assessment_rule_baseline_create_or_update(self, }, "type": "str", }, - system_database_name="master", - api_version="2022-11-01-preview", + system_database_name="str", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_vulnerability_assessment_rule_baseline_list_by_baseline(self, resource_group): + response = self.client.sql_vulnerability_assessment_rule_baseline.list_by_baseline( + resource_group_name=resource_group.name, + server_name="str", + vulnerability_assessment_name="str", + baseline_name="str", + system_database_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_rule_baselines_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_rule_baselines_operations.py index 1ad4af4ac172..6bf231607367 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_rule_baselines_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_rule_baselines_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -27,8 +27,7 @@ def test_sql_vulnerability_assessment_rule_baselines_delete(self, resource_group vulnerability_assessment_name="str", baseline_name="str", rule_id="str", - system_database_name="master", - api_version="2022-11-01-preview", + system_database_name="str", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_rule_baselines_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_rule_baselines_operations_async.py index aade3f5bb53e..88778a13728d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_rule_baselines_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_rule_baselines_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -28,8 +28,7 @@ async def test_sql_vulnerability_assessment_rule_baselines_delete(self, resource vulnerability_assessment_name="str", baseline_name="str", rule_id="str", - system_database_name="master", - api_version="2022-11-01-preview", + system_database_name="str", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_scan_result_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_scan_result_operations.py index 0b9b54ca16fa..962bc2b9d9e0 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_scan_result_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_scan_result_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,31 +20,29 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sql_vulnerability_assessment_scan_result_list_by_scan(self, resource_group): - response = self.client.sql_vulnerability_assessment_scan_result.list_by_scan( + def test_sql_vulnerability_assessment_scan_result_get(self, resource_group): + response = self.client.sql_vulnerability_assessment_scan_result.get( resource_group_name=resource_group.name, server_name="str", vulnerability_assessment_name="str", scan_id="str", - system_database_name="master", - api_version="2022-11-01-preview", + scan_result_id="str", + system_database_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sql_vulnerability_assessment_scan_result_get(self, resource_group): - response = self.client.sql_vulnerability_assessment_scan_result.get( + def test_sql_vulnerability_assessment_scan_result_list_by_scan(self, resource_group): + response = self.client.sql_vulnerability_assessment_scan_result.list_by_scan( resource_group_name=resource_group.name, server_name="str", vulnerability_assessment_name="str", scan_id="str", - scan_result_id="str", - system_database_name="master", - api_version="2022-11-01-preview", + system_database_name="str", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_scan_result_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_scan_result_operations_async.py index ceb959ede613..f8087b4f853a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_scan_result_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_scan_result_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,31 +21,29 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_sql_vulnerability_assessment_scan_result_list_by_scan(self, resource_group): - response = self.client.sql_vulnerability_assessment_scan_result.list_by_scan( + async def test_sql_vulnerability_assessment_scan_result_get(self, resource_group): + response = await self.client.sql_vulnerability_assessment_scan_result.get( resource_group_name=resource_group.name, server_name="str", vulnerability_assessment_name="str", scan_id="str", - system_database_name="master", - api_version="2022-11-01-preview", + scan_result_id="str", + system_database_name="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_sql_vulnerability_assessment_scan_result_get(self, resource_group): - response = await self.client.sql_vulnerability_assessment_scan_result.get( + async def test_sql_vulnerability_assessment_scan_result_list_by_scan(self, resource_group): + response = self.client.sql_vulnerability_assessment_scan_result.list_by_scan( resource_group_name=resource_group.name, server_name="str", vulnerability_assessment_name="str", scan_id="str", - scan_result_id="str", - system_database_name="master", - api_version="2022-11-01-preview", + system_database_name="str", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_scans_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_scans_operations.py index ba597104a579..f88aba84b7e9 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_scans_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_scans_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,29 +20,27 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sql_vulnerability_assessment_scans_list_by_sql_vulnerability_assessments(self, resource_group): - response = self.client.sql_vulnerability_assessment_scans.list_by_sql_vulnerability_assessments( + def test_sql_vulnerability_assessment_scans_get(self, resource_group): + response = self.client.sql_vulnerability_assessment_scans.get( resource_group_name=resource_group.name, server_name="str", vulnerability_assessment_name="str", - system_database_name="master", - api_version="2022-11-01-preview", + scan_id="str", + system_database_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sql_vulnerability_assessment_scans_get(self, resource_group): - response = self.client.sql_vulnerability_assessment_scans.get( + def test_sql_vulnerability_assessment_scans_list_by_sql_vulnerability_assessments(self, resource_group): + response = self.client.sql_vulnerability_assessment_scans.list_by_sql_vulnerability_assessments( resource_group_name=resource_group.name, server_name="str", vulnerability_assessment_name="str", - scan_id="str", - system_database_name="master", - api_version="2022-11-01-preview", + system_database_name="str", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_scans_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_scans_operations_async.py index 760fab5ac911..ee32a05f34c0 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_scans_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessment_scans_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,29 +21,27 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_sql_vulnerability_assessment_scans_list_by_sql_vulnerability_assessments(self, resource_group): - response = self.client.sql_vulnerability_assessment_scans.list_by_sql_vulnerability_assessments( + async def test_sql_vulnerability_assessment_scans_get(self, resource_group): + response = await self.client.sql_vulnerability_assessment_scans.get( resource_group_name=resource_group.name, server_name="str", vulnerability_assessment_name="str", - system_database_name="master", - api_version="2022-11-01-preview", + scan_id="str", + system_database_name="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_sql_vulnerability_assessment_scans_get(self, resource_group): - response = await self.client.sql_vulnerability_assessment_scans.get( + async def test_sql_vulnerability_assessment_scans_list_by_sql_vulnerability_assessments(self, resource_group): + response = self.client.sql_vulnerability_assessment_scans.list_by_sql_vulnerability_assessments( resource_group_name=resource_group.name, server_name="str", vulnerability_assessment_name="str", - scan_id="str", - system_database_name="master", - api_version="2022-11-01-preview", + system_database_name="str", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessments_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessments_operations.py index 4c2f73ebf626..19cd888aa356 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessments_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessments_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_sql_vulnerability_assessments_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", vulnerability_assessment_name="str", - api_version="2022-11-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessments_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessments_operations_async.py index 340d6f171baf..0a2cadc5300a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessments_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessments_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_sql_vulnerability_assessments_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", vulnerability_assessment_name="str", - api_version="2022-11-01-preview", ) # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessments_settings_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessments_settings_operations.py index 0e7aac84f5e5..8029caf12c25 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessments_settings_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessments_settings_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,18 +18,6 @@ class TestSqlManagementSqlVulnerabilityAssessmentsSettingsOperations(AzureMgmtRe def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_sql_vulnerability_assessments_settings_list_by_server(self, resource_group): - response = self.client.sql_vulnerability_assessments_settings.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2022-11-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_sql_vulnerability_assessments_settings_get(self, resource_group): @@ -37,7 +25,6 @@ def test_sql_vulnerability_assessments_settings_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", vulnerability_assessment_name="str", - api_version="2022-11-01-preview", ) # please add some check logic here by yourself @@ -53,7 +40,7 @@ def test_sql_vulnerability_assessments_settings_create_or_update(self, resource_ parameters={ "id": "str", "name": "str", - "state": "str", + "properties": {"state": "str"}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -64,8 +51,18 @@ def test_sql_vulnerability_assessments_settings_create_or_update(self, resource_ }, "type": "str", }, - api_version="2022-11-01-preview", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_vulnerability_assessments_settings_list_by_server(self, resource_group): + response = self.client.sql_vulnerability_assessments_settings.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessments_settings_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessments_settings_operations_async.py index bb1867a42c11..9a1f53bc0a2d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessments_settings_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sql_vulnerability_assessments_settings_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,18 +19,6 @@ class TestSqlManagementSqlVulnerabilityAssessmentsSettingsOperationsAsync(AzureM def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_sql_vulnerability_assessments_settings_list_by_server(self, resource_group): - response = self.client.sql_vulnerability_assessments_settings.list_by_server( - resource_group_name=resource_group.name, - server_name="str", - api_version="2022-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_sql_vulnerability_assessments_settings_get(self, resource_group): @@ -38,7 +26,6 @@ async def test_sql_vulnerability_assessments_settings_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", vulnerability_assessment_name="str", - api_version="2022-11-01-preview", ) # please add some check logic here by yourself @@ -54,7 +41,7 @@ async def test_sql_vulnerability_assessments_settings_create_or_update(self, res parameters={ "id": "str", "name": "str", - "state": "str", + "properties": {"state": "str"}, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -65,8 +52,18 @@ async def test_sql_vulnerability_assessments_settings_create_or_update(self, res }, "type": "str", }, - api_version="2022-11-01-preview", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_vulnerability_assessments_settings_list_by_server(self, resource_group): + response = self.client.sql_vulnerability_assessments_settings.list_by_server( + resource_group_name=resource_group.name, + server_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_start_stop_managed_instance_schedules_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_start_stop_managed_instance_schedules_operations.py index 5232d4c7ecd1..be1941f50ee6 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_start_stop_managed_instance_schedules_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_start_stop_managed_instance_schedules_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,18 +18,6 @@ class TestSqlManagementStartStopManagedInstanceSchedulesOperations(AzureMgmtReco def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_start_stop_managed_instance_schedules_list_by_instance(self, resource_group): - response = self.client.start_stop_managed_instance_schedules.list_by_instance( - resource_group_name=resource_group.name, - managed_instance_name="str", - api_version="2022-08-01-preview", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_start_stop_managed_instance_schedules_get(self, resource_group): @@ -37,7 +25,6 @@ def test_start_stop_managed_instance_schedules_get(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", start_stop_schedule_name="str", - api_version="2022-08-01-preview", ) # please add some check logic here by yourself @@ -51,12 +38,15 @@ def test_start_stop_managed_instance_schedules_create_or_update(self, resource_g managed_instance_name="str", start_stop_schedule_name="str", parameters={ - "description": "", "id": "str", "name": "str", - "nextExecutionTime": "str", - "nextRunAction": "str", - "scheduleList": [{"startDay": "str", "startTime": "str", "stopDay": "str", "stopTime": "str"}], + "properties": { + "scheduleList": [{"startDay": "str", "startTime": "str", "stopDay": "str", "stopTime": "str"}], + "description": "str", + "nextExecutionTime": "str", + "nextRunAction": "str", + "timeZoneId": "str", + }, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -65,10 +55,8 @@ def test_start_stop_managed_instance_schedules_create_or_update(self, resource_g "lastModifiedBy": "str", "lastModifiedByType": "str", }, - "timeZoneId": "UTC", "type": "str", }, - api_version="2022-08-01-preview", ) # please add some check logic here by yourself @@ -81,8 +69,18 @@ def test_start_stop_managed_instance_schedules_delete(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", start_stop_schedule_name="str", - api_version="2022-08-01-preview", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_start_stop_managed_instance_schedules_list_by_instance(self, resource_group): + response = self.client.start_stop_managed_instance_schedules.list_by_instance( + resource_group_name=resource_group.name, + managed_instance_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_start_stop_managed_instance_schedules_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_start_stop_managed_instance_schedules_operations_async.py index 2617b2575f76..4d1746836a0e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_start_stop_managed_instance_schedules_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_start_stop_managed_instance_schedules_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,18 +19,6 @@ class TestSqlManagementStartStopManagedInstanceSchedulesOperationsAsync(AzureMgm def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient, is_async=True) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_start_stop_managed_instance_schedules_list_by_instance(self, resource_group): - response = self.client.start_stop_managed_instance_schedules.list_by_instance( - resource_group_name=resource_group.name, - managed_instance_name="str", - api_version="2022-08-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_start_stop_managed_instance_schedules_get(self, resource_group): @@ -38,7 +26,6 @@ async def test_start_stop_managed_instance_schedules_get(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", start_stop_schedule_name="str", - api_version="2022-08-01-preview", ) # please add some check logic here by yourself @@ -52,12 +39,15 @@ async def test_start_stop_managed_instance_schedules_create_or_update(self, reso managed_instance_name="str", start_stop_schedule_name="str", parameters={ - "description": "", "id": "str", "name": "str", - "nextExecutionTime": "str", - "nextRunAction": "str", - "scheduleList": [{"startDay": "str", "startTime": "str", "stopDay": "str", "stopTime": "str"}], + "properties": { + "scheduleList": [{"startDay": "str", "startTime": "str", "stopDay": "str", "stopTime": "str"}], + "description": "str", + "nextExecutionTime": "str", + "nextRunAction": "str", + "timeZoneId": "str", + }, "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -66,10 +56,8 @@ async def test_start_stop_managed_instance_schedules_create_or_update(self, reso "lastModifiedBy": "str", "lastModifiedByType": "str", }, - "timeZoneId": "UTC", "type": "str", }, - api_version="2022-08-01-preview", ) # please add some check logic here by yourself @@ -82,8 +70,18 @@ async def test_start_stop_managed_instance_schedules_delete(self, resource_group resource_group_name=resource_group.name, managed_instance_name="str", start_stop_schedule_name="str", - api_version="2022-08-01-preview", ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_start_stop_managed_instance_schedules_list_by_instance(self, resource_group): + response = self.client.start_stop_managed_instance_schedules.list_by_instance( + resource_group_name=resource_group.name, + managed_instance_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_subscription_usages_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_subscription_usages_operations.py index 904a8ae209b4..e91aecb15eca 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_subscription_usages_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_subscription_usages_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,23 +20,21 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_subscription_usages_list_by_location(self, resource_group): - response = self.client.subscription_usages.list_by_location( + def test_subscription_usages_get(self, resource_group): + response = self.client.subscription_usages.get( location_name="str", - api_version="2020-11-01-preview", + usage_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_subscription_usages_get(self, resource_group): - response = self.client.subscription_usages.get( + def test_subscription_usages_list_by_location(self, resource_group): + response = self.client.subscription_usages.list_by_location( location_name="str", - usage_name="str", - api_version="2020-11-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_subscription_usages_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_subscription_usages_operations_async.py index 5a3fe738892b..8ce805105e89 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_subscription_usages_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_subscription_usages_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,23 +21,21 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_subscription_usages_list_by_location(self, resource_group): - response = self.client.subscription_usages.list_by_location( + async def test_subscription_usages_get(self, resource_group): + response = await self.client.subscription_usages.get( location_name="str", - api_version="2020-11-01-preview", + usage_name="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_subscription_usages_get(self, resource_group): - response = await self.client.subscription_usages.get( + async def test_subscription_usages_list_by_location(self, resource_group): + response = self.client.subscription_usages.list_by_location( location_name="str", - usage_name="str", - api_version="2020-11-01-preview", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_synapse_link_workspaces_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_synapse_link_workspaces_operations.py index 9c6297679137..6c88ea939cdb 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_synapse_link_workspaces_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_synapse_link_workspaces_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_synapse_link_workspaces_list_by_database(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2022-05-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_synapse_link_workspaces_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_synapse_link_workspaces_operations_async.py index 9b9a6a2ae58f..3c24b413b829 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_synapse_link_workspaces_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_synapse_link_workspaces_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_synapse_link_workspaces_list_by_database(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2022-05-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sync_agents_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sync_agents_operations.py index 884014416b37..ffd77e5777df 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sync_agents_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sync_agents_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_sync_agents_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", sync_agent_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -39,17 +38,27 @@ def test_sync_agents_begin_create_or_update(self, resource_group): server_name="str", sync_agent_name="str", parameters={ - "expiryTime": "2020-02-20 00:00:00", "id": "str", - "isUpToDate": bool, - "lastAliveTime": "2020-02-20 00:00:00", "name": "str", - "state": "str", - "syncDatabaseId": "str", + "properties": { + "expiryTime": "2020-02-20 00:00:00", + "isUpToDate": bool, + "lastAliveTime": "2020-02-20 00:00:00", + "name": "str", + "state": "str", + "syncDatabaseId": "str", + "version": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "version": "str", }, - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -62,7 +71,6 @@ def test_sync_agents_begin_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", sync_agent_name="str", - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -74,7 +82,6 @@ def test_sync_agents_list_by_server(self, resource_group): response = self.client.sync_agents.list_by_server( resource_group_name=resource_group.name, server_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself @@ -87,7 +94,6 @@ def test_sync_agents_generate_key(self, resource_group): resource_group_name=resource_group.name, server_name="str", sync_agent_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -100,7 +106,6 @@ def test_sync_agents_list_linked_databases(self, resource_group): resource_group_name=resource_group.name, server_name="str", sync_agent_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sync_agents_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sync_agents_operations_async.py index 368e5ea0d855..66d79e4b71e5 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sync_agents_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sync_agents_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_sync_agents_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", sync_agent_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -41,17 +40,27 @@ async def test_sync_agents_begin_create_or_update(self, resource_group): server_name="str", sync_agent_name="str", parameters={ - "expiryTime": "2020-02-20 00:00:00", "id": "str", - "isUpToDate": bool, - "lastAliveTime": "2020-02-20 00:00:00", "name": "str", - "state": "str", - "syncDatabaseId": "str", + "properties": { + "expiryTime": "2020-02-20 00:00:00", + "isUpToDate": bool, + "lastAliveTime": "2020-02-20 00:00:00", + "name": "str", + "state": "str", + "syncDatabaseId": "str", + "version": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "version": "str", }, - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -66,7 +75,6 @@ async def test_sync_agents_begin_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", sync_agent_name="str", - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -79,7 +87,6 @@ async def test_sync_agents_list_by_server(self, resource_group): response = self.client.sync_agents.list_by_server( resource_group_name=resource_group.name, server_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself @@ -92,7 +99,6 @@ async def test_sync_agents_generate_key(self, resource_group): resource_group_name=resource_group.name, server_name="str", sync_agent_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -105,7 +111,6 @@ async def test_sync_agents_list_linked_databases(self, resource_group): resource_group_name=resource_group.name, server_name="str", sync_agent_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sync_groups_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sync_groups_operations.py index 362328a861a8..b06a3bc05a42 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sync_groups_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sync_groups_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,24 +20,66 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sync_groups_list_sync_database_ids(self, resource_group): - response = self.client.sync_groups.list_sync_database_ids( - location_name="str", - api_version="2020-11-01-preview", + def test_sync_groups_get(self, resource_group): + response = self.client.sync_groups.get( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + sync_group_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sync_groups_begin_refresh_hub_schema(self, resource_group): - response = self.client.sync_groups.begin_refresh_hub_schema( + def test_sync_groups_begin_create_or_update(self, resource_group): + response = self.client.sync_groups.begin_create_or_update( resource_group_name=resource_group.name, server_name="str", database_name="str", sync_group_name="str", - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "identity": { + "type": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "name": "str", + "properties": { + "conflictLoggingRetentionInDays": 0, + "conflictResolutionPolicy": "str", + "enableConflictLogging": bool, + "hubDatabasePassword": "str", + "hubDatabaseUserName": "str", + "interval": 0, + "lastSyncTime": "2020-02-20 00:00:00", + "privateEndpointName": "str", + "schema": { + "masterSyncMemberName": "str", + "tables": [ + { + "columns": [{"dataSize": "str", "dataType": "str", "quotedName": "str"}], + "quotedName": "str", + } + ], + }, + "syncDatabaseId": "str", + "syncState": "str", + "usePrivateLinkConnection": bool, + }, + "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -45,58 +87,91 @@ def test_sync_groups_begin_refresh_hub_schema(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sync_groups_list_hub_schemas(self, resource_group): - response = self.client.sync_groups.list_hub_schemas( + def test_sync_groups_begin_update(self, resource_group): + response = self.client.sync_groups.begin_update( resource_group_name=resource_group.name, server_name="str", database_name="str", sync_group_name="str", - api_version="2020-11-01-preview", - ) - result = [r for r in response] + parameters={ + "id": "str", + "identity": { + "type": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "name": "str", + "properties": { + "conflictLoggingRetentionInDays": 0, + "conflictResolutionPolicy": "str", + "enableConflictLogging": bool, + "hubDatabasePassword": "str", + "hubDatabaseUserName": "str", + "interval": 0, + "lastSyncTime": "2020-02-20 00:00:00", + "privateEndpointName": "str", + "schema": { + "masterSyncMemberName": "str", + "tables": [ + { + "columns": [{"dataSize": "str", "dataType": "str", "quotedName": "str"}], + "quotedName": "str", + } + ], + }, + "syncDatabaseId": "str", + "syncState": "str", + "usePrivateLinkConnection": bool, + }, + "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ).result() # call '.result()' to poll until service return final result + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sync_groups_list_logs(self, resource_group): - response = self.client.sync_groups.list_logs( + def test_sync_groups_begin_delete(self, resource_group): + response = self.client.sync_groups.begin_delete( resource_group_name=resource_group.name, server_name="str", database_name="str", sync_group_name="str", - start_time="str", - end_time="str", - type="str", - api_version="2020-11-01-preview", - ) - result = [r for r in response] + ).result() # call '.result()' to poll until service return final result + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sync_groups_cancel_sync(self, resource_group): - response = self.client.sync_groups.cancel_sync( + def test_sync_groups_list_by_database(self, resource_group): + response = self.client.sync_groups.list_by_database( resource_group_name=resource_group.name, server_name="str", database_name="str", - sync_group_name="str", - api_version="2020-11-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sync_groups_trigger_sync(self, resource_group): - response = self.client.sync_groups.trigger_sync( + def test_sync_groups_cancel_sync(self, resource_group): + response = self.client.sync_groups.cancel_sync( resource_group_name=resource_group.name, server_name="str", database_name="str", sync_group_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -104,64 +179,41 @@ def test_sync_groups_trigger_sync(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sync_groups_get(self, resource_group): - response = self.client.sync_groups.get( + def test_sync_groups_list_hub_schemas(self, resource_group): + response = self.client.sync_groups.list_hub_schemas( resource_group_name=resource_group.name, server_name="str", database_name="str", sync_group_name="str", - api_version="2020-11-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sync_groups_begin_create_or_update(self, resource_group): - response = self.client.sync_groups.begin_create_or_update( + def test_sync_groups_list_logs(self, resource_group): + response = self.client.sync_groups.list_logs( resource_group_name=resource_group.name, server_name="str", database_name="str", sync_group_name="str", - parameters={ - "conflictLoggingRetentionInDays": 0, - "conflictResolutionPolicy": "str", - "enableConflictLogging": bool, - "hubDatabasePassword": "str", - "hubDatabaseUserName": "str", - "id": "str", - "interval": 0, - "lastSyncTime": "2020-02-20 00:00:00", - "name": "str", - "privateEndpointName": "str", - "schema": { - "masterSyncMemberName": "str", - "tables": [ - {"columns": [{"dataSize": "str", "dataType": "str", "quotedName": "str"}], "quotedName": "str"} - ], - }, - "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, - "syncDatabaseId": "str", - "syncState": "str", - "type": "str", - "usePrivateLinkConnection": bool, - }, - api_version="2020-11-01-preview", - ).result() # call '.result()' to poll until service return final result - + start_time="str", + end_time="str", + type="str", + ) + result = [r for r in response] # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sync_groups_begin_delete(self, resource_group): - response = self.client.sync_groups.begin_delete( + def test_sync_groups_begin_refresh_hub_schema(self, resource_group): + response = self.client.sync_groups.begin_refresh_hub_schema( resource_group_name=resource_group.name, server_name="str", database_name="str", sync_group_name="str", - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -169,49 +221,22 @@ def test_sync_groups_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sync_groups_begin_update(self, resource_group): - response = self.client.sync_groups.begin_update( + def test_sync_groups_trigger_sync(self, resource_group): + response = self.client.sync_groups.trigger_sync( resource_group_name=resource_group.name, server_name="str", database_name="str", sync_group_name="str", - parameters={ - "conflictLoggingRetentionInDays": 0, - "conflictResolutionPolicy": "str", - "enableConflictLogging": bool, - "hubDatabasePassword": "str", - "hubDatabaseUserName": "str", - "id": "str", - "interval": 0, - "lastSyncTime": "2020-02-20 00:00:00", - "name": "str", - "privateEndpointName": "str", - "schema": { - "masterSyncMemberName": "str", - "tables": [ - {"columns": [{"dataSize": "str", "dataType": "str", "quotedName": "str"}], "quotedName": "str"} - ], - }, - "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, - "syncDatabaseId": "str", - "syncState": "str", - "type": "str", - "usePrivateLinkConnection": bool, - }, - api_version="2020-11-01-preview", - ).result() # call '.result()' to poll until service return final result + ) # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sync_groups_list_by_database(self, resource_group): - response = self.client.sync_groups.list_by_database( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - api_version="2020-11-01-preview", + def test_sync_groups_list_sync_database_ids(self, resource_group): + response = self.client.sync_groups.list_sync_database_ids( + location_name="str", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sync_groups_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sync_groups_operations_async.py index 8fedff1b1bd0..ea85b008d0ea 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sync_groups_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sync_groups_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,25 +21,67 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_sync_groups_list_sync_database_ids(self, resource_group): - response = self.client.sync_groups.list_sync_database_ids( - location_name="str", - api_version="2020-11-01-preview", + async def test_sync_groups_get(self, resource_group): + response = await self.client.sync_groups.get( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + sync_group_name="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_sync_groups_begin_refresh_hub_schema(self, resource_group): + async def test_sync_groups_begin_create_or_update(self, resource_group): response = await ( - await self.client.sync_groups.begin_refresh_hub_schema( + await self.client.sync_groups.begin_create_or_update( resource_group_name=resource_group.name, server_name="str", database_name="str", sync_group_name="str", - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "identity": { + "type": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "name": "str", + "properties": { + "conflictLoggingRetentionInDays": 0, + "conflictResolutionPolicy": "str", + "enableConflictLogging": bool, + "hubDatabasePassword": "str", + "hubDatabaseUserName": "str", + "interval": 0, + "lastSyncTime": "2020-02-20 00:00:00", + "privateEndpointName": "str", + "schema": { + "masterSyncMemberName": "str", + "tables": [ + { + "columns": [{"dataSize": "str", "dataType": "str", "quotedName": "str"}], + "quotedName": "str", + } + ], + }, + "syncDatabaseId": "str", + "syncState": "str", + "usePrivateLinkConnection": bool, + }, + "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) ).result() # call '.result()' to poll until service return final result @@ -48,30 +90,82 @@ async def test_sync_groups_begin_refresh_hub_schema(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_sync_groups_list_hub_schemas(self, resource_group): - response = self.client.sync_groups.list_hub_schemas( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - sync_group_name="str", - api_version="2020-11-01-preview", - ) - result = [r async for r in response] + async def test_sync_groups_begin_update(self, resource_group): + response = await ( + await self.client.sync_groups.begin_update( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + sync_group_name="str", + parameters={ + "id": "str", + "identity": { + "type": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "name": "str", + "properties": { + "conflictLoggingRetentionInDays": 0, + "conflictResolutionPolicy": "str", + "enableConflictLogging": bool, + "hubDatabasePassword": "str", + "hubDatabaseUserName": "str", + "interval": 0, + "lastSyncTime": "2020-02-20 00:00:00", + "privateEndpointName": "str", + "schema": { + "masterSyncMemberName": "str", + "tables": [ + { + "columns": [{"dataSize": "str", "dataType": "str", "quotedName": "str"}], + "quotedName": "str", + } + ], + }, + "syncDatabaseId": "str", + "syncState": "str", + "usePrivateLinkConnection": bool, + }, + "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ) + ).result() # call '.result()' to poll until service return final result + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_sync_groups_list_logs(self, resource_group): - response = self.client.sync_groups.list_logs( + async def test_sync_groups_begin_delete(self, resource_group): + response = await ( + await self.client.sync_groups.begin_delete( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + sync_group_name="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sync_groups_list_by_database(self, resource_group): + response = self.client.sync_groups.list_by_database( resource_group_name=resource_group.name, server_name="str", database_name="str", - sync_group_name="str", - start_time="str", - end_time="str", - type="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself @@ -85,7 +179,6 @@ async def test_sync_groups_cancel_sync(self, resource_group): server_name="str", database_name="str", sync_group_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -93,84 +186,42 @@ async def test_sync_groups_cancel_sync(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_sync_groups_trigger_sync(self, resource_group): - response = await self.client.sync_groups.trigger_sync( + async def test_sync_groups_list_hub_schemas(self, resource_group): + response = self.client.sync_groups.list_hub_schemas( resource_group_name=resource_group.name, server_name="str", database_name="str", sync_group_name="str", - api_version="2020-11-01-preview", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_sync_groups_get(self, resource_group): - response = await self.client.sync_groups.get( + async def test_sync_groups_list_logs(self, resource_group): + response = self.client.sync_groups.list_logs( resource_group_name=resource_group.name, server_name="str", database_name="str", sync_group_name="str", - api_version="2020-11-01-preview", + start_time="str", + end_time="str", + type="str", ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_sync_groups_begin_create_or_update(self, resource_group): - response = await ( - await self.client.sync_groups.begin_create_or_update( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - sync_group_name="str", - parameters={ - "conflictLoggingRetentionInDays": 0, - "conflictResolutionPolicy": "str", - "enableConflictLogging": bool, - "hubDatabasePassword": "str", - "hubDatabaseUserName": "str", - "id": "str", - "interval": 0, - "lastSyncTime": "2020-02-20 00:00:00", - "name": "str", - "privateEndpointName": "str", - "schema": { - "masterSyncMemberName": "str", - "tables": [ - { - "columns": [{"dataSize": "str", "dataType": "str", "quotedName": "str"}], - "quotedName": "str", - } - ], - }, - "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, - "syncDatabaseId": "str", - "syncState": "str", - "type": "str", - "usePrivateLinkConnection": bool, - }, - api_version="2020-11-01-preview", - ) - ).result() # call '.result()' to poll until service return final result - + result = [r async for r in response] # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_sync_groups_begin_delete(self, resource_group): + async def test_sync_groups_begin_refresh_hub_schema(self, resource_group): response = await ( - await self.client.sync_groups.begin_delete( + await self.client.sync_groups.begin_refresh_hub_schema( resource_group_name=resource_group.name, server_name="str", database_name="str", sync_group_name="str", - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -179,54 +230,22 @@ async def test_sync_groups_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_sync_groups_begin_update(self, resource_group): - response = await ( - await self.client.sync_groups.begin_update( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - sync_group_name="str", - parameters={ - "conflictLoggingRetentionInDays": 0, - "conflictResolutionPolicy": "str", - "enableConflictLogging": bool, - "hubDatabasePassword": "str", - "hubDatabaseUserName": "str", - "id": "str", - "interval": 0, - "lastSyncTime": "2020-02-20 00:00:00", - "name": "str", - "privateEndpointName": "str", - "schema": { - "masterSyncMemberName": "str", - "tables": [ - { - "columns": [{"dataSize": "str", "dataType": "str", "quotedName": "str"}], - "quotedName": "str", - } - ], - }, - "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, - "syncDatabaseId": "str", - "syncState": "str", - "type": "str", - "usePrivateLinkConnection": bool, - }, - api_version="2020-11-01-preview", - ) - ).result() # call '.result()' to poll until service return final result + async def test_sync_groups_trigger_sync(self, resource_group): + response = await self.client.sync_groups.trigger_sync( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + sync_group_name="str", + ) # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_sync_groups_list_by_database(self, resource_group): - response = self.client.sync_groups.list_by_database( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - api_version="2020-11-01-preview", + async def test_sync_groups_list_sync_database_ids(self, resource_group): + response = self.client.sync_groups.list_sync_database_ids( + location_name="str", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sync_members_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sync_members_operations.py index fc55313dc798..97a77815bcf6 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sync_members_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sync_members_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -27,7 +27,6 @@ def test_sync_members_get(self, resource_group): database_name="str", sync_group_name="str", sync_member_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -43,23 +42,37 @@ def test_sync_members_begin_create_or_update(self, resource_group): sync_group_name="str", sync_member_name="str", parameters={ - "databaseName": "str", - "databaseType": "str", "id": "str", + "identity": { + "type": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, "name": "str", - "password": "str", - "privateEndpointName": "str", - "serverName": "str", - "sqlServerDatabaseId": "str", - "syncAgentId": "str", - "syncDirection": "str", - "syncMemberAzureDatabaseResourceId": "str", - "syncState": "str", + "properties": { + "databaseName": "str", + "databaseType": "str", + "password": "str", + "privateEndpointName": "str", + "serverName": "str", + "sqlServerDatabaseId": "str", + "syncAgentId": "str", + "syncDirection": "str", + "syncMemberAzureDatabaseResourceId": "str", + "syncState": "str", + "usePrivateLinkConnection": bool, + "userName": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "usePrivateLinkConnection": bool, - "userName": "str", }, - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -67,14 +80,45 @@ def test_sync_members_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sync_members_begin_delete(self, resource_group): - response = self.client.sync_members.begin_delete( + def test_sync_members_begin_update(self, resource_group): + response = self.client.sync_members.begin_update( resource_group_name=resource_group.name, server_name="str", database_name="str", sync_group_name="str", sync_member_name="str", - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "identity": { + "type": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "name": "str", + "properties": { + "databaseName": "str", + "databaseType": "str", + "password": "str", + "privateEndpointName": "str", + "serverName": "str", + "sqlServerDatabaseId": "str", + "syncAgentId": "str", + "syncDirection": "str", + "syncMemberAzureDatabaseResourceId": "str", + "syncState": "str", + "usePrivateLinkConnection": bool, + "userName": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -82,31 +126,13 @@ def test_sync_members_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sync_members_begin_update(self, resource_group): - response = self.client.sync_members.begin_update( + def test_sync_members_begin_delete(self, resource_group): + response = self.client.sync_members.begin_delete( resource_group_name=resource_group.name, server_name="str", database_name="str", sync_group_name="str", sync_member_name="str", - parameters={ - "databaseName": "str", - "databaseType": "str", - "id": "str", - "name": "str", - "password": "str", - "privateEndpointName": "str", - "serverName": "str", - "sqlServerDatabaseId": "str", - "syncAgentId": "str", - "syncDirection": "str", - "syncMemberAzureDatabaseResourceId": "str", - "syncState": "str", - "type": "str", - "usePrivateLinkConnection": bool, - "userName": "str", - }, - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -120,7 +146,6 @@ def test_sync_members_list_by_sync_group(self, resource_group): server_name="str", database_name="str", sync_group_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself @@ -128,30 +153,28 @@ def test_sync_members_list_by_sync_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sync_members_list_member_schemas(self, resource_group): - response = self.client.sync_members.list_member_schemas( + def test_sync_members_begin_refresh_member_schema(self, resource_group): + response = self.client.sync_members.begin_refresh_member_schema( resource_group_name=resource_group.name, server_name="str", database_name="str", sync_group_name="str", sync_member_name="str", - api_version="2020-11-01-preview", - ) - result = [r for r in response] + ).result() # call '.result()' to poll until service return final result + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sync_members_begin_refresh_member_schema(self, resource_group): - response = self.client.sync_members.begin_refresh_member_schema( + def test_sync_members_list_member_schemas(self, resource_group): + response = self.client.sync_members.list_member_schemas( resource_group_name=resource_group.name, server_name="str", database_name="str", sync_group_name="str", sync_member_name="str", - api_version="2020-11-01-preview", - ).result() # call '.result()' to poll until service return final result - + ) + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sync_members_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sync_members_operations_async.py index 7b493741cb1d..95361f3238c8 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sync_members_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_sync_members_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -28,7 +28,6 @@ async def test_sync_members_get(self, resource_group): database_name="str", sync_group_name="str", sync_member_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -45,23 +44,37 @@ async def test_sync_members_begin_create_or_update(self, resource_group): sync_group_name="str", sync_member_name="str", parameters={ - "databaseName": "str", - "databaseType": "str", "id": "str", + "identity": { + "type": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, "name": "str", - "password": "str", - "privateEndpointName": "str", - "serverName": "str", - "sqlServerDatabaseId": "str", - "syncAgentId": "str", - "syncDirection": "str", - "syncMemberAzureDatabaseResourceId": "str", - "syncState": "str", + "properties": { + "databaseName": "str", + "databaseType": "str", + "password": "str", + "privateEndpointName": "str", + "serverName": "str", + "sqlServerDatabaseId": "str", + "syncAgentId": "str", + "syncDirection": "str", + "syncMemberAzureDatabaseResourceId": "str", + "syncState": "str", + "usePrivateLinkConnection": bool, + "userName": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "usePrivateLinkConnection": bool, - "userName": "str", }, - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -70,15 +83,46 @@ async def test_sync_members_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_sync_members_begin_delete(self, resource_group): + async def test_sync_members_begin_update(self, resource_group): response = await ( - await self.client.sync_members.begin_delete( + await self.client.sync_members.begin_update( resource_group_name=resource_group.name, server_name="str", database_name="str", sync_group_name="str", sync_member_name="str", - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "identity": { + "type": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "name": "str", + "properties": { + "databaseName": "str", + "databaseType": "str", + "password": "str", + "privateEndpointName": "str", + "serverName": "str", + "sqlServerDatabaseId": "str", + "syncAgentId": "str", + "syncDirection": "str", + "syncMemberAzureDatabaseResourceId": "str", + "syncState": "str", + "usePrivateLinkConnection": bool, + "userName": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) ).result() # call '.result()' to poll until service return final result @@ -87,32 +131,14 @@ async def test_sync_members_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_sync_members_begin_update(self, resource_group): + async def test_sync_members_begin_delete(self, resource_group): response = await ( - await self.client.sync_members.begin_update( + await self.client.sync_members.begin_delete( resource_group_name=resource_group.name, server_name="str", database_name="str", sync_group_name="str", sync_member_name="str", - parameters={ - "databaseName": "str", - "databaseType": "str", - "id": "str", - "name": "str", - "password": "str", - "privateEndpointName": "str", - "serverName": "str", - "sqlServerDatabaseId": "str", - "syncAgentId": "str", - "syncDirection": "str", - "syncMemberAzureDatabaseResourceId": "str", - "syncState": "str", - "type": "str", - "usePrivateLinkConnection": bool, - "userName": "str", - }, - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -127,22 +153,6 @@ async def test_sync_members_list_by_sync_group(self, resource_group): server_name="str", database_name="str", sync_group_name="str", - api_version="2020-11-01-preview", - ) - result = [r async for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_sync_members_list_member_schemas(self, resource_group): - response = self.client.sync_members.list_member_schemas( - resource_group_name=resource_group.name, - server_name="str", - database_name="str", - sync_group_name="str", - sync_member_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself @@ -158,9 +168,22 @@ async def test_sync_members_begin_refresh_member_schema(self, resource_group): database_name="str", sync_group_name="str", sync_member_name="str", - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sync_members_list_member_schemas(self, resource_group): + response = self.client.sync_members.list_member_schemas( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + sync_group_name="str", + sync_member_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_tde_certificates_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_tde_certificates_operations.py index 5550b8a2f045..f4f0085451ca 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_tde_certificates_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_tde_certificates_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,8 +24,20 @@ def test_tde_certificates_begin_create(self, resource_group): response = self.client.tde_certificates.begin_create( resource_group_name=resource_group.name, server_name="str", - parameters={"certPassword": "str", "id": "str", "name": "str", "privateBlob": "str", "type": "str"}, - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"privateBlob": "str", "certPassword": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_tde_certificates_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_tde_certificates_operations_async.py index da0817d445aa..0089b45532e3 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_tde_certificates_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_tde_certificates_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,8 +26,20 @@ async def test_tde_certificates_begin_create(self, resource_group): await self.client.tde_certificates.begin_create( resource_group_name=resource_group.name, server_name="str", - parameters={"certPassword": "str", "id": "str", "name": "str", "privateBlob": "str", "type": "str"}, - api_version="2020-11-01-preview", + parameters={ + "id": "str", + "name": "str", + "properties": {"privateBlob": "str", "certPassword": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) ).result() # call '.result()' to poll until service return final result diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_time_zones_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_time_zones_operations.py index bcce320da7bd..1663cf2a68a0 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_time_zones_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_time_zones_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,23 +20,21 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_time_zones_list_by_location(self, resource_group): - response = self.client.time_zones.list_by_location( + def test_time_zones_get(self, resource_group): + response = self.client.time_zones.get( location_name="str", - api_version="2020-11-01-preview", + time_zone_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_time_zones_get(self, resource_group): - response = self.client.time_zones.get( + def test_time_zones_list_by_location(self, resource_group): + response = self.client.time_zones.list_by_location( location_name="str", - time_zone_id="str", - api_version="2020-11-01-preview", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_time_zones_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_time_zones_operations_async.py index 69929c9c88c6..e7f48917eb12 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_time_zones_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_time_zones_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,23 +21,21 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_time_zones_list_by_location(self, resource_group): - response = self.client.time_zones.list_by_location( + async def test_time_zones_get(self, resource_group): + response = await self.client.time_zones.get( location_name="str", - api_version="2020-11-01-preview", + time_zone_id="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_time_zones_get(self, resource_group): - response = await self.client.time_zones.get( + async def test_time_zones_list_by_location(self, resource_group): + response = self.client.time_zones.list_by_location( location_name="str", - time_zone_id="str", - api_version="2020-11-01-preview", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_transparent_data_encryptions_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_transparent_data_encryptions_operations.py index da64d7581a6f..d7c56421f5ad 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_transparent_data_encryptions_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_transparent_data_encryptions_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,6 +18,46 @@ class TestSqlManagementTransparentDataEncryptionsOperations(AzureMgmtRecordedTes def setup_method(self, method): self.client = self.create_mgmt_client(SqlManagementClient) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_transparent_data_encryptions_get(self, resource_group): + response = self.client.transparent_data_encryptions.get( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + tde_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_transparent_data_encryptions_begin_create_or_update(self, resource_group): + response = self.client.transparent_data_encryptions.begin_create_or_update( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + tde_name="str", + parameters={ + "id": "str", + "name": "str", + "properties": {"state": "str", "scanState": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_transparent_data_encryptions_list_by_database(self, resource_group): @@ -25,7 +65,6 @@ def test_transparent_data_encryptions_list_by_database(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2022-08-01-preview", ) result = [r for r in response] # please add some check logic here by yourself @@ -33,28 +72,25 @@ def test_transparent_data_encryptions_list_by_database(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_transparent_data_encryptions_get(self, resource_group): - response = self.client.transparent_data_encryptions.get( + def test_transparent_data_encryptions_begin_resume(self, resource_group): + response = self.client.transparent_data_encryptions.begin_resume( resource_group_name=resource_group.name, server_name="str", database_name="str", tde_name="str", - api_version="2022-08-01-preview", - ) + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_transparent_data_encryptions_begin_create_or_update(self, resource_group): - response = self.client.transparent_data_encryptions.begin_create_or_update( + def test_transparent_data_encryptions_begin_suspend(self, resource_group): + response = self.client.transparent_data_encryptions.begin_suspend( resource_group_name=resource_group.name, server_name="str", database_name="str", tde_name="str", - parameters={"id": "str", "name": "str", "state": "str", "type": "str"}, - api_version="2022-08-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_transparent_data_encryptions_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_transparent_data_encryptions_operations_async.py index b21e4bbb6fff..0ee8f39ec1eb 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_transparent_data_encryptions_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_transparent_data_encryptions_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,42 +21,82 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_transparent_data_encryptions_list_by_database(self, resource_group): - response = self.client.transparent_data_encryptions.list_by_database( + async def test_transparent_data_encryptions_get(self, resource_group): + response = await self.client.transparent_data_encryptions.get( resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2022-08-01-preview", + tde_name="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_transparent_data_encryptions_get(self, resource_group): - response = await self.client.transparent_data_encryptions.get( + async def test_transparent_data_encryptions_begin_create_or_update(self, resource_group): + response = await ( + await self.client.transparent_data_encryptions.begin_create_or_update( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + tde_name="str", + parameters={ + "id": "str", + "name": "str", + "properties": {"state": "str", "scanState": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_transparent_data_encryptions_list_by_database(self, resource_group): + response = self.client.transparent_data_encryptions.list_by_database( resource_group_name=resource_group.name, server_name="str", database_name="str", - tde_name="str", - api_version="2022-08-01-preview", ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_transparent_data_encryptions_begin_resume(self, resource_group): + response = await ( + await self.client.transparent_data_encryptions.begin_resume( + resource_group_name=resource_group.name, + server_name="str", + database_name="str", + tde_name="str", + ) + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_transparent_data_encryptions_begin_create_or_update(self, resource_group): + async def test_transparent_data_encryptions_begin_suspend(self, resource_group): response = await ( - await self.client.transparent_data_encryptions.begin_create_or_update( + await self.client.transparent_data_encryptions.begin_suspend( resource_group_name=resource_group.name, server_name="str", database_name="str", tde_name="str", - parameters={"id": "str", "name": "str", "state": "str", "type": "str"}, - api_version="2022-08-01-preview", ) ).result() # call '.result()' to poll until service return final result diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_usages_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_usages_operations.py index 005fa924cbb7..f48cb7ea5262 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_usages_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_usages_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,7 +24,6 @@ def test_usages_list_by_instance_pool(self, resource_group): response = self.client.usages.list_by_instance_pool( resource_group_name=resource_group.name, instance_pool_name="str", - api_version="2021-02-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_usages_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_usages_operations_async.py index 6242bdd9c9f5..742bf6ba2c5e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_usages_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_usages_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ async def test_usages_list_by_instance_pool(self, resource_group): response = self.client.usages.list_by_instance_pool( resource_group_name=resource_group.name, instance_pool_name="str", - api_version="2021-02-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_virtual_clusters_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_virtual_clusters_operations.py index d61935941d90..c6203eafa9cd 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_virtual_clusters_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_virtual_clusters_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,33 +20,53 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_clusters_list(self, resource_group): - response = self.client.virtual_clusters.list( - api_version="2022-05-01-preview", + def test_virtual_clusters_get(self, resource_group): + response = self.client.virtual_clusters.get( + resource_group_name=resource_group.name, + virtual_cluster_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_clusters_list_by_resource_group(self, resource_group): - response = self.client.virtual_clusters.list_by_resource_group( + def test_virtual_clusters_begin_create_or_update(self, resource_group): + response = self.client.virtual_clusters.begin_create_or_update( resource_group_name=resource_group.name, - api_version="2022-05-01-preview", - ) - result = [r for r in response] + virtual_cluster_name="str", + parameters={ + "location": "str", + "id": "str", + "name": "str", + "properties": {"childResources": ["str"], "subnetId": "str", "version": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + ).result() # call '.result()' to poll until service return final result + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_clusters_get(self, resource_group): - response = self.client.virtual_clusters.get( + def test_virtual_clusters_begin_update(self, resource_group): + response = self.client.virtual_clusters.begin_update( resource_group_name=resource_group.name, virtual_cluster_name="str", - api_version="2022-05-01-preview", - ) + parameters={ + "properties": {"childResources": ["str"], "subnetId": "str", "version": "str"}, + "tags": {"str": "str"}, + }, + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... @@ -57,7 +77,6 @@ def test_virtual_clusters_begin_delete(self, resource_group): response = self.client.virtual_clusters.begin_delete( resource_group_name=resource_group.name, virtual_cluster_name="str", - api_version="2022-05-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -65,14 +84,19 @@ def test_virtual_clusters_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_virtual_clusters_begin_update(self, resource_group): - response = self.client.virtual_clusters.begin_update( + def test_virtual_clusters_list_by_resource_group(self, resource_group): + response = self.client.virtual_clusters.list_by_resource_group( resource_group_name=resource_group.name, - virtual_cluster_name="str", - parameters={"childResources": ["str"], "subnetId": "str", "tags": {"str": "str"}, "version": "str"}, - api_version="2022-05-01-preview", - ).result() # call '.result()' to poll until service return final result + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_virtual_clusters_list(self, resource_group): + response = self.client.virtual_clusters.list() + result = [r for r in response] # please add some check logic here by yourself # ... @@ -82,7 +106,6 @@ def test_virtual_clusters_begin_update_dns_servers(self, resource_group): response = self.client.virtual_clusters.begin_update_dns_servers( resource_group_name=resource_group.name, virtual_cluster_name="str", - api_version="2022-05-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_virtual_clusters_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_virtual_clusters_operations_async.py index 8f67b6cefa9c..5fda192346d1 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_virtual_clusters_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_virtual_clusters_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,33 +21,57 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_clusters_list(self, resource_group): - response = self.client.virtual_clusters.list( - api_version="2022-05-01-preview", + async def test_virtual_clusters_get(self, resource_group): + response = await self.client.virtual_clusters.get( + resource_group_name=resource_group.name, + virtual_cluster_name="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_clusters_list_by_resource_group(self, resource_group): - response = self.client.virtual_clusters.list_by_resource_group( - resource_group_name=resource_group.name, - api_version="2022-05-01-preview", - ) - result = [r async for r in response] + async def test_virtual_clusters_begin_create_or_update(self, resource_group): + response = await ( + await self.client.virtual_clusters.begin_create_or_update( + resource_group_name=resource_group.name, + virtual_cluster_name="str", + parameters={ + "location": "str", + "id": "str", + "name": "str", + "properties": {"childResources": ["str"], "subnetId": "str", "version": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + ) + ).result() # call '.result()' to poll until service return final result + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_clusters_get(self, resource_group): - response = await self.client.virtual_clusters.get( - resource_group_name=resource_group.name, - virtual_cluster_name="str", - api_version="2022-05-01-preview", - ) + async def test_virtual_clusters_begin_update(self, resource_group): + response = await ( + await self.client.virtual_clusters.begin_update( + resource_group_name=resource_group.name, + virtual_cluster_name="str", + parameters={ + "properties": {"childResources": ["str"], "subnetId": "str", "version": "str"}, + "tags": {"str": "str"}, + }, + ) + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... @@ -59,7 +83,6 @@ async def test_virtual_clusters_begin_delete(self, resource_group): await self.client.virtual_clusters.begin_delete( resource_group_name=resource_group.name, virtual_cluster_name="str", - api_version="2022-05-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -68,16 +91,19 @@ async def test_virtual_clusters_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_virtual_clusters_begin_update(self, resource_group): - response = await ( - await self.client.virtual_clusters.begin_update( - resource_group_name=resource_group.name, - virtual_cluster_name="str", - parameters={"childResources": ["str"], "subnetId": "str", "tags": {"str": "str"}, "version": "str"}, - api_version="2022-05-01-preview", - ) - ).result() # call '.result()' to poll until service return final result + async def test_virtual_clusters_list_by_resource_group(self, resource_group): + response = self.client.virtual_clusters.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_virtual_clusters_list(self, resource_group): + response = self.client.virtual_clusters.list() + result = [r async for r in response] # please add some check logic here by yourself # ... @@ -88,7 +114,6 @@ async def test_virtual_clusters_begin_update_dns_servers(self, resource_group): await self.client.virtual_clusters.begin_update_dns_servers( resource_group_name=resource_group.name, virtual_cluster_name="str", - api_version="2022-05-01-preview", ) ).result() # call '.result()' to poll until service return final result diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_virtual_network_rules_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_virtual_network_rules_operations.py index 2c6268e46383..4432fabf4304 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_virtual_network_rules_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_virtual_network_rules_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_virtual_network_rules_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", virtual_network_rule_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -40,13 +39,22 @@ def test_virtual_network_rules_begin_create_or_update(self, resource_group): virtual_network_rule_name="str", parameters={ "id": "str", - "ignoreMissingVnetServiceEndpoint": bool, "name": "str", - "state": "str", + "properties": { + "virtualNetworkSubnetId": "str", + "ignoreMissingVnetServiceEndpoint": bool, + "state": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "virtualNetworkSubnetId": "str", }, - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -59,7 +67,6 @@ def test_virtual_network_rules_begin_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", virtual_network_rule_name="str", - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -71,7 +78,6 @@ def test_virtual_network_rules_list_by_server(self, resource_group): response = self.client.virtual_network_rules.list_by_server( resource_group_name=resource_group.name, server_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_virtual_network_rules_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_virtual_network_rules_operations_async.py index 4eed6409d93e..a972f23b89e0 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_virtual_network_rules_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_virtual_network_rules_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_virtual_network_rules_get(self, resource_group): resource_group_name=resource_group.name, server_name="str", virtual_network_rule_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -42,13 +41,22 @@ async def test_virtual_network_rules_begin_create_or_update(self, resource_group virtual_network_rule_name="str", parameters={ "id": "str", - "ignoreMissingVnetServiceEndpoint": bool, "name": "str", - "state": "str", + "properties": { + "virtualNetworkSubnetId": "str", + "ignoreMissingVnetServiceEndpoint": bool, + "state": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "virtualNetworkSubnetId": "str", }, - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -63,7 +71,6 @@ async def test_virtual_network_rules_begin_delete(self, resource_group): resource_group_name=resource_group.name, server_name="str", virtual_network_rule_name="str", - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -76,7 +83,6 @@ async def test_virtual_network_rules_list_by_server(self, resource_group): response = self.client.virtual_network_rules.list_by_server( resource_group_name=resource_group.name, server_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_workload_classifiers_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_workload_classifiers_operations.py index 84b8c20f9224..80c654638916 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_workload_classifiers_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_workload_classifiers_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -27,7 +27,6 @@ def test_workload_classifiers_get(self, resource_group): database_name="str", workload_group_name="str", workload_classifier_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -43,17 +42,26 @@ def test_workload_classifiers_begin_create_or_update(self, resource_group): workload_group_name="str", workload_classifier_name="str", parameters={ - "context": "str", - "endTime": "str", "id": "str", - "importance": "str", - "label": "str", - "memberName": "str", "name": "str", - "startTime": "str", + "properties": { + "memberName": "str", + "context": "str", + "endTime": "str", + "importance": "str", + "label": "str", + "startTime": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -68,7 +76,6 @@ def test_workload_classifiers_begin_delete(self, resource_group): database_name="str", workload_group_name="str", workload_classifier_name="str", - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -82,7 +89,6 @@ def test_workload_classifiers_list_by_workload_group(self, resource_group): server_name="str", database_name="str", workload_group_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_workload_classifiers_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_workload_classifiers_operations_async.py index 1896b2b24d0a..06db0b36d9ef 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_workload_classifiers_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_workload_classifiers_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -28,7 +28,6 @@ async def test_workload_classifiers_get(self, resource_group): database_name="str", workload_group_name="str", workload_classifier_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -45,17 +44,26 @@ async def test_workload_classifiers_begin_create_or_update(self, resource_group) workload_group_name="str", workload_classifier_name="str", parameters={ - "context": "str", - "endTime": "str", "id": "str", - "importance": "str", - "label": "str", - "memberName": "str", "name": "str", - "startTime": "str", + "properties": { + "memberName": "str", + "context": "str", + "endTime": "str", + "importance": "str", + "label": "str", + "startTime": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -72,7 +80,6 @@ async def test_workload_classifiers_begin_delete(self, resource_group): database_name="str", workload_group_name="str", workload_classifier_name="str", - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -87,7 +94,6 @@ async def test_workload_classifiers_list_by_workload_group(self, resource_group) server_name="str", database_name="str", workload_group_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_workload_groups_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_workload_groups_operations.py index fda6d8259f34..51854ba849dc 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_workload_groups_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_workload_groups_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ def test_workload_groups_get(self, resource_group): server_name="str", database_name="str", workload_group_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -42,16 +41,25 @@ def test_workload_groups_begin_create_or_update(self, resource_group): workload_group_name="str", parameters={ "id": "str", - "importance": "str", - "maxResourcePercent": 0, - "maxResourcePercentPerRequest": 0.0, - "minResourcePercent": 0, - "minResourcePercentPerRequest": 0.0, "name": "str", - "queryExecutionTimeout": 0, + "properties": { + "maxResourcePercent": 0, + "minResourcePercent": 0, + "minResourcePercentPerRequest": 0.0, + "importance": "str", + "maxResourcePercentPerRequest": 0.0, + "queryExecutionTimeout": 0, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -65,7 +73,6 @@ def test_workload_groups_begin_delete(self, resource_group): server_name="str", database_name="str", workload_group_name="str", - api_version="2020-11-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -78,7 +85,6 @@ def test_workload_groups_list_by_database(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2020-11-01-preview", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_workload_groups_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_workload_groups_operations_async.py index 87d779ac223b..d69f488be660 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_workload_groups_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_workload_groups_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -27,7 +27,6 @@ async def test_workload_groups_get(self, resource_group): server_name="str", database_name="str", workload_group_name="str", - api_version="2020-11-01-preview", ) # please add some check logic here by yourself @@ -44,16 +43,25 @@ async def test_workload_groups_begin_create_or_update(self, resource_group): workload_group_name="str", parameters={ "id": "str", - "importance": "str", - "maxResourcePercent": 0, - "maxResourcePercentPerRequest": 0.0, - "minResourcePercent": 0, - "minResourcePercentPerRequest": 0.0, "name": "str", - "queryExecutionTimeout": 0, + "properties": { + "maxResourcePercent": 0, + "minResourcePercent": 0, + "minResourcePercentPerRequest": 0.0, + "importance": "str", + "maxResourcePercentPerRequest": 0.0, + "queryExecutionTimeout": 0, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -69,7 +77,6 @@ async def test_workload_groups_begin_delete(self, resource_group): server_name="str", database_name="str", workload_group_name="str", - api_version="2020-11-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -83,7 +90,6 @@ async def test_workload_groups_list_by_database(self, resource_group): resource_group_name=resource_group.name, server_name="str", database_name="str", - api_version="2020-11-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/pyproject.toml b/sdk/sql/azure-mgmt-sql/pyproject.toml index bace00567842..70c8a60253f3 100644 --- a/sdk/sql/azure-mgmt-sql/pyproject.toml +++ b/sdk/sql/azure-mgmt-sql/pyproject.toml @@ -29,7 +29,7 @@ keywords = [ "azure sdk", ] dependencies = [ - "msrest>=0.7.1", + "isodate>=0.6.1", "azure-mgmt-core>=1.6.0", "typing-extensions>=4.6.0", ] @@ -54,8 +54,8 @@ content-type = "text/markdown" [tool.setuptools.packages.find] exclude = [ "tests*", - "samples*", "generated_tests*", + "samples*", "generated_samples*", "doc*", "azure", diff --git a/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql.py b/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql.py index b092c13a3c7f..4a1bad9ca99f 100644 --- a/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql.py +++ b/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding: utf-8 # ------------------------------------------------------------------------- diff --git a/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_auth.py b/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_auth.py index ccc2494cc095..b4e97291ea90 100644 --- a/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_auth.py +++ b/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_auth.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding: utf-8 # ------------------------------------------------------------------------- diff --git a/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_database.py b/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_database.py index ce4810120e4d..836379012adb 100644 --- a/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_database.py +++ b/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_database.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding: utf-8 # ------------------------------------------------------------------------- diff --git a/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_elastic_pool.py b/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_elastic_pool.py index 9ff9218f41e9..02c7055ae380 100644 --- a/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_elastic_pool.py +++ b/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_elastic_pool.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding: utf-8 # ------------------------------------------------------------------------- diff --git a/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_failover_group.py b/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_failover_group.py index 116bd6993240..e665d3611af5 100644 --- a/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_failover_group.py +++ b/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_failover_group.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding: utf-8 # ------------------------------------------------------------------------- diff --git a/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_job.py b/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_job.py index a7b3b76ecf65..bcec6ddaeb8d 100644 --- a/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_job.py +++ b/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_job.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding: utf-8 # ------------------------------------------------------------------------- diff --git a/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_managed_db.py b/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_managed_db.py index 1a1955b6f541..abe4340945b0 100644 --- a/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_managed_db.py +++ b/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_managed_db.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding: utf-8 # ------------------------------------------------------------------------- diff --git a/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_server.py b/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_server.py index b08575867506..cd4779f2b42c 100644 --- a/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_server.py +++ b/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_server.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding: utf-8 # ------------------------------------------------------------------------- diff --git a/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_sync.py b/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_sync.py index 4b5964b300e0..ff3af2ad0524 100644 --- a/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_sync.py +++ b/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_sync.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding: utf-8 # ------------------------------------------------------------------------- diff --git a/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_vulnerability_assessment.py b/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_vulnerability_assessment.py index f501dd3b2774..3c6f1e7a0a72 100644 --- a/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_vulnerability_assessment.py +++ b/sdk/sql/azure-mgmt-sql/tests/disable_test_cli_mgmt_sql_vulnerability_assessment.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding: utf-8 # ------------------------------------------------------------------------- diff --git a/sdk/sql/azure-mgmt-sql/tests/disable_test_mgmt_sql.py b/sdk/sql/azure-mgmt-sql/tests/disable_test_mgmt_sql.py index db1a729e9a31..5ba7e1c8236d 100644 --- a/sdk/sql/azure-mgmt-sql/tests/disable_test_mgmt_sql.py +++ b/sdk/sql/azure-mgmt-sql/tests/disable_test_mgmt_sql.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding: utf-8 # ------------------------------------------------------------------------- diff --git a/sdk/sql/azure-mgmt-sql/tests/test_cli_mgmt_sql_managed_instance.py b/sdk/sql/azure-mgmt-sql/tests/test_cli_mgmt_sql_managed_instance.py index 42527427f559..077ff03f694f 100644 --- a/sdk/sql/azure-mgmt-sql/tests/test_cli_mgmt_sql_managed_instance.py +++ b/sdk/sql/azure-mgmt-sql/tests/test_cli_mgmt_sql_managed_instance.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding: utf-8 # ------------------------------------------------------------------------- diff --git a/sdk/sql/azure-mgmt-sql/tsp-location.yaml b/sdk/sql/azure-mgmt-sql/tsp-location.yaml new file mode 100644 index 000000000000..754f59c914ae --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/sql/resource-manager/Microsoft.Sql/SQL +commit: 41784cfad64229e05cb37b1532a686a0cc3a60a9 +repo: Azure/azure-rest-api-specs +additionalDirectories: